summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorcduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 07:33:11 +0000
committercduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 07:33:11 +0000
commit268125115bce8b824756c14735d28f846781680b (patch)
treef48731ef19db92117723bfc9ea3bbf9a78d86ecb /chrome/common/extensions
parentbe8b83b4a3c633ad037a7dcf7644b6146481a217 (diff)
downloadchromium_src-268125115bce8b824756c14735d28f846781680b.zip
chromium_src-268125115bce8b824756c14735d28f846781680b.tar.gz
chromium_src-268125115bce8b824756c14735d28f846781680b.tar.bz2
Prevent chrome.app JSON schema from loading on every page
The app API along with app.window and app.runtime have been converted to use the feature system. Bindings are not added to the chrome object for unavailable APIs that are children of available APIs. For example, if chrome.app is available, we will not add lazy bindings to chrome for app.window and app.runtime. This eliminates the need to load the app schema, because we no longer need to get chrome.app to add the app.runtime and app.window bindings. BUG=55316 Review URL: https://chromiumcodereview.appspot.com/13604005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/api/_api_features.json26
-rw-r--r--chrome/common/extensions/api/app.json2
-rw-r--r--chrome/common/extensions/api/extension_api_unittest.cc19
3 files changed, 36 insertions, 11 deletions
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 1ed1017..e8d9acd 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -3,6 +3,26 @@
// found in the LICENSE file.
{
+ "app": {
+ "channel": "stable",
+ "extension_types": ["hosted_app", "extension"],
+ "contexts": [
+ "blessed_extension", "unblessed_extension", "content_script", "web_page"
+ ],
+ "matches": [
+ "http://*/*", "https://*/*", "chrome-extension://*/*", "file://*/*"
+ ]
+ },
+ "app.runtime": {
+ "channel": "stable",
+ "contexts": ["blessed_extension"],
+ "dependencies": ["permission:app.runtime"]
+ },
+ "app.window": {
+ "channel": "stable",
+ "contexts": ["blessed_extension"],
+ "dependencies": ["permission:app.window"]
+ },
"app.currentWindowInternal": {
"internal": true,
"channel": "stable",
@@ -21,7 +41,9 @@
"events": {
"internal": true,
"channel": "stable",
- "contexts": ["blessed_extension", "unblessed_extension", "content_script", "web_page"],
+ "contexts": [
+ "blessed_extension", "unblessed_extension", "content_script", "web_page"
+ ],
"matches": ["<all_urls>"]
},
"fileBrowserHandlerInternal": {
@@ -40,6 +62,6 @@
"extension_types": ["hosted_app"],
"contexts": ["blessed_extension", "web_page"],
// Any webpage can use the webstore API.
- "matches": [ "http://*/*", "https://*/*" ]
+ "matches": ["http://*/*", "https://*/*"]
}
}
diff --git a/chrome/common/extensions/api/app.json b/chrome/common/extensions/api/app.json
index 0faef3c..7735f63 100644
--- a/chrome/common/extensions/api/app.json
+++ b/chrome/common/extensions/api/app.json
@@ -6,8 +6,6 @@
{
"namespace": "app",
"nodoc": true,
- "unprivileged": true,
- "matches": [ "<all_urls>" ],
"types": [
{
"id": "Details",
diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc
index f980b57..f32d451 100644
--- a/chrome/common/extensions/api/extension_api_unittest.cc
+++ b/chrome/common/extensions/api/extension_api_unittest.cc
@@ -172,10 +172,14 @@ TEST(ExtensionAPI, APIFeatures) {
{ "test2.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() },
{ "test3", false, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") },
{ "test3.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") },
- { "test3.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
- { "test4", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
- { "test4.foo", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
- { "test4.foo", false, Feature::UNBLESSED_EXTENSION_CONTEXT, GURL() },
+ { "test3.foo", true, Feature::BLESSED_EXTENSION_CONTEXT,
+ GURL("http://bad.com") },
+ { "test4", true, Feature::BLESSED_EXTENSION_CONTEXT,
+ GURL("http://bad.com") },
+ { "test4.foo", false, Feature::BLESSED_EXTENSION_CONTEXT,
+ GURL("http://bad.com") },
+ { "test4.foo", false, Feature::UNBLESSED_EXTENSION_CONTEXT,
+ GURL("http://bad.com") },
{ "test4.foo.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() },
{ "test5", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
{ "test5", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
@@ -380,11 +384,12 @@ TEST_F(ExtensionAPITest, URLMatching) {
EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net"));
EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html"));
- // But not internal URLs (for chrome-extension:// the app API is injected by
- // GetSchemasForExtension).
+ // But not internal URLs.
EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags"));
EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags"));
- EXPECT_FALSE(MatchesURL(api.get(), "app",
+
+ // "app" should be available to chrome-extension URLs.
+ EXPECT_TRUE(MatchesURL(api.get(), "app",
"chrome-extension://fakeextension"));
// "storage" API (for example) isn't available to any URLs.