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:
@@ -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