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

Unified Diff: extensions/renderer/dispatcher.cc

Issue 404883002: Allow extension APIs to be called from WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compile Created 6 years, 5 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
« no previous file with comments | « extensions/common/features/simple_feature_unittest.cc ('k') | extensions/renderer/resources/binding.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index c030d3da1843b1ad96ec3168657749786d0c71b1..caf7caea0fb1effa42e473c6544ce8ae79f4a4af 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -376,12 +376,6 @@ bool Dispatcher::CheckContextAccessToExtensionAPI(
return false;
}
- if (!context->extension()) {
- context->isolate()->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(context->isolate(), "Not in an extension.")));
- return false;
- }
-
// Theoretically we could end up with bindings being injected into sandboxed
// frames, for example content scripts. Don't let them execute API functions.
blink::WebFrame* frame = context->web_frame();
@@ -858,7 +852,8 @@ void Dispatcher::UpdateBindingsForContext(ScriptContext* context) {
case Feature::BLESSED_EXTENSION_CONTEXT:
case Feature::UNBLESSED_EXTENSION_CONTEXT:
- case Feature::CONTENT_SCRIPT_CONTEXT: {
+ case Feature::CONTENT_SCRIPT_CONTEXT:
+ case Feature::WEBUI_CONTEXT: {
// Extension context; iterate through all the APIs and bind the available
// ones.
const FeatureProvider* api_feature_provider =
@@ -1136,10 +1131,13 @@ Feature::Context Dispatcher::ClassifyJavaScriptContext(
: Feature::UNBLESSED_EXTENSION_CONTEXT;
}
- if (url.is_valid())
- return Feature::WEB_PAGE_CONTEXT;
+ if (!url.is_valid())
+ return Feature::UNSPECIFIED_CONTEXT;
+
+ if (url.SchemeIs(content::kChromeUIScheme))
+ return Feature::WEBUI_CONTEXT;
- return Feature::UNSPECIFIED_CONTEXT;
+ return Feature::WEB_PAGE_CONTEXT;
}
v8::Handle<v8::Object> Dispatcher::GetOrCreateObject(
« no previous file with comments | « extensions/common/features/simple_feature_unittest.cc ('k') | extensions/renderer/resources/binding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698