Update to Chromium revision 5fdc0fab (#520840)

- Windows now builds with clang by default.
This commit is contained in:
Marshall Greenblatt
2017-12-07 16:44:24 -05:00
parent d5e141648b
commit 8d51acb9be
153 changed files with 2189 additions and 3387 deletions

View File

@@ -718,9 +718,9 @@ void CefBrowserImpl::OnLoadError(blink::WebLocalFrame* frame,
if (load_handler.get()) {
CefRefPtr<CefFrameImpl> cef_frame = GetWebFrameImpl(frame);
const cef_errorcode_t errorCode =
static_cast<cef_errorcode_t>(error.reason);
const std::string& errorText = error.localized_description.Utf8();
const GURL& failedUrl = error.unreachable_url;
static_cast<cef_errorcode_t>(error.reason());
const std::string& errorText = net::ErrorToString(error.reason());
const GURL& failedUrl = error.url();
load_handler->OnLoadError(this, cef_frame.get(), errorCode, errorText,
failedUrl.spec());
}

View File

@@ -26,10 +26,6 @@
#include "libcef/renderer/browser_impl.h"
#include "libcef/renderer/extensions/extensions_renderer_client.h"
#include "libcef/renderer/extensions/print_render_frame_helper_delegate.h"
#include "libcef/renderer/media/cef_key_systems.h"
#include "libcef/renderer/pepper/pepper_helper.h"
#include "libcef/renderer/plugins/cef_plugin_placeholder.h"
#include "libcef/renderer/plugins/plugin_preroller.h"
#include "libcef/renderer/render_frame_observer.h"
#include "libcef/renderer/render_message_filter.h"
#include "libcef/renderer/render_thread_observer.h"
@@ -47,14 +43,14 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pepper_permission_util.h"
#include "chrome/common/constants.mojom.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/renderer_resources.h"
#include "chrome/renderer/content_settings_observer.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/renderer/loadtimes_extension_bindings.h"
#include "chrome/renderer/media/chrome_key_systems.h"
#include "chrome/renderer/pepper/chrome_pdf_print_client.h"
#include "chrome/renderer/plugins/power_saver_info.h"
#include "chrome/renderer/pepper/pepper_helper.h"
#include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/nacl/common/nacl_constants.h"
#include "components/printing/renderer/print_render_frame_helper.h"
@@ -70,7 +66,6 @@
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/plugin_instance_throttler.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_visitor.h"
#include "content/renderer/render_widget.h"
@@ -79,6 +74,10 @@
#include "ipc/ipc_sync_channel.h"
#include "media/base/media.h"
#include "printing/print_settings.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/WebKit/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebPrerenderingSupport.h"
#include "third_party/WebKit/public/platform/WebRuntimeFeatures.h"
@@ -131,34 +130,6 @@ class CefPrerendererClient : public content::RenderViewObserver,
bool IsPrefetchOnly() override { return false; }
};
void AppendParams(const std::vector<base::string16>& additional_names,
const std::vector<base::string16>& additional_values,
blink::WebVector<blink::WebString>* existing_names,
blink::WebVector<blink::WebString>* existing_values) {
DCHECK(additional_names.size() == additional_values.size());
DCHECK(existing_names->size() == existing_values->size());
size_t existing_size = existing_names->size();
size_t total_size = existing_size + additional_names.size();
blink::WebVector<blink::WebString> names(total_size);
blink::WebVector<blink::WebString> values(total_size);
for (size_t i = 0; i < existing_size; ++i) {
names[i] = (*existing_names)[i];
values[i] = (*existing_values)[i];
}
for (size_t i = 0; i < additional_names.size(); ++i) {
names[existing_size + i] = blink::WebString::FromUTF16(additional_names[i]);
values[existing_size + i] =
blink::WebString::FromUTF16(additional_values[i]);
}
existing_names->Swap(names);
existing_values->Swap(values);
}
bool IsStandaloneExtensionProcess() {
return extensions::ExtensionsEnabled() &&
extensions::CefExtensionsRendererClient::
@@ -319,6 +290,9 @@ void CefContentRendererClient::WebKitInitialized() {
}
}
url_loader_factory_ =
blink::Platform::Current()->CreateDefaultURLLoaderFactory();
// Notify the render process handler.
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
if (application.get()) {
@@ -329,21 +303,6 @@ void CefContentRendererClient::WebKitInitialized() {
}
}
void CefContentRendererClient::DevToolsAgentAttached() {
CEF_REQUIRE_RT();
++devtools_agent_count_;
}
void CefContentRendererClient::DevToolsAgentDetached() {
CEF_REQUIRE_RT();
--devtools_agent_count_;
if (devtools_agent_count_ == 0 && uncaught_exception_stack_size_ > 0) {
// When the last DevToolsAgent is detached the stack size is set to 0.
// Restore the user-specified stack size here.
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
}
}
scoped_refptr<base::SingleThreadTaskRunner>
CefContentRendererClient::GetCurrentTaskRunner() {
// Check if currently on the render thread.
@@ -401,7 +360,7 @@ void CefContentRendererClient::RenderThreadStarted() {
thread->GetChannel()->AddFilter(new CefRenderMessageFilter);
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
spellcheck_.reset(new SpellCheck());
spellcheck_.reset(new SpellCheck(this));
thread->AddObserver(spellcheck_.get());
}
@@ -474,7 +433,7 @@ void CefContentRendererClient::RenderFrameCreated(
new CefRenderFrameObserver(render_frame);
service_manager::BinderRegistry* registry = render_frame_observer->registry();
new CefPepperHelper(render_frame);
new PepperHelper(render_frame);
new printing::PrintRenderFrameHelper(
render_frame,
base::WrapUnique(new extensions::CefPrintRenderFrameHelperDelegate()));
@@ -484,8 +443,18 @@ void CefContentRendererClient::RenderFrameCreated(
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableSpellChecking))
new SpellCheckProvider(render_frame, spellcheck_.get());
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
SpellCheckProvider* spell_check_provider =
new SpellCheckProvider(render_frame, spellcheck_.get(), this);
// TODO(xiaochengh): Design better way to sync between Chrome-side and
// Blink-side spellcheck enabled states. See crbug.com/710097.
//
// TODO(alexmos): Do this for all frames so that this works properly for
// OOPIFs. See https://crbug.com/789273.
if (render_frame->IsMainFrame())
spell_check_provider->EnableSpellcheck(
spellcheck_->IsSpellcheckEnabled());
}
BrowserCreated(render_frame->GetRenderView(), render_frame);
}
@@ -494,22 +463,6 @@ void CefContentRendererClient::RenderViewCreated(
content::RenderView* render_view) {
new CefPrerendererClient(render_view);
if (extensions::ExtensionsEnabled())
extensions_renderer_client_->RenderViewCreated(render_view);
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
// This is a workaround keeping the behavior that, the Blink side spellcheck
// enabled state is initialized on RenderView creation.
// TODO(xiaochengh): Design better way to sync between Chrome-side and
// Blink-side spellcheck enabled states. See crbug.com/710097.
if (SpellCheckProvider* provider =
SpellCheckProvider::Get(render_view->GetMainRenderFrame())) {
provider->EnableSpellcheck(spellcheck_->IsSpellcheckEnabled());
}
}
BrowserCreated(render_view, render_view->GetMainRenderFrame());
}
@@ -525,13 +478,13 @@ bool CefContentRendererClient::OverrideCreatePlugin(
}
GURL url(params.url);
CefViewHostMsg_GetPluginInfo_Output output;
render_frame->Send(new CefViewHostMsg_GetPluginInfo(
chrome::mojom::PluginInfoPtr plugin_info = chrome::mojom::PluginInfo::New();
ChromeContentRendererClient::GetPluginInfoHost()->GetPluginInfo(
render_frame->GetRoutingID(), url,
render_frame->GetWebFrame()->Parent() == nullptr,
render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), orig_mime_type,
&output));
*plugin = CreatePlugin(render_frame, params, output);
&plugin_info);
*plugin = ChromeContentRendererClient::CreatePlugin(render_frame, params,
*plugin_info);
return true;
}
@@ -657,7 +610,7 @@ CefContentRendererClient::CreateBrowserPluginDelegate(
void CefContentRendererClient::AddSupportedKeySystems(
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) {
AddCefKeySystems(key_systems);
AddChromeKeySystems(key_systems);
}
void CefContentRendererClient::RunScriptsAtDocumentStart(
@@ -678,158 +631,38 @@ void CefContentRendererClient::RunScriptsAtDocumentIdle(
extensions_renderer_client_->RunScriptsAtDocumentIdle(render_frame);
}
void CefContentRendererClient::DevToolsAgentAttached(
content::RenderFrame* render_frame,
int session_id) {
CEF_REQUIRE_RT();
++devtools_agent_count_;
}
void CefContentRendererClient::DevToolsAgentDetached(
content::RenderFrame* render_frame,
int session_id) {
CEF_REQUIRE_RT();
--devtools_agent_count_;
if (devtools_agent_count_ == 0 && uncaught_exception_stack_size_ > 0) {
// When the last DevToolsAgent is detached the stack size is set to 0.
// Restore the user-specified stack size here.
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
}
}
void CefContentRendererClient::GetInterface(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
content::RenderThread::Get()->GetConnector()->BindInterface(
service_manager::Identity(chrome::mojom::kServiceName), interface_name,
std::move(interface_pipe));
}
void CefContentRendererClient::WillDestroyCurrentMessageLoop() {
base::AutoLock lock_scope(single_process_cleanup_lock_);
single_process_cleanup_complete_ = true;
}
// static
blink::WebPlugin* CefContentRendererClient::CreatePlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& original_params,
const CefViewHostMsg_GetPluginInfo_Output& output) {
const content::WebPluginInfo& info = output.plugin;
const std::string& actual_mime_type = output.actual_mime_type;
const base::string16& group_name = output.group_name;
const std::string& identifier = output.group_identifier;
CefViewHostMsg_GetPluginInfo_Status status = output.status;
GURL url(original_params.url);
std::string orig_mime_type = original_params.mime_type.Utf8();
CefPluginPlaceholder* placeholder = NULL;
// 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.
if (status == CefViewHostMsg_GetPluginInfo_Status::kNotFound ||
orig_mime_type == content::kBrowserPluginMimeType) {
placeholder = CefPluginPlaceholder::CreateLoadableMissingPlugin(
render_frame, original_params);
} else {
// TODO(bauerb): This should be in content/.
blink::WebPluginParams params(original_params);
for (const auto& mime_type : info.mime_types) {
if (mime_type.mime_type == actual_mime_type) {
AppendParams(mime_type.additional_param_names,
mime_type.additional_param_values, &params.attribute_names,
&params.attribute_values);
break;
}
}
if (params.mime_type.IsNull() && (actual_mime_type.size() > 0)) {
// Webkit might say that mime type is null while we already know the
// actual mime type via CefViewHostMsg_GetPluginInfo. In that case
// we should use what we know since WebpluginDelegateProxy does some
// specific initializations based on this information.
params.mime_type = blink::WebString::FromUTF8(actual_mime_type);
}
auto create_blocked_plugin = [&render_frame, &params, &info, &identifier,
&group_name](int template_id,
const base::string16& message) {
return CefPluginPlaceholder::CreateBlockedPlugin(
render_frame, params, info, identifier, group_name, template_id,
message, PowerSaverInfo());
};
blink::WebLocalFrame* frame = render_frame->GetWebFrame();
switch (status) {
case CefViewHostMsg_GetPluginInfo_Status::kNotFound: {
NOTREACHED();
break;
}
case CefViewHostMsg_GetPluginInfo_Status::kAllowed:
case CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: {
// Delay loading plugins if prerendering.
// TODO(mmenke): In the case of prerendering, feed into
// CefContentRendererClient::CreatePlugin instead, to
// reduce the chance of future regressions.
bool is_prerendering = false;
bool power_saver_setting_on =
status ==
CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
PowerSaverInfo power_saver_info =
PowerSaverInfo::Get(render_frame, power_saver_setting_on, params,
info, frame->GetDocument().Url());
if (power_saver_info.blocked_for_background_tab || is_prerendering ||
!power_saver_info.poster_attribute.empty()) {
placeholder = CefPluginPlaceholder::CreateBlockedPlugin(
render_frame, params, info, identifier, group_name,
power_saver_info.poster_attribute.empty()
? IDR_BLOCKED_PLUGIN_HTML
: IDR_PLUGIN_POSTER_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
power_saver_info);
placeholder->set_blocked_for_prerendering(is_prerendering);
placeholder->AllowLoading();
break;
}
std::unique_ptr<content::PluginInstanceThrottler> throttler;
if (power_saver_info.power_saver_enabled) {
throttler = content::PluginInstanceThrottler::Create(
content::RenderFrame::DONT_RECORD_DECISION);
// PluginPreroller manages its own lifetime.
new CefPluginPreroller(
render_frame, params, info, identifier, group_name,
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
throttler.get());
}
return render_frame->CreatePlugin(info, params, std::move(throttler));
}
case CefViewHostMsg_GetPluginInfo_Status::kDisabled: {
// Intentionally using the blocked plugin resources instead of the
// disabled plugin resources. This provides better messaging (no link to
// chrome://plugins) and adds testing support.
placeholder = create_blocked_plugin(
IDR_BLOCKED_PLUGIN_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY,
group_name));
break;
}
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: {
NOTREACHED() << "Plugin installation is not supported.";
break;
}
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: {
placeholder = create_blocked_plugin(
IDR_BLOCKED_PLUGIN_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
break;
}
case CefViewHostMsg_GetPluginInfo_Status::kUnauthorized: {
placeholder = create_blocked_plugin(
IDR_BLOCKED_PLUGIN_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name));
placeholder->AllowLoading();
break;
}
case CefViewHostMsg_GetPluginInfo_Status::kBlocked: {
placeholder = create_blocked_plugin(
IDR_BLOCKED_PLUGIN_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
placeholder->AllowLoading();
content::RenderThread::Get()->RecordAction(
base::UserMetricsAction("Plugin_Blocked"));
break;
}
case CefViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: {
placeholder = create_blocked_plugin(
IDR_BLOCKED_PLUGIN_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY,
group_name));
content::RenderThread::Get()->RecordAction(
base::UserMetricsAction("Plugin_BlockedByPolicy"));
break;
}
default:
break;
}
}
placeholder->SetStatus(status);
return placeholder->plugin();
}
void CefContentRendererClient::BrowserCreated(
content::RenderView* render_view,
content::RenderFrame* render_frame) {

View File

@@ -18,7 +18,14 @@
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "base/sequenced_task_runner.h"
#include "chrome/common/plugin.mojom.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/render_thread.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
namespace blink {
class WebURLLoaderFactory;
}
namespace extensions {
class CefExtensionsRendererClient;
@@ -37,11 +44,11 @@ class WebCacheImpl;
class CefGuestView;
class CefRenderThreadObserver;
struct Cef_CrossOriginWhiteListEntry_Params;
struct CefViewHostMsg_GetPluginInfo_Output;
class ChromePDFPrintClient;
class SpellCheck;
class CefContentRendererClient : public content::ContentRendererClient,
public service_manager::LocalInterfaceProvider,
public base::MessageLoop::DestructionObserver {
public:
CefContentRendererClient();
@@ -74,10 +81,12 @@ class CefContentRendererClient : public content::ContentRendererClient,
return uncaught_exception_stack_size_;
}
void WebKitInitialized();
// Used by CefRenderURLRequest to create WebURLLoaders.
blink::WebURLLoaderFactory* url_loader_factory() const {
return url_loader_factory_.get();
}
void DevToolsAgentAttached();
void DevToolsAgentDetached();
void WebKitInitialized();
// Returns the task runner for the current thread. Returns NULL if the current
// thread is not the main render process thread.
@@ -128,15 +137,18 @@ class CefContentRendererClient : public content::ContentRendererClient,
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
void DevToolsAgentAttached(content::RenderFrame* render_frame,
int session_id) override;
void DevToolsAgentDetached(content::RenderFrame* render_frame,
int session_id) override;
// service_manager::LocalInterfaceProvider implementation.
void GetInterface(const std::string& name,
mojo::ScopedMessagePipeHandle request_handle) override;
// MessageLoop::DestructionObserver implementation.
void WillDestroyCurrentMessageLoop() override;
static blink::WebPlugin* CreatePlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const CefViewHostMsg_GetPluginInfo_Output& output);
private:
void BrowserCreated(content::RenderView* render_view,
content::RenderFrame* render_frame);
@@ -148,6 +160,7 @@ class CefContentRendererClient : public content::ContentRendererClient,
std::unique_ptr<CefRenderThreadObserver> observer_;
std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
std::unique_ptr<SpellCheck> spellcheck_;
std::unique_ptr<blink::WebURLLoaderFactory> url_loader_factory_;
// Map of RenderView pointers to CefBrowserImpl references.
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl>> BrowserMap;

View File

@@ -18,7 +18,6 @@
#include "content/public/renderer/render_thread.h"
#include "extensions/common/constants.h"
#include "extensions/common/switches.h"
#include "extensions/renderer/api/automation/automation_api_helper.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/extension_frame_helper.h"
#include "extensions/renderer/extensions_render_frame_observer.h"
@@ -150,12 +149,6 @@ void CefExtensionsRendererClient::RenderFrameCreated(
extension_dispatcher_->OnRenderFrameCreated(render_frame);
}
void CefExtensionsRendererClient::RenderViewCreated(
content::RenderView* render_view) {
// Manages its own lifetime.
new extensions::AutomationApiHelper(render_view);
}
bool CefExtensionsRendererClient::OverrideCreatePlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params) {

View File

@@ -25,7 +25,6 @@ class WebURL;
namespace content {
class BrowserPluginDelegate;
class RenderFrame;
class RenderView;
} // namespace content
namespace extensions {
@@ -52,7 +51,6 @@ class CefExtensionsRendererClient : public ExtensionsRendererClient {
void RenderThreadStarted();
void RenderFrameCreated(content::RenderFrame* render_frame,
service_manager::BinderRegistry* registry);
void RenderViewCreated(content::RenderView* render_view);
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
const blink::WebPluginParams& params);
bool WillSendRequest(blink::WebLocalFrame* frame,

View File

@@ -1,145 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/renderer/media/cef_key_systems.h"
#include <string>
#include <vector>
#include "base/logging.h"
#include "base/strings/string16.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "components/cdm/renderer/widevine_key_system_properties.h"
#include "content/public/renderer/render_thread.h"
#include "libcef/common/cef_messages.h"
#include "media/base/eme_constants.h"
#include "media/base/key_system_properties.h"
#include "media/media_features.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
// The following must be after widevine_cdm_version.h.
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
#include <gnu/libc-version.h>
#include "base/version.h"
#endif
using media::KeySystemProperties;
using media::SupportedCodecs;
namespace {
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
bool IsPepperCdmAvailable(
const std::string& pepper_type,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values) {
bool is_available = false;
content::RenderThread::Get()->Send(
new CefViewHostMsg_IsInternalPluginAvailableForMimeType(
pepper_type, &is_available, additional_param_names,
additional_param_values));
return is_available;
}
#if defined(WIDEVINE_CDM_AVAILABLE)
// This function finds "codecs" and parses the value into the vector |codecs|.
// Converts the codec strings to UTF-8 since we only expect ASCII strings and
// this simplifies the rest of the code in this file.
void GetSupportedCodecsForPepperCdm(
const std::vector<base::string16>& additional_param_names,
const std::vector<base::string16>& additional_param_values,
std::vector<std::string>* codecs) {
DCHECK(codecs->empty());
DCHECK_EQ(additional_param_names.size(), additional_param_values.size());
for (size_t i = 0; i < additional_param_names.size(); ++i) {
if (additional_param_names[i] ==
base::ASCIIToUTF16(kCdmSupportedCodecsParamName)) {
const base::string16& codecs_string16 = additional_param_values[i];
std::string codecs_string;
if (!base::UTF16ToUTF8(codecs_string16.c_str(), codecs_string16.length(),
&codecs_string)) {
DLOG(WARNING) << "Non-UTF-8 codecs string.";
// Continue using the best effort conversion.
}
*codecs = base::SplitString(
codecs_string, std::string(1, kCdmSupportedCodecsValueDelimiter),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
break;
}
}
}
void AddPepperBasedWidevine(
std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) {
#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
base::Version glibc_version(gnu_get_libc_version());
DCHECK(glibc_version.IsValid());
if (glibc_version < base::Version(WIDEVINE_CDM_MIN_GLIBC_VERSION))
return;
#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
std::vector<base::string16> additional_param_names;
std::vector<base::string16> additional_param_values;
if (!IsPepperCdmAvailable(kWidevineCdmPluginMimeType, &additional_param_names,
&additional_param_values)) {
DVLOG(1) << "Widevine CDM is not currently available.";
return;
}
std::vector<std::string> codecs;
GetSupportedCodecsForPepperCdm(additional_param_names,
additional_param_values, &codecs);
SupportedCodecs supported_codecs = media::EME_CODEC_NONE;
// Audio codecs are always supported.
// TODO(sandersd): Distinguish these from those that are directly supported,
// as those may offer a higher level of protection.
supported_codecs |= media::EME_CODEC_WEBM_OPUS;
supported_codecs |= media::EME_CODEC_WEBM_VORBIS;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
supported_codecs |= media::EME_CODEC_MP4_AAC;
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
for (size_t i = 0; i < codecs.size(); ++i) {
if (codecs[i] == kCdmSupportedCodecVp8)
supported_codecs |= media::EME_CODEC_WEBM_VP8;
if (codecs[i] == kCdmSupportedCodecVp9) {
supported_codecs |= media::EME_CODEC_WEBM_VP9;
supported_codecs |= media::EME_CODEC_COMMON_VP9;
}
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
if (codecs[i] == kCdmSupportedCodecAvc1)
supported_codecs |= media::EME_CODEC_MP4_AVC1;
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
}
using Robustness = cdm::WidevineKeySystemProperties::Robustness;
concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties(
supported_codecs,
Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
Robustness::SW_SECURE_DECODE, // Maximum video robustness.
media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
media::EmeSessionTypeSupport::
NOT_SUPPORTED, // persistent-release-message.
media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier.
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
} // namespace
void AddCefKeySystems(
std::vector<std::unique_ptr<KeySystemProperties>>* key_systems_properties) {
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE)
AddPepperBasedWidevine(key_systems_properties);
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
}

View File

@@ -1,19 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_RENDERER_MEDIA_CEF_KEY_SYSTEMS_H_
#define CEF_LIBCEF_RENDERER_MEDIA_CEF_KEY_SYSTEMS_H_
#include <memory>
#include <vector>
namespace media {
class KeySystemProperties;
}
// Register the key systems supported by populating |key_systems_properties|.
void AddCefKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>>*
key_systems_properties);
#endif // CEF_LIBCEF_RENDERER_MEDIA_CEF_KEY_SYSTEMS_H_

View File

@@ -1,29 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/renderer/pepper/pepper_helper.h"
#include <memory>
#include "libcef/renderer/pepper/renderer_pepper_host_factory.h"
#include "base/memory/ptr_util.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
CefPepperHelper::CefPepperHelper(content::RenderFrame* render_frame)
: RenderFrameObserver(render_frame) {}
CefPepperHelper::~CefPepperHelper() {}
void CefPepperHelper::DidCreatePepperPlugin(content::RendererPpapiHost* host) {
// TODO(brettw) figure out how to hook up the host factory. It needs some
// kind of filter-like system to allow dynamic additions.
host->GetPpapiHost()->AddHostFactoryFilter(
base::MakeUnique<CefRendererPepperHostFactory>(host));
}
void CefPepperHelper::OnDestruct() {
delete this;
}

View File

@@ -1,26 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_RENDERER_PEPPER_PEPPER_HELPER_H_
#define CEF_LIBCEF_RENDERER_PEPPER_PEPPER_HELPER_H_
#include "base/compiler_specific.h"
#include "content/public/renderer/render_frame_observer.h"
// This class listens for Pepper creation events from the RenderFrame and
// attaches the parts required for Chrome-specific plugin support.
class CefPepperHelper : public content::RenderFrameObserver {
public:
explicit CefPepperHelper(content::RenderFrame* render_frame);
~CefPepperHelper() override;
// RenderFrameObserver.
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
void OnDestruct() override;
private:
DISALLOW_COPY_AND_ASSIGN(CefPepperHelper);
};
#endif // CEF_LIBCEF_RENDERER_PEPPER_PEPPER_HELPER_H_

View File

@@ -1,110 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/renderer/pepper/renderer_pepper_host_factory.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
#include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
#include "chrome/renderer/pepper/pepper_uma_host.h"
#include "components/pdf/renderer/pepper_pdf_host.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_message_utils.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
using ppapi::host::ResourceHost;
CefRendererPepperHostFactory::CefRendererPepperHostFactory(
content::RendererPpapiHost* host)
: host_(host) {}
CefRendererPepperHostFactory::~CefRendererPepperHostFactory() {}
std::unique_ptr<ResourceHost> CefRendererPepperHostFactory::CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
const IPC::Message& message) {
DCHECK_EQ(host_->GetPpapiHost(), host);
// Make sure the plugin is giving us a valid instance for this resource.
if (!host_->IsValidInstance(instance))
return nullptr;
if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_FLASH)) {
switch (message.type()) {
case PpapiHostMsg_Flash_Create::ID: {
return base::MakeUnique<PepperFlashRendererHost>(host_, instance,
resource);
}
case PpapiHostMsg_FlashFullscreen_Create::ID: {
return base::MakeUnique<PepperFlashFullscreenHost>(host_, instance,
resource);
}
case PpapiHostMsg_FlashMenu_Create::ID: {
ppapi::proxy::SerializedFlashMenu serialized_menu;
if (ppapi::UnpackMessage<PpapiHostMsg_FlashMenu_Create>(
message, &serialized_menu)) {
return base::MakeUnique<PepperFlashMenuHost>(
host_, instance, resource, serialized_menu);
}
break;
}
}
}
// TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
// We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
// rid of its use in PDF if possible.
if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_FLASH) ||
host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_PRIVATE)) {
switch (message.type()) {
case PpapiHostMsg_FlashFontFile_Create::ID: {
ppapi::proxy::SerializedFontDescription description;
PP_PrivateFontCharset charset;
if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(
message, &description, &charset)) {
return base::MakeUnique<PepperFlashFontFileHost>(
host_, instance, resource, description, charset);
}
break;
}
case PpapiHostMsg_FlashDRM_Create::ID:
return base::MakeUnique<PepperFlashDRMRendererHost>(host_, instance,
resource);
}
}
if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_PRIVATE)) {
switch (message.type()) {
case PpapiHostMsg_PDF_Create::ID: {
return base::MakeUnique<pdf::PepperPDFHost>(host_, instance, resource);
}
}
}
// Permissions for the following interfaces will be checked at the
// time of the corresponding instance's method calls. Currently these
// interfaces are available only for whitelisted apps which may not have
// access to the other private interfaces.
switch (message.type()) {
case PpapiHostMsg_UMA_Create::ID: {
return base::MakeUnique<PepperUMAHost>(host_, instance, resource);
}
}
NOTREACHED() << "Unhandled message type: " << message.type();
return nullptr;
}

