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, |