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

Unified Diff: chrome/renderer/extensions/custom_bindings_util.cc

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aa comments 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/extensions/custom_bindings_util.cc
diff --git a/chrome/renderer/extensions/custom_bindings_util.cc b/chrome/renderer/extensions/custom_bindings_util.cc
index 352f7015e9852eaa8710ca2a83e34e1f9203dfad..d00324b0beb5dd120690f91b94f37104d9f939d3 100644
--- a/chrome/renderer/extensions/custom_bindings_util.cc
+++ b/chrome/renderer/extensions/custom_bindings_util.cc
@@ -10,6 +10,7 @@
#include "base/string_util.h"
#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/renderer/extensions/app_bindings.h"
#include "chrome/renderer/extensions/chrome_v8_extension.h"
#include "chrome/renderer/extensions/chrome_private_custom_bindings.h"
#include "chrome/renderer/extensions/context_menus_custom_bindings.h"
@@ -72,6 +73,8 @@ std::vector<v8::Extension*> GetAll(ExtensionDispatcher* extension_dispatcher) {
std::vector<v8::Extension*> result;
// Custom bindings that have native code parts.
+ result.push_back(new AppBindings(
+ kDependencyCount, kDependencies, extension_dispatcher));
result.push_back(new ChromePrivateCustomBindings(
kDependencyCount, kDependencies, extension_dispatcher));
result.push_back(new ContextMenusCustomBindings(
@@ -149,7 +152,7 @@ std::string GetAPIName(const std::string& v8_extension_name) {
bool AllowAPIInjection(const std::string& api_name,
const Extension& extension,
- ExtensionDispatcher* extension_dispatcher) {
+ ChromeV8Context::ContextType context_type) {
CHECK(api_name != "");
// As in ExtensionAPI::GetSchemasForExtension, we need to allow any bindings
@@ -158,12 +161,20 @@ bool AllowAPIInjection(const std::string& api_name,
extension.required_permission_set()->HasAnyAccessToAPI(api_name) ||
extension.optional_permission_set()->HasAnyAccessToAPI(api_name);
- if (extension_dispatcher->is_extension_process()) {
- return allowed;
- } else {
- return allowed &&
- !ExtensionAPI::GetInstance()->IsWholeAPIPrivileged(api_name);
+ switch (context_type) {
+ case ChromeV8Context::PRIVILEGED:
+ return allowed;
+
+ case ChromeV8Context::CONTENT_SCRIPT:
+ case ChromeV8Context::UNPRIVILEGED:
+ return allowed &&
+ !ExtensionAPI::GetInstance()->IsWholeAPIPrivileged(api_name);
+
+ case ChromeV8Context::WEB_PAGE:
+ NOTREACHED();
}
+
+ return false;
}
} // namespace custom_bindings_util

Powered by Google App Engine
This is Rietveld 408576698