View File

@@ -1,34 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LIBCEF_RENDERER_PEPPER_RENDERER_PEPPER_HOST_FACTORY_H_
#define LIBCEF_RENDERER_PEPPER_RENDERER_PEPPER_HOST_FACTORY_H_
#include "base/macros.h"
#include "ppapi/host/host_factory.h"
namespace content {
class RendererPpapiHost;
}
class CefRendererPepperHostFactory : public ppapi::host::HostFactory {
public:
explicit CefRendererPepperHostFactory(content::RendererPpapiHost* host);
~CefRendererPepperHostFactory() override;
// HostFactory.
std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
const IPC::Message& message) override;
private:
// Not owned by this object.
content::RendererPpapiHost* host_;
DISALLOW_COPY_AND_ASSIGN(CefRendererPepperHostFactory);
};
#endif // LIBCEF_RENDERER_PEPPER_RENDERER_PEPPER_HOST_FACTORY_H_

View File

@@ -1,313 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/renderer/plugins/cef_plugin_placeholder.h"
#include <utility>
#include "libcef/common/cef_messages.h"
#include "libcef/renderer/content_renderer_client.h"
#include "libcef/renderer/plugins/plugin_preroller.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/renderer_resources.h"
#include "chrome/renderer/custom_menu_commands.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "gin/object_template_builder.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/gfx/geometry/size.h"
#include "url/url_util.h"
using base::UserMetricsAction;
using content::RenderThread;
using content::RenderView;
namespace {
const CefPluginPlaceholder* g_last_active_menu = NULL;
} // namespace
gin::WrapperInfo CefPluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin};
CefPluginPlaceholder::CefPluginPlaceholder(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const std::string& html_data,
const base::string16& title)
: plugins::LoadablePluginPlaceholder(render_frame, params, html_data),
status_(CefViewHostMsg_GetPluginInfo_Status::kAllowed),
title_(title),
context_menu_request_id_(0) {
RenderThread::Get()->AddObserver(this);
}
CefPluginPlaceholder::~CefPluginPlaceholder() {
RenderThread::Get()->RemoveObserver(this);
if (context_menu_request_id_ && render_frame())
render_frame()->CancelContextMenu(context_menu_request_id_);
}
// static
CefPluginPlaceholder* CefPluginPlaceholder::CreateLoadableMissingPlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params) {
const base::StringPiece template_html(
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_BLOCKED_PLUGIN_HTML));
base::DictionaryValue values;
values.SetString("message",
l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED));
std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
// Will destroy itself when its WebViewPlugin is going away.
return new CefPluginPlaceholder(render_frame, params, html_data,
params.mime_type.Utf16());
}
// static
CefPluginPlaceholder* CefPluginPlaceholder::CreateBlockedPlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const content::WebPluginInfo& info,
const std::string& identifier,
const base::string16& name,
int template_id,
const base::string16& message,
const PowerSaverInfo& power_saver_info) {
base::DictionaryValue values;
values.SetString("message", message);
values.SetString("name", name);
values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
values.SetString(
"pluginType",
render_frame->IsMainFrame() &&
render_frame->GetWebFrame()->GetDocument().IsPluginDocument()
? "document"
: "embedded");
if (!power_saver_info.poster_attribute.empty()) {
values.SetString("poster", power_saver_info.poster_attribute);
values.SetString("baseurl", power_saver_info.base_url.spec());
if (!power_saver_info.custom_poster_size.IsEmpty()) {
float zoom_factor = blink::WebView::ZoomLevelToZoomFactor(
render_frame->GetWebFrame()->View()->ZoomLevel());
int width =
roundf(power_saver_info.custom_poster_size.width() / zoom_factor);
int height =
roundf(power_saver_info.custom_poster_size.height() / zoom_factor);
values.SetString("visibleWidth", base::IntToString(width) + "px");
values.SetString("visibleHeight", base::IntToString(height) + "px");
}
}
const base::StringPiece template_html(
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
DCHECK(!template_html.empty())
<< "unable to load template. ID: " << template_id;
std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
// |blocked_plugin| will destroy itself when its WebViewPlugin is going away.
CefPluginPlaceholder* blocked_plugin =
new CefPluginPlaceholder(render_frame, params, html_data, name);
if (!power_saver_info.poster_attribute.empty())
blocked_plugin->BlockForPowerSaverPoster();
blocked_plugin->SetPluginInfo(info);
blocked_plugin->SetIdentifier(identifier);
blocked_plugin->set_power_saver_enabled(power_saver_info.power_saver_enabled);
blocked_plugin->set_blocked_for_background_tab(
power_saver_info.blocked_for_background_tab);
return blocked_plugin;
}
void CefPluginPlaceholder::SetStatus(
CefViewHostMsg_GetPluginInfo_Status status) {
status_ = status;
}
bool CefPluginPlaceholder::OnMessageReceived(const IPC::Message& message) {
// We don't swallow these messages because multiple blocked plugins and other
// objects have an interest in them.
IPC_BEGIN_MESSAGE_MAP(CefPluginPlaceholder, message)
IPC_MESSAGE_HANDLER(CefViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins)
IPC_END_MESSAGE_MAP()
return false;
}
void CefPluginPlaceholder::ShowPermissionBubbleCallback() {
// CEF does not use IDR_PREFER_HTML_PLUGIN_HTML which would originate this
// callback.
NOTREACHED();
}
void CefPluginPlaceholder::PluginListChanged() {
if (!render_frame() || !plugin())
return;
blink::WebLocalFrame* web_frame = render_frame()->GetWebFrame();
if (!web_frame->Top()->IsWebLocalFrame())
return;
blink::WebDocument document =
web_frame->Top()->ToWebLocalFrame()->GetDocument();
if (document.IsNull())
return;
CefViewHostMsg_GetPluginInfo_Output output;
std::string mime_type(GetPluginParams().mime_type.Utf8());
render_frame()->Send(new CefViewHostMsg_GetPluginInfo(
routing_id(), GURL(GetPluginParams().url), web_frame->Parent() == nullptr,
web_frame->Top()->GetSecurityOrigin(), mime_type, &output));
if (output.status == status_)
return;
blink::WebPlugin* new_plugin = CefContentRendererClient::CreatePlugin(
render_frame(), GetPluginParams(), output);
ReplacePlugin(new_plugin);
}
void CefPluginPlaceholder::OnMenuAction(int request_id, unsigned action) {
DCHECK_EQ(context_menu_request_id_, request_id);
if (g_last_active_menu != this)
return;
switch (action) {
case chrome::MENU_COMMAND_PLUGIN_RUN: {
RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Menu"));
MarkPluginEssential(
content::PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK);
LoadPlugin();
break;
}
case chrome::MENU_COMMAND_PLUGIN_HIDE: {
RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Hide_Menu"));
HidePlugin();
break;
}
default:
NOTREACHED();
}
}
void CefPluginPlaceholder::OnMenuClosed(int request_id) {
DCHECK_EQ(context_menu_request_id_, request_id);
context_menu_request_id_ = 0;
}
v8::Local<v8::Value> CefPluginPlaceholder::GetV8Handle(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, this).ToV8();
}
void CefPluginPlaceholder::ShowContextMenu(const blink::WebMouseEvent& event) {
if (context_menu_request_id_)
return; // Don't allow nested context menu requests.
if (!render_frame())
return;
content::ContextMenuParams params;
if (!title_.empty()) {
content::MenuItem name_item;
name_item.label = title_;
params.custom_items.push_back(name_item);
content::MenuItem separator_item;
separator_item.type = content::MenuItem::SEPARATOR;
params.custom_items.push_back(separator_item);
}
if (!GetPluginInfo().path.value().empty()) {
content::MenuItem run_item;
run_item.action = chrome::MENU_COMMAND_PLUGIN_RUN;
// Disable this menu item if the plugin is blocked by policy.
run_item.enabled = LoadingAllowed();
run_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_RUN);
params.custom_items.push_back(run_item);
}
content::MenuItem hide_item;
hide_item.action = chrome::MENU_COMMAND_PLUGIN_HIDE;
bool is_main_frame_plugin_document =
render_frame()->IsMainFrame() &&
render_frame()->GetWebFrame()->GetDocument().IsPluginDocument();
hide_item.enabled = !is_main_frame_plugin_document;
hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE);
params.custom_items.push_back(hide_item);
blink::WebPoint point(event.PositionInWidget().x, event.PositionInWidget().y);
if (plugin() && plugin()->Container())
point = plugin()->Container()->LocalToRootFramePoint(point);
params.x = point.x;
params.y = point.y;
context_menu_request_id_ = render_frame()->ShowContextMenu(this, params);
g_last_active_menu = this;
}
blink::WebPlugin* CefPluginPlaceholder::CreatePlugin() {
std::unique_ptr<content::PluginInstanceThrottler> throttler;
// If the plugin has already been marked essential in its placeholder form,
// we shouldn't create a new throttler and start the process all over again.
if (power_saver_enabled()) {
throttler = content::PluginInstanceThrottler::Create(
content::RenderFrame::DONT_RECORD_DECISION);
// PluginPreroller manages its own lifetime.
new CefPluginPreroller(
render_frame(), GetPluginParams(), GetPluginInfo(), GetIdentifier(),
title_, l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, title_),
throttler.get());
}
return render_frame()->CreatePlugin(GetPluginInfo(), GetPluginParams(),
std::move(throttler));
}
void CefPluginPlaceholder::OnBlockedContent(
content::RenderFrame::PeripheralContentStatus status,
bool is_same_origin) {
DCHECK(render_frame());
}
gin::ObjectTemplateBuilder CefPluginPlaceholder::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
gin::ObjectTemplateBuilder builder =
gin::Wrappable<CefPluginPlaceholder>::GetObjectTemplateBuilder(isolate)
.SetMethod<void (CefPluginPlaceholder::*)()>(
"hide", &CefPluginPlaceholder::HideCallback)
.SetMethod<void (CefPluginPlaceholder::*)()>(
"load", &CefPluginPlaceholder::LoadCallback)
.SetMethod<void (CefPluginPlaceholder::*)()>(
"didFinishLoading",
&CefPluginPlaceholder::DidFinishLoadingCallback)
.SetMethod("showPermissionBubble",
&CefPluginPlaceholder::ShowPermissionBubbleCallback);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnablePluginPlaceholderTesting)) {
builder.SetMethod<void (CefPluginPlaceholder::*)()>(
"didFinishIconRepositionForTesting",
&CefPluginPlaceholder::DidFinishIconRepositionForTestingCallback);
}
return builder;
}

