Chromium Code Reviews| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 | 506 |
| 507 const Extension* ChromeContentRendererClient::GetExtensionByOrigin( | 507 const Extension* ChromeContentRendererClient::GetExtensionByOrigin( |
| 508 const WebSecurityOrigin& origin) const { | 508 const WebSecurityOrigin& origin) const { |
| 509 if (!EqualsASCII(origin.protocol(), extensions::kExtensionScheme)) | 509 if (!EqualsASCII(origin.protocol(), extensions::kExtensionScheme)) |
| 510 return NULL; | 510 return NULL; |
| 511 | 511 |
| 512 const std::string extension_id = origin.host().utf8().data(); | 512 const std::string extension_id = origin.host().utf8().data(); |
| 513 return extension_dispatcher_->extensions()->GetByID(extension_id); | 513 return extension_dispatcher_->extensions()->GetByID(extension_id); |
| 514 } | 514 } |
| 515 | 515 |
| 516 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.
| |
| 517 extensions::ScriptContext* in) { | |
| 518 if (in->context_type() == extensions::Feature::BLESSED_EXTENSION_CONTEXT || | |
| 519 in->context_type() == extensions::Feature::WEBUI_CONTEXT) { | |
| 520 *out = in; | |
| 521 } | |
| 522 } | |
| 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 // See chrome/common/extensions/api/_api_features.json for API names |
| 524 const Extension* extension = | 532 const std::string perms[] = {"appViewInternal", "extensionOptionsInternal", |
| 525 GetExtensionByOrigin(document.securityOrigin()); | 533 "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
| |
| 526 if (extension) { | 534 |
| 527 const extensions::APIPermission::ID perms[] = { | 535 extensions::ScriptContext* context = NULL; |
| 528 extensions::APIPermission::kAppView, | 536 extension_dispatcher_->script_context_set().ForEach( |
| 529 extensions::APIPermission::kEmbeddedExtensionOptions, | 537 render_frame->GetRenderView(), |
| 530 extensions::APIPermission::kWebView, | 538 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
| |
| 531 }; | 539 |
|
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.
| |
| 532 for (size_t i = 0; i < arraysize(perms); ++i) { | 540 for (size_t i = 0; i < arraysize(perms); ++i) { |
| 533 if (extension->permissions_data()->HasAPIPermission(perms[i])) | 541 if (context->GetAvailability(perms[i]).is_available()) { |
| 534 return false; | 542 return false; |
| 535 } | 543 } |
| 536 } | 544 } |
| 537 } | 545 } |
| 538 | 546 |
| 539 ChromeViewHostMsg_GetPluginInfo_Output output; | 547 ChromeViewHostMsg_GetPluginInfo_Output output; |
| 540 #if defined(ENABLE_PLUGINS) | 548 #if defined(ENABLE_PLUGINS) |
| 541 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( | 549 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( |
| 542 render_frame->GetRoutingID(), GURL(params.url), | 550 render_frame->GetRoutingID(), GURL(params.url), |
| 543 frame->top()->document().url(), orig_mime_type, &output)); | 551 frame->top()->document().url(), orig_mime_type, &output)); |
| 544 | 552 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 const ChromeViewHostMsg_GetPluginInfo_Output& output) { | 592 const ChromeViewHostMsg_GetPluginInfo_Output& output) { |
| 585 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; | 593 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; |
| 586 const WebPluginInfo& plugin = output.plugin; | 594 const WebPluginInfo& plugin = output.plugin; |
| 587 const std::string& actual_mime_type = output.actual_mime_type; | 595 const std::string& actual_mime_type = output.actual_mime_type; |
| 588 const base::string16& group_name = output.group_name; | 596 const base::string16& group_name = output.group_name; |
| 589 const std::string& identifier = output.group_identifier; | 597 const std::string& identifier = output.group_identifier; |
| 590 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; | 598 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; |
| 591 GURL url(original_params.url); | 599 GURL url(original_params.url); |
| 592 std::string orig_mime_type = original_params.mimeType.utf8(); | 600 std::string orig_mime_type = original_params.mimeType.utf8(); |
| 593 ChromePluginPlaceholder* placeholder = NULL; | 601 ChromePluginPlaceholder* placeholder = NULL; |
| 594 | |
|
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.
| |
| 595 // If the browser plugin is to be enabled, this should be handled by the | 602 // If the browser plugin is to be enabled, this should be handled by the |
| 596 // renderer, so the code won't reach here due to the early exit in | 603 // renderer, so the code won't reach here due to the early exit in |
| 597 // OverrideCreatePlugin. | 604 // OverrideCreatePlugin. |
| 598 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || | 605 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || |
| 599 orig_mime_type == content::kBrowserPluginMimeType) { | 606 orig_mime_type == content::kBrowserPluginMimeType) { |
| 600 #if defined(OS_ANDROID) | 607 #if defined(OS_ANDROID) |
| 601 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) { | 608 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) { |
| 602 base::StringPiece template_html( | 609 base::StringPiece template_html( |
| 603 ResourceBundle::GetSharedInstance().GetRawDataResource( | 610 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 604 IDR_MOBILE_YOUTUBE_PLUGIN_HTML)); | 611 IDR_MOBILE_YOUTUBE_PLUGIN_HTML)); |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1501 | 1508 |
| 1502 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) | 1509 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) |
| 1503 return true; | 1510 return true; |
| 1504 | 1511 |
| 1505 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 1512 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 1506 return channel <= chrome::VersionInfo::CHANNEL_DEV; | 1513 return channel <= chrome::VersionInfo::CHANNEL_DEV; |
| 1507 #else | 1514 #else |
| 1508 return false; | 1515 return false; |
| 1509 #endif | 1516 #endif |
| 1510 } | 1517 } |
| OLD | NEW |