mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Update to Chromium revision 133430.
- Move custom scheme registration to CefApp::OnRegisterCustomSchemes(). This is required by the introduction of ContentClient::AddAdditionalSchemes() and fixes a race condition when registering standard schemes in different processes. - Execute V8 functions using V8Proxy. This is required for inspector instrumentation to work correctly and fixes an assertion in WebCore related to V8RecursionScope. - Enable verbose V8 TryCatch logging. - Mac: Expose UnderlayOpenGLHostingWindow interface that should be used for all CEF windows. - Add CefSettings.remote_debugging_port option. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@602 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "base/bind_helpers.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/renderer_host/resource_request_info_impl.h"
|
||||
#include "content/browser/tab_contents/tab_contents.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
@@ -160,9 +160,10 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderViewHost* host) {
|
||||
DCHECK(host);
|
||||
CEF_REQUIRE_UIT();
|
||||
TabContents* tab_contents = static_cast<TabContents*>(host->GetDelegate());
|
||||
if (tab_contents)
|
||||
return static_cast<CefBrowserHostImpl*>(tab_contents->GetDelegate());
|
||||
WebContentsImpl* web_contents =
|
||||
static_cast<WebContentsImpl*>(host->GetDelegate());
|
||||
if (web_contents)
|
||||
return static_cast<CefBrowserHostImpl*>(web_contents->GetDelegate());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "libcef/browser/browser_message_filter.h"
|
||||
|
||||
#include "libcef/browser/origin_whitelist_impl.h"
|
||||
#include "libcef/browser/scheme_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
|
||||
@@ -49,6 +48,5 @@ void CefBrowserMessageFilter::RegisterOnUIThread() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Send existing registrations to the new render process.
|
||||
RegisterSchemesWithHost(host_);
|
||||
RegisterCrossOriginWhitelistEntriesWithHost(host_);
|
||||
}
|
||||
|
@@ -3,8 +3,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/scheme_impl.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
@@ -15,7 +13,6 @@
|
||||
#include "libcef/browser/resource_request_job.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/url_request_context_getter.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/response_impl.h"
|
||||
|
||||
@@ -25,7 +22,6 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "googleurl/src/url_util.h"
|
||||
#include "net/base/completion_callback.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
@@ -53,13 +49,6 @@ bool IsStandardScheme(const std::string& scheme) {
|
||||
return url_util::IsStandard(scheme.c_str(), scheme_comp);
|
||||
}
|
||||
|
||||
void RegisterStandardScheme(const std::string& scheme) {
|
||||
CEF_REQUIRE_UIT();
|
||||
url_parse::Component scheme_comp(0, scheme.length());
|
||||
if (!url_util::IsStandard(scheme.c_str(), scheme_comp))
|
||||
url_util::AddStandardScheme(scheme.c_str());
|
||||
}
|
||||
|
||||
// Copied from net/url_request/url_request_job_manager.cc.
|
||||
struct SchemeToFactory {
|
||||
const char* scheme;
|
||||
@@ -200,69 +189,6 @@ class CefUrlRequestManager {
|
||||
handler_map_.clear();
|
||||
}
|
||||
|
||||
// Check if a scheme has already been registered.
|
||||
bool HasRegisteredScheme(const std::string& scheme) {
|
||||
std::string scheme_lower = ToLower(scheme);
|
||||
|
||||
// Don't register builtin schemes.
|
||||
if (IsBuiltinScheme(scheme_lower))
|
||||
return true;
|
||||
|
||||
scheme_map_lock_.Acquire();
|
||||
bool registered = (scheme_map_.find(scheme_lower) != scheme_map_.end());
|
||||
scheme_map_lock_.Release();
|
||||
return registered;
|
||||
}
|
||||
|
||||
// Register a scheme.
|
||||
bool RegisterScheme(const std::string& scheme,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
if (HasRegisteredScheme(scheme)) {
|
||||
NOTREACHED() << "Scheme already registered: " << scheme;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string scheme_lower = ToLower(scheme);
|
||||
|
||||
SchemeInfo info;
|
||||
info.is_standard = is_standard;
|
||||
info.is_local = is_local;
|
||||
info.is_display_isolated = is_display_isolated;
|
||||
|
||||
scheme_map_lock_.Acquire();
|
||||
scheme_map_.insert(std::make_pair(scheme_lower, info));
|
||||
scheme_map_lock_.Release();
|
||||
|
||||
if (is_standard && !content::RenderProcessHost::run_renderer_in_process()) {
|
||||
// When running in multi-process mode the scheme must be registered with
|
||||
// url_util in the browser process as well.
|
||||
RegisterStandardScheme(scheme_lower);
|
||||
}
|
||||
|
||||
SendRegisterScheme(scheme_lower, is_standard, is_local,
|
||||
is_display_isolated);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send all existing scheme registrations to the specified host.
|
||||
void RegisterSchemesWithHost(content::RenderProcessHost* host) {
|
||||
base::AutoLock lock_scope(scheme_map_lock_);
|
||||
|
||||
if (scheme_map_.empty())
|
||||
return;
|
||||
|
||||
SchemeMap::const_iterator it = scheme_map_.begin();
|
||||
for (; it != scheme_map_.end(); ++it) {
|
||||
host->Send(
|
||||
new CefProcessMsg_RegisterScheme(it->first, it->second.is_standard,
|
||||
it->second.is_local,
|
||||
it->second.is_display_isolated));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Retrieve the matching handler factory, if any. |scheme| will already be in
|
||||
// lower case.
|
||||
@@ -328,40 +254,12 @@ class CefUrlRequestManager {
|
||||
return job;
|
||||
}
|
||||
|
||||
// Send the register scheme message to all currently existing hosts.
|
||||
void SendRegisterScheme(const std::string& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
content::RenderProcessHost::iterator i(
|
||||
content::RenderProcessHost::AllHostsIterator());
|
||||
for (; !i.IsAtEnd(); i.Advance()) {
|
||||
i.GetCurrentValue()->Send(
|
||||
new CefProcessMsg_RegisterScheme(scheme_name, is_standard, is_local,
|
||||
is_display_isolated));
|
||||
}
|
||||
}
|
||||
|
||||
// Map (scheme, domain) to factories. This map will only be accessed on the IO
|
||||
// thread.
|
||||
typedef std::map<std::pair<std::string, std::string>,
|
||||
CefRefPtr<CefSchemeHandlerFactory> > HandlerMap;
|
||||
HandlerMap handler_map_;
|
||||
|
||||
struct SchemeInfo {
|
||||
bool is_standard;
|
||||
bool is_local;
|
||||
bool is_display_isolated;
|
||||
};
|
||||
|
||||
// Map of registered schemes. Access to this map must be protected by the
|
||||
// associated lock.
|
||||
typedef std::map<std::string, SchemeInfo> SchemeMap;
|
||||
SchemeMap scheme_map_;
|
||||
base::Lock scheme_map_lock_;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CefUrlRequestManager);
|
||||
};
|
||||
|
||||
@@ -374,34 +272,6 @@ CefUrlRequestManager* CefUrlRequestManager::GetInstance() {
|
||||
} // namespace
|
||||
|
||||
|
||||
bool CefRegisterCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CEF_CURRENTLY_ON(CEF_UIT)) {
|
||||
// Must be executed on the UI thread.
|
||||
return CefUrlRequestManager::GetInstance()->RegisterScheme(scheme_name,
|
||||
is_standard, is_local, is_display_isolated);
|
||||
} else {
|
||||
// Verify that the scheme has not already been registered.
|
||||
if (CefUrlRequestManager::GetInstance()->HasRegisteredScheme(scheme_name)) {
|
||||
NOTREACHED() << "Scheme already registered: " << scheme_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(base::IgnoreResult(&CefRegisterCustomScheme), scheme_name,
|
||||
is_standard, is_local, is_display_isolated));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CefRegisterSchemeHandlerFactory(
|
||||
const CefString& scheme_name,
|
||||
const CefString& domain_name,
|
||||
@@ -440,8 +310,3 @@ bool CefClearSchemeHandlerFactories() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RegisterSchemesWithHost(content::RenderProcessHost* host) {
|
||||
CEF_REQUIRE_UIT();
|
||||
CefUrlRequestManager::GetInstance()->RegisterSchemesWithHost(host);
|
||||
}
|
||||
|
@@ -1,16 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework 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_BROWSER_SCHEME_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
|
||||
|
||||
namespace content {
|
||||
class RenderProcessHost;
|
||||
}
|
||||
|
||||
// Called when a new RenderProcessHost is created to send existing scheme
|
||||
// registration information.
|
||||
void RegisterSchemesWithHost(content::RenderProcessHost* host);
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
|
@@ -120,13 +120,6 @@ IPC_MESSAGE_ROUTED1(CefMsg_Response,
|
||||
IPC_MESSAGE_ROUTED1(CefMsg_ResponseAck,
|
||||
int /* request_id */)
|
||||
|
||||
// Sent to child processes to register a scheme.
|
||||
IPC_MESSAGE_CONTROL4(CefProcessMsg_RegisterScheme,
|
||||
std::string /* sheme_name */,
|
||||
bool /* is_standard */,
|
||||
bool /* is_local */,
|
||||
bool /* is_display_isolated */)
|
||||
|
||||
// Sent to child processes to add or remove a cross-origin whitelist entry.
|
||||
IPC_MESSAGE_CONTROL5(CefProcessMsg_ModifyCrossOriginWhitelistEntry,
|
||||
bool /* add */,
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "include/cef_stream.h"
|
||||
#include "include/cef_version.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/scheme_registrar_impl.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
@@ -42,6 +43,21 @@ void CefContentClient::AddNPAPIPlugins(
|
||||
webkit::npapi::PluginList* plugin_list) {
|
||||
}
|
||||
|
||||
void CefContentClient::AddAdditionalSchemes(
|
||||
std::vector<std::string>* standard_schemes,
|
||||
std::vector<std::string>* savable_schemes) {
|
||||
if (application_.get()) {
|
||||
CefRefPtr<CefSchemeRegistrarImpl> schemeRegistrar(
|
||||
new CefSchemeRegistrarImpl());
|
||||
application_->OnRegisterCustomSchemes(schemeRegistrar.get());
|
||||
schemeRegistrar->GetStandardSchemes(standard_schemes);
|
||||
|
||||
// No references to the registar should be kept.
|
||||
schemeRegistrar->Detach();
|
||||
DCHECK(schemeRegistrar->VerifyRefCount());
|
||||
}
|
||||
}
|
||||
|
||||
bool CefContentClient::HasWebUIScheme(const GURL& url) const {
|
||||
// There are no WebUI URLs in CEF.
|
||||
return false;
|
||||
|
@@ -28,6 +28,9 @@ class CefContentClient : public content::ContentClient {
|
||||
std::vector<content::PepperPluginInfo>* plugins) OVERRIDE;
|
||||
virtual void AddNPAPIPlugins(
|
||||
webkit::npapi::PluginList* plugin_list) OVERRIDE;
|
||||
virtual void AddAdditionalSchemes(
|
||||
std::vector<std::string>* standard_schemes,
|
||||
std::vector<std::string>* savable_schemes) OVERRIDE;
|
||||
virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE;
|
||||
virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE;
|
||||
virtual std::string GetUserAgent() const OVERRIDE;
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "base/file_path.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "content/public/browser/browser_main_runner.h"
|
||||
@@ -197,6 +198,12 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.remote_debugging_port >= 1024 &&
|
||||
settings.remote_debugging_port <= 65535) {
|
||||
command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort,
|
||||
base::IntToString(settings.remote_debugging_port));
|
||||
}
|
||||
|
||||
// TODO(cef): Figure out how to support the sandbox.
|
||||
if (!command_line->HasSwitch(switches::kNoSandbox))
|
||||
command_line->AppendSwitch(switches::kNoSandbox);
|
||||
@@ -211,6 +218,9 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
commandLinePtr->Detach(NULL);
|
||||
}
|
||||
|
||||
content::SetContentClient(&content_client_);
|
||||
InitializeContentClient(process_type);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -220,12 +230,6 @@ void CefMainDelegate::PreSandboxStartup() {
|
||||
#endif
|
||||
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
std::string process_type =
|
||||
command_line.GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
content::SetContentClient(&content_client_);
|
||||
InitializeContentClient(process_type);
|
||||
|
||||
if (command_line.HasSwitch(switches::kPackLoadingDisabled))
|
||||
content_client_.set_pack_loading_disabled(true);
|
||||
else
|
||||
@@ -341,6 +345,8 @@ void CefMainDelegate::InitializeContentClient(
|
||||
void CefMainDelegate::InitializeResourceBundle() {
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
|
||||
// Mac OS-X does not support customization of the pack load paths.
|
||||
#if !defined(OS_MACOSX)
|
||||
FilePath pak_file, locales_dir;
|
||||
|
||||
if (command_line.HasSwitch(switches::kPackFilePath))
|
||||
@@ -360,6 +366,7 @@ void CefMainDelegate::InitializeResourceBundle() {
|
||||
|
||||
if (!locales_dir.empty())
|
||||
PathService::Override(ui::DIR_LOCALES, locales_dir);
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
std::string locale = command_line.GetSwitchValueASCII(switches::kLocale);
|
||||
if (locale.empty())
|
||||
@@ -372,7 +379,7 @@ void CefMainDelegate::InitializeResourceBundle() {
|
||||
#if defined(OS_WIN)
|
||||
// Explicitly load cef.pak on Windows.
|
||||
if (file_util::PathExists(pak_file))
|
||||
ResourceBundle::AddDataPackToSharedInstance(pak_file);
|
||||
ResourceBundle::GetSharedInstance().AddDataPack(pak_file);
|
||||
else
|
||||
NOTREACHED() << "Could not load cef.pak";
|
||||
#endif
|
||||
|
67
libcef/common/scheme_registrar_impl.cc
Normal file
67
libcef/common/scheme_registrar_impl.cc
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework 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/common/scheme_registrar_impl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "libcef/renderer/content_renderer_client.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
|
||||
CefSchemeRegistrarImpl::CefSchemeRegistrarImpl()
|
||||
: supported_thread_id_(base::PlatformThread::CurrentId()) {
|
||||
}
|
||||
|
||||
bool CefSchemeRegistrarImpl::AddCustomScheme(
|
||||
const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (is_standard)
|
||||
standard_schemes_.push_back(scheme_name);
|
||||
|
||||
if (CefContentRendererClient::Get()) {
|
||||
// Register the custom scheme with WebKit.
|
||||
CefContentRendererClient::Get()->AddCustomScheme(scheme_name, is_local,
|
||||
is_display_isolated);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefSchemeRegistrarImpl::GetStandardSchemes(
|
||||
std::vector<std::string>* standard_schemes) {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
if (standard_schemes_.empty())
|
||||
return;
|
||||
|
||||
standard_schemes->insert(standard_schemes->end(), standard_schemes_.begin(),
|
||||
standard_schemes_.end());
|
||||
}
|
||||
|
||||
bool CefSchemeRegistrarImpl::VerifyRefCount() {
|
||||
return (GetRefCt() == 1);
|
||||
}
|
||||
|
||||
void CefSchemeRegistrarImpl::Detach() {
|
||||
if (VerifyContext())
|
||||
supported_thread_id_ = base::kInvalidThreadId;
|
||||
}
|
||||
|
||||
bool CefSchemeRegistrarImpl::VerifyContext() {
|
||||
if (base::PlatformThread::CurrentId() != supported_thread_id_) {
|
||||
// This object should only be accessed from the thread that created it.
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
46
libcef/common/scheme_registrar_impl.h
Normal file
46
libcef/common/scheme_registrar_impl.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework 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_COMMON_SCHEME_REGISTRAR_IMPL_H_
|
||||
#define CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_scheme.h"
|
||||
|
||||
#include "base/threading/platform_thread.h"
|
||||
|
||||
class CefSchemeRegistrarImpl : public CefSchemeRegistrar {
|
||||
public:
|
||||
CefSchemeRegistrarImpl();
|
||||
|
||||
// CefSchemeRegistrar methods.
|
||||
virtual bool AddCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) OVERRIDE;
|
||||
|
||||
void GetStandardSchemes(std::vector<std::string>* standard_schemes);
|
||||
|
||||
// Verify that only a single reference exists to all CefSchemeRegistrarImpl
|
||||
// objects.
|
||||
bool VerifyRefCount();
|
||||
|
||||
void Detach();
|
||||
|
||||
private:
|
||||
// Verify that the object is being accessed from the correct thread.
|
||||
bool VerifyContext();
|
||||
|
||||
base::PlatformThreadId supported_thread_id_;
|
||||
|
||||
std::vector<std::string> standard_schemes_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefSchemeRegistrarImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSchemeRegistrarImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_
|
@@ -7,7 +7,6 @@
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/content_client.h"
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/render_message_filter.h"
|
||||
#include "libcef/renderer/render_process_observer.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
@@ -17,9 +16,18 @@
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "ipc/ipc_sync_channel.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
|
||||
struct CefContentRendererClient::SchemeInfo {
|
||||
std::string scheme_name;
|
||||
bool is_local;
|
||||
bool is_display_isolated;
|
||||
};
|
||||
|
||||
CefContentRendererClient::CefContentRendererClient() {
|
||||
}
|
||||
|
||||
@@ -71,13 +79,38 @@ void CefContentRendererClient::OnBrowserDestroyed(CefBrowserImpl* browser) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefContentRendererClient::AddCustomScheme(
|
||||
const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
SchemeInfo info = {scheme_name, is_local, is_display_isolated};
|
||||
scheme_info_list_.push_back(info);
|
||||
}
|
||||
|
||||
void CefContentRendererClient::RegisterCustomSchemes() {
|
||||
if (scheme_info_list_.empty())
|
||||
return;
|
||||
|
||||
SchemeInfoList::const_iterator it = scheme_info_list_.begin();
|
||||
for (; it != scheme_info_list_.end(); ++it) {
|
||||
const SchemeInfo& info = *it;
|
||||
if (info.is_local) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(
|
||||
WebKit::WebString::fromUTF8(info.scheme_name));
|
||||
}
|
||||
if (info.is_display_isolated) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(
|
||||
WebKit::WebString::fromUTF8(info.scheme_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefContentRendererClient::RenderThreadStarted() {
|
||||
render_loop_ = base::MessageLoopProxy::current();
|
||||
observer_.reset(new CefRenderProcessObserver());
|
||||
|
||||
content::RenderThread* thread = content::RenderThread::Get();
|
||||
thread->AddObserver(observer_.get());
|
||||
thread->GetChannel()->AddFilter(new CefRenderMessageFilter);
|
||||
|
||||
thread->Send(new CefProcessHostMsg_RenderThreadStarted);
|
||||
|
||||
|
@@ -6,8 +6,8 @@
|
||||
#define CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
@@ -37,6 +37,14 @@ class CefContentRendererClient : public content::ContentRendererClient {
|
||||
// Called from CefBrowserImpl::OnDestruct().
|
||||
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
||||
|
||||
// Add a custom scheme registration.
|
||||
void AddCustomScheme(const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
// Register the custom schemes with WebKit.
|
||||
void RegisterCustomSchemes();
|
||||
|
||||
// Render thread message loop proxy.
|
||||
base::MessageLoopProxy* render_loop() const { return render_loop_.get(); }
|
||||
|
||||
@@ -110,6 +118,11 @@ class CefContentRendererClient : public content::ContentRendererClient {
|
||||
// Map of RenderView pointers to CefBrowserImpl references.
|
||||
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl> > BrowserMap;
|
||||
BrowserMap browsers_;
|
||||
|
||||
// Information about custom schemes that need to be registered with WebKit.
|
||||
struct SchemeInfo;
|
||||
typedef std::list<SchemeInfo> SchemeInfoList;
|
||||
SchemeInfoList scheme_info_list_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
||||
|
@@ -1,69 +0,0 @@
|
||||
/// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// 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_message_filter.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "googleurl/src/url_util.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
|
||||
CefRenderMessageFilter::CefRenderMessageFilter()
|
||||
: channel_(NULL) {
|
||||
}
|
||||
|
||||
CefRenderMessageFilter::~CefRenderMessageFilter() {
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::OnFilterAdded(IPC::Channel* channel) {
|
||||
channel_ = channel;
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::OnFilterRemoved() {
|
||||
}
|
||||
|
||||
bool CefRenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(CefRenderMessageFilter, message)
|
||||
IPC_MESSAGE_HANDLER(CefProcessMsg_RegisterScheme, OnRegisterScheme)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
return handled;
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::OnRegisterScheme(
|
||||
const std::string& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
if (is_standard) {
|
||||
// Make this registration as early as possible.
|
||||
url_parse::Component scheme_comp(0, scheme_name.length());
|
||||
if (!url_util::IsStandard(scheme_name.c_str(), scheme_comp))
|
||||
url_util::AddStandardScheme(scheme_name.c_str());
|
||||
}
|
||||
|
||||
CEF_POST_TASK_RT(
|
||||
base::Bind(&CefRenderMessageFilter::RegisterSchemeOnRenderThread, this,
|
||||
scheme_name, is_local, is_display_isolated));
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::RegisterSchemeOnRenderThread(
|
||||
const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
CEF_REQUIRE_RT();
|
||||
if (is_local) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(
|
||||
WebKit::WebString::fromUTF8(scheme_name));
|
||||
}
|
||||
if (is_display_isolated) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(
|
||||
WebKit::WebString::fromUTF8(scheme_name));
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (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.
|
||||
|
||||
#ifndef CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_
|
||||
#define CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_
|
||||
|
||||
#include <string>
|
||||
#include "ipc/ipc_channel_proxy.h"
|
||||
|
||||
// This class sends and receives control messages on the renderer process.
|
||||
class CefRenderMessageFilter : public IPC::ChannelProxy::MessageFilter {
|
||||
public:
|
||||
CefRenderMessageFilter();
|
||||
virtual ~CefRenderMessageFilter();
|
||||
|
||||
// IPC::ChannelProxy::MessageFilter implementation.
|
||||
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
|
||||
virtual void OnFilterRemoved() OVERRIDE;
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
|
||||
private:
|
||||
// Message handlers called on the IO thread.
|
||||
void OnRegisterScheme(const std::string& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
void RegisterSchemeOnRenderThread(const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
IPC::Channel* channel_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefRenderMessageFilter);
|
||||
};
|
||||
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_
|
@@ -6,6 +6,7 @@
|
||||
#include "libcef/renderer/render_process_observer.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/content_client.h"
|
||||
#include "libcef/renderer/content_renderer_client.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/path_service.h"
|
||||
@@ -49,6 +50,9 @@ void CefRenderProcessObserver::WebKitInitialized() {
|
||||
// TODO(cef): Enable these once the implementation supports it.
|
||||
WebKit::WebRuntimeFeatures::enableNotifications(false);
|
||||
|
||||
// Register any custom schemes with WebKit.
|
||||
CefContentRendererClient::Get()->RegisterCustomSchemes();
|
||||
|
||||
// Notify the render process handler.
|
||||
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
||||
if (application.get()) {
|
||||
|
@@ -2,10 +2,19 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
#include "third_party/WebKit/Source/WebCore/config.h"
|
||||
MSVC_PUSH_WARNING_LEVEL(0);
|
||||
#include "V8Proxy.h" // NOLINT(build/include)
|
||||
#include "V8RecursionScope.h" // NOLINT(build/include)
|
||||
MSVC_POP_WARNING();
|
||||
#undef LOG
|
||||
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
||||
#include "libcef/common/tracker.h"
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
@@ -16,7 +25,6 @@
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
static const char kCefTrackObject[] = "Cef::TrackObject";
|
||||
@@ -61,7 +69,7 @@ class V8TrackObject : public CefTrackNode {
|
||||
inline CefRefPtr<CefV8Accessor> GetAccessor() {
|
||||
return accessor_;
|
||||
}
|
||||
|
||||
|
||||
inline void SetHandler(CefRefPtr<CefV8Handler> handler) {
|
||||
handler_ = handler;
|
||||
}
|
||||
@@ -69,7 +77,7 @@ class V8TrackObject : public CefTrackNode {
|
||||
inline CefRefPtr<CefV8Handler> GetHandler() {
|
||||
return handler_;
|
||||
}
|
||||
|
||||
|
||||
inline void SetUserData(CefRefPtr<CefBase> user_data) {
|
||||
user_data_ = user_data;
|
||||
}
|
||||
@@ -530,16 +538,27 @@ bool CefV8ContextImpl::Eval(const CefString& code,
|
||||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(val);
|
||||
v8::Handle<v8::Value> code_val = GetV8String(code);
|
||||
|
||||
// Execute the eval function.
|
||||
v8::TryCatch try_catch;
|
||||
v8::Local<v8::Value> func_rv = func->Call(obj, 1, &code_val);
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> func_rv;
|
||||
|
||||
retval = NULL;
|
||||
exception = NULL;
|
||||
|
||||
// Execute the function call using the V8Proxy so that inspector
|
||||
// instrumentation works.
|
||||
WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve();
|
||||
DCHECK(proxy);
|
||||
if (proxy)
|
||||
func_rv = proxy->callFunction(func, obj, 1, &code_val);
|
||||
|
||||
if (try_catch.HasCaught()) {
|
||||
exception = new CefV8ExceptionImpl(try_catch.Message());
|
||||
return false;
|
||||
} else {
|
||||
} else if (!func_rv.IsEmpty()) {
|
||||
retval = new CefV8ValueImpl(func_rv);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Context> CefV8ContextImpl::GetContext() {
|
||||
@@ -952,6 +971,7 @@ bool CefV8ValueImpl::DeleteValue(const CefString& key) {
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool del = obj->Delete(GetV8String(key));
|
||||
return (!HasCaught(try_catch) && del);
|
||||
}
|
||||
@@ -969,6 +989,7 @@ bool CefV8ValueImpl::DeleteValue(int index) {
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool del = obj->Delete(index);
|
||||
return (!HasCaught(try_catch) && del);
|
||||
}
|
||||
@@ -986,6 +1007,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(const CefString& key) {
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> value = obj->Get(GetV8String(key));
|
||||
if (!HasCaught(try_catch) && !value.IsEmpty())
|
||||
return new CefV8ValueImpl(value);
|
||||
@@ -1005,6 +1027,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(int index) {
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> value = obj->Get(v8::Number::New(index));
|
||||
if (!HasCaught(try_catch) && !value.IsEmpty())
|
||||
return new CefV8ValueImpl(value);
|
||||
@@ -1021,8 +1044,9 @@ bool CefV8ValueImpl::SetValue(const CefString& key,
|
||||
if (impl && !key.empty()) {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->Set(GetV8String(key), impl->GetHandle(),
|
||||
static_cast<v8::PropertyAttribute>(attribute));
|
||||
return (!HasCaught(try_catch) && set);
|
||||
@@ -1045,8 +1069,9 @@ bool CefV8ValueImpl::SetValue(int index, CefRefPtr<CefV8Value> value) {
|
||||
if (impl) {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->Set(index, impl->GetHandle());
|
||||
return (!HasCaught(try_catch) && set);
|
||||
} else {
|
||||
@@ -1083,6 +1108,7 @@ bool CefV8ValueImpl::SetValue(const CefString& key, AccessControl settings,
|
||||
NULL : AccessorSetterCallbackImpl;
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->SetAccessor(GetV8String(key), getter, setter, obj,
|
||||
static_cast<v8::AccessControl>(settings),
|
||||
static_cast<v8::PropertyAttribute>(attribute));
|
||||
@@ -1250,10 +1276,21 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::ExecuteFunctionWithContext(
|
||||
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
v8::Local<v8::Value> func_rv = func->Call(recv, argc, argv);
|
||||
if (!HasCaught(try_catch))
|
||||
retval = new CefV8ValueImpl(func_rv);
|
||||
{
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> func_rv;
|
||||
|
||||
// Execute the function call using the V8Proxy so that inspector
|
||||
// instrumentation works.
|
||||
WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve();
|
||||
DCHECK(proxy);
|
||||
if (proxy)
|
||||
func_rv = proxy->callFunction(func, recv, argc, argv);
|
||||
|
||||
if (!HasCaught(try_catch) && !func_rv.IsEmpty())
|
||||
retval = new CefV8ValueImpl(func_rv);
|
||||
}
|
||||
|
||||
if (argv)
|
||||
delete [] argv;
|
||||
|
Reference in New Issue
Block a user