View File

@@ -1,85 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_RENDERER_PLUGINS_CEF_PLUGIN_PLACEHOLDER_H_
#define CEF_LIBCEF_RENDERER_PLUGINS_CEF_PLUGIN_PLACEHOLDER_H_
#include <stdint.h>
#include "base/macros.h"
#include "chrome/renderer/plugins/power_saver_info.h"
#include "components/plugins/renderer/loadable_plugin_placeholder.h"
#include "content/public/renderer/context_menu_client.h"
#include "content/public/renderer/render_thread_observer.h"
enum class CefViewHostMsg_GetPluginInfo_Status;
class CefPluginPlaceholder final : public plugins::LoadablePluginPlaceholder,
public content::RenderThreadObserver,
public content::ContextMenuClient,
public gin::Wrappable<CefPluginPlaceholder> {
public:
static gin::WrapperInfo kWrapperInfo;
static CefPluginPlaceholder* CreateBlockedPlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const content::WebPluginInfo& info,
const std::string& identifier,
const base::string16& name,
int resource_id,
const base::string16& message,
const PowerSaverInfo& power_saver_info);
// Creates a new WebViewPlugin with a MissingPlugin as a delegate.
static CefPluginPlaceholder* CreateLoadableMissingPlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params);
void SetStatus(CefViewHostMsg_GetPluginInfo_Status status);
private:
CefPluginPlaceholder(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const std::string& html_data,
const base::string16& title);
~CefPluginPlaceholder() override;
// content::LoadablePluginPlaceholder overrides:
blink::WebPlugin* CreatePlugin() override;
void OnBlockedContent(content::RenderFrame::PeripheralContentStatus status,
bool is_same_origin) override;
// gin::Wrappable (via PluginPlaceholder) method
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) final;
// content::RenderViewObserver (via PluginPlaceholder) override:
bool OnMessageReceived(const IPC::Message& message) override;
// WebViewPlugin::Delegate (via PluginPlaceholder) methods:
v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) override;
void ShowContextMenu(const blink::WebMouseEvent&) override;
// content::RenderThreadObserver methods:
void PluginListChanged() override;
// content::ContextMenuClient methods:
void OnMenuAction(int request_id, unsigned action) override;
void OnMenuClosed(int request_id) override;
// Show the Plugins permission bubble.
void ShowPermissionBubbleCallback();
CefViewHostMsg_GetPluginInfo_Status status_;
base::string16 title_;
int context_menu_request_id_; // Nonzero when request pending.
base::string16 plugin_name_;
DISALLOW_COPY_AND_ASSIGN(CefPluginPlaceholder);
};
#endif // CEF_LIBCEF_RENDERER_PLUGINS_CEF_PLUGIN_PLACEHOLDER_H_

