Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9611)

Unified Diff: chrome/renderer/resources/extensions/downloads_custom_bindings.js

Issue 16924017: A few minor changes to the chrome.downloads extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r214130 Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/api/downloads.idl ('k') | content/browser/download/download_item_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/downloads_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/downloads_custom_bindings.js b/chrome/renderer/resources/extensions/downloads_custom_bindings.js
index be7d1c42cbd23248b6ee856e1e09d1e92b18c655..88efbac64dea41723e01a8c293695b6bc3b80832 100644
--- a/chrome/renderer/resources/extensions/downloads_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/downloads_custom_bindings.js
@@ -16,19 +16,36 @@ eventBindings.registerArgumentMassager(
// Copy the id so that extensions can't change it.
var downloadId = downloadItem.id;
var suggestable = true;
+ function isValidResult(result) {
+ if (result === undefined)
+ return false;
+ if (typeof(result) != 'object') {
+ console.error('Error: Invocation of form suggest(' + typeof(result) +
+ ') doesn\'t match definition suggest({filename: string, ' +
+ 'conflictAction: string})');
+ return false;
+ } else if ((typeof(result.filename) != 'string') ||
+ (result.filename.length == 0)) {
+ console.error('Error: "filename" parameter to suggest() must be a ' +
+ 'non-empty string');
+ return false;
+ } else if ([undefined, 'uniquify', 'overwrite', 'prompt'].indexOf(
+ result.conflictAction) < 0) {
+ console.error('Error: "conflictAction" parameter to suggest() must be ' +
+ 'one of undefined, "uniquify", "overwrite", "prompt"');
+ return false;
+ }
+ return true;
+ }
function suggestCallback(result) {
if (!suggestable) {
console.error('suggestCallback may not be called more than once.');
return;
}
suggestable = false;
- if ((typeof(result) == 'object') &&
- result.filename &&
- (typeof(result.filename) == 'string') &&
- ((result.conflict_action == undefined) ||
- (typeof(result.conflict_action) == 'string'))) {
+ if (isValidResult(result)) {
downloadsInternal.determineFilename(
- downloadId, result.filename, result.conflict_action || "");
+ downloadId, result.filename, result.conflictAction || "");
} else {
downloadsInternal.determineFilename(downloadId, "", "");
}
« no previous file with comments | « chrome/common/extensions/api/downloads.idl ('k') | content/browser/download/download_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698