summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-03 04:43:19 +0000
committercduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-03 04:43:19 +0000
commit52eafbd0e4f3e9fdadd90bd98c7187c2c386cfbe (patch)
treef7f1bd25ba72f0bd7b8d8107cb8455bfac0849d7
parentcfadadda51529137a8c9462a1f7247e92208fc92 (diff)
downloadchromium_src-52eafbd0e4f3e9fdadd90bd98c7187c2c386cfbe.zip
chromium_src-52eafbd0e4f3e9fdadd90bd98c7187c2c386cfbe.tar.gz
chromium_src-52eafbd0e4f3e9fdadd90bd98c7187c2c386cfbe.tar.bz2
Remove internal APIs from the chrome object
Internal APIs like webRequestInternal were showing up on the chrome object. This patch prevents that from happening, and adds a new "internal" field to _api_features.json. BUG=120070, 55316 Review URL: https://chromiumcodereview.appspot.com/13097012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191984 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_bindings_apitest.cc6
-rw-r--r--chrome/common/extensions/api/_api_features.json26
-rw-r--r--chrome/common/extensions/api/app_current_window_internal.idl2
-rw-r--r--chrome/common/extensions/api/downloads_internal.idl2
-rw-r--r--chrome/common/extensions/api/events.json1
-rw-r--r--chrome/common/extensions/api/extension_api.cc2
-rw-r--r--chrome/common/extensions/api/file_browser_handler_internal.json1
-rw-r--r--chrome/common/extensions/api/web_request_internal.json1
-rw-r--r--chrome/common/extensions/features/api_feature.cc8
-rw-r--r--chrome/common/extensions/features/api_feature.h5
-rw-r--r--chrome/common/extensions/features/base_feature_provider.cc2
-rw-r--r--chrome/common/extensions/features/base_feature_provider.h2
-rw-r--r--chrome/common/extensions/features/complex_feature.cc5
-rw-r--r--chrome/common/extensions/features/complex_feature.h2
-rw-r--r--chrome/common/extensions/features/feature.h3
-rw-r--r--chrome/common/extensions/features/simple_feature.cc5
-rw-r--r--chrome/common/extensions/features/simple_feature.h2
-rw-r--r--chrome/renderer/extensions/dispatcher.cc6
-rw-r--r--chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/manifest.json5
-rw-r--r--chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.html6
-rw-r--r--chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.js9
21 files changed, 92 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_bindings_apitest.cc b/chrome/browser/extensions/extension_bindings_apitest.cc
index 4870054..1eb5f90 100644
--- a/chrome/browser/extensions/extension_bindings_apitest.cc
+++ b/chrome/browser/extensions/extension_bindings_apitest.cc
@@ -35,3 +35,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) {
host->render_view_host(), "testLastError()", &result));
EXPECT_TRUE(result);
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, InternalAPIsNotOnChromeObject) {
+ ASSERT_TRUE(RunExtensionSubtest(
+ "bindings/internal_apis_not_on_chrome_object",
+ "page.html")) << message_;
+}
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 8657cdc..1ed1017 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -3,11 +3,37 @@
// found in the LICENSE file.
{
+ "app.currentWindowInternal": {
+ "internal": true,
+ "channel": "stable",
+ "contexts": ["blessed_extension", "unblessed_extension", "content_script"]
+ },
"bookmarks": {
"channel": "stable",
"dependencies": ["permission:bookmarks"],
"contexts": ["blessed_extension"]
},
+ "downloadsInternal": {
+ "internal": true,
+ "channel": "stable",
+ "contexts": ["blessed_extension", "unblessed_extension", "content_script"]
+ },
+ "events": {
+ "internal": true,
+ "channel": "stable",
+ "contexts": ["blessed_extension", "unblessed_extension", "content_script", "web_page"],
+ "matches": ["<all_urls>"]
+ },
+ "fileBrowserHandlerInternal": {
+ "internal": true,
+ "channel": "stable",
+ "contexts": ["blessed_extension", "unblessed_extension", "content_script"]
+ },
+ "webRequestInternal": {
+ "internal": true,
+ "channel": "stable",
+ "contexts": ["blessed_extension", "unblessed_extension", "content_script"]
+ },
"webstore": {
// Hosted apps can use the webstore API from within a blessed context.
"channel": "stable",
diff --git a/chrome/common/extensions/api/app_current_window_internal.idl b/chrome/common/extensions/api/app_current_window_internal.idl
index 2aff3c6..c063bea 100644
--- a/chrome/common/extensions/api/app_current_window_internal.idl
+++ b/chrome/common/extensions/api/app_current_window_internal.idl
@@ -4,7 +4,7 @@
// This is used by the app window API internally to pass through messages to
// the shell window.
-[internal, nodoc] namespace app.currentWindowInternal {
+[nodoc] namespace app.currentWindowInternal {
// TODO(asargent) - We need to add support for referencing types in
// other namespaces (crbug.com/158654). For now just duplicate this
diff --git a/chrome/common/extensions/api/downloads_internal.idl b/chrome/common/extensions/api/downloads_internal.idl
index 449ae87..9da2c1d 100644
--- a/chrome/common/extensions/api/downloads_internal.idl
+++ b/chrome/common/extensions/api/downloads_internal.idl
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-[permissions=downloads_internal, internal=true, nodoc=true]
+[permissions=downloads_internal, nodoc=true]
namespace downloadsInternal {
interface Functions {
// Secretly called when onDeterminingFilename handlers return.
diff --git a/chrome/common/extensions/api/events.json b/chrome/common/extensions/api/events.json
index 37ab89c..d28eb93 100644
--- a/chrome/common/extensions/api/events.json
+++ b/chrome/common/extensions/api/events.json
@@ -8,7 +8,6 @@
"compiler_options": {
"implemented_in": "chrome/browser/extensions/api/declarative/declarative_api.h"
},
- "internal": true,
"unprivileged": true,
"types": [
{
diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc
index d2c2b78..b1095a4 100644
--- a/chrome/common/extensions/api/extension_api.cc
+++ b/chrome/common/extensions/api/extension_api.cc
@@ -334,7 +334,7 @@ ExtensionAPI::~ExtensionAPI() {
void ExtensionAPI::InitDefaultConfiguration() {
RegisterDependencyProvider(
- "api", BaseFeatureProvider::GetApiFeatures());
+ "api", BaseFeatureProvider::GetAPIFeatures());
RegisterDependencyProvider(
"manifest", BaseFeatureProvider::GetManifestFeatures());
RegisterDependencyProvider(
diff --git a/chrome/common/extensions/api/file_browser_handler_internal.json b/chrome/common/extensions/api/file_browser_handler_internal.json
index a50a0a8..7bb6771 100644
--- a/chrome/common/extensions/api/file_browser_handler_internal.json
+++ b/chrome/common/extensions/api/file_browser_handler_internal.json
@@ -9,7 +9,6 @@
"implemented_in": "chrome/browser/chromeos/extensions/file_browser_handler_api.h"
},
"nodoc": true,
- "internal": true,
"platforms": ["chromeos"],
"types": [
{
diff --git a/chrome/common/extensions/api/web_request_internal.json b/chrome/common/extensions/api/web_request_internal.json
index e401a01..0cdd760 100644
--- a/chrome/common/extensions/api/web_request_internal.json
+++ b/chrome/common/extensions/api/web_request_internal.json
@@ -6,7 +6,6 @@
{
"namespace": "webRequestInternal",
"nodoc": true,
- "internal": true,
"functions": [
{
"name": "addEventListener",
diff --git a/chrome/common/extensions/features/api_feature.cc b/chrome/common/extensions/features/api_feature.cc
index 09b8c19..0020632 100644
--- a/chrome/common/extensions/features/api_feature.cc
+++ b/chrome/common/extensions/features/api_feature.cc
@@ -6,17 +6,23 @@
namespace extensions {
-APIFeature::APIFeature() {
+APIFeature::APIFeature() : internal_(false) {
}
APIFeature::~APIFeature() {
}
+bool APIFeature::IsInternal() const {
+ return internal_;
+}
+
std::string APIFeature::Parse(const DictionaryValue* value) {
std::string error = SimpleFeature::Parse(value);
if (!error.empty())
return error;
+ value->GetBoolean("internal", &internal_);
+
if (GetContexts()->empty())
return name() + ": API features must specify at least one context.";
diff --git a/chrome/common/extensions/features/api_feature.h b/chrome/common/extensions/features/api_feature.h
index e6484ae4..edd58d1 100644
--- a/chrome/common/extensions/features/api_feature.h
+++ b/chrome/common/extensions/features/api_feature.h
@@ -14,7 +14,12 @@ class APIFeature : public SimpleFeature {
APIFeature();
virtual ~APIFeature();
+ virtual bool IsInternal() const OVERRIDE;
+
virtual std::string Parse(const DictionaryValue* value) OVERRIDE;
+
+ private:
+ bool internal_;
};
} // extensions
diff --git a/chrome/common/extensions/features/base_feature_provider.cc b/chrome/common/extensions/features/base_feature_provider.cc
index 3e2c5e5..b702d62 100644
--- a/chrome/common/extensions/features/base_feature_provider.cc
+++ b/chrome/common/extensions/features/base_feature_provider.cc
@@ -137,7 +137,7 @@ BaseFeatureProvider::~BaseFeatureProvider() {
}
// static
-BaseFeatureProvider* BaseFeatureProvider::GetApiFeatures() {
+BaseFeatureProvider* BaseFeatureProvider::GetAPIFeatures() {
return g_static.Get().api_features.get();
}
diff --git a/chrome/common/extensions/features/base_feature_provider.h b/chrome/common/extensions/features/base_feature_provider.h
index 5a68f6f..389f8ac 100644
--- a/chrome/common/extensions/features/base_feature_provider.h
+++ b/chrome/common/extensions/features/base_feature_provider.h
@@ -28,7 +28,7 @@ class BaseFeatureProvider : public FeatureProvider {
// Gets an instance for the _api_features.json file that is baked into
// Chrome as a resource.
- static BaseFeatureProvider* GetApiFeatures();
+ static BaseFeatureProvider* GetAPIFeatures();
// Gets an instance for the _manifest_features.json file that is baked into
// Chrome as a resource.
diff --git a/chrome/common/extensions/features/complex_feature.cc b/chrome/common/extensions/features/complex_feature.cc
index 43a41b0..f6f1c11 100644
--- a/chrome/common/extensions/features/complex_feature.cc
+++ b/chrome/common/extensions/features/complex_feature.cc
@@ -67,6 +67,11 @@ std::set<Feature::Context>* ComplexFeature::GetContexts() {
return features_[0]->GetContexts();
}
+bool ComplexFeature::IsInternal() const {
+ NOTREACHED();
+ return false;
+}
+
std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result,
Manifest::Type type,
const GURL& url) const {
diff --git a/chrome/common/extensions/features/complex_feature.h b/chrome/common/extensions/features/complex_feature.h
index 3013348..84c2d47 100644
--- a/chrome/common/extensions/features/complex_feature.h
+++ b/chrome/common/extensions/features/complex_feature.h
@@ -47,6 +47,8 @@ class ComplexFeature : public Feature {
virtual std::set<Context>* GetContexts() OVERRIDE;
+ virtual bool IsInternal() const OVERRIDE;
+
private:
FeatureList features_;
diff --git a/chrome/common/extensions/features/feature.h b/chrome/common/extensions/features/feature.h
index 748d04f..95fc241 100644
--- a/chrome/common/extensions/features/feature.h
+++ b/chrome/common/extensions/features/feature.h
@@ -135,6 +135,9 @@ class Feature {
virtual std::set<Context>* GetContexts() = 0;
+ // Tests whether this is an internal API or not.
+ virtual bool IsInternal() const = 0;
+
// Returns true if the feature is available to be parsed into a new extension
// manifest.
Availability IsAvailableToManifest(const std::string& extension_id,
diff --git a/chrome/common/extensions/features/simple_feature.cc b/chrome/common/extensions/features/simple_feature.cc
index 9011e35..13c8573 100644
--- a/chrome/common/extensions/features/simple_feature.cc
+++ b/chrome/common/extensions/features/simple_feature.cc
@@ -406,6 +406,11 @@ std::set<Feature::Context>* SimpleFeature::GetContexts() {
return &contexts_;
}
+bool SimpleFeature::IsInternal() const {
+ NOTREACHED();
+ return false;
+}
+
bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const {
// An empty whitelist means the absence of a whitelist, rather than a
// whitelist that allows no ID through. This could be surprising behavior, so
diff --git a/chrome/common/extensions/features/simple_feature.h b/chrome/common/extensions/features/simple_feature.h
index 4d1581d4..7fa4226 100644
--- a/chrome/common/extensions/features/simple_feature.h
+++ b/chrome/common/extensions/features/simple_feature.h
@@ -86,6 +86,8 @@ class SimpleFeature : public Feature {
virtual std::set<Context>* GetContexts() OVERRIDE;
+ virtual bool IsInternal() const OVERRIDE;
+
protected:
Availability CreateAvailability(AvailabilityResult result) const;
Availability CreateAvailability(AvailabilityResult result,
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc
index 1016fc6..bf62a06 100644
--- a/chrome/renderer/extensions/dispatcher.cc
+++ b/chrome/renderer/extensions/dispatcher.cc
@@ -16,6 +16,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/features/base_feature_provider.h"
#include "chrome/common/extensions/features/feature.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/message_bundle.h"
@@ -680,6 +681,11 @@ void Dispatcher::RegisterSchemaGeneratedBindings(
it != apis.end(); ++it) {
const std::string& api_name = *it;
+ Feature* feature =
+ BaseFeatureProvider::GetAPIFeatures()->GetFeature(api_name);
+ if (feature && feature->IsInternal())
+ continue;
+
std::vector<std::string> split;
base::SplitString(api_name, '.', &split);
diff --git a/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/manifest.json b/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/manifest.json
new file mode 100644
index 0000000..2b4a739
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/manifest.json
@@ -0,0 +1,5 @@
+{
+ "name": "Internal APIs",
+ "manifest_version": 2,
+ "version": "1"
+}
diff --git a/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.html b/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.html
new file mode 100644
index 0000000..e56bb5a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.html
@@ -0,0 +1,6 @@
+<!--
+ * Copyright (c) 2013 The Chromium Authors. All rights reserved. Use of this
+ * source code is governed by a BSD-style license that can be found in the
+ * LICENSE file.
+-->
+<script src="page.js"></script>
diff --git a/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.js b/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.js
new file mode 100644
index 0000000..e2e4d34
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bindings/internal_apis_not_on_chrome_object/page.js
@@ -0,0 +1,9 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+chrome.test.assertFalse(chrome.hasOwnProperty('downloadsInternal'));
+chrome.test.assertFalse(chrome.hasOwnProperty('events'));
+chrome.test.assertFalse(chrome.hasOwnProperty('fileBrowserHandlerInternal'));
+chrome.test.assertFalse(chrome.hasOwnProperty('webRequestInternal'));
+chrome.test.succeed();