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

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: @r185803 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 binding for the webRequest API. 5 // Custom binding for the webRequest API.
6 6
7 var binding = require('binding').Binding.create('webRequest'); 7 var binding = require('binding').Binding.create('webRequest');
8 8
9 var webRequestNatives = requireNative('web_request'); 9 var webRequestNatives = requireNative('web_request');
10 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName; 10 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 }; 55 };
56 56
57 // Registers a callback to be called when this event is dispatched. If 57 // Registers a callback to be called when this event is dispatched. If
58 // opt_filter is specified, then the callback is only called for events that 58 // opt_filter is specified, then the callback is only called for events that
59 // match the given filters. If opt_extraInfo is specified, the given optional 59 // match the given filters. If opt_extraInfo is specified, the given optional
60 // info is sent to the callback. 60 // info is sent to the callback.
61 WebRequestEvent.prototype.addListener = 61 WebRequestEvent.prototype.addListener =
62 function(cb, opt_filter, opt_extraInfo) { 62 function(cb, opt_filter, opt_extraInfo) {
63 if (!this.eventOptions_.supportsListeners) 63 if (!this.eventOptions_.supportsListeners)
64 throw new Error('This event does not support listeners.'); 64 throw new Error('This event does not support listeners.');
65 // NOTE(benjhayden) New APIs should not use this subEventName trick! It does
66 // not play well with event pages. See downloads.onDeterminingFilename and
67 // ExtensionDownloadsEventRouter for an alternative approach.
65 var subEventName = GetUniqueSubEventName(this.eventName_); 68 var subEventName = GetUniqueSubEventName(this.eventName_);
66 // Note: this could fail to validate, in which case we would not add the 69 // Note: this could fail to validate, in which case we would not add the
67 // subEvent listener. 70 // subEvent listener.
68 validate(Array.prototype.slice.call(arguments, 1), this.extraArgSchemas_); 71 validate(Array.prototype.slice.call(arguments, 1), this.extraArgSchemas_);
69 webRequestInternal.addEventListener( 72 webRequestInternal.addEventListener(
70 cb, opt_filter, opt_extraInfo, this.eventName_, subEventName); 73 cb, opt_filter, opt_extraInfo, this.eventName_, subEventName);
71 74
72 var subEvent = new chrome.Event(subEventName, this.argSchemas_); 75 var subEvent = new chrome.Event(subEventName, this.argSchemas_);
73 var subEventCallback = cb; 76 var subEventCallback = cb;
74 if (opt_extraInfo && opt_extraInfo.indexOf('blocking') >= 0) { 77 if (opt_extraInfo && opt_extraInfo.indexOf('blocking') >= 0) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 var apiFunctions = api.apiFunctions; 158 var apiFunctions = api.apiFunctions;
156 159
157 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() { 160 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
158 var args = Array.prototype.slice.call(arguments); 161 var args = Array.prototype.slice.call(arguments);
159 sendRequest(this.name, args, this.definition.parameters, 162 sendRequest(this.name, args, this.definition.parameters,
160 {forIOThread: true}); 163 {forIOThread: true});
161 }); 164 });
162 }); 165 });
163 166
164 exports.binding = binding.generate(); 167 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/event.js ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698