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.
|
|
|
|
|
|
|
|
#include "libcef/renderer/render_process_observer.h"
|
|
|
|
#include "libcef/common/cef_messages.h"
|
2013-06-24 20:57:05 +02:00
|
|
|
#include "libcef/common/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
|
|
|
|
2013-06-24 20:57:05 +02:00
|
|
|
#include "net/base/net_module.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
|
|
|
|
|
|
|
CefRenderProcessObserver::CefRenderProcessObserver() {
|
2013-06-24 20:57:05 +02:00
|
|
|
net::NetModule::SetResourceProvider(NetResourceProvider);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRenderProcessObserver::~CefRenderProcessObserver() {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefRenderProcessObserver::OnControlMessageReceived(
|
|
|
|
const IPC::Message& message) {
|
|
|
|
bool handled = true;
|
|
|
|
IPC_BEGIN_MESSAGE_MAP(CefRenderProcessObserver, message)
|
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_ModifyCrossOriginWhitelistEntry,
|
|
|
|
OnModifyCrossOriginWhitelistEntry)
|
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_ClearCrossOriginWhitelist,
|
|
|
|
OnClearCrossOriginWhitelist)
|
|
|
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
|
|
|
IPC_END_MESSAGE_MAP()
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefRenderProcessObserver::WebKitInitialized() {
|
2012-12-31 11:41:15 +01:00
|
|
|
CefContentRendererClient::Get()->WebKitInitialized();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
void CefRenderProcessObserver::OnRenderProcessShutdown() {
|
|
|
|
CefContentRendererClient::Get()->OnRenderProcessShutdown();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefRenderProcessObserver::OnModifyCrossOriginWhitelistEntry(
|
|
|
|
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) {
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry(
|
2012-04-03 03:34:16 +02:00
|
|
|
gurl,
|
2013-11-08 22:28:56 +01: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 {
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebSecurityPolicy::removeOriginAccessWhitelistEntry(
|
2012-04-03 03:34:16 +02:00
|
|
|
gurl,
|
2013-11-08 22:28:56 +01: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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefRenderProcessObserver::OnClearCrossOriginWhitelist() {
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebSecurityPolicy::resetOriginAccessWhitelists();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|