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

Unified Diff: chrome/renderer/resources/extensions/schema_generated_bindings.js

Issue 9309114: Allow "internal" APIs to be specified in extension API schemas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/schema_generated_bindings.js
diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js
index 48fb43a687a9655d0662ad7edd2adfad0d89e591..df126906ea7050abd57103c9fb40392d055c07ae 100644
--- a/chrome/renderer/resources/extensions/schema_generated_bindings.js
+++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js
@@ -15,17 +15,14 @@ var chrome = chrome || {};
var chromeHidden = GetChromeHidden();
- if (!chrome)
- chrome = {};
-
- function apiExists(path) {
- var resolved = chrome;
- path.split(".").forEach(function(next) {
- if (resolved)
- resolved = resolved[next];
- });
- return !!resolved;
- }
+ // The object to generate the bindings for "internal" APIs in, so that
+ // extensions can't directly call them (without access to chromeHidden),
+ // but are still needed for internal mechanisms of extensions (e.g. events).
+ //
+ // This is distinct to the "*Private" APIs which are controlled via
+ // having strict permissions and aren't generated *anywhere* unless needed.
+ var internalAPIs = {};
+ chromeHidden.internalAPIs = internalAPIs;
function forEach(dict, f) {
for (key in dict) {
@@ -385,7 +382,9 @@ var chrome = chrome || {};
if (!isSchemaNodeSupported(apiDef, platform, manifestVersion))
return;
- var module = chrome;
+ // See comment on internalAPIs at the top.
+ var module = apiDef.internal ? internalAPIs : chrome;
+
var namespaces = apiDef.namespace.split('.');
for (var index = 0, name; name = namespaces[index]; index++) {
module[name] = module[name] || {};
@@ -574,12 +573,12 @@ var chrome = chrome || {};
// TOOD(mihaip): remove this alias once the webstore stops calling
// beginInstallWithManifest2.
// See http://crbug.com/100242
- if (apiExists("webstorePrivate")) {
+ if (chrome.webstorePrivate) {
chrome.webstorePrivate.beginInstallWithManifest2 =
chrome.webstorePrivate.beginInstallWithManifest3;
}
- if (apiExists("test"))
+ if (chrome.test)
chrome.test.getApiDefinitions = GetExtensionAPIDefinition;
});
})();

Powered by Google App Engine
This is Rietveld 408576698