summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples/api/downloads
diff options
context:
space:
mode:
authorbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-03 21:57:57 +0000
committerbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-03 21:57:57 +0000
commit12188afff126b98305fc7fbd8e6dddb150b25e71 (patch)
treec6ae639cf1e51167fc03ff6421d15b8cee928105 /chrome/common/extensions/docs/examples/api/downloads
parent861ec93ff39ca21ad51e0fff793e392442a3f013 (diff)
downloadchromium_src-12188afff126b98305fc7fbd8e6dddb150b25e71.zip
chromium_src-12188afff126b98305fc7fbd8e6dddb150b25e71.tar.gz
chromium_src-12188afff126b98305fc7fbd8e6dddb150b25e71.tar.bz2
Implement chrome.downloads.onDeterminingFilename() to allow extensions to participate in the download filename determination process.
Docs staged: http://basho.cam.corp.google.com:8000/extensions/downloads.html#event-onDeterminingFilename Example: chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) { suggest({filename: item.filename, overwrite: true}); }); chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) { window.setTimeout(function() { suggest({filename: item.mime.split('/')[0] + '/' + item.filename, overwrite: false}); }, 1); return true; // handling asynchronously }); BUG=12133 BUG=68108 Review URL: https://chromiumcodereview.appspot.com/11574006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/examples/api/downloads')
-rw-r--r--chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/bg.js11
-rw-r--r--chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/manifest.json14
2 files changed, 25 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/bg.js b/chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/bg.js
new file mode 100644
index 0000000..d7d9047
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/bg.js
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Force all downloads to overwrite any existing files instead of inserting
+// ' (1)', ' (2)', etc.
+
+chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
+ suggest({filename: item.filename,
+ overwrite: true});
+});
diff --git a/chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/manifest.json b/chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/manifest.json
new file mode 100644
index 0000000..c1f8999
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/downloads/downloads_overwrite/manifest.json
@@ -0,0 +1,14 @@
+{
+ "name": "Downloads Overwrite Existing Files",
+ "description": "All downloads overwrite existing files instead of adding ' (1)', ' (2)', etc.",
+ "version": "1",
+ "minimum_chrome_version": "26.0.1428",
+ "background": {
+ "scripts": ["bg.js"],
+ "persistent": false
+ },
+ "permissions": [
+ "downloads"
+ ],
+ "manifest_version": 2
+}