Update to Chromium revision 187216.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1136 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-03-12 20:23:24 +00:00
parent 254cba733a
commit c3b02b7231
35 changed files with 368 additions and 233 deletions

View File

@ -17,5 +17,5 @@
{ {
'chromium_url': 'http://src.chromium.org/svn/trunk/src', 'chromium_url': 'http://src.chromium.org/svn/trunk/src',
'chromium_revision': '184577', 'chromium_revision': '187216',
} }

View File

@ -892,6 +892,7 @@
'libcef/browser/resource_request_job.cc', 'libcef/browser/resource_request_job.cc',
'libcef/browser/resource_request_job.h', 'libcef/browser/resource_request_job.h',
'libcef/browser/scheme_impl.cc', 'libcef/browser/scheme_impl.cc',
'libcef/browser/scheme_impl.h',
'libcef/browser/scheme_registration.cc', 'libcef/browser/scheme_registration.cc',
'libcef/browser/scheme_registration.h', 'libcef/browser/scheme_registration.h',
'libcef/browser/speech_recognition_manager_delegate.cc', 'libcef/browser/speech_recognition_manager_delegate.cc',

View File

@ -297,26 +297,12 @@ quota::SpecialStoragePolicy* CefBrowserContext::GetSpecialStoragePolicy() {
} }
net::URLRequestContextGetter* CefBrowserContext::CreateRequestContext( net::URLRequestContextGetter* CefBrowserContext::CreateRequestContext(
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers) {
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler) {
DCHECK(!url_request_getter_); DCHECK(!url_request_getter_);
// CEF doesn't use URLDataManager for serving chrome internal protocols.
// |chrome_protocol_handler| and |chrome_devtools_protocol_handler| are
// ignored so as not to conflict with CEF's protocol implementation.
url_request_getter_ = new CefURLRequestContextGetter( url_request_getter_ = new CefURLRequestContextGetter(
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
blob_protocol_handler.Pass(), protocol_handlers);
file_system_protocol_handler.Pass(),
developer_protocol_handler.Pass());
resource_context_->set_url_request_context_getter(url_request_getter_.get()); resource_context_->set_url_request_context_getter(url_request_getter_.get());
return url_request_getter_.get(); return url_request_getter_.get();
} }
@ -325,16 +311,7 @@ net::URLRequestContextGetter*
CefBrowserContext::CreateRequestContextForStoragePartition( CefBrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path, const base::FilePath& partition_path,
bool in_memory, bool in_memory,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers) {
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler) {
return NULL; return NULL;
} }

View File

@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "net/url_request/url_request_job_factory.h" #include "net/url_request/url_request_job_factory.h"
namespace content { namespace content {
@ -48,29 +49,11 @@ class CefBrowserContext : public content::BrowserContext {
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
net::URLRequestContextGetter* CreateRequestContext( net::URLRequestContextGetter* CreateRequestContext(
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers);
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler);
net::URLRequestContextGetter* CreateRequestContextForStoragePartition( net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
const base::FilePath& partition_path, const base::FilePath& partition_path,
bool in_memory, bool in_memory,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers);
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler);
// To disable window rendering call this function with |override|=true // To disable window rendering call this function with |override|=true
// just before calling WebContents::Create. This will cause // just before calling WebContents::Create. This will cause

View File

@ -1069,7 +1069,7 @@ gfx::NativeView CefBrowserHostImpl::GetContentView() const {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!web_contents_.get()) if (!web_contents_.get())
return NULL; return NULL;
return web_contents_->GetNativeView(); return web_contents_->GetView()->GetNativeView();
} }
content::WebContents* CefBrowserHostImpl::GetWebContents() const { content::WebContents* CefBrowserHostImpl::GetWebContents() const {
@ -1351,7 +1351,7 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
} }
if (web_contents_.get()) if (web_contents_.get())
web_contents_->Focus(); web_contents_->GetView()->Focus();
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::OnSetFocus, this, source)); base::Bind(&CefBrowserHostImpl::OnSetFocus, this, source));

View File

@ -16,7 +16,9 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "chrome/browser/net/proxy_service_factory.h" #include "chrome/browser/net/proxy_service_factory.h"
#include "content/browser/webui/content_web_ui_controller_factory.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
@ -51,6 +53,13 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
} }
} }
void CefBrowserMainParts::PostMainMessageLoopStart() {
// Don't use the default WebUI controller factory because is conflicts with
// CEF's internal handling of "chrome://tracing".
content::WebUIControllerFactory::UnregisterFactoryForTesting(
content::ContentWebUIControllerFactory::GetInstance());
}
int CefBrowserMainParts::PreCreateThreads() { int CefBrowserMainParts::PreCreateThreads() {
PlatformInitialize(); PlatformInitialize();
net::NetModule::SetResourceProvider(&ResourceProvider); net::NetModule::SetResourceProvider(&ResourceProvider);

View File

@ -38,6 +38,7 @@ class CefBrowserMainParts : public content::BrowserMainParts {
virtual ~CefBrowserMainParts(); virtual ~CefBrowserMainParts();
virtual void PreMainMessageLoopStart() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE;
virtual void PostMainMessageLoopStart() OVERRIDE;
virtual int PreCreateThreads() OVERRIDE; virtual int PreCreateThreads() OVERRIDE;
virtual void PreMainMessageLoopRun() OVERRIDE; virtual void PreMainMessageLoopRun() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE;

View File

@ -14,6 +14,7 @@
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/frame_host_impl.h" #include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/internal_scheme_handler.h" #include "libcef/browser/internal_scheme_handler.h"
#include "libcef/browser/scheme_impl.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "base/command_line.h" #include "base/command_line.h"
@ -24,15 +25,18 @@
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "content/browser/net/view_http_cache_job_factory.h"
#include "content/browser/net/view_blob_internals_job_factory.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "grit/cef_resources.h" #include "grit/cef_resources.h"
#include "ipc/ipc_channel.h" #include "ipc/ipc_channel.h"
#include "net/url_request/url_request.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "webkit/user_agent/user_agent_util.h" #include "webkit/user_agent/user_agent_util.h"
namespace scheme { namespace scheme {
const char kChromeScheme[] = "chrome";
const char kChromeURL[] = "chrome://"; const char kChromeURL[] = "chrome://";
const char kChromeProcessMessage[] = "chrome.send"; const char kChromeProcessMessage[] = "chrome.send";
@ -595,11 +599,46 @@ void OnChromeTracingProcessMessage(CefRefPtr<CefBrowser> browser,
} }
} }
// Wrapper for a ChromeProtocolHandler instance from
// content/browser/webui/url_data_manager_backend.cc.
class ChromeProtocolHandlerWrapper :
public net::URLRequestJobFactory::ProtocolHandler {
public:
explicit ChromeProtocolHandlerWrapper(
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> chrome_protocol_handler)
: chrome_protocol_handler_(chrome_protocol_handler.Pass()) {
}
virtual net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const OVERRIDE {
// Keep synchronized with the checks in ChromeProtocolHandler::MaybeCreateJob.
if (content::ViewHttpCacheJobFactory::IsSupportedURL(request->url()) ||
(request->url().SchemeIs(chrome::kChromeUIScheme) &&
request->url().host() == chrome::kChromeUIAppCacheInternalsHost) ||
content::ViewBlobInternalsJobFactory::IsSupportedURL(request->url()) ||
#if defined(USE_TCMALLOC)
(request->url().SchemeIs(chrome::kChromeUIScheme) &&
request->url().host() == chrome::kChromeUITcmallocHost) ||
#endif
(request->url().SchemeIs(chrome::kChromeUIScheme) &&
request->url().host() == chrome::kChromeUIHistogramHost)) {
return chrome_protocol_handler_->MaybeCreateJob(request, network_delegate);
}
// Use the protocol handler registered with CEF.
return scheme::GetRequestJob(request, network_delegate);
}
private:
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> chrome_protocol_handler_;
};
} // namespace } // namespace
void RegisterChromeHandler() { void RegisterChromeHandler() {
CefRegisterSchemeHandlerFactory( CefRegisterSchemeHandlerFactory(
kChromeScheme, chrome::kChromeUIScheme,
std::string(), std::string(),
CreateInternalHandlerFactory( CreateInternalHandlerFactory(
make_scoped_ptr<InternalHandlerDelegate>(new Delegate()))); make_scoped_ptr<InternalHandlerDelegate>(new Delegate())));
@ -650,4 +689,12 @@ void OnChromeProcessMessage(CefRefPtr<CefBrowser> browser,
} }
} }
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
WrapChromeProtocolHandler(
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler) {
return make_scoped_ptr(
new ChromeProtocolHandlerWrapper(chrome_protocol_handler.Pass()));
}
} // namespace scheme } // namespace scheme

