2013-01-03 18:24:24 +01:00
|
|
|
/// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Portions (c) 2011 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.
|
|
|
|
|
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/common/cef_messages.h"
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "libcef/common/net/net_resource_provider.h"
|
2012-04-24 20:01:48 +02:00
|
|
|
#include "libcef/renderer/content_renderer_client.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-10-21 21:52:29 +02:00
|
|
|
#include "components/visitedlink/renderer/visitedlink_slave.h"
|
|
|
|
#include "content/public/renderer/render_thread.h"
|
2013-06-24 20:57:05 +02:00
|
|
|
#include "net/base/net_module.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "services/service_manager/public/cpp/interface_registry.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"
|
|
|
|
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
bool CefRenderThreadObserver::is_incognito_process_ = false;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2016-10-21 21:52:29 +02:00
|
|
|
CefRenderThreadObserver::CefRenderThreadObserver()
|
|
|
|
: visited_link_slave_(new visitedlink::VisitedLinkSlave) {
|
2013-06-24 20:57:05 +02:00
|
|
|
net::NetModule::SetResourceProvider(NetResourceProvider);
|
2016-10-21 21:52:29 +02:00
|
|
|
|
|
|
|
content::RenderThread* thread = content::RenderThread::Get();
|
|
|
|
thread->GetInterfaceRegistry()->AddInterface(
|
|
|
|
visited_link_slave_->GetBindCallback());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
CefRenderThreadObserver::~CefRenderThreadObserver() {
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
bool CefRenderThreadObserver::OnControlMessageReceived(
|
2012-04-03 03:34:16 +02:00
|
|
|
const IPC::Message& message) {
|
|
|
|
bool handled = true;
|
2016-05-25 01:35:43 +02:00
|
|
|
IPC_BEGIN_MESSAGE_MAP(CefRenderThreadObserver, message)
|
2015-07-16 23:40:01 +02:00
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_SetIsIncognitoProcess,
|
|
|
|
OnSetIsIncognitoProcess)
|
2012-04-03 03:34:16 +02:00
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_ModifyCrossOriginWhitelistEntry,
|
|
|
|
OnModifyCrossOriginWhitelistEntry)
|
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_ClearCrossOriginWhitelist,
|
|
|
|
OnClearCrossOriginWhitelist)
|
|
|
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
|
|
|
IPC_END_MESSAGE_MAP()
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnRenderProcessShutdown() {
|
2013-01-03 18:24:24 +01:00
|
|
|
CefContentRendererClient::Get()->OnRenderProcessShutdown();
|
2016-10-21 21:52:29 +02:00
|
|
|
visited_link_slave_.reset();
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnSetIsIncognitoProcess(
|
2015-07-16 23:40:01 +02:00
|
|
|
bool is_incognito_process) {
|
|
|
|
is_incognito_process_ = is_incognito_process;
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnModifyCrossOriginWhitelistEntry(
|
2012-04-03 03:34:16 +02:00
|
|
|
bool add,
|
2012-11-20 21:08:36 +01:00
|
|
|
const Cef_CrossOriginWhiteListEntry_Params& params) {
|
|
|
|
GURL gurl = GURL(params.source_origin);
|
2012-04-03 03:34:16 +02:00
|
|
|
if (add) {
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
2012-04-03 03:34:16 +02:00
|
|
|
gurl,
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebString::FromUTF8(params.target_protocol),
|
|
|
|
blink::WebString::FromUTF8(params.target_domain),
|
2012-11-20 21:08:36 +01:00
|
|
|
params.allow_target_subdomains);
|
2012-04-03 03:34:16 +02:00
|
|
|
} else {
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebSecurityPolicy::RemoveOriginAccessWhitelistEntry(
|
2012-04-03 03:34:16 +02:00
|
|
|
gurl,
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebString::FromUTF8(params.target_protocol),
|
|
|
|
blink::WebString::FromUTF8(params.target_domain),
|
2012-11-20 21:08:36 +01:00
|
|
|
params.allow_target_subdomains);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnClearCrossOriginWhitelist() {
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebSecurityPolicy::ResetOriginAccessWhitelists();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|