Chromium Code Reviews| Index: chrome/renderer/chrome_content_renderer_client.cc |
| diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc |
| index d2a85a59fc0b156f0dd142ea6967843f8ed51c3b..8c43ada0dc6ad421e0de69ae1be28ccd00a08956 100644 |
| --- a/chrome/renderer/chrome_content_renderer_client.cc |
| +++ b/chrome/renderer/chrome_content_renderer_client.cc |
| @@ -513,6 +513,14 @@ const Extension* ChromeContentRendererClient::GetExtensionByOrigin( |
| return extension_dispatcher_->extensions()->GetByID(extension_id); |
| } |
| +void GetScriptContextForGuestView(extensions::ScriptContext** out, |
|
not at google - send to devlin
2014/08/07 23:06:03
should be in an anonymous namespace.
and "Find" m
ericzeng
2014/08/08 00:23:47
Done.
|
| + extensions::ScriptContext* in) { |
| + if (in->context_type() == extensions::Feature::BLESSED_EXTENSION_CONTEXT || |
| + in->context_type() == extensions::Feature::WEBUI_CONTEXT) { |
| + *out = in; |
| + } |
| +} |
| + |
| bool ChromeContentRendererClient::OverrideCreatePlugin( |
| content::RenderFrame* render_frame, |
| WebLocalFrame* frame, |
| @@ -520,18 +528,18 @@ bool ChromeContentRendererClient::OverrideCreatePlugin( |
| WebPlugin** plugin) { |
| std::string orig_mime_type = params.mimeType.utf8(); |
| if (orig_mime_type == content::kBrowserPluginMimeType) { |
| - WebDocument document = frame->document(); |
| - const Extension* extension = |
| - GetExtensionByOrigin(document.securityOrigin()); |
| - if (extension) { |
| - const extensions::APIPermission::ID perms[] = { |
| - extensions::APIPermission::kAppView, |
| - extensions::APIPermission::kEmbeddedExtensionOptions, |
| - extensions::APIPermission::kWebView, |
| - }; |
| - for (size_t i = 0; i < arraysize(perms); ++i) { |
| - if (extension->permissions_data()->HasAPIPermission(perms[i])) |
| - return false; |
| + // See chrome/common/extensions/api/_api_features.json for API names |
| + const std::string perms[] = {"appViewInternal", "extensionOptionsInternal", |
| + "webViewInternal"}; |
|
not at google - send to devlin
2014/08/07 23:06:03
hm, in https://codereview.chromium.org/426593007/
Fady Samuel
2014/08/07 23:14:01
Nope, perhaps something in chrome/common/guest_vie
|
| + |
| + extensions::ScriptContext* context = NULL; |
| + extension_dispatcher_->script_context_set().ForEach( |
| + render_frame->GetRenderView(), |
| + base::Bind(&GetScriptContextForGuestView, &context)); |
|
Fady Samuel
2014/08/07 23:09:29
If I'm reading this correctly, context will be NUL
ericzeng
2014/08/08 00:23:47
Fixed the null pointer issue - see kalman's commen
|
| + |
|
not at google - send to devlin
2014/08/07 23:06:03
you need to check whether it actually found a cont
ericzeng
2014/08/08 00:23:47
Done.
|
| + for (size_t i = 0; i < arraysize(perms); ++i) { |
| + if (context->GetAvailability(perms[i]).is_available()) { |
| + return false; |
| } |
| } |
| } |
| @@ -591,7 +599,6 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( |
| GURL url(original_params.url); |
| std::string orig_mime_type = original_params.mimeType.utf8(); |
| ChromePluginPlaceholder* placeholder = NULL; |
| - |
|
not at google - send to devlin
2014/08/07 23:06:03
probably should revert this change.
ericzeng
2014/08/08 00:23:47
Done.
|
| // If the browser plugin is to be enabled, this should be handled by the |
| // renderer, so the code won't reach here due to the early exit in |
| // OverrideCreatePlugin. |