View File

@@ -1,95 +0,0 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/renderer/plugins/plugin_preroller.h"
#include "libcef/renderer/plugins/cef_plugin_placeholder.h"
#include "base/base64.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/renderer_resources.h"
#include "chrome/renderer/plugins/power_saver_info.h"
#include "third_party/WebKit/public/platform/WebRect.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebPlugin.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
#include "ui/gfx/codec/png_codec.h"
CefPluginPreroller::CefPluginPreroller(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const content::WebPluginInfo& info,
const std::string& identifier,
const base::string16& name,
const base::string16& message,
content::PluginInstanceThrottler* throttler)
: RenderFrameObserver(render_frame),
params_(params),
info_(info),
identifier_(identifier),
name_(name),
message_(message),
throttler_(throttler) {
DCHECK(throttler);
throttler_->AddObserver(this);
}
CefPluginPreroller::~CefPluginPreroller() {
if (throttler_)
throttler_->RemoveObserver(this);
}
void CefPluginPreroller::OnKeyframeExtracted(const SkBitmap* bitmap) {
std::vector<unsigned char> png_data;
if (!gfx::PNGCodec::EncodeBGRASkBitmap(*bitmap, false, &png_data)) {
DLOG(ERROR) << "Provided keyframe could not be encoded as PNG.";
return;
}
base::StringPiece png_as_string(reinterpret_cast<char*>(&png_data[0]),
png_data.size());
std::string data_url_header = "data:image/png;base64,";
std::string data_url_body;
base::Base64Encode(png_as_string, &data_url_body);
keyframe_data_url_ = GURL(data_url_header + data_url_body);
}
void CefPluginPreroller::OnThrottleStateChange() {
if (!throttler_->IsThrottled())
return;
PowerSaverInfo power_saver_info;
power_saver_info.power_saver_enabled = true;
power_saver_info.poster_attribute = keyframe_data_url_.spec();
power_saver_info.custom_poster_size = throttler_->GetSize();
CefPluginPlaceholder* placeholder = CefPluginPlaceholder::CreateBlockedPlugin(
render_frame(), params_, info_, identifier_, name_,
IDR_PLUGIN_POSTER_HTML, message_, power_saver_info);
placeholder->SetPremadePlugin(throttler_);
placeholder->set_power_saver_enabled(true);
placeholder->AllowLoading();
blink::WebPluginContainer* container =
throttler_->GetWebPlugin()->Container();
container->SetPlugin(placeholder->plugin());
bool success = placeholder->plugin()->Initialize(container);
DCHECK(success);
container->Invalidate();
container->ReportGeometry();
delete this;
}
void CefPluginPreroller::OnThrottlerDestroyed() {
throttler_ = nullptr;
delete this;
}
void CefPluginPreroller::OnDestruct() {
delete this;
}