View File

@ -7,10 +7,14 @@
#pragma once #pragma once
#include <string> #include <string>
#include "include/cef_browser.h" #include "include/cef_browser.h"
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "include/cef_process_message.h" #include "include/cef_process_message.h"
#include "base/memory/scoped_ptr.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/url_request/url_request_job_factory.h"
namespace base { namespace base {
class ListValue; class ListValue;
@ -22,7 +26,6 @@ class BrowserContext;
namespace scheme { namespace scheme {
extern const char kChromeScheme[];
extern const char kChromeURL[]; extern const char kChromeURL[];
extern const char kChromeProcessMessage[]; extern const char kChromeProcessMessage[];
@ -41,6 +44,13 @@ void DidFinishChromeLoad(CefRefPtr<CefFrame> frame,
void OnChromeProcessMessage(CefRefPtr<CefBrowser> browser, void OnChromeProcessMessage(CefRefPtr<CefBrowser> browser,
const base::ListValue& arguments); const base::ListValue& arguments);
// Create a new ProtocolHandler that will filter the URLs passed to the default
// "chrome" protocol handler and forward the rest to CEF's handler.
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
WrapChromeProtocolHandler(
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler);
} // namespace scheme } // namespace scheme
#endif // CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_ #endif // CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_

View File

@ -367,22 +367,10 @@ void CefContentBrowserClient::RenderProcessHostCreated(
net::URLRequestContextGetter* CefContentBrowserClient::CreateRequestContext( net::URLRequestContextGetter* CefContentBrowserClient::CreateRequestContext(
content::BrowserContext* content_browser_context, content::BrowserContext* content_browser_context,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers) {
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler) {
CefBrowserContext* cef_browser_context = CefBrowserContext* cef_browser_context =
CefBrowserContextForBrowserContext(content_browser_context); CefBrowserContextForBrowserContext(content_browser_context);
return cef_browser_context->CreateRequestContext( return cef_browser_context->CreateRequestContext(protocol_handlers);
blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
chrome_devtools_protocol_handler.Pass());
} }
net::URLRequestContextGetter* net::URLRequestContextGetter*
@ -390,23 +378,11 @@ CefContentBrowserClient::CreateRequestContextForStoragePartition(
content::BrowserContext* content_browser_context, content::BrowserContext* content_browser_context,
const base::FilePath& partition_path, const base::FilePath& partition_path,
bool in_memory, bool in_memory,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers) {
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler) {
CefBrowserContext* cef_browser_context = CefBrowserContext* cef_browser_context =
CefBrowserContextForBrowserContext(content_browser_context); CefBrowserContextForBrowserContext(content_browser_context);
return cef_browser_context->CreateRequestContextForStoragePartition( return cef_browser_context->CreateRequestContextForStoragePartition(
partition_path, in_memory, blob_protocol_handler.Pass(), partition_path, in_memory, protocol_handlers);
file_system_protocol_handler.Pass(),
developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
chrome_devtools_protocol_handler.Pass());
} }
void CefContentBrowserClient::AppendExtraCommandLineSwitches( void CefContentBrowserClient::AppendExtraCommandLineSwitches(

View File

@ -68,30 +68,12 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::RenderProcessHost* host) OVERRIDE; content::RenderProcessHost* host) OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContext( virtual net::URLRequestContextGetter* CreateRequestContext(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler) OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const base::FilePath& partition_path, const base::FilePath& partition_path,
bool in_memory, bool in_memory,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
chrome_devtools_protocol_handler) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) OVERRIDE; int child_process_id) OVERRIDE;
virtual content::QuotaPermissionContext* virtual content::QuotaPermissionContext*

View File

@ -25,6 +25,8 @@
#include "net/cookies/parsed_cookie.h" #include "net/cookies/parsed_cookie.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
using content::BrowserThread;
namespace { namespace {
// Callback class for visiting cookies. // Callback class for visiting cookies.
@ -286,9 +288,12 @@ bool CefCookieManagerImpl::SetStoragePath(
file_util::CreateDirectory(new_path)) { file_util::CreateDirectory(new_path)) {
const base::FilePath& cookie_path = new_path.AppendASCII("Cookies"); const base::FilePath& cookie_path = new_path.AppendASCII("Cookies");
persistent_store = persistent_store =
new SQLitePersistentCookieStore(cookie_path, new SQLitePersistentCookieStore(
persist_session_cookies, cookie_path,
NULL); BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
persist_session_cookies,
NULL);
} else { } else {
NOTREACHED() << "The cookie storage directory could not be created"; NOTREACHED() << "The cookie storage directory could not be created";
storage_path_.clear(); storage_path_.clear();

View File

@ -19,6 +19,7 @@
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "grit/cef_resources.h" #include "grit/cef_resources.h"
#include "net/base/tcp_listen_socket.h" #include "net/base/tcp_listen_socket.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
@ -175,7 +176,8 @@ std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
std::string page_id = binding_->GetIdentifier(rvh); std::string page_id = binding_->GetIdentifier(rvh);
std::string host = http_scheme ? std::string host = http_scheme ?
base::StringPrintf("http://localhost:%d/devtools/", port) : base::StringPrintf("http://localhost:%d/devtools/", port) :
scheme::kChromeDevToolsURL; base::StringPrintf("%s://%s/devtools/", chrome::kChromeDevToolsScheme,
scheme::kChromeDevToolsHost);
return base::StringPrintf( return base::StringPrintf(
"%sdevtools.html?ws=localhost:%d/devtools/page/%s", "%sdevtools.html?ws=localhost:%d/devtools/page/%s",

View File

@ -3,16 +3,18 @@
// be found in the LICENSE file. // be found in the LICENSE file.
#include "libcef/browser/devtools_scheme_handler.h" #include "libcef/browser/devtools_scheme_handler.h"
#include <string> #include <string>
#include "libcef/browser/internal_scheme_handler.h" #include "libcef/browser/internal_scheme_handler.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "content/public/common/url_constants.h"
#include "grit/devtools_resources_map.h" #include "grit/devtools_resources_map.h"
namespace scheme { namespace scheme {
const char kChromeDevToolsScheme[] = "chrome-devtools";
const char kChromeDevToolsHost[] = "devtools"; const char kChromeDevToolsHost[] = "devtools";
const char kChromeDevToolsURL[] = "chrome-devtools://devtools/";
namespace { namespace {
@ -43,7 +45,7 @@ class Delegate : public InternalHandlerDelegate {
void RegisterChromeDevToolsHandler() { void RegisterChromeDevToolsHandler() {
CefRegisterSchemeHandlerFactory( CefRegisterSchemeHandlerFactory(
kChromeDevToolsScheme, chrome::kChromeDevToolsScheme,
kChromeDevToolsHost, kChromeDevToolsHost,
CreateInternalHandlerFactory( CreateInternalHandlerFactory(
make_scoped_ptr<InternalHandlerDelegate>(new Delegate()))); make_scoped_ptr<InternalHandlerDelegate>(new Delegate())));

View File

@ -8,9 +8,7 @@
namespace scheme { namespace scheme {
extern const char kChromeDevToolsScheme[];
extern const char kChromeDevToolsHost[]; extern const char kChromeDevToolsHost[];
extern const char kChromeDevToolsURL[];
// Register the chrome-devtools scheme handler. // Register the chrome-devtools scheme handler.
void RegisterChromeDevToolsHandler(); void RegisterChromeDevToolsHandler();

View File

@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/prefs/pref_registry_syncable.h" #include "components/user_prefs/pref_registry_syncable.h"
// Required by PrefProxyConfigTrackerImpl::RegisterUserPrefs. // Required by PrefProxyConfigTrackerImpl::RegisterUserPrefs.
void PrefRegistrySyncable::RegisterDictionaryPref( void PrefRegistrySyncable::RegisterDictionaryPref(

View File

@ -376,10 +376,10 @@ void CefResourceRequestJob::AddCookieHeaderAndStart() {
void CefResourceRequestJob::DoLoadCookies() { void CefResourceRequestJob::DoLoadCookies() {
net::CookieOptions options; net::CookieOptions options;
options.set_include_httponly(); options.set_include_httponly();
request_->context()->cookie_store()->GetCookiesWithInfoAsync( request_->context()->cookie_store()->GetCookiesWithOptionsAsync(
request_->url(), options, request_->url(), options,
base::Bind(&CefResourceRequestJob::OnCookiesLoaded, base::Bind(&CefResourceRequestJob::OnCookiesLoaded,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void CefResourceRequestJob::CheckCookiePolicyAndLoad( void CefResourceRequestJob::CheckCookiePolicyAndLoad(
@ -403,9 +403,7 @@ void CefResourceRequestJob::CheckCookiePolicyAndLoad(
DoStartTransaction(); DoStartTransaction();
} }
void CefResourceRequestJob::OnCookiesLoaded( void CefResourceRequestJob::OnCookiesLoaded(const std::string& cookie_line) {
const std::string& cookie_line,
const std::vector<net::CookieStore::CookieInfo>& cookie_infos) {
if (!cookie_line.empty()) { if (!cookie_line.empty()) {
CefRequest::HeaderMap headerMap; CefRequest::HeaderMap headerMap;
cef_request_->GetHeaderMap(headerMap); cef_request_->GetHeaderMap(headerMap);

View File

@ -47,9 +47,7 @@ class CefResourceRequestJob : public net::URLRequestJob {
void AddCookieHeaderAndStart(); void AddCookieHeaderAndStart();
void DoLoadCookies(); void DoLoadCookies();
void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list); void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list);
void OnCookiesLoaded( void OnCookiesLoaded(const std::string& cookie_line);
const std::string& cookie_line,
const std::vector<net::CookieStore::CookieInfo>& cookie_infos);
void DoStartTransaction(); void DoStartTransaction();
void StartTransaction(); void StartTransaction();

View File

@ -124,11 +124,6 @@ class CefUrlRequestManager {
// Retrieve the singleton instance. // Retrieve the singleton instance.
static CefUrlRequestManager* GetInstance(); static CefUrlRequestManager* GetInstance();
net::URLRequestJobFactoryImpl* GetJobFactoryImpl() {
return static_cast<CefURLRequestContextGetter*>(
_Context->request_context().get())->job_factory_impl();
}
bool AddFactory(const std::string& scheme, bool AddFactory(const std::string& scheme,
const std::string& domain, const std::string& domain,
CefRefPtr<CefSchemeHandlerFactory> factory) { CefRefPtr<CefSchemeHandlerFactory> factory) {
@ -146,11 +141,9 @@ class CefUrlRequestManager {
if (!IsStandardScheme(scheme_lower)) if (!IsStandardScheme(scheme_lower))
domain_lower.clear(); domain_lower.clear();
handler_map_[make_pair(scheme_lower, domain_lower)] = factory; SetProtocolHandlerIfNecessary(scheme_lower, true);
net::URLRequestJobFactoryImpl* job_factory = GetJobFactoryImpl(); handler_map_[make_pair(scheme_lower, domain_lower)] = factory;
job_factory->SetProtocolHandler(scheme_lower,
new ProtocolHandler(scheme_lower));
return true; return true;
} }
@ -168,8 +161,11 @@ class CefUrlRequestManager {
HandlerMap::iterator iter = HandlerMap::iterator iter =
handler_map_.find(make_pair(scheme_lower, domain_lower)); handler_map_.find(make_pair(scheme_lower, domain_lower));
if (iter != handler_map_.end()) if (iter != handler_map_.end()) {
handler_map_.erase(iter); handler_map_.erase(iter);
SetProtocolHandlerIfNecessary(scheme_lower, false);
}
} }
// Clear all the existing URL handlers and unregister the ProtocolFactory. // Clear all the existing URL handlers and unregister the ProtocolFactory.
@ -178,21 +174,68 @@ class CefUrlRequestManager {
net::URLRequestJobFactoryImpl* job_factory = GetJobFactoryImpl(); net::URLRequestJobFactoryImpl* job_factory = GetJobFactoryImpl();
// Unregister with the ProtocolFactory. // Create a unique set of scheme names.
std::set<std::string> schemes; std::set<std::string> schemes;
for (HandlerMap::const_iterator i = handler_map_.begin(); for (HandlerMap::const_iterator i = handler_map_.begin();
i != handler_map_.end(); ++i) { i != handler_map_.end(); ++i) {
schemes.insert(i->first.first); schemes.insert(i->first.first);
} }
for (std::set<std::string>::const_iterator scheme = schemes.begin(); for (std::set<std::string>::const_iterator scheme = schemes.begin();
scheme != schemes.end(); ++scheme) { scheme != schemes.end(); ++scheme) {
job_factory->SetProtocolHandler(*scheme, NULL); const std::string& scheme_name = *scheme;
if (!scheme::IsInternalProtectedScheme(scheme_name)) {
bool set_protocol = job_factory->SetProtocolHandler(scheme_name, NULL);
DCHECK(set_protocol);
}
} }
handler_map_.clear(); handler_map_.clear();
} }
// Helper for chaining ProtocolHandler implementations.
net::URLRequestJob* GetRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate) {
CEF_REQUIRE_IOT();
return GetRequestJob(request, network_delegate, request->url().scheme());
}
private: private:
net::URLRequestJobFactoryImpl* GetJobFactoryImpl() {
return static_cast<CefURLRequestContextGetter*>(
_Context->request_context().get())->job_factory_impl();
}
// Add or remove the protocol handler if necessary. |scheme| will already be
// in lower case.
void SetProtocolHandlerIfNecessary(const std::string& scheme, bool add) {
// Don't modify a protocol handler for internal protected schemes or if the
// protocol handler is still needed by other registered factories.
if (scheme::IsInternalProtectedScheme(scheme) || HasFactory(scheme))
return;
net::URLRequestJobFactoryImpl* job_factory = GetJobFactoryImpl();
bool set_protocol = job_factory->SetProtocolHandler(
scheme,
(add ? new ProtocolHandler(scheme) : NULL));
DCHECK(set_protocol);
}
// Returns true if any factory currently exists for |scheme|. |scheme| will
// already be in lower case.
bool HasFactory(const std::string& scheme) {
if (handler_map_.empty())
return false;
for (HandlerMap::const_iterator i = handler_map_.begin();
i != handler_map_.end(); ++i) {
if (scheme == i->first.first)
return true;
}
return false;
}
// Retrieve the matching handler factory, if any. |scheme| will already be in // Retrieve the matching handler factory, if any. |scheme| will already be in
// lower case. // lower case.
CefRefPtr<CefSchemeHandlerFactory> GetHandlerFactory( CefRefPtr<CefSchemeHandlerFactory> GetHandlerFactory(
@ -313,3 +356,13 @@ bool CefClearSchemeHandlerFactories() {
return true; return true;
} }
namespace scheme {
net::URLRequestJob* GetRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate) {
return CefUrlRequestManager::GetInstance()->GetRequestJob(
request, network_delegate);
}
} // namespace scheme

View File

@ -0,0 +1,24 @@
// Copyright (c) 2013 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_
#pragma once
namespace net {
class NetworkDelegate;
class URLRequest;
class URLRequestJob;
}
namespace scheme {
// Helper for chaining net::URLRequestJobFactory::ProtocolHandler
// implementations.
net::URLRequestJob* GetRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_

View File

@ -7,16 +7,19 @@
#include "libcef/browser/devtools_scheme_handler.h" #include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/renderer/content_renderer_client.h" #include "libcef/renderer/content_renderer_client.h"
#include "content/public/common/url_constants.h"
#include "net/url_request/url_request_job_factory_impl.h"
namespace scheme { namespace scheme {
void AddStandardSchemes(std::vector<std::string>* standard_schemes) { void AddInternalStandardSchemes(std::vector<std::string>* standard_schemes) {
static struct { static struct {
const char* name; const char* name;
bool is_local; bool is_local;
bool is_display_isolated; bool is_display_isolated;
} schemes[] = { } schemes[] = {
{ scheme::kChromeScheme, true, true }, { chrome::kChromeUIScheme, true, true },
{ scheme::kChromeDevToolsScheme, true, false } { chrome::kChromeDevToolsScheme, true, false }
}; };
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i)
@ -31,13 +34,64 @@ void AddStandardSchemes(std::vector<std::string>* standard_schemes) {
} }
} }
bool IsInternalProtectedScheme(const std::string& scheme) {
// These values originate from StoragePartitionImplMap::Get() in
// content/browser/storage_partition_impl_map.cc and are modified by
// InstallInternalHandlers().
static const char* schemes[] = {
chrome::kBlobScheme,
chrome::kChromeUIScheme,
chrome::kFileSystemScheme,
};
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) {
if (scheme == schemes[i])
return true;
}
return false;
}
void InstallInternalProtectedHandlers(
net::URLRequestJobFactoryImpl* job_factory,
content::ProtocolHandlerMap* protocol_handlers) {
for (content::ProtocolHandlerMap::iterator it =
protocol_handlers->begin();
it != protocol_handlers->end();
++it) {
const std::string& scheme = it->first;
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> protocol_handler;
if (scheme == chrome::kChromeDevToolsScheme) {
// Don't use the default "chrome-devtools" handler.
continue;
} else if (scheme == chrome::kChromeUIScheme) {
// Filter the URLs that are passed to the default "chrome" handler so as
// not to interfere with CEF's "chrome" handler.
protocol_handler.reset(
scheme::WrapChromeProtocolHandler(
make_scoped_ptr(it->second.release())).release());
} else {
protocol_handler.reset(it->second.release());
}
// Make sure IsInternalScheme() stays synchronized with what Chromium is
// actually giving us.
DCHECK(IsInternalProtectedScheme(scheme));
bool set_protocol = job_factory->SetProtocolHandler(
scheme, protocol_handler.release());
DCHECK(set_protocol);
}
}
void RegisterInternalHandlers() { void RegisterInternalHandlers() {
scheme::RegisterChromeHandler(); scheme::RegisterChromeHandler();
scheme::RegisterChromeDevToolsHandler(); scheme::RegisterChromeDevToolsHandler();
} }
void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url) { void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url) {
if (validated_url.scheme() == scheme::kChromeScheme) if (validated_url.scheme() == chrome::kChromeUIScheme)
scheme::DidFinishChromeLoad(frame, validated_url); scheme::DidFinishChromeLoad(frame, validated_url);
} }

View File

@ -2,21 +2,41 @@
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_ #ifndef CEF_LIBCEF_BROWSER_SCHEME_REGISTRATION_H_
#define CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_ #define CEF_LIBCEF_BROWSER_SCHEME_REGISTRATION_H_
#pragma once #pragma once
#include <string> #include <string>
#include <vector> #include <vector>
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "content/public/browser/content_browser_client.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
namespace net {
class URLRequestJobFactoryImpl;
}
namespace scheme { namespace scheme {
// Add all standard schemes. // Add internal standard schemes.
void AddStandardSchemes(std::vector<std::string>* standard_schemes); void AddInternalStandardSchemes(std::vector<std::string>* standard_schemes);
// Register all internal scheme handlers. // Returns true if the specified |scheme| is handled internally and should not
// be explicitly registered or unregistered with the URLRequestJobFactory. A
// registered handler for one of these schemes (like "chrome") may still be
// triggered via chaining from an existing ProtocolHandler. |scheme| should
// always be a lower-case string.
bool IsInternalProtectedScheme(const std::string& scheme);
// Install the internal scheme handlers provided by Chromium that cannot be
// overridden.
void InstallInternalProtectedHandlers(
net::URLRequestJobFactoryImpl* job_factory,
content::ProtocolHandlerMap* protocol_handlers);
// Register the internal scheme handlers that can be overridden.
void RegisterInternalHandlers(); void RegisterInternalHandlers();
// Used to fire any asynchronous content updates. // Used to fire any asynchronous content updates.
@ -24,4 +44,4 @@ void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url);
} // namespace scheme } // namespace scheme
#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_ #endif // CEF_LIBCEF_BROWSER_SCHEME_REGISTRATION_H_

View File

@ -11,6 +11,7 @@
#include <vector> #include <vector>
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/browser/url_network_delegate.h" #include "libcef/browser/url_network_delegate.h"
#include "libcef/browser/url_request_context_proxy.h" #include "libcef/browser/url_request_context_proxy.h"
@ -21,7 +22,6 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/string_split.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/threading/worker_pool.h" #include "base/threading/worker_pool.h"
@ -41,7 +41,6 @@
#include "net/http/http_cache.h" #include "net/http/http_cache.h"
#include "net/http/http_server_properties_impl.h" #include "net/http/http_server_properties_impl.h"
#include "net/proxy/proxy_service.h" #include "net/proxy/proxy_service.h"
#include "net/url_request/protocol_intercept_job_factory.h"
#include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
@ -58,19 +57,13 @@ using content::BrowserThread;
CefURLRequestContextGetter::CefURLRequestContextGetter( CefURLRequestContextGetter::CefURLRequestContextGetter(
MessageLoop* io_loop, MessageLoop* io_loop,
MessageLoop* file_loop, MessageLoop* file_loop,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers)
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler)
: io_loop_(io_loop), : io_loop_(io_loop),
file_loop_(file_loop), file_loop_(file_loop) {
blob_protocol_handler_(blob_protocol_handler.Pass()),
file_system_protocol_handler_(file_system_protocol_handler.Pass()),
developer_protocol_handler_(developer_protocol_handler.Pass()) {
// Must first be created on the UI thread. // Must first be created on the UI thread.
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
std::swap(protocol_handlers_, *protocol_handlers);
} }
CefURLRequestContextGetter::~CefURLRequestContextGetter() { CefURLRequestContextGetter::~CefURLRequestContextGetter() {
@ -176,15 +169,12 @@ net::URLRequestContext* CefURLRequestContextGetter::GetURLRequestContext() {
scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
new net::URLRequestJobFactoryImpl()); new net::URLRequestJobFactoryImpl());
job_factory_impl_ = job_factory.get(); job_factory_impl_ = job_factory.get();
bool set_protocol = job_factory->SetProtocolHandler(
chrome::kBlobScheme, blob_protocol_handler_.release()); scheme::InstallInternalProtectedHandlers(job_factory.get(),
DCHECK(set_protocol); &protocol_handlers_);
set_protocol = job_factory->SetProtocolHandler( protocol_handlers_.clear();
chrome::kFileSystemScheme, file_system_protocol_handler_.release());
DCHECK(set_protocol); storage_->set_job_factory(job_factory.release());
storage_->set_job_factory(new net::ProtocolInterceptJobFactory(
job_factory.PassAs<net::URLRequestJobFactory>(),
developer_protocol_handler_.Pass()));
request_interceptor_.reset(new CefRequestInterceptor); request_interceptor_.reset(new CefRequestInterceptor);
} }
@ -222,9 +212,12 @@ void CefURLRequestContextGetter::SetCookieStoragePath(
file_util::CreateDirectory(path)) { file_util::CreateDirectory(path)) {
const base::FilePath& cookie_path = path.AppendASCII("Cookies"); const base::FilePath& cookie_path = path.AppendASCII("Cookies");
persistent_store = persistent_store =
new SQLitePersistentCookieStore(cookie_path, new SQLitePersistentCookieStore(
persist_session_cookies, cookie_path,
NULL); BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
persist_session_cookies,
NULL);
} else { } else {
NOTREACHED() << "The cookie storage directory could not be created"; NOTREACHED() << "The cookie storage directory could not be created";
} }

View File

@ -14,6 +14,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "content/public/browser/content_browser_client.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_job_factory.h" #include "net/url_request/url_request_job_factory.h"
@ -76,12 +77,7 @@ class CefURLRequestContextGetter : public net::URLRequestContextGetter {
CefURLRequestContextGetter( CefURLRequestContextGetter(
MessageLoop* io_loop, MessageLoop* io_loop,
MessageLoop* file_loop, MessageLoop* file_loop,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap* protocol_handlers);
blob_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler);
virtual ~CefURLRequestContextGetter(); virtual ~CefURLRequestContextGetter();
// net::URLRequestContextGetter implementation. // net::URLRequestContextGetter implementation.
@ -115,12 +111,7 @@ class CefURLRequestContextGetter : public net::URLRequestContextGetter {
scoped_ptr<net::URLRequestContextStorage> storage_; scoped_ptr<net::URLRequestContextStorage> storage_;
scoped_ptr<net::URLRequestContext> url_request_context_; scoped_ptr<net::URLRequestContext> url_request_context_;
scoped_ptr<net::URLSecurityManager> url_security_manager_; scoped_ptr<net::URLSecurityManager> url_security_manager_;
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> content::ProtocolHandlerMap protocol_handlers_;
blob_protocol_handler_;
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler_;
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
developer_protocol_handler_;
net::URLRequestJobFactoryImpl* job_factory_impl_; net::URLRequestJobFactoryImpl* job_factory_impl_;
typedef std::set<CefURLRequestContextProxy*> RequestContextProxySet; typedef std::set<CefURLRequestContextProxy*> RequestContextProxySet;

View File

@ -46,14 +46,6 @@ class CefCookieStoreProxy : public net::CookieStore {
cookie_store->GetCookiesWithOptionsAsync(url, options, callback); cookie_store->GetCookiesWithOptionsAsync(url, options, callback);
} }
void GetCookiesWithInfoAsync(
const GURL& url,
const net::CookieOptions& options,
const GetCookieInfoCallback& callback) OVERRIDE {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
cookie_store->GetCookiesWithInfoAsync(url, options, callback);
}
virtual void DeleteCookieAsync(const GURL& url, virtual void DeleteCookieAsync(const GURL& url,
const std::string& cookie_name, const std::string& cookie_name,
const base::Closure& callback) OVERRIDE { const base::Closure& callback) OVERRIDE {

View File

@ -53,7 +53,7 @@ void CefContentClient::AddAdditionalSchemes(
DCHECK(schemeRegistrar->VerifyRefCount()); DCHECK(schemeRegistrar->VerifyRefCount());
} }
scheme::AddStandardSchemes(standard_schemes); scheme::AddInternalStandardSchemes(standard_schemes);
} }
std::string CefContentClient::GetUserAgent() const { std::string CefContentClient::GetUserAgent() const {

View File

@ -227,9 +227,8 @@ bool CefDictionaryValueImpl::HasKey(const CefString& key) {
bool CefDictionaryValueImpl::GetKeys(KeyList& keys) { bool CefDictionaryValueImpl::GetKeys(KeyList& keys) {
CEF_VALUE_VERIFY_RETURN(false, 0); CEF_VALUE_VERIFY_RETURN(false, 0);
base::DictionaryValue::key_iterator it = const_value().begin_keys(); for (DictionaryValue::Iterator i(const_value()); !i.IsAtEnd(); i.Advance())
for (; it != const_value().end_keys(); ++it) keys.push_back(i.key());
keys.push_back(*it);
return true; return true;
} }

View File

@ -4,9 +4,12 @@
#include "libcef/renderer/chrome_bindings.h" #include "libcef/renderer/chrome_bindings.h"
#include "libcef/renderer/browser_impl.h" #include "libcef/renderer/browser_impl.h"
#include <string> #include <string>
#include "base/logging.h" #include "base/logging.h"
#include "base/values.h" #include "base/values.h"
#include "content/public/common/url_constants.h"
namespace scheme { namespace scheme {
@ -93,7 +96,7 @@ void OnContextCreated(CefRefPtr<CefBrowserImpl> browser,
CefRefPtr<CefFrameImpl> frame, CefRefPtr<CefFrameImpl> frame,
CefRefPtr<CefV8Context> context) { CefRefPtr<CefV8Context> context) {
GURL url = GURL(frame->GetURL().ToString()); GURL url = GURL(frame->GetURL().ToString());
if (url.scheme() != kChromeScheme) if (url.scheme() != chrome::kChromeUIScheme)
return; return;
CefRefPtr<CefV8Value> global = context->GetGlobal(); CefRefPtr<CefV8Value> global = context->GetGlobal();

View File

@ -12,7 +12,6 @@
namespace scheme { namespace scheme {
extern const char kChromeScheme[];
extern const char kChromeProcessMessage[]; extern const char kChromeProcessMessage[];
void OnContextCreated(CefRefPtr<CefBrowserImpl> browser, void OnContextCreated(CefRefPtr<CefBrowserImpl> browser,

View File

@ -40,13 +40,13 @@ MSVC_POP_WARNING();
#include "third_party/WebKit/Source/Platform/chromium/public/WebPrerenderingSupport.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebPrerenderingSupport.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebWorkerRunLoop.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPrerendererClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrerendererClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerRunLoop.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerScriptObserver.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerScriptObserver.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "webkit/glue/worker_task_runner.h" #include "webkit/glue/worker_task_runner.h"

View File

@ -79,6 +79,7 @@ class CefV8IsolateManager {
scoped_refptr<CefV8ContextState> GetContextState( scoped_refptr<CefV8ContextState> GetContextState(
v8::Handle<v8::Context> context) { v8::Handle<v8::Context> context) {
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
DCHECK(context.IsEmpty() || isolate_ == context->GetIsolate());
if (context_safety_impl_ == IMPL_DISABLED) if (context_safety_impl_ == IMPL_DISABLED)
return scoped_refptr<CefV8ContextState>(); return scoped_refptr<CefV8ContextState>();
@ -103,7 +104,9 @@ class CefV8IsolateManager {
} else { } else {
if (context_state_key_.IsEmpty()) { if (context_state_key_.IsEmpty()) {
context_state_key_ = context_state_key_ =
v8::Persistent<v8::String>::New(v8::String::New(kCefContextState)); v8::Persistent<v8::String>::New(
isolate_,
v8::String::New(kCefContextState));
} }
v8::Handle<v8::Object> object = context->Global(); v8::Handle<v8::Object> object = context->Global();
@ -184,6 +187,7 @@ class CefV8IsolateManager {
worker_url_ = worker_url; worker_url_ = worker_url;
} }
v8::Isolate* isolate() const { return isolate_; }
scoped_refptr<base::SequencedTaskRunner> task_runner() const { scoped_refptr<base::SequencedTaskRunner> task_runner() const {
return task_runner_; return task_runner_;
} }
@ -397,11 +401,13 @@ class CefV8MakeWeakParam {
}; };
// Callback for weak persistent reference destruction. // Callback for weak persistent reference destruction.
void TrackDestructor(v8::Persistent<v8::Value> object, void* parameter) { void TrackDestructor(v8::Isolate* isolate,
v8::Persistent<v8::Value> object,
void* parameter) {
if (parameter) if (parameter)
delete static_cast<CefV8MakeWeakParam*>(parameter); delete static_cast<CefV8MakeWeakParam*>(parameter);
object.Dispose(); object.Dispose(isolate);
object.Clear(); object.Clear();
} }
@ -817,6 +823,8 @@ bool CefV8HandleBase::BelongsToCurrentThread() const {
CefV8HandleBase::CefV8HandleBase(v8::Handle<v8::Context> context) { CefV8HandleBase::CefV8HandleBase(v8::Handle<v8::Context> context) {
CefV8IsolateManager* manager = GetIsolateManager(); CefV8IsolateManager* manager = GetIsolateManager();
DCHECK(manager); DCHECK(manager);
isolate_ = manager->isolate();
task_runner_ = manager->task_runner(); task_runner_ = manager->task_runner();
context_state_ = manager->GetContextState(context); context_state_ = manager->GetContextState(context);
} }
@ -1011,17 +1019,17 @@ WebKit::WebFrame* CefV8ContextImpl::GetWebFrame() {
// CefV8ValueImpl::Handle // CefV8ValueImpl::Handle
CefV8ValueImpl::Handle::~Handle() { CefV8ValueImpl::Handle::~Handle() {
// Persist the |tracker_| object (call MakeWeak) if: // Persist the handle (call MakeWeak) if:
// A. The value represents an Object or Function, and // A. The handle has been passed into a V8 function or used as a return value
// B. The handle has been passed into a V8 function or used as a return value
// from a V8 callback, and // from a V8 callback, and
// C. The associated context, if any, is still valid. // B. The associated context, if any, is still valid.
if (tracker_ && tracker_should_persist_ && if (should_persist_ && (!context_state_.get() || context_state_->IsValid())) {
(!context_state_.get() || context_state_->IsValid())) { handle_.MakeWeak(
handle_.MakeWeak(new CefV8MakeWeakParam(context_state_, tracker_), isolate(),
TrackDestructor); (tracker_ ? new CefV8MakeWeakParam(context_state_, tracker_) : NULL),
TrackDestructor);
} else { } else {
handle_.Dispose(); handle_.Dispose(isolate());
handle_.Clear(); handle_.Clear();
if (tracker_) if (tracker_)

View File

@ -102,6 +102,7 @@ class CefV8HandleBase :
bool BelongsToCurrentThread() const; bool BelongsToCurrentThread() const;
v8::Isolate* isolate() const { return isolate_; }
scoped_refptr<base::SequencedTaskRunner> task_runner() const { scoped_refptr<base::SequencedTaskRunner> task_runner() const {
return task_runner_; return task_runner_;
} }
@ -112,6 +113,7 @@ class CefV8HandleBase :
explicit CefV8HandleBase(v8::Handle<v8::Context> context); explicit CefV8HandleBase(v8::Handle<v8::Context> context);
protected: protected:
v8::Isolate* isolate_;
scoped_refptr<base::SequencedTaskRunner> task_runner_; scoped_refptr<base::SequencedTaskRunner> task_runner_;
scoped_refptr<CefV8ContextState> context_state_; scoped_refptr<CefV8ContextState> context_state_;
}; };
@ -126,10 +128,10 @@ class CefV8Handle : public CefV8HandleBase {
CefV8Handle(v8::Handle<v8::Context> context, handleType v) CefV8Handle(v8::Handle<v8::Context> context, handleType v)
: CefV8HandleBase(context), : CefV8HandleBase(context),
handle_(persistentType::New(v)) { handle_(persistentType::New(isolate(), v)) {
} }
virtual ~CefV8Handle() { virtual ~CefV8Handle() {
handle_.Dispose(); handle_.Dispose(isolate());
handle_.Clear(); handle_.Clear();
} }
@ -258,16 +260,16 @@ class CefV8ValueImpl : public CefV8Value {
Handle(v8::Handle<v8::Context> context, handleType v, CefTrackNode* tracker) Handle(v8::Handle<v8::Context> context, handleType v, CefTrackNode* tracker)
: CefV8HandleBase(context), : CefV8HandleBase(context),
handle_(persistentType::New(v)), handle_(persistentType::New(isolate(), v)),
tracker_(tracker), tracker_(tracker),
tracker_should_persist_(false) { should_persist_(false) {
} }
virtual ~Handle(); virtual ~Handle();
handleType GetHandle(bool should_persist) { handleType GetHandle(bool should_persist) {
DCHECK(IsValid()); DCHECK(IsValid());
if (should_persist && tracker_ && !tracker_should_persist_) if (should_persist && !should_persist_)
tracker_should_persist_ = true; should_persist_ = true;
return handle_; return handle_;
} }
@ -278,9 +280,8 @@ class CefV8ValueImpl : public CefV8Value {
// internal data or function handler objects that are reference counted. // internal data or function handler objects that are reference counted.
CefTrackNode* tracker_; CefTrackNode* tracker_;
// True if the |tracker_| object needs to persist due to an Object or // True if the handle needs to persist due to it being passed into V8.
// Function type being passed into V8. bool should_persist_;
bool tracker_should_persist_;
DISALLOW_COPY_AND_ASSIGN(Handle); DISALLOW_COPY_AND_ASSIGN(Handle);
}; };

View File

@ -61,9 +61,9 @@ Added: svn:eol-style
Index: WebCore/bindings/v8/WorkerScriptController.cpp Index: WebCore/bindings/v8/WorkerScriptController.cpp
=================================================================== ===================================================================
--- WebCore/bindings/v8/WorkerScriptController.cpp (revision 142426) --- WebCore/bindings/v8/WorkerScriptController.cpp (revision 145278)
+++ WebCore/bindings/v8/WorkerScriptController.cpp (working copy) +++ WebCore/bindings/v8/WorkerScriptController.cpp (working copy)
@@ -50,11 +50,23 @@ @@ -51,11 +51,23 @@
#if PLATFORM(CHROMIUM) #if PLATFORM(CHROMIUM)
#include <public/Platform.h> #include <public/Platform.h>
@ -87,7 +87,7 @@ Index: WebCore/bindings/v8/WorkerScriptController.cpp
WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
: m_workerContext(workerContext) : m_workerContext(workerContext)
, m_isolate(v8::Isolate::New()) , m_isolate(v8::Isolate::New())
@@ -72,6 +84,8 @@ @@ -73,6 +85,8 @@
WorkerScriptController::~WorkerScriptController() WorkerScriptController::~WorkerScriptController()
{ {
m_domDataStore.clear(); m_domDataStore.clear();
@ -96,7 +96,7 @@ Index: WebCore/bindings/v8/WorkerScriptController.cpp
#if PLATFORM(CHROMIUM) #if PLATFORM(CHROMIUM)
// The corresponding call to didStartWorkerRunLoop is in // The corresponding call to didStartWorkerRunLoop is in
// WorkerThread::workerThread(). // WorkerThread::workerThread().
@@ -133,6 +147,8 @@ @@ -134,6 +148,8 @@
v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype()); v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype());
globalObject->SetPrototype(jsWorkerContext); globalObject->SetPrototype(jsWorkerContext);
@ -105,7 +105,7 @@ Index: WebCore/bindings/v8/WorkerScriptController.cpp
return true; return true;
} }
@@ -257,6 +273,39 @@ @@ -258,6 +274,39 @@
return workerContext->script(); return workerContext->script();
} }
@ -147,7 +147,7 @@ Index: WebCore/bindings/v8/WorkerScriptController.cpp
#endif // ENABLE(WORKERS) #endif // ENABLE(WORKERS)
Index: WebCore/bindings/v8/WorkerScriptController.h Index: WebCore/bindings/v8/WorkerScriptController.h
=================================================================== ===================================================================
--- WebCore/bindings/v8/WorkerScriptController.h (revision 142426) --- WebCore/bindings/v8/WorkerScriptController.h (revision 145278)
+++ WebCore/bindings/v8/WorkerScriptController.h (working copy) +++ WebCore/bindings/v8/WorkerScriptController.h (working copy)
@@ -40,6 +40,10 @@ @@ -40,6 +40,10 @@
#include <wtf/Threading.h> #include <wtf/Threading.h>
@ -180,7 +180,7 @@ Index: WebCore/bindings/v8/WorkerScriptController.h
ScopedPersistent<v8::Context> m_context; ScopedPersistent<v8::Context> m_context;
Index: WebKit/chromium/public/WebWorkerInfo.h Index: WebKit/chromium/public/WebWorkerInfo.h
=================================================================== ===================================================================
--- WebKit/chromium/public/WebWorkerInfo.h (revision 142426) --- WebKit/chromium/public/WebWorkerInfo.h (revision 145278)
+++ WebKit/chromium/public/WebWorkerInfo.h (working copy) +++ WebKit/chromium/public/WebWorkerInfo.h (working copy)
@@ -35,9 +35,15 @@ @@ -35,9 +35,15 @@
@ -236,7 +236,7 @@ Added: svn:eol-style
Index: WebKit/chromium/src/WebWorkerInfo.cpp Index: WebKit/chromium/src/WebWorkerInfo.cpp
=================================================================== ===================================================================
--- WebKit/chromium/src/WebWorkerInfo.cpp (revision 142426) --- WebKit/chromium/src/WebWorkerInfo.cpp (revision 145278)
+++ WebKit/chromium/src/WebWorkerInfo.cpp (working copy) +++ WebKit/chromium/src/WebWorkerInfo.cpp (working copy)
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include "config.h" #include "config.h"

View File

@ -1,8 +1,8 @@
Index: features.gypi Index: features.gypi
=================================================================== ===================================================================
--- features.gypi (revision 143980) --- features.gypi (revision 145278)
+++ features.gypi (working copy) +++ features.gypi (working copy)
@@ -190,7 +190,7 @@ @@ -193,7 +193,7 @@
'ENABLE_CALENDAR_PICKER=1', 'ENABLE_CALENDAR_PICKER=1',
'ENABLE_DATALIST_ELEMENT=1', 'ENABLE_DATALIST_ELEMENT=1',
'ENABLE_INPUT_SPEECH=1', 'ENABLE_INPUT_SPEECH=1',
@ -11,7 +11,7 @@ Index: features.gypi
'ENABLE_INPUT_TYPE_WEEK=1', 'ENABLE_INPUT_TYPE_WEEK=1',
'ENABLE_INPUT_MULTIPLE_FIELDS_UI=1', 'ENABLE_INPUT_MULTIPLE_FIELDS_UI=1',
'ENABLE_LEGACY_NOTIFICATIONS=1', 'ENABLE_LEGACY_NOTIFICATIONS=1',
@@ -199,7 +199,7 @@ @@ -202,7 +202,7 @@
'ENABLE_NOTIFICATIONS=1', 'ENABLE_NOTIFICATIONS=1',
'ENABLE_ORIENTATION_EVENTS=0', 'ENABLE_ORIENTATION_EVENTS=0',
'ENABLE_PAGE_POPUP=1', 'ENABLE_PAGE_POPUP=1',

View File

@ -31,6 +31,7 @@ const char kV8WorkerParentTestUrl[] = "http://tests/V8Test.WorkerParent";
const char kV8WorkerTestUrl[] = "http://tests/V8Test.Worker.js"; const char kV8WorkerTestUrl[] = "http://tests/V8Test.Worker.js";
const char kV8TestMsg[] = "V8Test.Test"; const char kV8TestMsg[] = "V8Test.Test";
const char kV8TestCmdArg[] = "v8-test"; const char kV8TestCmdArg[] = "v8-test";
const char kV8RunTestMsg[] = "V8Test.RunTest";
const char kV8DevToolsURLMsg[] = "V8Test.DevToolsURL"; const char kV8DevToolsURLMsg[] = "V8Test.DevToolsURL";
const char kV8DevToolsLoadHookMsg[] = "V8Test.DevToolsLoadHook"; const char kV8DevToolsLoadHookMsg[] = "V8Test.DevToolsLoadHook";
@ -1585,7 +1586,7 @@ class V8RendererTest : public ClientApp::RenderDelegate {
test_context_ = test_context_ =
browser_->GetMainFrame()->GetV8Context(); browser_->GetMainFrame()->GetV8Context();
browser_->GetMainFrame()->ExecuteJavaScript( browser_->GetMainFrame()->ExecuteJavaScript(
"window.setTimeout(test, 0)", "about:blank", 0); "window.setTimeout(test, 0)", browser_->GetMainFrame()->GetURL(), 0);
} }
void RunOnUncaughtExceptionDevToolsTest() { void RunOnUncaughtExceptionDevToolsTest() {
@ -1595,7 +1596,8 @@ class V8RendererTest : public ClientApp::RenderDelegate {
// Show DevTools. // Show DevTools.
EXPECT_FALSE(devtools_url_.empty()); EXPECT_FALSE(devtools_url_.empty());
browser_->GetMainFrame()->ExecuteJavaScript( browser_->GetMainFrame()->ExecuteJavaScript(
"window.open('" + devtools_url_ + "');", "about:blank", 0); "window.open('" + devtools_url_ + "');",
browser_->GetMainFrame()->GetURL(), 0);
} }
// Test execution of a native function when the extension is loaded. // Test execution of a native function when the extension is loaded.
@ -1719,13 +1721,6 @@ class V8RendererTest : public ClientApp::RenderDelegate {
CefV8Value::CreateInt(12), CefV8Value::CreateInt(12),
V8_PROPERTY_ATTRIBUTE_NONE)); V8_PROPERTY_ATTRIBUTE_NONE));
} }
if (test_mode_ > V8TEST_NONE && url != kV8NavTestUrl &&
url.find("http://tests/") != std::string::npos) {
// Run the test asynchronously.
CefPostTask(TID_RENDERER,
NewCefRunnableMethod(this, &V8RendererTest::RunTest));
}
} }
virtual void OnContextReleased(CefRefPtr<ClientApp> app, virtual void OnContextReleased(CefRefPtr<ClientApp> app,
@ -2013,6 +2008,11 @@ class V8RendererTest : public ClientApp::RenderDelegate {
return false; return false;
} }
return true; return true;
} else if (message->GetName() == kV8RunTestMsg) {
// Run the test asynchronously.
CefPostTask(TID_RENDERER,
NewCefRunnableMethod(this, &V8RendererTest::RunTest));
return true;
} }
return false; return false;
} }
@ -2086,7 +2086,7 @@ class V8RendererTest : public ClientApp::RenderDelegate {
void DevToolsClosed() { void DevToolsClosed() {
browser_->GetMainFrame()->ExecuteJavaScript( browser_->GetMainFrame()->ExecuteJavaScript(
"window.setTimeout(test, 0);", "about:blank", 0); "window.setTimeout(test, 0);", browser_->GetMainFrame()->GetURL(), 0);
} }
protected: protected:
@ -2221,6 +2221,15 @@ class V8TestHandler : public TestHandler {
browser->GetHost()->GetDevToolsURL(true))); browser->GetHost()->GetDevToolsURL(true)));
EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg)); EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg));
} }
} else {
const std::string& url = frame->GetURL();
if (url != kV8NavTestUrl &&
url.find("http://tests/") != std::string::npos) {
// Run the test.
CefRefPtr<CefProcessMessage> return_msg =
CefProcessMessage::Create(kV8RunTestMsg);
EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg));
}
} }
} }