| 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, "", "");
|
| }
|
|
|