View File

@@ -1,57 +0,0 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_
#define CEF_LIBCEF_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_
#include "base/macros.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/renderer/plugin_instance_throttler.h"
#include "content/public/renderer/render_frame_observer.h"
#include "third_party/WebKit/public/web/WebPluginParams.h"
#include "url/gurl.h"
class SkBitmap;
// This class manages a plugin briefly for the purposes of keyframe extraction.
// Once a keyframe has been extracted, this class will replace the plugin with
// a ChromePluginPlaceholder. The actual plugin will continue to live in a
// throttled state. This class manages its own lifetime.
class CefPluginPreroller : public content::PluginInstanceThrottler::Observer,
public content::RenderFrameObserver {
public:
// Does not take ownership of |render_frame| or |throttler|.
CefPluginPreroller(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const content::WebPluginInfo& info,
const std::string& identifier,
const base::string16& name,
const base::string16& message,
content::PluginInstanceThrottler* throttler);
~CefPluginPreroller() override;
private:
// content::PluginInstanceThrottler::Observer methods:
void OnKeyframeExtracted(const SkBitmap* bitmap) override;
void OnThrottleStateChange() override;
void OnThrottlerDestroyed() override;
// content::RenderFrameObserver implementation.
void OnDestruct() override;
blink::WebPluginParams params_;
content::WebPluginInfo info_;
std::string identifier_;
base::string16 name_;
base::string16 message_;
content::PluginInstanceThrottler* throttler_;
GURL keyframe_data_url_;
DISALLOW_COPY_AND_ASSIGN(CefPluginPreroller);
};
#endif // CEF_LIBCEF_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_

