| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // Treat CDM invocations like JavaScript. | 238 // Treat CDM invocations like JavaScript. |
| 239 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) { | 239 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) { |
| 240 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); | 240 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); |
| 241 return true; | 241 return true; |
| 242 } | 242 } |
| 243 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) | 243 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) |
| 244 | 244 |
| 245 return false; | 245 return false; |
| 246 } | 246 } |
| 247 | 247 |
| 248 void IsGuestViewApiAvailableToScriptContext( |
| 249 bool* api_is_available, |
| 250 extensions::ScriptContext* context) { |
| 251 if (context->GetAvailability("guestViewInternal").is_available()) { |
| 252 *api_is_available = true; |
| 253 } |
| 254 } |
| 255 |
| 248 } // namespace | 256 } // namespace |
| 249 | 257 |
| 250 ChromeContentRendererClient::ChromeContentRendererClient() { | 258 ChromeContentRendererClient::ChromeContentRendererClient() { |
| 251 g_current_client = this; | 259 g_current_client = this; |
| 252 | 260 |
| 253 extensions::ExtensionsClient::Set( | 261 extensions::ExtensionsClient::Set( |
| 254 extensions::ChromeExtensionsClient::GetInstance()); | 262 extensions::ChromeExtensionsClient::GetInstance()); |
| 255 extensions::ExtensionsRendererClient::Set( | 263 extensions::ExtensionsRendererClient::Set( |
| 256 ChromeExtensionsRendererClient::GetInstance()); | 264 ChromeExtensionsRendererClient::GetInstance()); |
| 257 #if defined(ENABLE_PLUGINS) | 265 #if defined(ENABLE_PLUGINS) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 return extension_dispatcher_->extensions()->GetByID(extension_id); | 521 return extension_dispatcher_->extensions()->GetByID(extension_id); |
| 514 } | 522 } |
| 515 | 523 |
| 516 bool ChromeContentRendererClient::OverrideCreatePlugin( | 524 bool ChromeContentRendererClient::OverrideCreatePlugin( |
| 517 content::RenderFrame* render_frame, | 525 content::RenderFrame* render_frame, |
| 518 WebLocalFrame* frame, | 526 WebLocalFrame* frame, |
| 519 const WebPluginParams& params, | 527 const WebPluginParams& params, |
| 520 WebPlugin** plugin) { | 528 WebPlugin** plugin) { |
| 521 std::string orig_mime_type = params.mimeType.utf8(); | 529 std::string orig_mime_type = params.mimeType.utf8(); |
| 522 if (orig_mime_type == content::kBrowserPluginMimeType) { | 530 if (orig_mime_type == content::kBrowserPluginMimeType) { |
| 523 WebDocument document = frame->document(); | 531 bool guest_view_api_available = false; |
| 524 const Extension* extension = | 532 extension_dispatcher_->script_context_set().ForEach( |
| 525 GetExtensionByOrigin(document.securityOrigin()); | 533 render_frame->GetRenderView(), |
| 526 if (extension) { | 534 base::Bind(&IsGuestViewApiAvailableToScriptContext, |
| 527 const extensions::APIPermission::ID perms[] = { | 535 &guest_view_api_available)); |
| 528 extensions::APIPermission::kAppView, | 536 if (guest_view_api_available) |
| 529 extensions::APIPermission::kEmbeddedExtensionOptions, | 537 return false; |
| 530 extensions::APIPermission::kWebView, | |
| 531 }; | |
| 532 for (size_t i = 0; i < arraysize(perms); ++i) { | |
| 533 if (extension->permissions_data()->HasAPIPermission(perms[i])) | |
| 534 return false; | |
| 535 } | |
| 536 } | |
| 537 } | 538 } |
| 538 | 539 |
| 539 ChromeViewHostMsg_GetPluginInfo_Output output; | 540 ChromeViewHostMsg_GetPluginInfo_Output output; |
| 540 #if defined(ENABLE_PLUGINS) | 541 #if defined(ENABLE_PLUGINS) |
| 541 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( | 542 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( |
| 542 render_frame->GetRoutingID(), GURL(params.url), | 543 render_frame->GetRoutingID(), GURL(params.url), |
| 543 frame->top()->document().url(), orig_mime_type, &output)); | 544 frame->top()->document().url(), orig_mime_type, &output)); |
| 544 | 545 |
| 545 if (output.plugin.type == content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) | 546 if (output.plugin.type == content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) |
| 546 return false; | 547 return false; |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 | 1502 |
| 1502 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) | 1503 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) |
| 1503 return true; | 1504 return true; |
| 1504 | 1505 |
| 1505 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 1506 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 1506 return channel <= chrome::VersionInfo::CHANNEL_DEV; | 1507 return channel <= chrome::VersionInfo::CHANNEL_DEV; |
| 1507 #else | 1508 #else |
| 1508 return false; | 1509 return false; |
| 1509 #endif | 1510 #endif |
| 1510 } | 1511 } |
| OLD | NEW |