On Wednesday, June 26, 2013 5:59:26 AM UTC-7, jaaf wrote:
> Hi
> I am writting an extension that uses a data file (dictionary like file).
> I would like to allow the user to update this data file using a button whether in the popup or the options page to trigger the download from a given server.
> I mentionned this in the manifest the following way :
>
>
>
> "permissions": [
> "downloads",
> "
http://sousdomain.domain.com/HorsDrupal/data/"],
>
>
> I placed a button in the popup to call an update function in the javascript of the popup.
>
>
>
>
> function updateDict(){
>
>
> chrome.downloads.download( {url: "
http://sousdomain.domain.com/HorsDrupal/data/BasqueFr.txt", filename: "chrome.extension://@@extension_id/"})
The characters ':' and '/' are invalid. Try this instead:
chrome.downloads.download({url:"
http://sousdomain.domain.com/HorsDrupal/data/BasqueFr.txt", filename: chrome.i18n.getMessage("@@extension_id")});
I'll make the error messages more helpful.
> }
> I got the following answer in the console of the popup
>
>
>
>
> Error during downloads.download: I'm afraid I can't do that. sendRequest:22
> chromeHidden.handleResponse sendRequest:22
>
>
>
>
> The problem is the same if I place the button and the javascript in the options page.
>
>
> I also tried an alternative method indicated in the samples
>
>
>
>
> function updateDict(){
>
> chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
> suggest({filename: item.filename,
> conflict_action: 'overwrite'});
> });
> }
>
>
> This time the answer is
>
>
>
> Uncaught TypeError: Cannot call method 'addListener' of undefined popup.js:41
> updateDict popup.js:41
That looks like a bug. What version of chrome are you using?