View File

@@ -11,9 +11,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "chrome/common/render_messages.h"
#include "content/common/devtools_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/renderer/devtools/devtools_agent.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "url/gurl.h"
@@ -35,17 +33,7 @@ void CefRenderMessageFilter::OnFilterRemoved() {
bool CefRenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
// Observe the DevTools messages but don't handle them.
if (message.type() == DevToolsAgentMsg_Attach::ID) {
handled = false;
} else if (message.type() == DevToolsAgentMsg_Detach::ID) {
OnDevToolsAgentDetach(message.routing_id());
return false;
}
IPC_BEGIN_MESSAGE_MAP(CefRenderMessageFilter, message)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnDevToolsAgentAttach)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_IsCrashReportingEnabled,
OnIsCrashReportingEnabled)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -79,44 +67,8 @@ bool CefRenderMessageFilter::Send(IPC::Message* message) {
return false;
}
void CefRenderMessageFilter::OnDevToolsAgentAttach(const std::string& host_id,
int session_id) {
CEF_POST_TASK_RT(
base::Bind(&CefRenderMessageFilter::OnDevToolsAgentAttach_RT, this));
}
void CefRenderMessageFilter::OnDevToolsAgentDetach(int32_t routing_id) {
CEF_POST_TASK_RT(base::Bind(&CefRenderMessageFilter::OnDevToolsAgentDetach_RT,
this, routing_id));
}
void CefRenderMessageFilter::OnIsCrashReportingEnabled(bool* enabled) {
// TODO(cef): Explore whether it's useful for CEF clients to report when crash
// reporting is enabled.
*enabled = false;
}
void CefRenderMessageFilter::OnDevToolsAgentAttach_RT() {
CEF_REQUIRE_RT();
CefContentRendererClient::Get()->DevToolsAgentAttached();
}
void CefRenderMessageFilter::OnDevToolsAgentDetach_RT(int32_t routing_id) {
CEF_REQUIRE_RT();
// Wait for the DevToolsAgent to detach. It would be better to receive
// notification when the DevToolsAgent detaches but that's not currently
// available.
content::DevToolsAgent* agent =
content::DevToolsAgent::FromRoutingId(routing_id);
if (agent && agent->IsAttached()) {
// Try again in a bit.
CEF_POST_DELAYED_TASK_RT(
base::Bind(&CefRenderMessageFilter::OnDevToolsAgentDetach_RT, this,
routing_id),
50);
return;
}
CefContentRendererClient::Get()->DevToolsAgentDetached();
}

