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

Side by Side Diff: chrome/renderer/resources/extensions/downloads_custom_bindings.js

Issue 11574006: Implement chrome.downloads.onDeterminingFilename() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r185012 Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Custom bindings for the downloads API.
6
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8
9 chromeHidden.Event.registerArgumentMassager(
10 'downloads.onDeterminingFilename',
11 function massage_determining_filename(args, dispatch) {
12 var downloadItem = args[0];
13 // Copy the id so that extensions can't change it.
14 var downloadId = downloadItem.id;
15 var suggestable = true;
16 function suggestCallback(result) {
17 if (!suggestable) {
18 console.error('suggestCallback may not be called more than once.');
19 return;
20 }
21 suggestable = false;
22 if ((typeof(result) == 'object') &&
23 result.filename &&
24 (typeof(result.filename) == 'string') &&
25 ((result.overwrite === undefined) ||
26 (typeof(result.overwrite) == 'boolean'))) {
27 chromeHidden.internalAPIs.downloadsInternal.determineFilename(
28 downloadId,
29 result.filename,
30 result.overwrite || false);
31 } else {
32 chromeHidden.internalAPIs.downloadsInternal.determineFilename(
33 downloadId);
34 }
35 }
36 try {
37 var results = dispatch([downloadItem, suggestCallback]);
38 var ext_async = (results &&
Matt Perry 2013/02/27 22:33:47 nit: extAsync
benjhayden 2013/03/01 20:42:21 Done.
39 results.results &&
40 (results.results.length != 0) &&
41 (results.results[0] === true));
42 if (suggestable && !ext_async)
43 suggestCallback();
44 } catch (e) {
45 suggestCallback();
46 throw e;
47 }
48 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698