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

Unified Diff: extensions/renderer/dispatcher.cc

Issue 443723003: extensions: Register 'app' and 'webstore' bindings only if they are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/renderer/dispatcher.h ('k') | no next file » | 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 f27eba89d7aa253ff021d15e56cd78abeec0cd75..c30f91d16c04d5de9b993549178c5364bef07c04 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -1003,8 +1003,11 @@ void Dispatcher::UpdateBindingsForContext(ScriptContext* context) {
case Feature::BLESSED_WEB_PAGE_CONTEXT: {
// Web page context; it's too expensive to run the full bindings code.
// Hard-code that the app and webstore APIs are available...
- RegisterBinding("app", context);
- RegisterBinding("webstore", context);
+ if (IsApiAvailable(std::string("app"), context))
not at google - send to devlin 2014/08/05 22:43:39 it's easier to do if (context->GetAvailability("a
sadrul 2014/08/05 22:51:02 Nice! Done.
+ RegisterBinding("app", context);
+
+ if (IsApiAvailable(std::string("webstore"), context))
not at google - send to devlin 2014/08/05 22:43:39 also, no need to explicitly construct a std::strin
sadrul 2014/08/05 22:51:02 Acknowledged.
+ RegisterBinding("webstore", context);
not at google - send to devlin 2014/08/05 22:43:39 indentation
sadrul 2014/08/05 22:51:02 Done.
// ... and that the runtime API might be available if any extension can
// connect to it.
@@ -1166,6 +1169,13 @@ bool Dispatcher::IsSandboxedPage(const GURL& url) const {
return false;
}
+bool Dispatcher::IsApiAvailable(const std::string& api_name,
+ ScriptContext* context) {
+ return ExtensionAPI::GetSharedInstance()->IsAvailable(
+ api_name, context->extension(), context->context_type(),
+ context->GetURL()).is_available();
+}
+
Feature::Context Dispatcher::ClassifyJavaScriptContext(
const Extension* extension,
int extension_group,
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698