View File

@@ -28,13 +28,8 @@ class CefRenderMessageFilter : public IPC::MessageFilter {
private:
// Message handlers called on the IO thread.
void OnDevToolsAgentAttach(const std::string& host_id, int session_id);
void OnDevToolsAgentDetach(int32_t routing_id);
void OnIsCrashReportingEnabled(bool* enabled);
void OnDevToolsAgentAttach_RT();
void OnDevToolsAgentDetach_RT(int32_t routing_id);
IPC::Channel* channel_;
DISALLOW_COPY_AND_ASSIGN(CefRenderMessageFilter);

View File

@@ -9,15 +9,16 @@
#include "libcef/common/request_impl.h"
#include "libcef/common/response_impl.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/renderer/content_renderer_client.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/platform/WebURLLoader.h"
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
#include "third_party/WebKit/public/platform/WebURLLoaderFactory.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
@@ -102,8 +103,9 @@ class CefRenderURLRequest::Context
urlRequest.SetRequestorOrigin(
blink::WebSecurityOrigin::Create(urlRequest.Url()));
loader_ = blink::Platform::Current()->CreateURLLoader(urlRequest,
task_runner_.get());
loader_ =
CefContentRendererClient::Get()->url_loader_factory()->CreateURLLoader(
urlRequest, task_runner_.get());
loader_->LoadAsynchronously(urlRequest, url_client_.get());
return true;
}
@@ -139,7 +141,7 @@ class CefRenderURLRequest::Context
if (status_ == UR_IO_PENDING) {
status_ = UR_FAILED;
error_code_ = static_cast<CefURLRequest::ErrorCode>(error.reason);
error_code_ = static_cast<cef_errorcode_t>(error.reason());
}
OnComplete();

