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

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

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 years, 8 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 // This script contains privileged chrome extension related javascript APIs. 5 // This script contains privileged chrome extension related javascript APIs.
6 // It is loaded by pages whose URL has the chrome-extension protocol. 6 // It is loaded by pages whose URL has the chrome-extension protocol.
7 7
8 require('json_schema'); 8 require('json_schema');
9 require('event_bindings'); 9 require('event_bindings');
10 var GetExtensionAPIDefinition = 10 var GetExtensionAPIDefinition =
11 requireNative('apiDefinitions').GetExtensionAPIDefinition; 11 requireNative('apiDefinitions').GetExtensionAPIDefinition;
12 var IsMemberAllowed = requireNative('apiDefinitions').IsMemberAllowed;
12 var sendRequest = require('sendRequest').sendRequest; 13 var sendRequest = require('sendRequest').sendRequest;
13 14
14 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 15 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
15 16
16 // The object to generate the bindings for "internal" APIs in, so that 17 // The object to generate the bindings for "internal" APIs in, so that
17 // extensions can't directly call them (without access to chromeHidden), 18 // extensions can't directly call them (without access to chromeHidden),
18 // but are still needed for internal mechanisms of extensions (e.g. events). 19 // but are still needed for internal mechanisms of extensions (e.g. events).
19 // 20 //
20 // This is distinct to the "*Private" APIs which are controlled via 21 // This is distinct to the "*Private" APIs which are controlled via
21 // having strict permissions and aren't generated *anywhere* unless needed. 22 // having strict permissions and aren't generated *anywhere* unless needed.
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (t.type == 'object' && customTypes[t.id]) { 389 if (t.type == 'object' && customTypes[t.id]) {
389 customTypes[t.id].prototype.setSchema(t); 390 customTypes[t.id].prototype.setSchema(t);
390 } 391 }
391 }); 392 });
392 } 393 }
393 394
394 // Returns whether access to the content of a schema should be denied, 395 // Returns whether access to the content of a schema should be denied,
395 // based on the presence of "unprivileged" and whether this is an 396 // based on the presence of "unprivileged" and whether this is an
396 // extension process (versus e.g. a content script). 397 // extension process (versus e.g. a content script).
397 function isSchemaAccessAllowed(itemSchema) { 398 function isSchemaAccessAllowed(itemSchema) {
398 return isExtensionProcess || 399 if (apiDef.uses_feature_system) {
399 apiDef.unprivileged || 400 var result = IsMemberAllowed(apiDef.namespace + "." + itemSchema.name) ;
400 itemSchema.unprivileged; 401 return result;
402 } else {
403 // TODO(aa): Remove this when all APIs are ported to feature system.
404 return isExtensionProcess ||
405 apiDef.unprivileged ||
406 itemSchema.unprivileged;
407 }
401 } 408 }
402 409
403 // Adds a getter that throws an access denied error to object |mod| 410 // Adds a getter that throws an access denied error to object |mod|
404 // for property |name|. 411 // for property |name|.
405 function addUnprivilegedAccessGetter(mod, name) { 412 function addUnprivilegedAccessGetter(mod, name) {
406 mod.__defineGetter__(name, function() { 413 mod.__defineGetter__(name, function() {
407 throw new Error( 414 throw new Error('"' + name + '" cannot be used in this context.');
408 '"' + name + '" can only be used in extension processes. See ' +
409 'the content scripts documentation for more details.');
410 }); 415 });
411 } 416 }
412 417
413 // Setup Functions. 418 // Setup Functions.
414 if (apiDef.functions) { 419 if (apiDef.functions) {
415 apiDef.functions.forEach(function(functionDef) { 420 apiDef.functions.forEach(function(functionDef) {
416 if (functionDef.name in mod) { 421 if (functionDef.name in mod) {
417 throw new Error('Function ' + functionDef.name + 422 throw new Error('Function ' + functionDef.name +
418 ' already defined in ' + apiDef.namespace); 423 ' already defined in ' + apiDef.namespace);
419 } 424 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // beginInstallWithManifest2. 585 // beginInstallWithManifest2.
581 // See http://crbug.com/100242 586 // See http://crbug.com/100242
582 if (chrome.webstorePrivate) { 587 if (chrome.webstorePrivate) {
583 chrome.webstorePrivate.beginInstallWithManifest2 = 588 chrome.webstorePrivate.beginInstallWithManifest2 =
584 chrome.webstorePrivate.beginInstallWithManifest3; 589 chrome.webstorePrivate.beginInstallWithManifest3;
585 } 590 }
586 591
587 if (chrome.test) 592 if (chrome.test)
588 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; 593 chrome.test.getApiDefinitions = GetExtensionAPIDefinition;
589 }); 594 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698