2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/renderer/content_renderer_client.h"
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
|
|
|
|
// Enable deprecation warnings for MSVC. See http://crbug.com/585142.
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#pragma warning(push)
|
2017-05-17 11:29:28 +02:00
|
|
|
#pragma warning(default : 4996)
|
2016-03-16 03:55:59 +01:00
|
|
|
#endif
|
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
#include "libcef/browser/context.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/common/cef_messages.h"
|
2012-12-31 11:41:15 +01:00
|
|
|
#include "libcef/common/cef_switches.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/common/content_client.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/common/extensions/extensions_client.h"
|
|
|
|
#include "libcef/common/extensions/extensions_util.h"
|
2013-11-21 21:59:28 +01:00
|
|
|
#include "libcef/common/request_impl.h"
|
2012-11-20 21:08:36 +01:00
|
|
|
#include "libcef/common/values_impl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/renderer/browser_impl.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/renderer/extensions/extensions_renderer_client.h"
|
2017-09-06 23:40:58 +02:00
|
|
|
#include "libcef/renderer/extensions/print_render_frame_helper_delegate.h"
|
2014-04-04 18:50:38 +02:00
|
|
|
#include "libcef/renderer/render_frame_observer.h"
|
2012-11-02 19:16:28 +01:00
|
|
|
#include "libcef/renderer/render_message_filter.h"
|
2016-05-25 01:35:43 +02:00
|
|
|
#include "libcef/renderer/render_thread_observer.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/renderer/thread_util.h"
|
|
|
|
#include "libcef/renderer/v8_impl.h"
|
2013-10-16 02:25:38 +02:00
|
|
|
#include "libcef/renderer/webkit_glue.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
#include "base/command_line.h"
|
2016-01-06 20:20:54 +01:00
|
|
|
#include "base/macros.h"
|
2016-04-27 22:38:52 +02:00
|
|
|
#include "base/memory/ptr_util.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "base/metrics/user_metrics_action.h"
|
2012-12-31 11:41:15 +01:00
|
|
|
#include "base/path_service.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "base/stl_util.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "base/strings/string_number_conversions.h"
|
2014-04-04 18:50:38 +02:00
|
|
|
#include "base/strings/utf_string_conversions.h"
|
2016-01-06 20:20:54 +01:00
|
|
|
#include "build/build_config.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/common/constants.mojom.h"
|
2015-10-12 20:13:13 +02:00
|
|
|
#include "chrome/common/url_constants.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/renderer/chrome_content_renderer_client.h"
|
2013-04-04 20:10:17 +02:00
|
|
|
#include "chrome/renderer/loadtimes_extension_bindings.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/renderer/media/chrome_key_systems.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "chrome/renderer/pepper/chrome_pdf_print_client.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/renderer/pepper/pepper_helper.h"
|
|
|
|
#include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "components/content_settings/core/common/content_settings_types.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "components/nacl/common/nacl_constants.h"
|
2017-09-06 23:40:58 +02:00
|
|
|
#include "components/printing/renderer/print_render_frame_helper.h"
|
2016-08-31 13:25:56 +02:00
|
|
|
#include "components/spellcheck/renderer/spellcheck.h"
|
|
|
|
#include "components/spellcheck/renderer/spellcheck_provider.h"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "components/startup_metric_utils/common/startup_metric.mojom.h"
|
2016-01-12 01:19:51 +01:00
|
|
|
#include "components/visitedlink/renderer/visitedlink_slave.h"
|
2016-05-25 01:35:43 +02:00
|
|
|
#include "components/web_cache/renderer/web_cache_impl.h"
|
2013-12-17 23:04:35 +01:00
|
|
|
#include "content/common/frame_messages.h"
|
2013-02-02 01:21:59 +01:00
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
#include "content/public/browser/render_process_host.h"
|
2015-03-04 02:00:13 +01:00
|
|
|
#include "content/public/child/child_thread.h"
|
2013-06-24 18:40:40 +02:00
|
|
|
#include "content/public/common/content_constants.h"
|
2014-01-14 18:37:02 +01:00
|
|
|
#include "content/public/common/content_paths.h"
|
2015-11-10 21:18:16 +01:00
|
|
|
#include "content/public/common/content_switches.h"
|
2015-02-04 19:10:14 +01:00
|
|
|
#include "content/public/renderer/plugin_instance_throttler.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/renderer/render_view.h"
|
2014-10-07 22:44:33 +02:00
|
|
|
#include "content/public/renderer/render_view_visitor.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "content/renderer/render_widget.h"
|
2017-09-06 23:40:58 +02:00
|
|
|
#include "extensions/common/switches.h"
|
2015-11-10 21:18:16 +01:00
|
|
|
#include "extensions/renderer/renderer_extension_registry.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "ipc/ipc_sync_channel.h"
|
2012-12-31 11:41:15 +01:00
|
|
|
#include "media/base/media.h"
|
2015-12-09 17:10:16 +01:00
|
|
|
#include "printing/print_settings.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "services/service_manager/public/cpp/connector.h"
|
|
|
|
#include "services/service_manager/public/cpp/interface_provider.h"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "services/service_manager/public/cpp/service_context.h"
|
|
|
|
#include "third_party/WebKit/public/common/associated_interfaces/associated_interface_provider.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "third_party/WebKit/public/platform/Platform.h"
|
2016-02-05 01:49:19 +01:00
|
|
|
#include "third_party/WebKit/public/platform/URLConversion.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "third_party/WebKit/public/platform/WebPrerenderingSupport.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "third_party/WebKit/public/platform/WebRuntimeFeatures.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "third_party/WebKit/public/platform/WebString.h"
|
|
|
|
#include "third_party/WebKit/public/platform/WebURL.h"
|
2017-09-06 23:40:58 +02:00
|
|
|
#include "third_party/WebKit/public/platform/scheduler/renderer_process_type.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
|
2015-01-09 18:22:10 +01:00
|
|
|
#include "third_party/WebKit/public/web/WebElement.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebFrame.h"
|
2014-07-01 00:30:29 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebPrerendererClient.h"
|
|
|
|
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
|
|
|
#include "third_party/WebKit/public/web/WebView.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "ui/base/l10n/l10n_util.h"
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2015-04-08 15:16:17 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
#include "base/mac/mac_util.h"
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
|
|
|
#endif
|
|
|
|
|
2012-05-29 19:18:33 +02:00
|
|
|
namespace {
|
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
// Stub implementation of blink::WebPrerenderingSupport.
|
|
|
|
class CefPrerenderingSupport : public blink::WebPrerenderingSupport {
|
2012-05-29 19:18:33 +02:00
|
|
|
private:
|
2017-04-20 21:28:17 +02:00
|
|
|
void Add(const blink::WebPrerender& prerender) override {}
|
|
|
|
void Cancel(const blink::WebPrerender& prerender) override {}
|
|
|
|
void Abandon(const blink::WebPrerender& prerender) override {}
|
|
|
|
void PrefetchFinished() override {}
|
2012-05-29 19:18:33 +02:00
|
|
|
};
|
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
// Stub implementation of blink::WebPrerendererClient.
|
2012-05-29 19:18:33 +02:00
|
|
|
class CefPrerendererClient : public content::RenderViewObserver,
|
2013-11-08 22:28:56 +01:00
|
|
|
public blink::WebPrerendererClient {
|
2012-05-29 19:18:33 +02:00
|
|
|
public:
|
|
|
|
explicit CefPrerendererClient(content::RenderView* render_view)
|
|
|
|
: content::RenderViewObserver(render_view) {
|
|
|
|
DCHECK(render_view);
|
2017-04-20 21:28:17 +02:00
|
|
|
render_view->GetWebView()->SetPrerendererClient(this);
|
2012-05-29 19:18:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefPrerendererClient() override {}
|
2012-05-29 19:18:33 +02:00
|
|
|
|
2016-06-21 00:59:23 +02:00
|
|
|
// RenderViewObserver methods:
|
2017-05-17 11:29:28 +02:00
|
|
|
void OnDestruct() override { delete this; }
|
2016-06-21 00:59:23 +02:00
|
|
|
|
|
|
|
// WebPrerendererClient methods:
|
2017-04-20 21:28:17 +02:00
|
|
|
void WillAddPrerender(blink::WebPrerender* prerender) override {}
|
|
|
|
bool IsPrefetchOnly() override { return false; }
|
2012-05-29 19:18:33 +02:00
|
|
|
};
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
bool IsStandaloneExtensionProcess() {
|
|
|
|
return extensions::ExtensionsEnabled() &&
|
|
|
|
extensions::CefExtensionsRendererClient::
|
|
|
|
IsStandaloneExtensionProcess();
|
|
|
|
}
|
|
|
|
|
2012-05-29 19:18:33 +02:00
|
|
|
} // namespace
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// Placeholder object for guest views.
|
|
|
|
class CefGuestView : public content::RenderViewObserver {
|
|
|
|
public:
|
|
|
|
explicit CefGuestView(content::RenderView* render_view)
|
2017-05-17 11:29:28 +02:00
|
|
|
: content::RenderViewObserver(render_view) {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// RenderViewObserver methods.
|
|
|
|
void OnDestruct() override {
|
|
|
|
CefContentRendererClient::Get()->OnGuestViewDestroyed(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
CefContentRendererClient::CefContentRendererClient()
|
2018-03-20 21:15:08 +01:00
|
|
|
: main_entry_time_(base::TimeTicks::Now()),
|
|
|
|
devtools_agent_count_(0),
|
2013-02-02 01:21:59 +01:00
|
|
|
uncaught_exception_stack_size_(0),
|
|
|
|
single_process_cleanup_complete_(false) {
|
2015-11-10 21:18:16 +01:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
extensions_client_.reset(new extensions::CefExtensionsClient);
|
|
|
|
extensions::ExtensionsClient::Set(extensions_client_.get());
|
|
|
|
extensions_renderer_client_.reset(
|
|
|
|
new extensions::CefExtensionsRendererClient);
|
|
|
|
extensions::ExtensionsRendererClient::Set(
|
|
|
|
extensions_renderer_client_.get());
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
|
2015-12-09 17:10:16 +01:00
|
|
|
printing::SetAgent(CefContentClient::Get()->GetUserAgent());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentRendererClient::~CefContentRendererClient() {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// static
|
|
|
|
CefContentRendererClient* CefContentRendererClient::Get() {
|
|
|
|
return static_cast<CefContentRendererClient*>(
|
2013-04-16 00:16:01 +02:00
|
|
|
CefContentClient::Get()->renderer());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserImpl> CefContentRendererClient::GetBrowserForView(
|
|
|
|
content::RenderView* view) {
|
|
|
|
CEF_REQUIRE_RT_RETURN(NULL);
|
|
|
|
|
|
|
|
BrowserMap::const_iterator it = browsers_.find(view);
|
|
|
|
if (it != browsers_.end())
|
|
|
|
return it->second;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserImpl> CefContentRendererClient::GetBrowserForMainFrame(
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebFrame* frame) {
|
2012-04-03 03:34:16 +02:00
|
|
|
CEF_REQUIRE_RT_RETURN(NULL);
|
|
|
|
|
|
|
|
BrowserMap::const_iterator it = browsers_.begin();
|
|
|
|
for (; it != browsers_.end(); ++it) {
|
|
|
|
content::RenderView* render_view = it->second->render_view();
|
|
|
|
if (render_view && render_view->GetWebView() &&
|
2017-04-20 21:28:17 +02:00
|
|
|
render_view->GetWebView()->MainFrame() == frame) {
|
2012-04-03 03:34:16 +02:00
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentRendererClient::OnBrowserDestroyed(CefBrowserImpl* browser) {
|
|
|
|
BrowserMap::iterator it = browsers_.begin();
|
|
|
|
for (; it != browsers_.end(); ++it) {
|
|
|
|
if (it->second.get() == browser) {
|
|
|
|
browsers_.erase(it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No browser was found in the map.
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefContentRendererClient::HasGuestViewForView(content::RenderView* view) {
|
2015-11-17 19:20:13 +01:00
|
|
|
CEF_REQUIRE_RT_RETURN(false);
|
|
|
|
|
|
|
|
GuestViewMap::const_iterator it = guest_views_.find(view);
|
|
|
|
return it != guest_views_.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentRendererClient::OnGuestViewDestroyed(CefGuestView* guest_view) {
|
|
|
|
GuestViewMap::iterator it = guest_views_.begin();
|
|
|
|
for (; it != guest_views_.end(); ++it) {
|
2016-10-21 21:52:29 +02:00
|
|
|
if (it->second.get() == guest_view) {
|
2015-11-17 19:20:13 +01:00
|
|
|
guest_views_.erase(it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No guest view was found in the map.
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
void CefContentRendererClient::WebKitInitialized() {
|
2015-01-09 18:22:10 +01:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
2013-03-08 01:41:26 +01:00
|
|
|
|
2014-05-29 19:15:34 +02:00
|
|
|
// Create global objects associated with the default Isolate.
|
|
|
|
CefV8IsolateCreated();
|
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
// TODO(cef): Enable these once the implementation supports it.
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebRuntimeFeatures::EnableNotifications(false);
|
2012-12-31 11:41:15 +01:00
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
const CefContentClient::SchemeInfoList* schemes =
|
|
|
|
CefContentClient::Get()->GetCustomSchemes();
|
|
|
|
if (!schemes->empty()) {
|
2017-01-23 18:36:54 +01:00
|
|
|
// Register the custom schemes. The |is_standard| value is excluded here
|
|
|
|
// because it's not explicitly registered with Blink.
|
2013-06-05 01:37:26 +02:00
|
|
|
CefContentClient::SchemeInfoList::const_iterator it = schemes->begin();
|
|
|
|
for (; it != schemes->end(); ++it) {
|
|
|
|
const CefContentClient::SchemeInfo& info = *it;
|
2013-11-08 22:28:56 +01:00
|
|
|
const blink::WebString& scheme =
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebString::FromUTF8(info.scheme_name);
|
2013-04-18 19:58:23 +02:00
|
|
|
if (info.is_local)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_glue::RegisterURLSchemeAsLocal(scheme);
|
2013-04-18 19:58:23 +02:00
|
|
|
if (info.is_display_isolated)
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
|
2017-01-23 18:36:54 +01:00
|
|
|
if (info.is_secure)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_glue::RegisterURLSchemeAsSecure(scheme);
|
2012-12-31 11:41:15 +01:00
|
|
|
}
|
|
|
|
}
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
if (!cross_origin_whitelist_entries_.empty()) {
|
|
|
|
// Add the cross-origin white list entries.
|
|
|
|
for (size_t i = 0; i < cross_origin_whitelist_entries_.size(); ++i) {
|
|
|
|
const Cef_CrossOriginWhiteListEntry_Params& entry =
|
|
|
|
cross_origin_whitelist_entries_[i];
|
|
|
|
GURL gurl = GURL(entry.source_origin);
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
2017-05-17 11:29:28 +02:00
|
|
|
gurl, blink::WebString::FromUTF8(entry.target_protocol),
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebString::FromUTF8(entry.target_domain),
|
2012-12-31 11:41:15 +01:00
|
|
|
entry.allow_target_subdomains);
|
2012-04-24 20:01:48 +02:00
|
|
|
}
|
2012-12-31 11:41:15 +01:00
|
|
|
cross_origin_whitelist_entries_.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The number of stack trace frames to capture for uncaught exceptions.
|
2015-01-09 18:22:10 +01:00
|
|
|
if (command_line->HasSwitch(switches::kUncaughtExceptionStackSize)) {
|
2012-12-31 11:41:15 +01:00
|
|
|
int uncaught_exception_stack_size = 0;
|
2017-05-17 11:29:28 +02:00
|
|
|
base::StringToInt(command_line->GetSwitchValueASCII(
|
|
|
|
switches::kUncaughtExceptionStackSize),
|
|
|
|
&uncaught_exception_stack_size);
|
2012-12-31 11:41:15 +01:00
|
|
|
|
|
|
|
if (uncaught_exception_stack_size > 0) {
|
2013-01-03 18:24:24 +01:00
|
|
|
uncaught_exception_stack_size_ = uncaught_exception_stack_size;
|
|
|
|
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
2012-04-24 20:01:48 +02:00
|
|
|
}
|
|
|
|
}
|
2012-12-31 11:41:15 +01:00
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
url_loader_factory_ =
|
|
|
|
blink::Platform::Current()->CreateDefaultURLLoaderFactory();
|
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
// Notify the render process handler.
|
|
|
|
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
|
|
|
if (application.get()) {
|
|
|
|
CefRefPtr<CefRenderProcessHandler> handler =
|
|
|
|
application->GetRenderProcessHandler();
|
|
|
|
if (handler.get())
|
|
|
|
handler->OnWebKitInitialized();
|
|
|
|
}
|
2012-04-24 20:01:48 +02:00
|
|
|
}
|
|
|
|
|
2017-09-21 13:57:40 +02:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentRendererClient::GetCurrentTaskRunner() {
|
2013-01-03 18:24:24 +01:00
|
|
|
// Check if currently on the render thread.
|
|
|
|
if (CEF_CURRENTLY_ON_RT())
|
|
|
|
return render_task_runner_;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
void CefContentRendererClient::RunSingleProcessCleanup() {
|
|
|
|
DCHECK(content::RenderProcessHost::run_renderer_in_process());
|
|
|
|
|
|
|
|
// Make sure the render thread was actually started.
|
2014-09-27 01:48:19 +02:00
|
|
|
if (!render_task_runner_.get())
|
2013-02-02 01:21:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
|
|
|
|
RunSingleProcessCleanupOnUIThread();
|
|
|
|
} else {
|
2017-05-17 11:29:28 +02:00
|
|
|
content::BrowserThread::PostTask(
|
|
|
|
content::BrowserThread::UI, FROM_HERE,
|
2013-02-02 01:21:59 +01:00
|
|
|
base::Bind(&CefContentRendererClient::RunSingleProcessCleanupOnUIThread,
|
|
|
|
base::Unretained(this)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for the render thread cleanup to complete. Spin instead of using
|
|
|
|
// base::WaitableEvent because calling Wait() is not allowed on the UI
|
|
|
|
// thread.
|
|
|
|
bool complete = false;
|
|
|
|
do {
|
|
|
|
{
|
|
|
|
base::AutoLock lock_scope(single_process_cleanup_lock_);
|
|
|
|
complete = single_process_cleanup_complete_;
|
|
|
|
}
|
|
|
|
if (!complete)
|
|
|
|
base::PlatformThread::YieldCurrentThread();
|
|
|
|
} while (!complete);
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefContentRendererClient::RenderThreadStarted() {
|
2014-10-07 22:44:33 +02:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
render_task_runner_ = base::ThreadTaskRunnerHandle::Get();
|
2016-05-25 01:35:43 +02:00
|
|
|
observer_.reset(new CefRenderThreadObserver());
|
|
|
|
web_cache_impl_.reset(new web_cache::WebCacheImpl());
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
content::RenderThread* thread = content::RenderThread::Get();
|
2017-09-06 23:40:58 +02:00
|
|
|
|
|
|
|
thread->SetRendererProcessType(
|
|
|
|
IsStandaloneExtensionProcess()
|
|
|
|
? blink::scheduler::RendererProcessType::kExtensionRenderer
|
|
|
|
: blink::scheduler::RendererProcessType::kRenderer);
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
{
|
|
|
|
startup_metric_utils::mojom::StartupMetricHostPtr startup_metric_host;
|
|
|
|
GetConnector()->BindInterface(chrome::mojom::kServiceName,
|
|
|
|
&startup_metric_host);
|
|
|
|
startup_metric_host->RecordRendererMainEntryTime(main_entry_time_);
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
thread->AddObserver(observer_.get());
|
2012-11-02 19:16:28 +01:00
|
|
|
thread->GetChannel()->AddFilter(new CefRenderMessageFilter);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2014-10-07 22:44:33 +02:00
|
|
|
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
|
2018-03-20 21:15:08 +01:00
|
|
|
spellcheck_ = std::make_unique<SpellCheck>(®istry_, this);
|
2014-10-07 22:44:33 +02:00
|
|
|
}
|
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
if (content::RenderProcessHost::run_renderer_in_process()) {
|
|
|
|
// When running in single-process mode register as a destruction observer
|
|
|
|
// on the render thread's MessageLoop.
|
2013-04-16 00:16:01 +02:00
|
|
|
base::MessageLoop::current()->AddDestructionObserver(this);
|
2013-02-02 01:21:59 +01:00
|
|
|
}
|
|
|
|
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebPrerenderingSupport::Initialize(new CefPrerenderingSupport());
|
2012-05-29 19:18:33 +02:00
|
|
|
|
2015-04-08 15:16:17 +02:00
|
|
|
#if defined(OS_MACOSX)
|
2016-05-25 01:35:43 +02:00
|
|
|
{
|
2015-04-08 15:16:17 +02:00
|
|
|
base::ScopedCFTypeRef<CFStringRef> key(
|
|
|
|
base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding"));
|
|
|
|
base::ScopedCFTypeRef<CFStringRef> value;
|
|
|
|
|
|
|
|
// If the command-line switch is specified then set the value that will be
|
|
|
|
// checked in RenderThreadImpl::Init(). Otherwise, remove the application-
|
|
|
|
// level value.
|
|
|
|
if (command_line->HasSwitch(switches::kDisableScrollBounce))
|
|
|
|
value.reset(base::SysUTF8ToCFStringRef("false"));
|
|
|
|
|
|
|
|
CFPreferencesSetAppValue(key, value, kCFPreferencesCurrentApplication);
|
|
|
|
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
|
|
|
}
|
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (extensions::PdfExtensionEnabled()) {
|
|
|
|
pdf_print_client_.reset(new ChromePDFPrintClient());
|
|
|
|
pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get());
|
|
|
|
}
|
|
|
|
|
2015-11-10 21:18:16 +01:00
|
|
|
if (extensions::ExtensionsEnabled())
|
|
|
|
extensions_renderer_client_->RenderThreadStarted();
|
2017-05-31 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentRendererClient::RenderThreadConnected() {
|
|
|
|
content::RenderThread* thread = content::RenderThread::Get();
|
|
|
|
|
|
|
|
// Retrieve the new render thread information synchronously.
|
|
|
|
CefProcessHostMsg_GetNewRenderThreadInfo_Params params;
|
|
|
|
thread->Send(new CefProcessHostMsg_GetNewRenderThreadInfo(¶ms));
|
|
|
|
|
|
|
|
// Cross-origin entries need to be added after WebKit is initialized.
|
|
|
|
cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Notify the render process handler.
|
|
|
|
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
|
|
|
if (application.get()) {
|
|
|
|
CefRefPtr<CefRenderProcessHandler> handler =
|
|
|
|
application->GetRenderProcessHandler();
|
2012-11-20 21:08:36 +01:00
|
|
|
if (handler.get()) {
|
|
|
|
CefRefPtr<CefListValueImpl> listValuePtr(
|
2017-05-17 11:29:28 +02:00
|
|
|
new CefListValueImpl(¶ms.extra_info, false, true));
|
2012-11-20 21:08:36 +01:00
|
|
|
handler->OnRenderThreadCreated(listValuePtr.get());
|
|
|
|
listValuePtr->Detach(NULL);
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2015-08-14 16:41:08 +02:00
|
|
|
|
|
|
|
// Register extensions last because it will trigger WebKit initialization.
|
|
|
|
thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get());
|
2016-04-27 22:38:52 +02:00
|
|
|
|
|
|
|
WebKitInitialized();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
void CefContentRendererClient::RenderFrameCreated(
|
|
|
|
content::RenderFrame* render_frame) {
|
2017-09-06 23:40:58 +02:00
|
|
|
CefRenderFrameObserver* render_frame_observer =
|
|
|
|
new CefRenderFrameObserver(render_frame);
|
|
|
|
service_manager::BinderRegistry* registry = render_frame_observer->registry();
|
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
new PepperHelper(render_frame);
|
2017-09-06 23:40:58 +02:00
|
|
|
new printing::PrintRenderFrameHelper(
|
2016-11-23 21:54:29 +01:00
|
|
|
render_frame,
|
2017-09-06 23:40:58 +02:00
|
|
|
base::WrapUnique(new extensions::CefPrintRenderFrameHelperDelegate()));
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2015-11-10 21:18:16 +01:00
|
|
|
if (extensions::ExtensionsEnabled())
|
2017-09-06 23:40:58 +02:00
|
|
|
extensions_renderer_client_->RenderFrameCreated(render_frame, registry);
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-04-20 21:28:17 +02:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
2017-12-07 22:44:24 +01:00
|
|
|
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
|
2018-02-15 01:12:09 +01:00
|
|
|
new SpellCheckProvider(render_frame, spellcheck_.get(), this);
|
2017-12-07 22:44:24 +01:00
|
|
|
}
|
2017-04-20 21:28:17 +02:00
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
BrowserCreated(render_frame->GetRenderView(), render_frame);
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefContentRendererClient::RenderViewCreated(
|
|
|
|
content::RenderView* render_view) {
|
2015-07-16 23:40:01 +02:00
|
|
|
new CefPrerendererClient(render_view);
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
BrowserCreated(render_view, render_view->GetMainRenderFrame());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
bool CefContentRendererClient::OverrideCreatePlugin(
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
const blink::WebPluginParams& params,
|
|
|
|
blink::WebPlugin** plugin) {
|
2017-04-20 21:28:17 +02:00
|
|
|
std::string orig_mime_type = params.mime_type.Utf8();
|
2015-11-10 21:18:16 +01:00
|
|
|
if (extensions::ExtensionsEnabled() &&
|
|
|
|
!extensions_renderer_client_->OverrideCreatePlugin(render_frame,
|
|
|
|
params)) {
|
|
|
|
return false;
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
GURL url(params.url);
|
2017-12-07 22:44:24 +01:00
|
|
|
chrome::mojom::PluginInfoPtr plugin_info = chrome::mojom::PluginInfo::New();
|
|
|
|
ChromeContentRendererClient::GetPluginInfoHost()->GetPluginInfo(
|
2017-05-31 17:33:30 +02:00
|
|
|
render_frame->GetRoutingID(), url,
|
|
|
|
render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), orig_mime_type,
|
2017-12-07 22:44:24 +01:00
|
|
|
&plugin_info);
|
|
|
|
*plugin = ChromeContentRendererClient::CreatePlugin(render_frame, params,
|
|
|
|
*plugin_info);
|
2015-07-16 23:40:01 +02:00
|
|
|
return true;
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2015-10-14 20:23:08 +02:00
|
|
|
bool CefContentRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
|
|
|
const GURL& url,
|
|
|
|
const std::string& http_method,
|
|
|
|
bool is_initial_navigation,
|
|
|
|
bool is_server_redirect,
|
|
|
|
bool* send_referrer) {
|
2017-04-20 21:28:17 +02:00
|
|
|
DCHECK(!frame->Parent());
|
2015-10-14 20:23:08 +02:00
|
|
|
|
|
|
|
// For now, we skip the rest for POST submissions. This is because
|
|
|
|
// http://crbug.com/101395 is more likely to cause compatibility issues
|
|
|
|
// with hosted apps and extensions than WebUI pages. We will remove this
|
|
|
|
// check when cross-process POST submissions are supported.
|
|
|
|
if (http_method != "GET")
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
2015-11-10 21:18:16 +01:00
|
|
|
return extensions::CefExtensionsRendererClient::ShouldFork(
|
|
|
|
frame, url, is_initial_navigation, is_server_redirect, send_referrer);
|
2015-10-14 20:23:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-12 20:13:13 +02:00
|
|
|
bool CefContentRendererClient::WillSendRequest(
|
2017-01-23 18:36:54 +01:00
|
|
|
blink::WebLocalFrame* frame,
|
2015-10-12 20:13:13 +02:00
|
|
|
ui::PageTransition transition_type,
|
2016-11-23 21:54:29 +01:00
|
|
|
const blink::WebURL& url,
|
2015-10-12 20:13:13 +02:00
|
|
|
GURL* new_url) {
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
2015-11-10 21:18:16 +01:00
|
|
|
return extensions_renderer_client_->WillSendRequest(frame, transition_type,
|
|
|
|
url, new_url);
|
2015-10-12 20:13:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-12 01:19:51 +01:00
|
|
|
unsigned long long CefContentRendererClient::VisitedLinkHash(
|
2017-05-17 11:29:28 +02:00
|
|
|
const char* canonical_url,
|
|
|
|
size_t length) {
|
2016-10-21 21:52:29 +02:00
|
|
|
return observer_->visited_link_slave()->ComputeURLFingerprint(canonical_url,
|
|
|
|
length);
|
2016-01-12 01:19:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
|
2016-10-21 21:52:29 +02:00
|
|
|
return observer_->visited_link_slave()->IsVisited(link_hash);
|
2016-01-12 01:19:51 +01:00
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
content::BrowserPluginDelegate*
|
|
|
|
CefContentRendererClient::CreateBrowserPluginDelegate(
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
const std::string& mime_type,
|
|
|
|
const GURL& original_url) {
|
|
|
|
DCHECK(extensions::ExtensionsEnabled());
|
2015-11-10 21:18:16 +01:00
|
|
|
return extensions::CefExtensionsRendererClient::CreateBrowserPluginDelegate(
|
2017-05-17 11:29:28 +02:00
|
|
|
render_frame, mime_type, original_url);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefContentRendererClient::AddSupportedKeySystems(
|
|
|
|
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) {
|
2017-12-07 22:44:24 +01:00
|
|
|
AddChromeKeySystems(key_systems);
|
2015-08-31 13:28:07 +02:00
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
void CefContentRendererClient::RunScriptsAtDocumentStart(
|
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
if (extensions::ExtensionsEnabled())
|
|
|
|
extensions_renderer_client_->RunScriptsAtDocumentStart(render_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentRendererClient::RunScriptsAtDocumentEnd(
|
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
if (extensions::ExtensionsEnabled())
|
|
|
|
extensions_renderer_client_->RunScriptsAtDocumentEnd(render_frame);
|
|
|
|
}
|
|
|
|
|
2017-04-20 21:28:17 +02:00
|
|
|
void CefContentRendererClient::RunScriptsAtDocumentIdle(
|
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
if (extensions::ExtensionsEnabled())
|
|
|
|
extensions_renderer_client_->RunScriptsAtDocumentIdle(render_frame);
|
|
|
|
}
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
void CefContentRendererClient::DevToolsAgentAttached() {
|
2017-12-07 22:44:24 +01:00
|
|
|
CEF_REQUIRE_RT();
|
|
|
|
++devtools_agent_count_;
|
2013-02-02 01:21:59 +01:00
|
|
|
}
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
void CefContentRendererClient::DevToolsAgentDetached() {
|
2017-12-07 22:44:24 +01:00
|
|
|
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_);
|
|
|
|
}
|
|
|
|
}
|
2015-09-09 16:05:39 +02:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
void CefContentRendererClient::CreateRendererService(
|
|
|
|
service_manager::mojom::ServiceRequest service_request) {
|
|
|
|
service_context_ = std::make_unique<service_manager::ServiceContext>(
|
|
|
|
std::make_unique<service_manager::ForwardingService>(this),
|
|
|
|
std::move(service_request));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentRendererClient::OnStart() {
|
|
|
|
context()->connector()->BindConnectorRequest(std::move(connector_request_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentRendererClient::OnBindInterface(
|
|
|
|
const service_manager::BindSourceInfo& remote_info,
|
|
|
|
const std::string& name,
|
|
|
|
mojo::ScopedMessagePipeHandle handle) {
|
|
|
|
registry_.TryBindInterface(name, &handle);
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
void CefContentRendererClient::GetInterface(
|
|
|
|
const std::string& interface_name,
|
|
|
|
mojo::ScopedMessagePipeHandle interface_pipe) {
|
2018-03-20 21:15:08 +01:00
|
|
|
connector_->BindInterface(
|
2017-12-07 22:44:24 +01:00
|
|
|
service_manager::Identity(chrome::mojom::kServiceName), interface_name,
|
|
|
|
std::move(interface_pipe));
|
|
|
|
}
|
2015-09-09 16:05:39 +02:00
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
void CefContentRendererClient::WillDestroyCurrentMessageLoop() {
|
|
|
|
base::AutoLock lock_scope(single_process_cleanup_lock_);
|
|
|
|
single_process_cleanup_complete_ = true;
|
2015-09-09 16:05:39 +02:00
|
|
|
}
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
void CefContentRendererClient::BrowserCreated(
|
|
|
|
content::RenderView* render_view,
|
|
|
|
content::RenderFrame* render_frame) {
|
2016-01-06 20:20:54 +01:00
|
|
|
if (!render_view || !render_frame)
|
|
|
|
return;
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// Don't create another browser or guest view object if one already exists for
|
|
|
|
// the view.
|
|
|
|
if (GetBrowserForView(render_view).get() || HasGuestViewForView(render_view))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const int render_frame_routing_id = render_frame->GetRoutingID();
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
// Retrieve the browser information synchronously. This will also register
|
|
|
|
// the routing ids with the browser info object in the browser process.
|
|
|
|
CefProcessHostMsg_GetNewBrowserInfo_Params params;
|
2017-05-17 11:29:28 +02:00
|
|
|
content::RenderThread::Get()->Send(new CefProcessHostMsg_GetNewBrowserInfo(
|
2017-10-26 20:17:00 +02:00
|
|
|
render_frame_routing_id, ¶ms));
|
2015-11-17 19:20:13 +01:00
|
|
|
if (params.browser_id == 0) {
|
2017-05-09 22:45:57 +02:00
|
|
|
// The popup may have been canceled during creation.
|
2015-11-17 19:20:13 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-02 23:41:11 +01:00
|
|
|
|
2015-10-21 20:17:09 +02:00
|
|
|
if (params.is_guest_view) {
|
|
|
|
// Don't create a CefBrowser for guest views.
|
2017-05-17 11:29:28 +02:00
|
|
|
guest_views_.insert(std::make_pair(
|
2018-03-20 21:15:08 +01:00
|
|
|
render_view, std::make_unique<CefGuestView>(render_view)));
|
2015-07-16 23:40:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
// FIXME: It would be better if this API would be a callback from the
|
|
|
|
// WebKit layer, or if it would be exposed as an WebView instance method; the
|
|
|
|
// current implementation uses a static variable, and WebKit needs to be
|
|
|
|
// patched in order to make it work for each WebView instance
|
2017-04-20 21:28:17 +02:00
|
|
|
render_view->GetWebView()->SetUseExternalPopupMenusThisInstance(
|
2014-07-01 00:30:29 +02:00
|
|
|
!params.is_windowless);
|
|
|
|
#endif
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefRefPtr<CefBrowserImpl> browser = new CefBrowserImpl(
|
|
|
|
render_view, params.browser_id, params.is_popup, params.is_windowless);
|
2014-01-02 23:41:11 +01:00
|
|
|
browsers_.insert(std::make_pair(render_view, browser));
|
|
|
|
|
|
|
|
// Notify the render process handler.
|
|
|
|
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
|
|
|
if (application.get()) {
|
|
|
|
CefRefPtr<CefRenderProcessHandler> handler =
|
|
|
|
application->GetRenderProcessHandler();
|
|
|
|
if (handler.get())
|
|
|
|
handler->OnBrowserCreated(browser.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
void CefContentRendererClient::RunSingleProcessCleanupOnUIThread() {
|
|
|
|
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
|
|
|
|
|
// Clean up the single existing RenderProcessHost.
|
|
|
|
content::RenderProcessHost* host = NULL;
|
|
|
|
content::RenderProcessHost::iterator iterator(
|
|
|
|
content::RenderProcessHost::AllHostsIterator());
|
|
|
|
if (!iterator.IsAtEnd()) {
|
|
|
|
host = iterator.GetCurrentValue();
|
|
|
|
host->Cleanup();
|
|
|
|
iterator.Advance();
|
|
|
|
DCHECK(iterator.IsAtEnd());
|
|
|
|
}
|
|
|
|
DCHECK(host);
|
|
|
|
|
|
|
|
// Clear the run_renderer_in_process() flag to avoid a DCHECK in the
|
|
|
|
// RenderProcessHost destructor.
|
|
|
|
content::RenderProcessHost::SetRunRendererInProcess(false);
|
|
|
|
|
|
|
|
// Deletion of the RenderProcessHost object will stop the render thread and
|
|
|
|
// result in a call to WillDestroyCurrentMessageLoop.
|
|
|
|
// Cleanup() will cause deletion to be posted as a task on the UI thread but
|
|
|
|
// this task will only execute when running in multi-threaded message loop
|
|
|
|
// mode (because otherwise the UI message loop has already stopped). Therefore
|
|
|
|
// we need to explicitly delete the object when not running in this mode.
|
2013-09-03 20:06:25 +02:00
|
|
|
if (!CefContext::Get()->settings().multi_threaded_message_loop)
|
2013-02-02 01:21:59 +01:00
|
|
|
delete host;
|
|
|
|
}
|
2016-03-16 03:55:59 +01:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
service_manager::Connector* CefContentRendererClient::GetConnector() {
|
|
|
|
if (!connector_)
|
|
|
|
connector_ = service_manager::Connector::Create(&connector_request_);
|
|
|
|
return connector_.get();
|
|
|
|
}
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
// Enable deprecation warnings for MSVC. See http://crbug.com/585142.
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|