View File

@@ -713,8 +713,11 @@ void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
CefRefPtr<CefV8Exception> exception = new CefV8ExceptionImpl(
static_cast<CefV8ContextImpl*>(context.get())->GetV8Context(), message);
handler->OnUncaughtException(context->GetBrowser(), context->GetFrame(),
context, exception, stackTrace);
CefRefPtr<CefBrowser> browser = context->GetBrowser();
if (browser) {
handler->OnUncaughtException(browser, context->GetFrame(), context,
exception, stackTrace);
}
}
} // namespace
@@ -898,7 +901,9 @@ CefRefPtr<CefFrame> CefV8ContextImpl::GetFrame() {
if (webframe) {
CefRefPtr<CefBrowserImpl> browser =
CefBrowserImpl::GetBrowserForMainFrame(webframe->Top());
frame = browser->GetFrame(render_frame_util::GetIdentifier(webframe));
if (browser) {
frame = browser->GetFrame(render_frame_util::GetIdentifier(webframe));
}
}
return frame;

View File

@@ -24,7 +24,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "third_party/WebKit/Source/core/frame/LocalFrame.h"
#include "third_party/WebKit/Source/core/frame/Settings.h"
#include "third_party/WebKit/Source/core/frame/WebLocalFrameImpl.h"
#include "third_party/WebKit/Source/platform/ScriptForbiddenScope.h"
#include "third_party/WebKit/Source/platform/bindings/ScriptForbiddenScope.h"
#include "third_party/WebKit/Source/platform/bindings/V8Binding.h"
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
MSVC_POP_WARNING();
@@ -158,12 +158,9 @@ v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
if (start_line < 1)
start_line = 1;
const blink::KURL kurl =
source_url.IsEmpty() ? blink::KURL()
: blink::KURL(blink::kParsedURLString, source_url);
const blink::ScriptSourceCode ssc = blink::ScriptSourceCode(
source, kurl, blink::WebString() /* nonce */, blink::kNotParserInserted,
source, blink::ScriptSourceLocationType::kInternal,
blink::KURL(source_url),
WTF::TextPosition(WTF::OrdinalNumber::FromOneBasedInt(start_line),
WTF::OrdinalNumber::FromZeroBasedInt(0)));
@@ -179,8 +176,8 @@ v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
v8::Local<v8::Script> script;
if (!blink::V8ScriptRunner::CompileScript(blink::ScriptState::From(context),
ssc, accessControlStatus,
v8CacheOptions)
ssc, blink::ScriptFetchOptions(),
accessControlStatus, v8CacheOptions)
.ToLocal(&script)) {
DCHECK(tryCatch.HasCaught());
return result;