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

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

Issue 10257006: Move Declarative Web Request API out of experimental and make it a feature (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 7 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 var eventBindingsNatives = requireNative('event_bindings'); 5 var eventBindingsNatives = requireNative('event_bindings');
6 var AttachEvent = eventBindingsNatives.AttachEvent; 6 var AttachEvent = eventBindingsNatives.AttachEvent;
7 var DetachEvent = eventBindingsNatives.DetachEvent; 7 var DetachEvent = eventBindingsNatives.DetachEvent;
8 var Print = eventBindingsNatives.Print; 8 var Print = eventBindingsNatives.Print;
9 9
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 this.validate_ = []; 250 this.validate_ = [];
251 this.detach_(false); 251 this.detach_(false);
252 }; 252 };
253 253
254 // Gets the declarative API object, or undefined if this extension doesn't 254 // Gets the declarative API object, or undefined if this extension doesn't
255 // have access to it. 255 // have access to it.
256 // 256 //
257 // This is defined as a function (rather than a variable) because it isn't 257 // This is defined as a function (rather than a variable) because it isn't
258 // accessible until the schema bindings have been generated. 258 // accessible until the schema bindings have been generated.
259 function getDeclarativeAPI() { 259 function getDeclarativeAPI() {
260 if (chromeHidden.internalAPIs.experimental) 260 return chromeHidden.internalAPIs.declarative;
261 return chromeHidden.internalAPIs.experimental.declarative;
262 else
263 return undefined;
264 } 261 }
265 262
266 chrome.Event.prototype.addRules = function(rules, opt_cb) { 263 chrome.Event.prototype.addRules = function(rules, opt_cb) {
267 if (!this.eventOptions_.supportsRules) 264 if (!this.eventOptions_.supportsRules)
268 throw new Error("This event does not support rules."); 265 throw new Error("This event does not support rules.");
269 if (!getDeclarativeAPI()) { 266 if (!getDeclarativeAPI()) {
270 throw new Error("You must have permission to use the declarative " + 267 throw new Error("You must have permission to use the declarative " +
271 "API to support rules in events"); 268 "API to support rules in events");
272 } 269 }
273 getDeclarativeAPI().addRules(this.eventName_, rules, opt_cb); 270 getDeclarativeAPI().addRules(this.eventName_, rules, opt_cb);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 for (var i = 0; i < allAttachedEvents.length; ++i) { 306 for (var i = 0; i < allAttachedEvents.length; ++i) {
310 var event = allAttachedEvents[i]; 307 var event = allAttachedEvents[i];
311 if (event) 308 if (event)
312 event.detach_(false); 309 event.detach_(false);
313 } 310 }
314 }; 311 };
315 312
316 chromeHidden.dispatchError = function(msg) { 313 chromeHidden.dispatchError = function(msg) {
317 console.error(msg); 314 console.error(msg);
318 }; 315 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698