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

Side by Side Diff: chrome/renderer/resources/extensions/web_request_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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Custom bindings for the webRequest API. 5 // Custom bindings for the webRequest API.
6 6
7 var webRequestNatives = requireNative('web_request'); 7 var webRequestNatives = requireNative('web_request');
8 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName; 8 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName;
9 9
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 }; 52 };
53 53
54 // Registers a callback to be called when this event is dispatched. If 54 // Registers a callback to be called when this event is dispatched. If
55 // opt_filter is specified, then the callback is only called for events that 55 // opt_filter is specified, then the callback is only called for events that
56 // match the given filters. If opt_extraInfo is specified, the given optional 56 // match the given filters. If opt_extraInfo is specified, the given optional
57 // info is sent to the callback. 57 // info is sent to the callback.
58 WebRequestEvent.prototype.addListener = 58 WebRequestEvent.prototype.addListener =
59 function(cb, opt_filter, opt_extraInfo) { 59 function(cb, opt_filter, opt_extraInfo) {
60 if (!this.eventOptions_.supportsListeners) 60 if (!this.eventOptions_.supportsListeners)
61 throw new Error('This event does not support listeners.'); 61 throw new Error('This event does not support listeners.');
62 // NOTE(benjhayden) New APIs should not use this subEventName trick! It does
63 // not play well with event pages. See downloads.onDeterminingFilename and
64 // ExtensionDownloadsEventRouter for an alternative approach.
62 var subEventName = GetUniqueSubEventName(this.eventName_); 65 var subEventName = GetUniqueSubEventName(this.eventName_);
63 // Note: this could fail to validate, in which case we would not add the 66 // Note: this could fail to validate, in which case we would not add the
64 // subEvent listener. 67 // subEvent listener.
65 validate(Array.prototype.slice.call(arguments, 1), this.extraArgSchemas_); 68 validate(Array.prototype.slice.call(arguments, 1), this.extraArgSchemas_);
66 chromeHidden.internalAPIs.webRequestInternal.addEventListener( 69 chromeHidden.internalAPIs.webRequestInternal.addEventListener(
67 cb, opt_filter, opt_extraInfo, this.eventName_, subEventName); 70 cb, opt_filter, opt_extraInfo, this.eventName_, subEventName);
68 71
69 var subEvent = new chrome.Event(subEventName, this.argSchemas_); 72 var subEvent = new chrome.Event(subEventName, this.argSchemas_);
70 var subEventCallback = cb; 73 var subEventCallback = cb;
71 if (opt_extraInfo && opt_extraInfo.indexOf('blocking') >= 0) { 74 if (opt_extraInfo && opt_extraInfo.indexOf('blocking') >= 0) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 153
151 chromeHidden.registerCustomHook('webRequest', function(api) { 154 chromeHidden.registerCustomHook('webRequest', function(api) {
152 var apiFunctions = api.apiFunctions; 155 var apiFunctions = api.apiFunctions;
153 156
154 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() { 157 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
155 var args = Array.prototype.slice.call(arguments); 158 var args = Array.prototype.slice.call(arguments);
156 sendRequest(this.name, args, this.definition.parameters, 159 sendRequest(this.name, args, this.definition.parameters,
157 {forIOThread: true}); 160 {forIOThread: true});
158 }); 161 });
159 }); 162 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698