Update to Chromium revision a106f0ab (#464641)

- Remove CefWindowInfo.transparent_painting_enabled. Set
  CefBrowserSettings.background_color to an opaque or transparent
  value instead.
This commit is contained in:
Marshall Greenblatt
2017-04-20 15:28:17 -04:00
parent 2f6475c0d8
commit 3f71138d64
151 changed files with 2756 additions and 2295 deletions

View File

@ -140,9 +140,6 @@ assert(!enable_print_preview)
# Enable support for Widevine CDM. # Enable support for Widevine CDM.
assert(enable_widevine) assert(enable_widevine)
# Disable support for plugin installation.
assert(!enable_plugin_installation)
if (is_clang) { if (is_clang) {
# Don't use the chrome style plugin. # Don't use the chrome style plugin.
assert(!clang_use_chrome_plugins) assert(!clang_use_chrome_plugins)
@ -595,6 +592,9 @@ static_library("libcef_static") {
# we include Blink headers. # we include Blink headers.
"//third_party/WebKit/public/platform", "//third_party/WebKit/public/platform",
"//third_party/WebKit/public/web", "//third_party/WebKit/public/web",
# Crashpad code uses paths relative to this directory.
"//third_party/crashpad/crashpad",
] ]
public_deps = [ public_deps = [
@ -753,8 +753,8 @@ static_library("libcef_static") {
] ]
deps += [ deps += [
"//build/config/freetype",
"//build/linux:fontconfig", "//build/linux:fontconfig",
"//build/linux:freetype2",
] ]
} }

View File

@ -7,5 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{ {
'chromium_checkout': '939b32ee5ba05c396eef3fd992822fcca9a2e262', 'chromium_checkout': 'a106f0abbf69dad349d4aaf4bcc4f5d376dd2377',
} }

View File

@ -81,7 +81,6 @@ struct CefWindowInfoTraits {
target->height = src->height; target->height = src->height;
target->parent_window = src->parent_window; target->parent_window = src->parent_window;
target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->window = src->window; target->window = src->window;
} }
}; };
@ -114,15 +113,14 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
// monitor info and to act as the parent window for dialogs, context menus, // monitor info and to act as the parent window for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used // etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent window may not function // and some functionality that requires a parent window may not function
// correctly. If |transparent| is true a transparent background color will be // correctly. In order to create windowless browsers the
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true. // CefSettings.windowless_rendering_enabled value must be set to true.
// Transparent painting is enabled by default but can be disabled by setting
// CefBrowserSettings.background_color to an opaque value.
/// ///
void SetAsWindowless(CefWindowHandle parent, bool transparent) { void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = true; windowless_rendering_enabled = true;
parent_window = parent; parent_window = parent;
transparent_painting_enabled = transparent;
} }
}; };

View File

@ -87,7 +87,6 @@ struct CefWindowInfoTraits {
target->hidden = src->hidden; target->hidden = src->hidden;
target->parent_view = src->parent_view; target->parent_view = src->parent_view;
target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->view = src->view; target->view = src->view;
} }
}; };
@ -121,15 +120,14 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
// monitor info and to act as the parent view for dialogs, context menus, // monitor info and to act as the parent view for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used // etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent view may not function // and some functionality that requires a parent view may not function
// correctly. If |transparent| is true a transparent background color will be // correctly. In order to create windowless browsers the
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true. // CefSettings.windowless_rendering_enabled value must be set to true.
// Transparent painting is enabled by default but can be disabled by setting
// CefBrowserSettings.background_color to an opaque value.
/// ///
void SetAsWindowless(CefWindowHandle parent, bool transparent) { void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = true; windowless_rendering_enabled = true;
parent_view = parent; parent_view = parent;
transparent_painting_enabled = transparent;
} }
}; };

View File

@ -401,10 +401,14 @@ typedef struct _cef_settings_t {
int enable_net_security_expiration; int enable_net_security_expiration;
/// ///
// Opaque background color used for accelerated content. By default the // Background color used for the browser before a document is loaded and when
// background color will be white. Only the RGB compontents of the specified // no document color is specified. The alpha component must be either fully
// value will be used. The alpha component must greater than 0 to enable use // opaque (0xFF) or fully transparent (0x00). If the alpha component is fully
// of the background color but will be otherwise ignored. // opaque then the RGB components will be used as the background color. If the
// alpha component is fully transparent for a windowed browser then the
// default value of opaque white be used. If the alpha component is fully
// transparent for a windowless (off-screen) browser then transparent painting
// will be enabled.
/// ///
cef_color_t background_color; cef_color_t background_color;
@ -652,11 +656,14 @@ typedef struct _cef_browser_settings_t {
cef_state_t webgl; cef_state_t webgl;
/// ///
// Opaque background color used for the browser before a document is loaded // Background color used for the browser before a document is loaded and when
// and when no document color is specified. By default the background color // no document color is specified. The alpha component must be either fully
// will be the same as CefSettings.background_color. Only the RGB compontents // opaque (0xFF) or fully transparent (0x00). If the alpha component is fully
// of the specified value will be used. The alpha component must greater than // opaque then the RGB components will be used as the background color. If the
// 0 to enable use of the background color but will be otherwise ignored. // alpha component is fully transparent for a windowed browser then the
// CefSettings.background_color value will be used. If the alpha component is
// fully transparent for a windowless (off-screen) browser then transparent
// painting will be enabled.
/// ///
cef_color_t background_color; cef_color_t background_color;

View File

@ -92,17 +92,11 @@ typedef struct _cef_window_info_t {
// monitor will be used and some functionality that requires a parent window // monitor will be used and some functionality that requires a parent window
// may not function correctly. In order to create windowless browsers the // may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true. // CefSettings.windowless_rendering_enabled value must be set to true.
// Transparent painting is enabled by default but can be disabled by setting
// CefBrowserSettings.background_color to an opaque value.
/// ///
int windowless_rendering_enabled; int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
/// ///
// Pointer for the new browser window. Only used with windowed rendering. // Pointer for the new browser window. Only used with windowed rendering.
/// ///

View File

@ -102,17 +102,11 @@ typedef struct _cef_window_info_t {
// monitor will be used and some functionality that requires a parent view // monitor will be used and some functionality that requires a parent view
// may not function correctly. In order to create windowless browsers the // may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true. // CefSettings.windowless_rendering_enabled value must be set to true.
// Transparent painting is enabled by default but can be disabled by setting
// CefBrowserSettings.background_color to an opaque value.
/// ///
int windowless_rendering_enabled; int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
/// ///
// NSView pointer for the new browser view. Only used with windowed rendering. // NSView pointer for the new browser view. Only used with windowed rendering.
/// ///

View File

@ -82,17 +82,11 @@ typedef struct _cef_window_info_t {
// monitor will be used and some functionality that requires a parent window // monitor will be used and some functionality that requires a parent window
// may not function correctly. In order to create windowless browsers the // may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true. // CefSettings.windowless_rendering_enabled value must be set to true.
// Transparent painting is enabled by default but can be disabled by setting
// CefBrowserSettings.background_color to an opaque value.
/// ///
int windowless_rendering_enabled; int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
/// ///
// Handle for the new browser window. Only used with windowed rendering. // Handle for the new browser window. Only used with windowed rendering.
/// ///

View File

@ -88,7 +88,6 @@ struct CefWindowInfoTraits {
target->height = src->height; target->height = src->height;
target->parent_window = src->parent_window; target->parent_window = src->parent_window;
target->menu = src->menu; target->menu = src->menu;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->window = src->window; target->window = src->window;
} }
@ -140,15 +139,14 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
// monitor info and to act as the parent window for dialogs, context menus, // monitor info and to act as the parent window for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used // etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent window may not function // and some functionality that requires a parent window may not function
// correctly. If |transparent| is true a transparent background color will be // correctly. In order to create windowless browsers the
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true. // CefSettings.windowless_rendering_enabled value must be set to true.
// Transparent painting is enabled by default but can be disabled by setting
// CefBrowserSettings.background_color to an opaque value.
/// ///
void SetAsWindowless(CefWindowHandle parent, bool transparent) { void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = TRUE; windowless_rendering_enabled = TRUE;
parent_window = parent; parent_window = parent;
transparent_painting_enabled = transparent;
} }
}; };

View File

@ -28,6 +28,15 @@ CefBrowserContext::~CefBrowserContext() {
void CefBrowserContext::Initialize() { void CefBrowserContext::Initialize() {
content::BrowserContext::Initialize(this, GetPath()); content::BrowserContext::Initialize(this, GetPath());
resource_context_.reset(
new CefResourceContext(IsOffTheRecord(), GetHandler()));
// This must be called before creating any services to avoid hitting
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
// multiple browser contexts (due to pointer address reuse).
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
const bool extensions_enabled = extensions::ExtensionsEnabled(); const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled) { if (extensions_enabled) {
// Create the custom ExtensionSystem first because other KeyedServices // Create the custom ExtensionSystem first because other KeyedServices
@ -41,22 +50,18 @@ void CefBrowserContext::Initialize() {
} else { } else {
extension_system_->InitForRegularProfile(true); extension_system_->InitForRegularProfile(true);
} }
resource_context_->set_extensions_info_map(extension_system_->info_map());
} }
}
resource_context_.reset(new CefResourceContext( void CefBrowserContext::PostInitialize() {
IsOffTheRecord(),
extensions_enabled ? extension_system_->info_map() : NULL,
GetHandler()));
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
// Spell checking support and possibly other subsystems retrieve the // Spell checking support and possibly other subsystems retrieve the
// PrefService associated with a BrowserContext via UserPrefs::Get(). // PrefService associated with a BrowserContext via UserPrefs::Get().
PrefService* pref_service = GetPrefs(); PrefService* pref_service = GetPrefs();
DCHECK(pref_service); DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service); user_prefs::UserPrefs::Set(this, pref_service);
const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled && !is_proxy_) if (extensions_enabled && !is_proxy_)
extension_system_->Init(); extension_system_->Init();
} }

View File

@ -187,6 +187,9 @@ class CefBrowserContext : public ChromeProfileStub {
protected: protected:
~CefBrowserContext() override; ~CefBrowserContext() override;
// Must be called after all services have been initialized.
void PostInitialize();
// Must be called before the child object destructor has completed. // Must be called before the child object destructor has completed.
void Shutdown(); void Shutdown();

View File

@ -85,6 +85,8 @@ class ImplManager {
CefBrowserContextImpl* GetImplForContext( CefBrowserContextImpl* GetImplForContext(
const content::BrowserContext* context) { const content::BrowserContext* context) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!context)
return NULL;
const CefBrowserContext* cef_context = const CefBrowserContext* cef_context =
static_cast<const CefBrowserContext*>(context); static_cast<const CefBrowserContext*>(context);
@ -141,7 +143,14 @@ class ImplManager {
DISALLOW_COPY_AND_ASSIGN(ImplManager); DISALLOW_COPY_AND_ASSIGN(ImplManager);
}; };
base::LazyInstance<ImplManager> g_manager = LAZY_INSTANCE_INITIALIZER; #if DCHECK_IS_ON()
// Because of DCHECK()s in the object destructor.
base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
LAZY_INSTANCE_INITIALIZER;
#else
base::LazyInstance<ImplManager>::Leaky g_manager =
LAZY_INSTANCE_INITIALIZER;
#endif
} // namespace } // namespace
@ -259,9 +268,16 @@ void CefBrowserContextImpl::Initialize() {
CefString(&CefContext::Get()->settings().accept_language_list); CefString(&CefContext::Get()->settings().accept_language_list);
} }
// Initialize preferences. // Initialize a temporary PrefService object that may be referenced during
// BrowserContextServices initialization.
pref_service_ = browser_prefs::CreatePrefService( pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences); this, base::FilePath(), false, true);
CefBrowserContext::Initialize();
// Initialize the real PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences, false);
// Initialize visited links management. // Initialize visited links management.
base::FilePath visited_link_path; base::FilePath visited_link_path;
@ -275,13 +291,13 @@ void CefBrowserContextImpl::Initialize() {
visitedlink_listener_->CreateListenerForContext(this); visitedlink_listener_->CreateListenerForContext(this);
visitedlink_master_->Init(); visitedlink_master_->Init();
CefBrowserContext::Initialize();
// Initialize proxy configuration tracker. // Initialize proxy configuration tracker.
pref_proxy_config_tracker_.reset( pref_proxy_config_tracker_.reset(
ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
GetPrefs())); GetPrefs()));
CefBrowserContext::PostInitialize();
// Create the CefURLRequestContextGetterImpl via an indirect call to // Create the CefURLRequestContextGetterImpl via an indirect call to
// CreateRequestContext. Triggers a call to CefURLRequestContextGetterImpl:: // CreateRequestContext. Triggers a call to CefURLRequestContextGetterImpl::
// GetURLRequestContext() on the IO thread which creates the // GetURLRequestContext() on the IO thread which creates the

View File

@ -82,6 +82,8 @@ void CefBrowserContextProxy::Initialize() {
// This object's CefResourceContext needs to proxy some UserData requests to // This object's CefResourceContext needs to proxy some UserData requests to
// the parent object's CefResourceContext. // the parent object's CefResourceContext.
resource_context()->set_parent(parent_->resource_context()); resource_context()->set_parent(parent_->resource_context());
CefBrowserContext::PostInitialize();
} }
base::SupportsUserData::Data* base::SupportsUserData::Data*
@ -182,6 +184,11 @@ net::URLRequestContextGetter*
return nullptr; return nullptr;
} }
void CefBrowserContextProxy::RegisterInProcessServices(
StaticServiceMap* services) {
parent_->RegisterInProcessServices(services);
}
PrefService* CefBrowserContextProxy::GetPrefs() { PrefService* CefBrowserContextProxy::GetPrefs() {
return parent_->GetPrefs(); return parent_->GetPrefs();
} }

View File

@ -54,6 +54,7 @@ class CefBrowserContextProxy : public CefBrowserContext {
content::ProtocolHandlerMap* protocol_handlers, content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) content::URLRequestInterceptorScopedVector request_interceptors)
override; override;
void RegisterInProcessServices(StaticServiceMap* services) override;
// Profile methods. // Profile methods.
PrefService* GetPrefs() override; PrefService* GetPrefs() override;

View File

@ -50,6 +50,7 @@
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
#include "content/public/browser/download_url_parameters.h" #include "content/public/browser/download_url_parameters.h"
#include "content/public/browser/host_zoom_map.h" #include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
@ -70,6 +71,8 @@
#include "components/spellcheck/browser/spellcheck_platform.h" #include "components/spellcheck/browser/spellcheck_platform.h"
#endif #endif
using content::KeyboardEventProcessingResult;
namespace { namespace {
// Associates a CefBrowserHostImpl instance with a WebContents. This object will // Associates a CefBrowserHostImpl instance with a WebContents. This object will
@ -782,8 +785,8 @@ void CefBrowserHostImpl::Find(int identifier, const CefString& searchText,
blink::WebFindOptions options; blink::WebFindOptions options;
options.forward = forward; options.forward = forward;
options.matchCase = matchCase; options.match_case = matchCase;
options.findNext = findNext; options.find_next = findNext;
web_contents()->Find(identifier, searchText, options); web_contents()->Find(identifier, searchText, options);
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
@ -1038,8 +1041,8 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
return; return;
content::NativeWebKeyboardEvent web_event( content::NativeWebKeyboardEvent web_event(
blink::WebInputEvent::Undefined, blink::WebInputEvent::kUndefined,
blink::WebInputEvent::NoModifiers, blink::WebInputEvent::kNoModifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow())); ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
platform_delegate_->TranslateKeyEvent(web_event, event); platform_delegate_->TranslateKeyEvent(web_event, event);
platform_delegate_->SendKeyEvent(web_event); platform_delegate_->SendKeyEvent(web_event);
@ -1724,6 +1727,12 @@ void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
} }
} }
SkColor CefBrowserHostImpl::GetBackgroundColor() const {
// Don't use |platform_delegate_| because it's not thread-safe.
return CefContext::Get()->GetBackgroundColor(&settings_,
is_windowless_ ? STATE_ENABLED : STATE_DISABLED);
}
int CefBrowserHostImpl::browser_id() const { int CefBrowserHostImpl::browser_id() const {
return browser_info_->browser_id(); return browser_info_->browser_id();
} }
@ -1785,8 +1794,8 @@ bool CefBrowserHostImpl::IsFullscreenForTabOrPending(
blink::WebDisplayMode CefBrowserHostImpl::GetDisplayMode( blink::WebDisplayMode CefBrowserHostImpl::GetDisplayMode(
const content::WebContents* web_contents) const { const content::WebContents* web_contents) const {
return is_fullscreen_ ? blink::WebDisplayModeFullscreen : return is_fullscreen_ ? blink::kWebDisplayModeFullscreen :
blink::WebDisplayModeBrowser; blink::kWebDisplayModeBrowser;
} }
void CefBrowserHostImpl::FindReply( void CefBrowserHostImpl::FindReply(
@ -2170,29 +2179,29 @@ content::WebContents* CefBrowserHostImpl::GetActionableWebContents() {
return web_contents(); return web_contents();
} }
bool CefBrowserHostImpl::PreHandleKeyboardEvent( KeyboardEventProcessingResult CefBrowserHostImpl::PreHandleKeyboardEvent(
content::WebContents* source, content::WebContents* source,
const content::NativeWebKeyboardEvent& event, const content::NativeWebKeyboardEvent& event) {
bool* is_keyboard_shortcut) { if (platform_delegate_ && client_.get()) {
if (!platform_delegate_)
return false;
if (client_.get()) {
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler(); CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
if (handler.get()) { if (handler.get()) {
CefKeyEvent cef_event; CefKeyEvent cef_event;
if (!browser_util::GetCefKeyEvent(event, cef_event)) if (browser_util::GetCefKeyEvent(event, cef_event)) {
return false; cef_event.focus_on_editable_field = focus_on_editable_field_;
cef_event.focus_on_editable_field = focus_on_editable_field_; CefEventHandle event_handle = platform_delegate_->GetEventHandle(event);
bool is_keyboard_shortcut = false;
CefEventHandle event_handle = platform_delegate_->GetEventHandle(event); bool result = handler->OnPreKeyEvent(this, cef_event, event_handle,
return handler->OnPreKeyEvent(this, cef_event, event_handle, &is_keyboard_shortcut);
is_keyboard_shortcut); if (result)
return KeyboardEventProcessingResult::HANDLED;
else if (is_keyboard_shortcut)
return KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT;
}
} }
} }
return false; return KeyboardEventProcessingResult::NOT_HANDLED;
} }
void CefBrowserHostImpl::HandleKeyboardEvent( void CefBrowserHostImpl::HandleKeyboardEvent(
@ -2527,7 +2536,7 @@ void CefBrowserHostImpl::DidFinishNavigation(
// Don't call OnLoadStart for same page navigations (fragments, // Don't call OnLoadStart for same page navigations (fragments,
// history state). // history state).
if (!navigation_handle->IsSamePage()) if (!navigation_handle->IsSameDocument())
OnLoadStart(frame, navigation_handle->GetPageTransition()); OnLoadStart(frame, navigation_handle->GetPageTransition());
if (is_main_frame) if (is_main_frame)

View File

@ -339,6 +339,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Thread safe accessors. // Thread safe accessors.
const CefBrowserSettings& settings() const { return settings_; } const CefBrowserSettings& settings() const { return settings_; }
SkColor GetBackgroundColor() const;
CefRefPtr<CefClient> client() const { return client_; } CefRefPtr<CefClient> client() const { return client_; }
scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; } scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; }
int browser_id() const; int browser_id() const;
@ -391,10 +392,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool reverse) override; bool reverse) override;
bool HandleContextMenu( bool HandleContextMenu(
const content::ContextMenuParams& params) override; const content::ContextMenuParams& params) override;
bool PreHandleKeyboardEvent( content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
content::WebContents* source, content::WebContents* source,
const content::NativeWebKeyboardEvent& event, const content::NativeWebKeyboardEvent& event) override;
bool* is_keyboard_shortcut) override;
void HandleKeyboardEvent( void HandleKeyboardEvent(
content::WebContents* source, content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;

View File

@ -207,28 +207,28 @@ int CefBrowserPlatformDelegate::TranslateModifiers(uint32 cef_modifiers) {
int webkit_modifiers = 0; int webkit_modifiers = 0;
// Set modifiers based on key state. // Set modifiers based on key state.
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
webkit_modifiers |= blink::WebInputEvent::ShiftKey; webkit_modifiers |= blink::WebInputEvent::kShiftKey;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
webkit_modifiers |= blink::WebInputEvent::ControlKey; webkit_modifiers |= blink::WebInputEvent::kControlKey;
if (cef_modifiers & EVENTFLAG_ALT_DOWN) if (cef_modifiers & EVENTFLAG_ALT_DOWN)
webkit_modifiers |= blink::WebInputEvent::AltKey; webkit_modifiers |= blink::WebInputEvent::kAltKey;
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
webkit_modifiers |= blink::WebInputEvent::MetaKey; webkit_modifiers |= blink::WebInputEvent::kMetaKey;
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
webkit_modifiers |= blink::WebInputEvent::LeftButtonDown; webkit_modifiers |= blink::WebInputEvent::kLeftButtonDown;
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
webkit_modifiers |= blink::WebInputEvent::MiddleButtonDown; webkit_modifiers |= blink::WebInputEvent::kMiddleButtonDown;
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
webkit_modifiers |= blink::WebInputEvent::RightButtonDown; webkit_modifiers |= blink::WebInputEvent::kRightButtonDown;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
webkit_modifiers |= blink::WebInputEvent::CapsLockOn; webkit_modifiers |= blink::WebInputEvent::kCapsLockOn;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
webkit_modifiers |= blink::WebInputEvent::NumLockOn; webkit_modifiers |= blink::WebInputEvent::kNumLockOn;
if (cef_modifiers & EVENTFLAG_IS_LEFT) if (cef_modifiers & EVENTFLAG_IS_LEFT)
webkit_modifiers |= blink::WebInputEvent::IsLeft; webkit_modifiers |= blink::WebInputEvent::kIsLeft;
if (cef_modifiers & EVENTFLAG_IS_RIGHT) if (cef_modifiers & EVENTFLAG_IS_RIGHT)
webkit_modifiers |= blink::WebInputEvent::IsRight; webkit_modifiers |= blink::WebInputEvent::kIsRight;
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
webkit_modifiers |= blink::WebInputEvent::IsKeyPad; webkit_modifiers |= blink::WebInputEvent::kIsKeyPad;
return webkit_modifiers; return webkit_modifiers;
} }

View File

@ -134,6 +134,13 @@ class CefBrowserPlatformDelegate {
CefBrowserHostImpl* new_browser, CefBrowserHostImpl* new_browser,
bool is_devtools); bool is_devtools);
// Returns the background color for the browser. The alpha component will be
// either SK_AlphaTRANSPARENT or SK_AlphaOPAQUE (e.g. fully transparent or
// fully opaque). SK_AlphaOPAQUE will always be returned for windowed
// browsers. SK_ColorTRANSPARENT may be returned for windowless browsers to
// enable transparency.
virtual SkColor GetBackgroundColor() const = 0;
// Notify the window that it was resized. // Notify the window that it was resized.
virtual void WasResized() = 0; virtual void WasResized() = 0;

View File

@ -6,6 +6,8 @@
#include <utility> #include <utility>
#include "libcef/browser/context.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h" #include "build/build_config.h"
@ -29,28 +31,31 @@
namespace { namespace {
std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate( std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
const CefWindowInfo& window_info) { const CefWindowInfo& window_info,
SkColor background_color) {
#if defined(OS_WIN) #if defined(OS_WIN)
return base::WrapUnique(new CefBrowserPlatformDelegateNativeWin(window_info)); return base::MakeUnique<CefBrowserPlatformDelegateNativeWin>(
window_info, background_color);
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
return base::WrapUnique(new CefBrowserPlatformDelegateNativeMac(window_info)); return base::MakeUnique<CefBrowserPlatformDelegateNativeMac>(
window_info, background_color);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return base::WrapUnique( return base::MakeUnique<CefBrowserPlatformDelegateNativeLinux>(
new CefBrowserPlatformDelegateNativeLinux(window_info)); window_info, background_color);
#endif #endif
} }
std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate( std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) { std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) {
#if defined(OS_WIN) #if defined(OS_WIN)
return base::WrapUnique( return base::MakeUnique<CefBrowserPlatformDelegateOsrWin>(
new CefBrowserPlatformDelegateOsrWin(std::move(native_delegate))); std::move(native_delegate));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
return base::WrapUnique( return base::MakeUnique<CefBrowserPlatformDelegateOsrMac>(
new CefBrowserPlatformDelegateOsrMac(std::move(native_delegate))); std::move(native_delegate));
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return base::WrapUnique( return base::MakeUnique<CefBrowserPlatformDelegateOsrLinux>(
new CefBrowserPlatformDelegateOsrLinux(std::move(native_delegate))); std::move(native_delegate));
#endif #endif
} }
@ -59,24 +64,30 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
// static // static
std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create( std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
CefBrowserHostImpl::CreateParams& create_params) { CefBrowserHostImpl::CreateParams& create_params) {
const bool is_windowless =
create_params.window_info &&
create_params.window_info->windowless_rendering_enabled &&
create_params.client &&
create_params.client->GetRenderHandler().get();
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
if (create_params.window_info) { if (create_params.window_info) {
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(*create_params.window_info.get()); CreateNativeDelegate(*create_params.window_info.get(),
if (create_params.window_info->windowless_rendering_enabled && background_color);
create_params.client && if (is_windowless)
create_params.client->GetRenderHandler().get()) {
return CreateOSRDelegate(std::move(native_delegate)); return CreateOSRDelegate(std::move(native_delegate));
}
return std::move(native_delegate); return std::move(native_delegate);
} }
#if defined(USE_AURA) #if defined(USE_AURA)
else { else {
// CefWindowInfo is not used in this case. // CefWindowInfo is not used in this case.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo()); CreateNativeDelegate(CefWindowInfo(), background_color);
return base::WrapUnique(new CefBrowserPlatformDelegateViews( return base::MakeUnique<CefBrowserPlatformDelegateViews>(
std::move(native_delegate), std::move(native_delegate),
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()))); static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
} }
#endif // defined(USE_AURA) #endif // defined(USE_AURA)

View File

@ -10,17 +10,17 @@ namespace browser_util {
bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event, bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
CefKeyEvent& cef_event) { CefKeyEvent& cef_event) {
switch (event.type()) { switch (event.GetType()) {
case blink::WebKeyboardEvent::RawKeyDown: case blink::WebKeyboardEvent::kRawKeyDown:
cef_event.type = KEYEVENT_RAWKEYDOWN; cef_event.type = KEYEVENT_RAWKEYDOWN;
break; break;
case blink::WebKeyboardEvent::KeyDown: case blink::WebKeyboardEvent::kKeyDown:
cef_event.type = KEYEVENT_KEYDOWN; cef_event.type = KEYEVENT_KEYDOWN;
break; break;
case blink::WebKeyboardEvent::KeyUp: case blink::WebKeyboardEvent::kKeyUp:
cef_event.type = KEYEVENT_KEYUP; cef_event.type = KEYEVENT_KEYUP;
break; break;
case blink::WebKeyboardEvent::Char: case blink::WebKeyboardEvent::kChar:
cef_event.type = KEYEVENT_CHAR; cef_event.type = KEYEVENT_CHAR;
break; break;
default: default:
@ -28,22 +28,22 @@ bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
} }
cef_event.modifiers = 0; cef_event.modifiers = 0;
if (event.modifiers() & blink::WebKeyboardEvent::ShiftKey) if (event.GetModifiers() & blink::WebKeyboardEvent::kShiftKey)
cef_event.modifiers |= EVENTFLAG_SHIFT_DOWN; cef_event.modifiers |= EVENTFLAG_SHIFT_DOWN;
if (event.modifiers() & blink::WebKeyboardEvent::ControlKey) if (event.GetModifiers() & blink::WebKeyboardEvent::kControlKey)
cef_event.modifiers |= EVENTFLAG_CONTROL_DOWN; cef_event.modifiers |= EVENTFLAG_CONTROL_DOWN;
if (event.modifiers() & blink::WebKeyboardEvent::AltKey) if (event.GetModifiers() & blink::WebKeyboardEvent::kAltKey)
cef_event.modifiers |= EVENTFLAG_ALT_DOWN; cef_event.modifiers |= EVENTFLAG_ALT_DOWN;
if (event.modifiers() & blink::WebKeyboardEvent::MetaKey) if (event.GetModifiers() & blink::WebKeyboardEvent::kMetaKey)
cef_event.modifiers |= EVENTFLAG_COMMAND_DOWN; cef_event.modifiers |= EVENTFLAG_COMMAND_DOWN;
if (event.modifiers() & blink::WebKeyboardEvent::IsKeyPad) if (event.GetModifiers() & blink::WebKeyboardEvent::kIsKeyPad)
cef_event.modifiers |= EVENTFLAG_IS_KEY_PAD; cef_event.modifiers |= EVENTFLAG_IS_KEY_PAD;
cef_event.windows_key_code = event.windowsKeyCode; cef_event.windows_key_code = event.windows_key_code;
cef_event.native_key_code = event.nativeKeyCode; cef_event.native_key_code = event.native_key_code;
cef_event.is_system_key = event.isSystemKey; cef_event.is_system_key = event.is_system_key;
cef_event.character = event.text[0]; cef_event.character = event.text[0];
cef_event.unmodified_character = event.unmodifiedText[0]; cef_event.unmodified_character = event.unmodified_text[0];
return true; return true;
} }

View File

@ -277,8 +277,8 @@ safe_browsing::ClientSideDetectionService*
return NULL; return NULL;
} }
subresource_filter::RulesetService* subresource_filter::ContentRulesetService*
ChromeBrowserProcessStub::subresource_filter_ruleset_service() { ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
NOTREACHED(); NOTREACHED();
return NULL; return NULL;
} }

View File

@ -84,7 +84,7 @@ class ChromeBrowserProcessStub : public BrowserProcess,
safe_browsing::SafeBrowsingService* safe_browsing_service() override; safe_browsing::SafeBrowsingService* safe_browsing_service() override;
safe_browsing::ClientSideDetectionService* safe_browsing::ClientSideDetectionService*
safe_browsing_detection_service() override; safe_browsing_detection_service() override;
subresource_filter::RulesetService* subresource_filter::ContentRulesetService*
subresource_filter_ruleset_service() override; subresource_filter_ruleset_service() override;
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)

View File

@ -22,12 +22,12 @@
#include "base/debug/debugger.h" #include "base/debug/debugger.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "content/public/app/content_main.h" #include "content/app/content_service_manager_main_delegate.h"
#include "content/public/app/content_main_runner.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/main.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#if defined(OS_WIN) #if defined(OS_WIN)
@ -116,11 +116,28 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) {
argv_as_utf8[argv.size()] = nullptr; argv_as_utf8[argv.size()] = nullptr;
argv.clear(); argv.clear();
return crashpad::HandlerMain(static_cast<int>(storage.size()), return crashpad::HandlerMain(static_cast<int>(storage.size()),
argv_as_utf8.get()); argv_as_utf8.get(), nullptr);
} }
#endif // defined(OS_MACOSX) || defined(OS_WIN) #endif // defined(OS_MACOSX) || defined(OS_WIN)
bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
// Windowed browser colors must be fully opaque.
if (!is_windowless && CefColorGetA(cef_in) != SK_AlphaOPAQUE)
return false;
// Windowless browser colors may be fully transparent.
if (is_windowless && CefColorGetA(cef_in) == SK_AlphaTRANSPARENT) {
*sk_out = SK_ColorTRANSPARENT;
return true;
}
// Ignore the alpha component.
*sk_out = SkColorSetRGB(CefColorGetR(cef_in), CefColorGetG(cef_in),
CefColorGetB(cef_in));
return true;
}
} // namespace } // namespace
int CefExecuteProcess(const CefMainArgs& args, int CefExecuteProcess(const CefMainArgs& args,
@ -326,12 +343,12 @@ bool CefContext::Initialize(const CefMainArgs& args,
#endif #endif
main_delegate_.reset(new CefMainDelegate(application)); main_delegate_.reset(new CefMainDelegate(application));
main_runner_.reset(content::ContentMainRunner::Create());
browser_info_manager_.reset(new CefBrowserInfoManager); browser_info_manager_.reset(new CefBrowserInfoManager);
int exit_code; int exit_code;
// Initialize the content runner. // Initialize the content runner.
content::ContentMainParams params(main_delegate_.get());
#if defined(OS_WIN) #if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0}; sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == NULL) { if (windows_sandbox_info == NULL) {
@ -340,20 +357,20 @@ bool CefContext::Initialize(const CefMainArgs& args,
settings_.no_sandbox = true; settings_.no_sandbox = true;
} }
content::ContentMainParams params(main_delegate_.get());
params.instance = args.instance; params.instance = args.instance;
params.sandbox_info = params.sandbox_info =
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info); static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
exit_code = main_runner_->Initialize(params);
#else #else
content::ContentMainParams params(main_delegate_.get());
params.argc = args.argc; params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv); params.argv = const_cast<const char**>(args.argv);
exit_code = main_runner_->Initialize(params);
#endif #endif
sm_main_delegate_.reset(
new content::ContentServiceManagerMainDelegate(params));
sm_main_params_.reset(
new service_manager::MainParams(sm_main_delegate_.get()));
exit_code = service_manager::MainInitialize(*sm_main_params_);
DCHECK_LT(exit_code, 0); DCHECK_LT(exit_code, 0);
if (exit_code >= 0) if (exit_code >= 0)
return false; return false;
@ -363,7 +380,7 @@ bool CefContext::Initialize(const CefMainArgs& args,
// Run the process. Results in a call to CefMainDelegate::RunProcess() which // Run the process. Results in a call to CefMainDelegate::RunProcess() which
// will create the browser runner and message loop without blocking. // will create the browser runner and message loop without blocking.
exit_code = main_runner_->Run(); exit_code = service_manager::MainRun(*sm_main_params_);
initialized_ = true; initialized_ = true;
@ -413,6 +430,23 @@ bool CefContext::OnInitThread() {
return (base::PlatformThread::CurrentId() == init_thread_id_); return (base::PlatformThread::CurrentId() == init_thread_id_);
} }
SkColor CefContext::GetBackgroundColor(
const CefBrowserSettings* browser_settings,
cef_state_t windowless_state) const {
bool is_windowless = windowless_state == STATE_ENABLED ? true :
(windowless_state == STATE_DISABLED ? false :
!!settings_.windowless_rendering_enabled);
// Default to opaque white if no acceptable color values are found.
SkColor sk_color = SK_ColorWHITE;
if (!browser_settings ||
!GetColor(browser_settings->background_color, is_windowless, &sk_color)) {
GetColor(settings_.background_color, is_windowless, &sk_color);
}
return sk_color;
}
CefTraceSubscriber* CefContext::GetTraceSubscriber() { CefTraceSubscriber* CefContext::GetTraceSubscriber() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (shutting_down_) if (shutting_down_)
@ -488,9 +522,10 @@ void CefContext::FinalizeShutdown() {
main_delegate_->ShutdownBrowser(); main_delegate_->ShutdownBrowser();
// Shut down the content runner. // Shut down the content runner.
main_runner_->Shutdown(); service_manager::MainShutdown(*sm_main_params_);
browser_info_manager_.reset(NULL); browser_info_manager_.reset(NULL);
main_runner_.reset(NULL); sm_main_params_.reset(NULL);
sm_main_delegate_.reset(NULL);
main_delegate_.reset(NULL); main_delegate_.reset(NULL);
} }

View File

@ -13,13 +13,18 @@
#include "include/cef_app.h" #include "include/cef_app.h"
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "third_party/skia/include/core/SkColor.h"
namespace base { namespace base {
class WaitableEvent; class WaitableEvent;
} }
namespace content { namespace content {
class ContentMainRunner; class ContentServiceManagerMainDelegate;
}
namespace service_manager {
struct MainParams;
} }
class CefBrowserHostImpl; class CefBrowserHostImpl;
@ -55,6 +60,17 @@ class CefContext {
const CefSettings& settings() const { return settings_; } const CefSettings& settings() const { return settings_; }
// Returns the background color for the browser. If |browser_settings| is
// nullptr or does not specify a color then the global settings will be used.
// The alpha component will be either SK_AlphaTRANSPARENT or SK_AlphaOPAQUE
// (e.g. fully transparent or fully opaque). If |is_windowless| is
// STATE_DISABLED then SK_AlphaTRANSPARENT will always be returned. If
// |is_windowless| is STATE_ENABLED then SK_ColorTRANSPARENT may be returned
// to enable transparency for windowless browsers. See additional comments on
// CefSettings.background_color and CefBrowserSettings.background_color.
SkColor GetBackgroundColor(const CefBrowserSettings* browser_settings,
cef_state_t windowless_state) const;
CefTraceSubscriber* GetTraceSubscriber(); CefTraceSubscriber* GetTraceSubscriber();
// Populate the request context settings based on CefSettings and command- // Populate the request context settings based on CefSettings and command-
@ -81,7 +97,8 @@ class CefContext {
CefSettings settings_; CefSettings settings_;
std::unique_ptr<CefMainDelegate> main_delegate_; std::unique_ptr<CefMainDelegate> main_delegate_;
std::unique_ptr<content::ContentMainRunner> main_runner_; std::unique_ptr<content::ContentServiceManagerMainDelegate> sm_main_delegate_;
std::unique_ptr<service_manager::MainParams> sm_main_params_;
std::unique_ptr<CefTraceSubscriber> trace_subscriber_; std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_; std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;
}; };

View File

@ -35,7 +35,7 @@ CefContextMenuParamsImpl::TypeFlags CefContextMenuParamsImpl::GetTypeFlags() {
type_flags |= CM_TYPEFLAG_FRAME; type_flags |= CM_TYPEFLAG_FRAME;
if (!params.link_url.is_empty()) if (!params.link_url.is_empty())
type_flags |= CM_TYPEFLAG_LINK; type_flags |= CM_TYPEFLAG_LINK;
if (params.media_type != blink::WebContextMenuData::MediaTypeNone) if (params.media_type != blink::WebContextMenuData::kMediaTypeNone)
type_flags |= CM_TYPEFLAG_MEDIA; type_flags |= CM_TYPEFLAG_MEDIA;
if (!params.selection_text.empty()) if (!params.selection_text.empty())
type_flags |= CM_TYPEFLAG_SELECTION; type_flags |= CM_TYPEFLAG_SELECTION;

View File

@ -82,7 +82,7 @@ int ResponseWriter::Write(net::IOBuffer* buffer,
return num_bytes; return num_bytes;
base::Value* id = new base::Value(stream_id_); base::Value* id = new base::Value(stream_id_);
base::StringValue* chunkValue = new base::StringValue(chunk); base::Value* chunkValue = new base::Value(chunk);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
@ -116,9 +116,10 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
const CefBrowserSettings& settings, const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) { const CefPoint& inspect_element_at) {
CefBrowserSettings new_settings = settings; CefBrowserSettings new_settings = settings;
if (CefColorGetA(new_settings.background_color) == 0) { if (!windowInfo.windowless_rendering_enabled &&
// Use white as the default background color for DevTools instead of the CefColorGetA(new_settings.background_color) != SK_AlphaOPAQUE) {
// CefSettings.background_color value. // Use white as the default background color for windowed DevTools instead
// of the CefSettings.background_color value.
new_settings.background_color = SK_ColorWHITE; new_settings.background_color = SK_ColorWHITE;
} }

View File

@ -150,7 +150,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
callback.Run(suggested_path, callback.Run(suggested_path,
DownloadItem::TARGET_DISPOSITION_OVERWRITE, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
suggested_path); suggested_path,
content::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
} }
@ -168,7 +169,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
callback.Run(path, callback.Run(path,
DownloadItem::TARGET_DISPOSITION_OVERWRITE, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
path); path, content::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
base::WeakPtr<DownloadManager> manager_; base::WeakPtr<DownloadManager> manager_;
@ -360,7 +361,8 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
callback.Run(item->GetForcedFilePath(), callback.Run(item->GetForcedFilePath(),
DownloadItem::TARGET_DISPOSITION_OVERWRITE, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
item->GetForcedFilePath()); item->GetForcedFilePath(),
content::DOWNLOAD_INTERRUPT_REASON_NONE);
return true; return true;
} }

View File

@ -34,6 +34,7 @@
#include "extensions/browser/notification_types.h" #include "extensions/browser/notification_types.h"
#include "extensions/browser/null_app_sorting.h" #include "extensions/browser/null_app_sorting.h"
#include "extensions/browser/quota_service.h" #include "extensions/browser/quota_service.h"
#include "extensions/browser/renderer_startup_helper.h"
#include "extensions/browser/runtime_data.h" #include "extensions/browser/runtime_data.h"
#include "extensions/browser/service_worker_manager.h" #include "extensions/browser/service_worker_manager.h"
#include "extensions/browser/value_store/value_store_factory.h" #include "extensions/browser/value_store/value_store_factory.h"
@ -82,6 +83,9 @@ CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
: browser_context_(browser_context), : browser_context_(browser_context),
initialized_(false), initialized_(false),
registry_(ExtensionRegistry::Get(browser_context)), registry_(ExtensionRegistry::Get(browser_context)),
renderer_helper_(
extensions::RendererStartupHelperFactory::GetForBrowserContext(
browser_context)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
} }
@ -391,24 +395,8 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
make_scoped_refptr(extension))); make_scoped_refptr(extension)));
// Tell renderers about the new extension, unless it's a theme (renderers // Tell renderers about the loaded extension.
// don't need to know about themes). renderer_helper_->OnExtensionLoaded(*extension);
if (!extension->is_theme()) {
for (content::RenderProcessHost::iterator i(
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
content::RenderProcessHost* host = i.GetCurrentValue();
if (host->GetBrowserContext() == browser_context_) {
// We don't need to include tab permisisons here, since the extension
// was just loaded.
std::vector<ExtensionMsg_Loaded_Params> loaded_extensions(
1, ExtensionMsg_Loaded_Params(extension,
false /* no tab permissions */));
host->Send(
new ExtensionMsg_Loaded(loaded_extensions));
}
}
}
// Tell subsystems that use the EXTENSION_LOADED notification about the new // Tell subsystems that use the EXTENSION_LOADED notification about the new
// extension. // extension.
@ -485,13 +473,8 @@ void CefExtensionSystem::NotifyExtensionUnloaded(
content::Source<content::BrowserContext>(browser_context_), content::Source<content::BrowserContext>(browser_context_),
content::Details<UnloadedExtensionInfo>(&details)); content::Details<UnloadedExtensionInfo>(&details));
for (content::RenderProcessHost::iterator i( // Tell renderers about the unloaded extension.
content::RenderProcessHost::AllHostsIterator()); renderer_helper_->OnExtensionUnloaded(*extension);
!i.IsAtEnd(); i.Advance()) {
content::RenderProcessHost* host = i.GetCurrentValue();
if (host->GetBrowserContext() == browser_context_)
host->Send(new ExtensionMsg_Unloaded(extension->id()));
}
UnregisterExtensionWithRequestContexts(extension->id(), reason); UnregisterExtensionWithRequestContexts(extension->id(), reason);
} }

View File

@ -138,6 +138,10 @@ class CefExtensionSystem : public ExtensionSystem {
// Sets of enabled/disabled/terminated/blacklisted extensions. Not owned. // Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
ExtensionRegistry* registry_; ExtensionRegistry* registry_;
// The associated RendererStartupHelper. Guaranteed to outlive the
// ExtensionSystem, and thus us.
extensions::RendererStartupHelper* renderer_helper_;
// Must be the last member. // Must be the last member.
base::WeakPtrFactory<CefExtensionSystem> weak_ptr_factory_; base::WeakPtrFactory<CefExtensionSystem> weak_ptr_factory_;

View File

@ -44,7 +44,8 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_); CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_);
if (owner_browser->IsWindowless()) { if (owner_browser->IsWindowless()) {
CefWebContentsViewOSR* view_osr = new CefWebContentsViewOSR(false); CefWebContentsViewOSR* view_osr =
new CefWebContentsViewOSR(owner_browser->GetBackgroundColor());
params->view = view_osr; params->view = view_osr;
params->delegate_view = view_osr; params->delegate_view = view_osr;
} }

View File

@ -10,11 +10,17 @@
#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host.h"
CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative( CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative(
const CefWindowInfo& window_info) const CefWindowInfo& window_info,
SkColor background_color)
: window_info_(window_info), : window_info_(window_info),
background_color_(background_color),
windowless_handler_(nullptr) { windowless_handler_(nullptr) {
} }
SkColor CefBrowserPlatformDelegateNative::GetBackgroundColor() const {
return background_color_;
}
void CefBrowserPlatformDelegateNative::WasResized() { void CefBrowserPlatformDelegateNative::WasResized() {
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost(); content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host) if (host)

View File

@ -25,6 +25,7 @@ class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate {
}; };
// CefBrowserPlatformDelegate methods: // CefBrowserPlatformDelegate methods:
SkColor GetBackgroundColor() const override;
void WasResized() override; void WasResized() override;
void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override; void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override;
void SendMouseEvent(const blink::WebMouseEvent& event) override; void SendMouseEvent(const blink::WebMouseEvent& event) override;
@ -39,9 +40,11 @@ class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate {
} }
protected: protected:
explicit CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info); CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info,
SkColor background_color);
CefWindowInfo window_info_; CefWindowInfo window_info_;
const SkColor background_color_;
WindowlessHandler* windowless_handler_; // Not owned by this object. WindowlessHandler* windowless_handler_; // Not owned by this object.
}; };

View File

@ -43,8 +43,9 @@ long GetSystemUptime() {
} // namespace } // namespace
CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux( CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
const CefWindowInfo& window_info) const CefWindowInfo& window_info,
: CefBrowserPlatformDelegateNative(window_info), SkColor background_color)
: CefBrowserPlatformDelegateNative(window_info, background_color),
host_window_created_(false), host_window_created_(false),
window_widget_(nullptr), window_widget_(nullptr),
window_x11_(nullptr) { window_x11_(nullptr) {
@ -82,17 +83,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
// Add a reference that will be released in BrowserDestroyed(). // Add a reference that will be released in BrowserDestroyed().
browser_->AddRef(); browser_->AddRef();
SkColor background_color = SK_ColorWHITE;
const CefSettings& settings = CefContext::Get()->settings();
if (CefColorGetA(settings.background_color) > 0) {
background_color = SkColorSetRGB(
CefColorGetR(settings.background_color),
CefColorGetG(settings.background_color),
CefColorGetB(settings.background_color));
}
CefWindowDelegateView* delegate_view = CefWindowDelegateView* delegate_view =
new CefWindowDelegateView(background_color); new CefWindowDelegateView(GetBackgroundColor());
delegate_view->Init(window_info_.window, delegate_view->Init(window_info_.window,
browser_->web_contents(), browser_->web_contents(),
gfx::Rect(gfx::Point(), rect.size())); gfx::Rect(gfx::Point(), rect.size()));
@ -253,19 +245,19 @@ void CefBrowserPlatformDelegateNativeLinux::HandleExternalProtocol(
void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent( void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
content::NativeWebKeyboardEvent& result, content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const { const CefKeyEvent& key_event) const {
result.windowsKeyCode = key_event.windows_key_code; result.windows_key_code = key_event.windows_key_code;
result.nativeKeyCode = key_event.native_key_code; result.native_key_code = key_event.native_key_code;
result.isSystemKey = key_event.is_system_key ? 1 : 0; result.is_system_key = key_event.is_system_key ? 1 : 0;
switch (key_event.type) { switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN: case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN: case KEYEVENT_KEYDOWN:
result.setType(blink::WebInputEvent::RawKeyDown); result.SetType(blink::WebInputEvent::kRawKeyDown);
break; break;
case KEYEVENT_KEYUP: case KEYEVENT_KEYUP:
result.setType(blink::WebInputEvent::KeyUp); result.SetType(blink::WebInputEvent::kKeyUp);
break; break;
case KEYEVENT_CHAR: case KEYEVENT_CHAR:
result.setType(blink::WebInputEvent::Char); result.SetType(blink::WebInputEvent::kChar);
break; break;
default: default:
NOTREACHED(); NOTREACHED();
@ -273,20 +265,20 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
// Populate DOM values that will be passed to JavaScript handlers via // Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent. // KeyboardEvent.
result.domCode = result.dom_code =
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode( static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
key_event.native_key_code)); key_event.native_key_code));
int keysym = ui::XKeysymForWindowsKeyCode( int keysym = ui::XKeysymForWindowsKeyCode(
static_cast<ui::KeyboardCode>(key_event.windows_key_code), static_cast<ui::KeyboardCode>(key_event.windows_key_code),
!!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN)); !!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
base::char16 ch = ui::GetUnicodeCharacterFromXKeySym(keysym); base::char16 ch = ui::GetUnicodeCharacterFromXKeySym(keysym);
result.domKey = static_cast<int>(ui::XKeySymToDomKey(keysym, ch)); result.dom_key = static_cast<int>(ui::XKeySymToDomKey(keysym, ch));
result.text[0] = key_event.character; result.text[0] = key_event.character;
result.unmodifiedText[0] = key_event.unmodified_character; result.unmodified_text[0] = key_event.unmodified_character;
result.setModifiers( result.SetModifiers(
result.modifiers() | TranslateModifiers(key_event.modifiers)); result.GetModifiers() | TranslateModifiers(key_event.modifiers));
} }
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent( void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
@ -298,25 +290,25 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
switch (type) { switch (type) {
case MBT_LEFT: case MBT_LEFT:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
break; break;
case MBT_MIDDLE: case MBT_MIDDLE:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
break; break;
case MBT_RIGHT: case MBT_RIGHT:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
break; break;
default: default:
NOTREACHED(); NOTREACHED();
} }
result.clickCount = clickCount; result.click_count = clickCount;
} }
void CefBrowserPlatformDelegateNativeLinux::TranslateMoveEvent( void CefBrowserPlatformDelegateNativeLinux::TranslateMoveEvent(
@ -326,21 +318,21 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMoveEvent(
TranslateMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
if (!mouseLeave) { if (!mouseLeave) {
result.setType(blink::WebInputEvent::MouseMove); result.SetType(blink::WebInputEvent::kMouseMove);
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
else else
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} else { } else {
result.setType(blink::WebInputEvent::MouseLeave); result.SetType(blink::WebInputEvent::kMouseLeave);
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} }
result.clickCount = 0; result.click_count = 0;
} }
void CefBrowserPlatformDelegateNativeLinux::TranslateWheelEvent( void CefBrowserPlatformDelegateNativeLinux::TranslateWheelEvent(
@ -350,28 +342,28 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateWheelEvent(
result = blink::WebMouseWheelEvent(); result = blink::WebMouseWheelEvent();
TranslateMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
result.setType(blink::WebInputEvent::MouseWheel); result.SetType(blink::WebInputEvent::kMouseWheel);
static const double scrollbarPixelsPerGtkTick = 40.0; static const double scrollbarPixelsPerGtkTick = 40.0;
result.deltaX = deltaX; result.delta_x = deltaX;
result.deltaY = deltaY; result.delta_y = deltaY;
result.wheelTicksX = result.deltaX / scrollbarPixelsPerGtkTick; result.wheel_ticks_x = deltaX / scrollbarPixelsPerGtkTick;
result.wheelTicksY = result.deltaY / scrollbarPixelsPerGtkTick; result.wheel_ticks_y = deltaY / scrollbarPixelsPerGtkTick;
result.hasPreciseScrollingDeltas = true; result.has_precise_scrolling_deltas = true;
// Unless the phase and momentumPhase are passed in as parameters to this // Unless the phase and momentumPhase are passed in as parameters to this
// function, there is no way to know them // function, there is no way to know them
result.phase = blink::WebMouseWheelEvent::PhaseNone; result.phase = blink::WebMouseWheelEvent::kPhaseNone;
result.momentumPhase = blink::WebMouseWheelEvent::PhaseNone; result.momentum_phase = blink::WebMouseWheelEvent::kPhaseNone;
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
else else
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} }
CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle( CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
@ -390,20 +382,17 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMouseEvent(
blink::WebMouseEvent& result, blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const { const CefMouseEvent& mouse_event) const {
// position // position
result.x = mouse_event.x; result.SetPositionInWidget(mouse_event.x, mouse_event.y);
result.y = mouse_event.y;
result.windowX = result.x;
result.windowY = result.y;
const gfx::Point& screen_pt = GetScreenPoint(gfx::Point(result.x, result.y)); const gfx::Point& screen_pt =
result.globalX = screen_pt.x(); GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y));
result.globalY = screen_pt.y(); result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
// modifiers // modifiers
result.setModifiers( result.SetModifiers(
result.modifiers() | TranslateModifiers(mouse_event.modifiers)); result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
// timestamp // timestamp
result.setTimeStampSeconds(GetSystemUptime()); result.SetTimeStampSeconds(GetSystemUptime());
} }

View File

@ -13,8 +13,8 @@ class CefWindowX11;
class CefBrowserPlatformDelegateNativeLinux : class CefBrowserPlatformDelegateNativeLinux :
public CefBrowserPlatformDelegateNative { public CefBrowserPlatformDelegateNative {
public: public:
explicit CefBrowserPlatformDelegateNativeLinux( CefBrowserPlatformDelegateNativeLinux(const CefWindowInfo& window_info,
const CefWindowInfo& window_info); SkColor background_color);
// CefBrowserPlatformDelegate methods: // CefBrowserPlatformDelegate methods:
void BrowserDestroyed(CefBrowserHostImpl* browser) override; void BrowserDestroyed(CefBrowserHostImpl* browser) override;

View File

@ -11,8 +11,8 @@
class CefBrowserPlatformDelegateNativeMac : class CefBrowserPlatformDelegateNativeMac :
public CefBrowserPlatformDelegateNative { public CefBrowserPlatformDelegateNative {
public: public:
explicit CefBrowserPlatformDelegateNativeMac( CefBrowserPlatformDelegateNativeMac(const CefWindowInfo& window_info,
const CefWindowInfo& window_info); SkColor background_color);
// CefBrowserPlatformDelegate methods: // CefBrowserPlatformDelegate methods:
void BrowserDestroyed(CefBrowserHostImpl* browser) override; void BrowserDestroyed(CefBrowserHostImpl* browser) override;
@ -40,7 +40,8 @@ class CefBrowserPlatformDelegateNativeMac :
CefEventHandle GetEventHandle( CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override; const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override; std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner() override; std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override; std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
private: private:

View File

@ -141,8 +141,9 @@ NSUInteger NativeModifiers(int cef_modifiers) {
} // namespace } // namespace
CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac( CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac(
const CefWindowInfo& window_info) const CefWindowInfo& window_info,
: CefBrowserPlatformDelegateNative(window_info), SkColor background_color)
: CefBrowserPlatformDelegateNative(window_info, background_color),
host_window_created_(false) { host_window_created_(false) {
} }
@ -347,9 +348,9 @@ void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
result = content::NativeWebKeyboardEvent(synthetic_event); result = content::NativeWebKeyboardEvent(synthetic_event);
if (key_event.type == KEYEVENT_CHAR) if (key_event.type == KEYEVENT_CHAR)
result.setType(blink::WebInputEvent::Char); result.SetType(blink::WebInputEvent::kChar);
result.isSystemKey = key_event.is_system_key; result.is_system_key = key_event.is_system_key;
} }
void CefBrowserPlatformDelegateNativeMac::TranslateClickEvent( void CefBrowserPlatformDelegateNativeMac::TranslateClickEvent(
@ -361,25 +362,25 @@ void CefBrowserPlatformDelegateNativeMac::TranslateClickEvent(
switch (type) { switch (type) {
case MBT_LEFT: case MBT_LEFT:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
break; break;
case MBT_MIDDLE: case MBT_MIDDLE:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
break; break;
case MBT_RIGHT: case MBT_RIGHT:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
break; break;
default: default:
NOTREACHED(); NOTREACHED();
} }
result.clickCount = clickCount; result.click_count = clickCount;
} }
void CefBrowserPlatformDelegateNativeMac::TranslateMoveEvent( void CefBrowserPlatformDelegateNativeMac::TranslateMoveEvent(
@ -389,21 +390,21 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMoveEvent(
TranslateMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
if (!mouseLeave) { if (!mouseLeave) {
result.setType(blink::WebInputEvent::MouseMove); result.SetType(blink::WebInputEvent::kMouseMove);
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
else else
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} else { } else {
result.setType(blink::WebInputEvent::MouseLeave); result.SetType(blink::WebInputEvent::kMouseLeave);
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} }
result.clickCount = 0; result.click_count = 0;
} }
void CefBrowserPlatformDelegateNativeMac::TranslateWheelEvent( void CefBrowserPlatformDelegateNativeMac::TranslateWheelEvent(
@ -413,28 +414,28 @@ void CefBrowserPlatformDelegateNativeMac::TranslateWheelEvent(
result = blink::WebMouseWheelEvent(); result = blink::WebMouseWheelEvent();
TranslateMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
result.setType(blink::WebInputEvent::MouseWheel); result.SetType(blink::WebInputEvent::kMouseWheel);
static const double scrollbarPixelsPerCocoaTick = 40.0; static const double scrollbarPixelsPerCocoaTick = 40.0;
result.deltaX = deltaX; result.delta_y = deltaX;
result.deltaY = deltaY; result.delta_y = deltaY;
result.wheelTicksX = result.deltaX / scrollbarPixelsPerCocoaTick; result.wheel_ticks_x = deltaX / scrollbarPixelsPerCocoaTick;
result.wheelTicksY = result.deltaY / scrollbarPixelsPerCocoaTick; result.wheel_ticks_y = deltaY / scrollbarPixelsPerCocoaTick;
result.hasPreciseScrollingDeltas = true; result.has_precise_scrolling_deltas = true;
// Unless the phase and momentumPhase are passed in as parameters to this // Unless the phase and momentumPhase are passed in as parameters to this
// function, there is no way to know them // function, there is no way to know them
result.phase = blink::WebMouseWheelEvent::PhaseNone; result.phase = blink::WebMouseWheelEvent::kPhaseNone;
result.momentumPhase = blink::WebMouseWheelEvent::PhaseNone; result.momentum_phase = blink::WebMouseWheelEvent::kPhaseNone;
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
else else
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} }
CefEventHandle CefBrowserPlatformDelegateNativeMac::GetEventHandle( CefEventHandle CefBrowserPlatformDelegateNativeMac::GetEventHandle(
@ -461,20 +462,17 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMouseEvent(
blink::WebMouseEvent& result, blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const { const CefMouseEvent& mouse_event) const {
// position // position
result.x = mouse_event.x; result.SetPositionInWidget(mouse_event.x, mouse_event.y);
result.y = mouse_event.y;
result.windowX = result.x;
result.windowY = result.y;
const gfx::Point& screen_pt = GetScreenPoint(gfx::Point(result.x, result.y)); const gfx::Point& screen_pt =
result.globalX = screen_pt.x(); GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y));
result.globalY = screen_pt.y(); result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
// modifiers // modifiers
result.setModifiers( result.SetModifiers(
result.modifiers() | TranslateModifiers(mouse_event.modifiers)); result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
// timestamp - Mac OSX specific // timestamp - Mac OSX specific
result.setTimeStampSeconds(currentEventTimestamp()); result.SetTimeStampSeconds(currentEventTimestamp());
} }

View File

@ -115,8 +115,9 @@ WORD KeyStatesToWord() {
} // namespace } // namespace
CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin( CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
const CefWindowInfo& window_info) const CefWindowInfo& window_info,
: CefBrowserPlatformDelegateNative(window_info), SkColor background_color)
: CefBrowserPlatformDelegateNative(window_info, background_color),
host_window_created_(false), host_window_created_(false),
window_widget_(nullptr) { window_widget_(nullptr) {
} }
@ -163,15 +164,6 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
DCHECK(!window_widget_); DCHECK(!window_widget_);
SkColor background_color = SK_ColorWHITE;
const CefSettings& settings = CefContext::Get()->settings();
if (CefColorGetA(settings.background_color) > 0) {
background_color = SkColorSetRGB(
CefColorGetR(settings.background_color),
CefColorGetG(settings.background_color),
CefColorGetB(settings.background_color));
}
// Adjust for potential display scaling. // Adjust for potential display scaling.
gfx::Point point = gfx::Point(cr.right, cr.bottom); gfx::Point point = gfx::Point(cr.right, cr.bottom);
float scale = display::Screen::GetScreen()-> float scale = display::Screen::GetScreen()->
@ -180,7 +172,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
gfx::ScalePoint(gfx::PointF(point), 1.0f / scale)); gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
CefWindowDelegateView* delegate_view = CefWindowDelegateView* delegate_view =
new CefWindowDelegateView(background_color); new CefWindowDelegateView(GetBackgroundColor());
delegate_view->Init(window_info_.window, delegate_view->Init(window_info_.window,
browser_->web_contents(), browser_->web_contents(),
gfx::Rect(0, 0, point.x(), point.y())); gfx::Rect(0, 0, point.x(), point.y()));
@ -331,27 +323,27 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
if (!msg.hwnd) if (!msg.hwnd)
return; return;
switch (event.type()) { switch (event.GetType()) {
case blink::WebInputEvent::RawKeyDown: case blink::WebInputEvent::kRawKeyDown:
msg.message = event.isSystemKey ? WM_SYSKEYDOWN : WM_KEYDOWN; msg.message = event.is_system_key ? WM_SYSKEYDOWN : WM_KEYDOWN;
break; break;
case blink::WebInputEvent::KeyUp: case blink::WebInputEvent::kKeyUp:
msg.message = event.isSystemKey ? WM_SYSKEYUP : WM_KEYUP; msg.message = event.is_system_key ? WM_SYSKEYUP : WM_KEYUP;
break; break;
case blink::WebInputEvent::Char: case blink::WebInputEvent::kChar:
msg.message = event.isSystemKey ? WM_SYSCHAR: WM_CHAR; msg.message = event.is_system_key ? WM_SYSCHAR: WM_CHAR;
break; break;
default: default:
NOTREACHED(); NOTREACHED();
return; return;
} }
msg.wParam = event.windowsKeyCode; msg.wParam = event.windows_key_code;
UINT scan_code = ::MapVirtualKeyW(event.windowsKeyCode, MAPVK_VK_TO_VSC); UINT scan_code = ::MapVirtualKeyW(event.windows_key_code, MAPVK_VK_TO_VSC);
msg.lParam = (scan_code << 16) | // key scan code msg.lParam = (scan_code << 16) | // key scan code
1; // key repeat count 1; // key repeat count
if (event.modifiers() & content::NativeWebKeyboardEvent::AltKey) if (event.GetModifiers() & content::NativeWebKeyboardEvent::kAltKey)
msg.lParam |= (1 << 29); msg.lParam |= (1 << 29);
DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam); DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
@ -368,19 +360,19 @@ void CefBrowserPlatformDelegateNativeWin::HandleExternalProtocol(
void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent( void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
content::NativeWebKeyboardEvent& result, content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const { const CefKeyEvent& key_event) const {
result.windowsKeyCode = key_event.windows_key_code; result.windows_key_code = key_event.windows_key_code;
result.nativeKeyCode = key_event.native_key_code; result.native_key_code = key_event.native_key_code;
result.isSystemKey = key_event.is_system_key ? 1 : 0; result.is_system_key = key_event.is_system_key ? 1 : 0;
switch (key_event.type) { switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN: case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN: case KEYEVENT_KEYDOWN:
result.setType(blink::WebInputEvent::RawKeyDown); result.SetType(blink::WebInputEvent::kRawKeyDown);
break; break;
case KEYEVENT_KEYUP: case KEYEVENT_KEYUP:
result.setType(blink::WebInputEvent::KeyUp); result.SetType(blink::WebInputEvent::kKeyUp);
break; break;
case KEYEVENT_CHAR: case KEYEVENT_CHAR:
result.setType(blink::WebInputEvent::Char); result.SetType(blink::WebInputEvent::kChar);
break; break;
default: default:
NOTREACHED(); NOTREACHED();
@ -388,27 +380,27 @@ void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
// Populate DOM values that will be passed to JavaScript handlers via // Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent. // KeyboardEvent.
result.domCode = result.dom_code =
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode( static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
key_event.native_key_code)); key_event.native_key_code));
if (result.type() == blink::WebInputEvent::Char) { if (result.GetType() == blink::WebInputEvent::kChar) {
result.domKey = ui::DomKey::FromCharacter(key_event.windows_key_code); result.dom_key = ui::DomKey::FromCharacter(key_event.windows_key_code);
} else { } else {
// TODO(cef): CefKeyEvent does not currently pass extended key status (see // TODO(cef): CefKeyEvent does not currently pass extended key status (see
// WM_KEYDOWN docs) which would be necessary to pass EF_IS_EXTENDED_KEY as // WM_KEYDOWN docs) which would be necessary to pass EF_IS_EXTENDED_KEY as
// the |flags| parameter to DomKeyFromKeyboardCode(). // the |flags| parameter to DomKeyFromKeyboardCode().
result.domKey = ui::PlatformKeyMap::DomKeyFromKeyboardCode( result.dom_key = ui::PlatformKeyMap::DomKeyFromKeyboardCode(
ui::KeyboardCodeForWindowsKeyCode(key_event.windows_key_code), 0); ui::KeyboardCodeForWindowsKeyCode(key_event.windows_key_code), 0);
} }
if (result.type() == blink::WebInputEvent::Char || if (result.GetType() == blink::WebInputEvent::kChar ||
result.type() == blink::WebInputEvent::RawKeyDown) { result.GetType() == blink::WebInputEvent::kRawKeyDown) {
result.text[0] = result.windowsKeyCode; result.text[0] = result.windows_key_code;
result.unmodifiedText[0] = result.windowsKeyCode; result.unmodified_text[0] = result.windows_key_code;
} }
result.setModifiers( result.SetModifiers(
result.modifiers() | TranslateModifiers(key_event.modifiers)); result.GetModifiers() | TranslateModifiers(key_event.modifiers));
} }
void CefBrowserPlatformDelegateNativeWin::TranslateClickEvent( void CefBrowserPlatformDelegateNativeWin::TranslateClickEvent(
@ -420,25 +412,25 @@ void CefBrowserPlatformDelegateNativeWin::TranslateClickEvent(
switch (type) { switch (type) {
case MBT_LEFT: case MBT_LEFT:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
break; break;
case MBT_MIDDLE: case MBT_MIDDLE:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
break; break;
case MBT_RIGHT: case MBT_RIGHT:
result.setType(mouseUp ? blink::WebInputEvent::MouseUp : result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
blink::WebInputEvent::MouseDown); blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
break; break;
default: default:
NOTREACHED(); NOTREACHED();
} }
result.clickCount = clickCount; result.click_count = clickCount;
} }
void CefBrowserPlatformDelegateNativeWin::TranslateMoveEvent( void CefBrowserPlatformDelegateNativeWin::TranslateMoveEvent(
@ -448,21 +440,21 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMoveEvent(
TranslateMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
if (!mouseLeave) { if (!mouseLeave) {
result.setType(blink::WebInputEvent::MouseMove); result.SetType(blink::WebInputEvent::kMouseMove);
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Left; result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Middle; result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::Right; result.button = blink::WebMouseEvent::Button::kRight;
else else
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} else { } else {
result.setType(blink::WebInputEvent::MouseLeave); result.SetType(blink::WebInputEvent::kMouseLeave);
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
} }
result.clickCount = 0; result.click_count = 0;
} }
void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent( void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent(
@ -471,8 +463,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent(
int deltaX, int deltaY) const { int deltaX, int deltaY) const {
TranslateMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
result.setType(blink::WebInputEvent::MouseWheel); result.SetType(blink::WebInputEvent::kMouseWheel);
result.button = blink::WebMouseEvent::Button::NoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
float wheelDelta; float wheelDelta;
bool horizontalScroll = false; bool horizontalScroll = false;
@ -494,19 +486,19 @@ void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent(
ULONG scrollLines = defaultScrollLinesPerWheelDelta; ULONG scrollLines = defaultScrollLinesPerWheelDelta;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
if (scrollLines == WHEEL_PAGESCROLL) if (scrollLines == WHEEL_PAGESCROLL)
result.scrollByPage = true; result.scroll_by_page = true;
if (!result.scrollByPage) if (!result.scroll_by_page)
scrollDelta *= static_cast<FLOAT>(scrollLines) * scrollbarPixelsPerLine; scrollDelta *= static_cast<FLOAT>(scrollLines) * scrollbarPixelsPerLine;
} }
// Set scroll amount based on above calculations. WebKit expects positive // Set scroll amount based on above calculations. WebKit expects positive
// deltaY to mean "scroll up" and positive deltaX to mean "scroll left". // deltaY to mean "scroll up" and positive deltaX to mean "scroll left".
if (horizontalScroll) { if (horizontalScroll) {
result.deltaX = scrollDelta; result.delta_x = scrollDelta;
result.wheelTicksX = wheelDelta; result.wheel_ticks_x = wheelDelta;
} else { } else {
result.deltaY = scrollDelta; result.delta_y = scrollDelta;
result.wheelTicksY = wheelDelta; result.wheel_ticks_y = wheelDelta;
} }
} }
@ -536,21 +528,18 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMouseEvent(
blink::WebMouseEvent& result, blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const { const CefMouseEvent& mouse_event) const {
// position // position
result.x = mouse_event.x; result.SetPositionInWidget(mouse_event.x, mouse_event.y);
result.y = mouse_event.y;
result.windowX = result.x;
result.windowY = result.y;
const gfx::Point& screen_pt = GetScreenPoint(gfx::Point(result.x, result.y)); const gfx::Point& screen_pt =
result.globalX = screen_pt.x(); GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y));
result.globalY = screen_pt.y(); result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
// modifiers // modifiers
result.setModifiers( result.SetModifiers(
result.modifiers() | TranslateModifiers(mouse_event.modifiers)); result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
// timestamp // timestamp
result.setTimeStampSeconds(GetMessageTime() / 1000.0); result.SetTimeStampSeconds(GetMessageTime() / 1000.0);
} }
// static // static

View File

@ -13,8 +13,8 @@
class CefBrowserPlatformDelegateNativeWin : class CefBrowserPlatformDelegateNativeWin :
public CefBrowserPlatformDelegateNative { public CefBrowserPlatformDelegateNative {
public: public:
explicit CefBrowserPlatformDelegateNativeWin( CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info,
const CefWindowInfo& window_info); SkColor background_color);
// CefBrowserPlatformDelegate methods: // CefBrowserPlatformDelegate methods:
void BrowserDestroyed(CefBrowserHostImpl* browser) override; void BrowserDestroyed(CefBrowserHostImpl* browser) override;

View File

@ -289,10 +289,11 @@ class CefNativeMenuWin::MenuHostWindow {
// We currently don't support items with both icons and checkboxes. // We currently don't support items with both icons and checkboxes.
const gfx::ImageSkia skia_icon = icon.AsImageSkia(); const gfx::ImageSkia skia_icon = icon.AsImageSkia();
DCHECK(type != ui::MenuModel::TYPE_CHECK); DCHECK(type != ui::MenuModel::TYPE_CHECK);
gfx::Canvas canvas(skia_icon.size(), 1.0f, false); std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas(
canvas.DrawImageInt(skia_icon, 0, 0); skia_icon.width(), skia_icon.height(), false);
canvas->drawBitmap(*skia_icon.bitmap(), 0, 0);
DrawToNativeContext( DrawToNativeContext(
canvas.sk_canvas(), dc, canvas.get(), dc,
draw_item_struct->rcItem.left + kItemLeftMargin, draw_item_struct->rcItem.left + kItemLeftMargin,
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
draw_item_struct->rcItem.top - skia_icon.height()) / 2, NULL); draw_item_struct->rcItem.top - skia_icon.height()) / 2, NULL);
@ -308,9 +309,11 @@ class CefNativeMenuWin::MenuHostWindow {
state = draw_item_struct->itemState & ODS_SELECTED ? state = draw_item_struct->itemState & ODS_SELECTED ?
NativeTheme::kHovered : NativeTheme::kNormal; NativeTheme::kHovered : NativeTheme::kNormal;
} }
gfx::Canvas canvas(gfx::Size(config.check_width, config.check_height),
1.0f, std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas(
false); config.check_width, config.check_height, false);
cc::SkiaPaintCanvas paint_canvas(canvas.get());
NativeTheme::ExtraParams extra; NativeTheme::ExtraParams extra;
extra.menu_check.is_radio = false; extra.menu_check.is_radio = false;
gfx::Rect bounds(0, 0, config.check_width, config.check_height); gfx::Rect bounds(0, 0, config.check_width, config.check_height);
@ -319,13 +322,13 @@ class CefNativeMenuWin::MenuHostWindow {
ui::NativeTheme* native_theme = ui::NativeTheme* native_theme =
ui::NativeTheme::GetInstanceForNativeUi(); ui::NativeTheme::GetInstanceForNativeUi();
native_theme->Paint( native_theme->Paint(
canvas.sk_canvas(), NativeTheme::kMenuCheckBackground, &paint_canvas, NativeTheme::kMenuCheckBackground,
state, bounds, extra); state, bounds, extra);
native_theme->Paint( native_theme->Paint(
canvas.sk_canvas(), NativeTheme::kMenuCheck, state, bounds, extra); &paint_canvas, NativeTheme::kMenuCheck, state, bounds, extra);
// Draw checkbox to menu. // Draw checkbox to menu.
DrawToNativeContext(canvas.sk_canvas(), dc, DrawToNativeContext(canvas.get(), dc,
draw_item_struct->rcItem.left + kItemLeftMargin, draw_item_struct->rcItem.left + kItemLeftMargin,
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
draw_item_struct->rcItem.top - config.check_height) / 2, NULL); draw_item_struct->rcItem.top - config.check_height) / 2, NULL);

View File

@ -295,7 +295,7 @@ class CefWebUIControllerFactory : public content::WebUIControllerFactory {
~CefWebUIControllerFactory() override {} ~CefWebUIControllerFactory() override {}
private: private:
friend struct base::DefaultLazyInstanceTraits<CefWebUIControllerFactory>; friend struct base::LazyInstanceTraitsBase<CefWebUIControllerFactory>;
// From chrome/browser/chrome_content_browser_client.cc // From chrome/browser/chrome_content_browser_client.cc

View File

@ -116,16 +116,18 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
std::unique_ptr<net::ProxyConfigService> proxy_config_service, std::unique_ptr<net::ProxyConfigService> proxy_config_service,
content::URLRequestInterceptorScopedVector request_interceptors) content::URLRequestInterceptorScopedVector request_interceptors)
: settings_(settings), : settings_(settings),
net_log_(g_browser_process->net_log()), io_state_(base::MakeUnique<IOState>()) {
io_task_runner_(std::move(io_task_runner)),
file_task_runner_(std::move(file_task_runner)),
proxy_config_service_(std::move(proxy_config_service)),
request_interceptors_(std::move(request_interceptors)) {
// Must first be created on the UI thread. // Must first be created on the UI thread.
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(net_log_);
std::swap(protocol_handlers_, *protocol_handlers); io_state_->net_log_ = g_browser_process->net_log(),
DCHECK(io_state_->net_log_);
io_state_->io_task_runner_ = std::move(io_task_runner);
io_state_->file_task_runner_ = std::move(file_task_runner);
io_state_->proxy_config_service_ = std::move(proxy_config_service);
io_state_->request_interceptors_ = std::move(request_interceptors);
std::swap(io_state_->protocol_handlers_, *protocol_handlers);
auto io_thread_proxy = auto io_thread_proxy =
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
@ -141,7 +143,8 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
force_google_safesearch_.MoveToThread(io_thread_proxy); force_google_safesearch_.MoveToThread(io_thread_proxy);
#if defined(OS_POSIX) && !defined(OS_ANDROID) #if defined(OS_POSIX) && !defined(OS_ANDROID)
gsapi_library_name_ = pref_service->GetString(prefs::kGSSAPILibraryName); io_state_->gsapi_library_name_ =
pref_service->GetString(prefs::kGSSAPILibraryName);
#endif #endif
auth_server_whitelist_.Init( auth_server_whitelist_.Init(
@ -159,11 +162,8 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() { CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
// This destructor may not be called during shutdown. Perform any required
// Delete the ProxyService object here so that any pending requests will be // shutdown in ShutdownOnIOThread() instead.
// canceled before the associated URLRequestContext is destroyed in this
// object's destructor.
storage_->set_proxy_service(NULL);
} }
// static // static
@ -187,12 +187,32 @@ void CefURLRequestContextGetterImpl::ShutdownOnUIThread() {
force_google_safesearch_.Destroy(); force_google_safesearch_.Destroy();
auth_server_whitelist_.Destroy(); auth_server_whitelist_.Destroy();
auth_negotiate_delegate_whitelist_.Destroy(); auth_negotiate_delegate_whitelist_.Destroy();
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefURLRequestContextGetterImpl::ShutdownOnIOThread, this));
}
void CefURLRequestContextGetterImpl::ShutdownOnIOThread() {
CEF_REQUIRE_IOT();
shutting_down_ = true;
// Delete the ProxyService object here so that any pending requests will be
// canceled before the URLRequestContext is destroyed.
io_state_->storage_->set_proxy_service(NULL);
io_state_.reset();
NotifyContextShuttingDown();
} }
net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() { net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (!url_request_context_.get()) { if (shutting_down_)
return nullptr;
if (!io_state_->url_request_context_.get()) {
const base::CommandLine* command_line = const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
@ -200,11 +220,11 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
if (settings_.cache_path.length > 0) if (settings_.cache_path.length > 0)
cache_path = base::FilePath(CefString(&settings_.cache_path)); cache_path = base::FilePath(CefString(&settings_.cache_path));
url_request_context_.reset(new CefURLRequestContextImpl()); io_state_->url_request_context_.reset(new CefURLRequestContextImpl());
url_request_context_->set_net_log(net_log_); io_state_->url_request_context_->set_net_log(io_state_->net_log_);
storage_.reset( io_state_->storage_.reset(new net::URLRequestContextStorage(
new net::URLRequestContextStorage(url_request_context_.get())); io_state_->url_request_context_.get()));
SetCookieStoragePath(cache_path, SetCookieStoragePath(cache_path,
settings_.persist_session_cookies ? true : false); settings_.persist_session_cookies ? true : false);
@ -212,49 +232,51 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
std::unique_ptr<CefNetworkDelegate> network_delegate( std::unique_ptr<CefNetworkDelegate> network_delegate(
new CefNetworkDelegate()); new CefNetworkDelegate());
network_delegate->set_force_google_safesearch(&force_google_safesearch_); network_delegate->set_force_google_safesearch(&force_google_safesearch_);
storage_->set_network_delegate(std::move(network_delegate)); io_state_->storage_->set_network_delegate(std::move(network_delegate));
const std::string& accept_language = const std::string& accept_language =
settings_.accept_language_list.length > 0 ? settings_.accept_language_list.length > 0 ?
CefString(&settings_.accept_language_list): "en-US,en"; CefString(&settings_.accept_language_list): "en-US,en";
storage_->set_http_user_agent_settings(base::WrapUnique( io_state_->storage_->set_http_user_agent_settings(base::WrapUnique(
new CefHttpUserAgentSettings(accept_language))); new CefHttpUserAgentSettings(accept_language)));
storage_->set_host_resolver( io_state_->storage_->set_host_resolver(
net::HostResolver::CreateDefaultResolver(net_log_)); net::HostResolver::CreateDefaultResolver(io_state_->net_log_));
storage_->set_cert_verifier(net::CertVerifier::CreateDefault()); io_state_->storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
std::unique_ptr<net::TransportSecurityState> transport_security_state( std::unique_ptr<net::TransportSecurityState> transport_security_state(
new net::TransportSecurityState); new net::TransportSecurityState);
transport_security_state->set_enforce_net_security_expiration( transport_security_state->set_enforce_net_security_expiration(
settings_.enable_net_security_expiration ? true : false); settings_.enable_net_security_expiration ? true : false);
storage_->set_transport_security_state(std::move(transport_security_state)); io_state_->storage_->set_transport_security_state(
std::move(transport_security_state));
std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs(
net::ct::CreateLogVerifiersForKnownLogs()); net::ct::CreateLogVerifiersForKnownLogs());
std::unique_ptr<net::MultiLogCTVerifier> ct_verifier( std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(
new net::MultiLogCTVerifier()); new net::MultiLogCTVerifier());
ct_verifier->AddLogs(ct_logs); ct_verifier->AddLogs(ct_logs);
storage_->set_cert_transparency_verifier(std::move(ct_verifier)); io_state_->storage_->set_cert_transparency_verifier(std::move(ct_verifier));
std::unique_ptr<net::CTPolicyEnforcer> ct_policy_enforcer( std::unique_ptr<net::CTPolicyEnforcer> ct_policy_enforcer(
new net::CTPolicyEnforcer); new net::CTPolicyEnforcer);
ct_policy_enforcer->set_enforce_net_security_expiration( ct_policy_enforcer->set_enforce_net_security_expiration(
settings_.enable_net_security_expiration ? true : false); settings_.enable_net_security_expiration ? true : false);
storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer)); io_state_->storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer));
std::unique_ptr<net::ProxyService> system_proxy_service = std::unique_ptr<net::ProxyService> system_proxy_service =
ProxyServiceFactory::CreateProxyService( ProxyServiceFactory::CreateProxyService(
net_log_, io_state_->net_log_,
url_request_context_.get(), io_state_->url_request_context_.get(),
url_request_context_->network_delegate(), io_state_->url_request_context_->network_delegate(),
std::move(proxy_config_service_), std::move(io_state_->proxy_config_service_),
*command_line, *command_line,
quick_check_enabled_.GetValue(), quick_check_enabled_.GetValue(),
pac_https_url_stripping_enabled_.GetValue()); pac_https_url_stripping_enabled_.GetValue());
storage_->set_proxy_service(std::move(system_proxy_service)); io_state_->storage_->set_proxy_service(std::move(system_proxy_service));
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); io_state_->storage_->set_ssl_config_service(
new net::SSLConfigServiceDefaults);
std::vector<std::string> supported_schemes; std::vector<std::string> supported_schemes;
supported_schemes.push_back("basic"); supported_schemes.push_back("basic");
@ -262,18 +284,18 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
supported_schemes.push_back("ntlm"); supported_schemes.push_back("ntlm");
supported_schemes.push_back("negotiate"); supported_schemes.push_back("negotiate");
http_auth_preferences_.reset( io_state_->http_auth_preferences_.reset(
new net::HttpAuthPreferences(supported_schemes new net::HttpAuthPreferences(supported_schemes
#if defined(OS_POSIX) && !defined(OS_ANDROID) #if defined(OS_POSIX) && !defined(OS_ANDROID)
, gsapi_library_name_ , io_state_->gsapi_library_name_
#endif #endif
)); ));
storage_->set_http_auth_handler_factory( io_state_->storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerRegistryFactory::Create( net::HttpAuthHandlerRegistryFactory::Create(
http_auth_preferences_.get(), io_state_->http_auth_preferences_.get(),
url_request_context_->host_resolver())); io_state_->url_request_context_->host_resolver()));
storage_->set_http_server_properties(base::WrapUnique( io_state_->storage_->set_http_server_properties(base::WrapUnique(
new net::HttpServerPropertiesImpl)); new net::HttpServerPropertiesImpl));
base::FilePath http_cache_path; base::FilePath http_cache_path;
@ -294,74 +316,77 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
net::HttpNetworkSession::Params network_session_params; net::HttpNetworkSession::Params network_session_params;
network_session_params.host_resolver = network_session_params.host_resolver =
url_request_context_->host_resolver(); io_state_->url_request_context_->host_resolver();
network_session_params.cert_verifier = network_session_params.cert_verifier =
url_request_context_->cert_verifier(); io_state_->url_request_context_->cert_verifier();
network_session_params.transport_security_state = network_session_params.transport_security_state =
url_request_context_->transport_security_state(); io_state_->url_request_context_->transport_security_state();
network_session_params.cert_transparency_verifier = network_session_params.cert_transparency_verifier =
url_request_context_->cert_transparency_verifier(); io_state_->url_request_context_->cert_transparency_verifier();
network_session_params.ct_policy_enforcer = network_session_params.ct_policy_enforcer =
url_request_context_->ct_policy_enforcer(); io_state_->url_request_context_->ct_policy_enforcer();
network_session_params.proxy_service = network_session_params.proxy_service =
url_request_context_->proxy_service(); io_state_->url_request_context_->proxy_service();
network_session_params.ssl_config_service = network_session_params.ssl_config_service =
url_request_context_->ssl_config_service(); io_state_->url_request_context_->ssl_config_service();
network_session_params.http_auth_handler_factory = network_session_params.http_auth_handler_factory =
url_request_context_->http_auth_handler_factory(); io_state_->url_request_context_->http_auth_handler_factory();
network_session_params.http_server_properties = network_session_params.http_server_properties =
url_request_context_->http_server_properties(); io_state_->url_request_context_->http_server_properties();
network_session_params.ignore_certificate_errors = network_session_params.ignore_certificate_errors =
settings_.ignore_certificate_errors ? true : false; settings_.ignore_certificate_errors ? true : false;
network_session_params.net_log = net_log_; network_session_params.net_log = io_state_->net_log_;
storage_->set_http_network_session( io_state_->storage_->set_http_network_session(
base::WrapUnique(new net::HttpNetworkSession(network_session_params))); base::WrapUnique(new net::HttpNetworkSession(network_session_params)));
storage_->set_http_transaction_factory(base::WrapUnique( io_state_->storage_->set_http_transaction_factory(base::WrapUnique(
new net::HttpCache(storage_->http_network_session(), new net::HttpCache(io_state_->storage_->http_network_session(),
std::move(main_backend), std::move(main_backend),
true /* set_up_quic_server_info */))); true /* set_up_quic_server_info */)));
std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory(
new net::URLRequestJobFactoryImpl()); new net::URLRequestJobFactoryImpl());
url_request_manager_.reset(new CefURLRequestManager(job_factory.get())); io_state_->url_request_manager_.reset(
new CefURLRequestManager(job_factory.get()));
// Install internal scheme handlers that cannot be overridden. // Install internal scheme handlers that cannot be overridden.
scheme::InstallInternalProtectedHandlers( scheme::InstallInternalProtectedHandlers(
job_factory.get(), job_factory.get(),
url_request_manager_.get(), io_state_->url_request_manager_.get(),
&protocol_handlers_, &io_state_->protocol_handlers_,
network_session_params.host_resolver); network_session_params.host_resolver);
protocol_handlers_.clear(); io_state_->protocol_handlers_.clear();
// Register internal scheme handlers that can be overridden. // Register internal scheme handlers that can be overridden.
scheme::RegisterInternalHandlers(url_request_manager_.get()); scheme::RegisterInternalHandlers(io_state_->url_request_manager_.get());
request_interceptors_.push_back(base::MakeUnique<CefRequestInterceptor>()); io_state_->request_interceptors_.push_back(
base::MakeUnique<CefRequestInterceptor>());
// Set up interceptors in the reverse order. // Set up interceptors in the reverse order.
std::unique_ptr<net::URLRequestJobFactory> top_job_factory = std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
std::move(job_factory); std::move(job_factory);
for (auto i = request_interceptors_.rbegin(); for (auto i = io_state_->request_interceptors_.rbegin();
i != request_interceptors_.rend(); ++i) { i != io_state_->request_interceptors_.rend(); ++i) {
top_job_factory.reset(new net::URLRequestInterceptingJobFactory( top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
std::move(top_job_factory), std::move(*i))); std::move(top_job_factory), std::move(*i)));
} }
request_interceptors_.clear(); io_state_->request_interceptors_.clear();
storage_->set_job_factory(std::move(top_job_factory)); io_state_->storage_->set_job_factory(std::move(top_job_factory));
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
// Only do this for the first (global) request context. // Only do this for the first (global) request context.
static bool request_context_for_nss_set = false; static bool request_context_for_nss_set = false;
if (!request_context_for_nss_set) { if (!request_context_for_nss_set) {
net::SetURLRequestContextForNSSHttpIO(url_request_context_.get()); net::SetURLRequestContextForNSSHttpIO(
io_state_->url_request_context_.get());
request_context_for_nss_set = true; request_context_for_nss_set = true;
} }
#endif #endif
} }
return url_request_context_.get(); return io_state_->url_request_context_.get();
} }
scoped_refptr<base::SingleThreadTaskRunner> scoped_refptr<base::SingleThreadTaskRunner>
@ -370,7 +395,7 @@ scoped_refptr<base::SingleThreadTaskRunner>
} }
net::HostResolver* CefURLRequestContextGetterImpl::GetHostResolver() const { net::HostResolver* CefURLRequestContextGetterImpl::GetHostResolver() const {
return url_request_context_->host_resolver(); return io_state_->url_request_context_->host_resolver();
} }
void CefURLRequestContextGetterImpl::SetCookieStoragePath( void CefURLRequestContextGetterImpl::SetCookieStoragePath(
@ -378,9 +403,9 @@ void CefURLRequestContextGetterImpl::SetCookieStoragePath(
bool persist_session_cookies) { bool persist_session_cookies) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (url_request_context_->cookie_store() && if (io_state_->url_request_context_->cookie_store() &&
((cookie_store_path_.empty() && path.empty()) || ((io_state_->cookie_store_path_.empty() && path.empty()) ||
cookie_store_path_ == path)) { io_state_->cookie_store_path_ == path)) {
// The path has not changed so don't do anything. // The path has not changed so don't do anything.
return; return;
} }
@ -412,23 +437,23 @@ void CefURLRequestContextGetterImpl::SetCookieStoragePath(
new net::CookieMonster(persistent_store.get(), NULL)); new net::CookieMonster(persistent_store.get(), NULL));
if (persistent_store.get() && persist_session_cookies) if (persistent_store.get() && persist_session_cookies)
cookie_monster->SetPersistSessionCookies(true); cookie_monster->SetPersistSessionCookies(true);
cookie_store_path_ = path; io_state_->cookie_store_path_ = path;
// Restore the previously supported schemes. // Restore the previously supported schemes.
CefCookieManagerImpl::SetCookieMonsterSchemes(cookie_monster.get(), CefCookieManagerImpl::SetCookieMonsterSchemes(
cookie_supported_schemes_); cookie_monster.get(), io_state_->cookie_supported_schemes_);
storage_->set_cookie_store(std::move(cookie_monster)); io_state_->storage_->set_cookie_store(std::move(cookie_monster));
} }
void CefURLRequestContextGetterImpl::SetCookieSupportedSchemes( void CefURLRequestContextGetterImpl::SetCookieSupportedSchemes(
const std::vector<std::string>& schemes) { const std::vector<std::string>& schemes) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
cookie_supported_schemes_ = schemes; io_state_->cookie_supported_schemes_ = schemes;
CefCookieManagerImpl::SetCookieMonsterSchemes( CefCookieManagerImpl::SetCookieMonsterSchemes(
static_cast<net::CookieMonster*>(GetExistingCookieStore()), static_cast<net::CookieMonster*>(GetExistingCookieStore()),
cookie_supported_schemes_); io_state_->cookie_supported_schemes_);
} }
void CefURLRequestContextGetterImpl::AddHandler( void CefURLRequestContextGetterImpl::AddHandler(
@ -438,34 +463,36 @@ void CefURLRequestContextGetterImpl::AddHandler(
base::Bind(&CefURLRequestContextGetterImpl::AddHandler, this, handler)); base::Bind(&CefURLRequestContextGetterImpl::AddHandler, this, handler));
return; return;
} }
handler_list_.push_back(handler); io_state_->handler_list_.push_back(handler);
} }
net::CookieStore* net::CookieStore*
CefURLRequestContextGetterImpl::GetExistingCookieStore() const { CefURLRequestContextGetterImpl::GetExistingCookieStore() const {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (url_request_context_ && url_request_context_->cookie_store()) if (io_state_->url_request_context_ &&
return url_request_context_->cookie_store(); io_state_->url_request_context_->cookie_store()) {
return io_state_->url_request_context_->cookie_store();
}
LOG(ERROR) << "Cookie store does not exist"; LOG(ERROR) << "Cookie store does not exist";
return nullptr; return nullptr;
} }
void CefURLRequestContextGetterImpl::CreateProxyConfigService() { void CefURLRequestContextGetterImpl::CreateProxyConfigService() {
if (proxy_config_service_.get()) if (io_state_->proxy_config_service_.get())
return; return;
proxy_config_service_ = io_state_->proxy_config_service_ =
net::ProxyService::CreateSystemProxyConfigService( net::ProxyService::CreateSystemProxyConfigService(
io_task_runner_, file_task_runner_); io_state_->io_task_runner_, io_state_->file_task_runner_);
} }
void CefURLRequestContextGetterImpl::UpdateServerWhitelist() { void CefURLRequestContextGetterImpl::UpdateServerWhitelist() {
http_auth_preferences_->set_server_whitelist( io_state_->http_auth_preferences_->set_server_whitelist(
auth_server_whitelist_.GetValue()); auth_server_whitelist_.GetValue());
} }
void CefURLRequestContextGetterImpl::UpdateDelegateWhitelist() { void CefURLRequestContextGetterImpl::UpdateDelegateWhitelist() {
http_auth_preferences_->set_delegate_whitelist( io_state_->http_auth_preferences_->set_delegate_whitelist(
auth_negotiate_delegate_whitelist_.GetValue()); auth_negotiate_delegate_whitelist_.GetValue());
} }

View File

@ -81,7 +81,7 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
net::CookieStore* GetExistingCookieStore() const; net::CookieStore* GetExistingCookieStore() const;
CefURLRequestManager* request_manager() const { CefURLRequestManager* request_manager() const {
return url_request_manager_.get(); return io_state_->url_request_manager_.get();
} }
private: private:
@ -89,29 +89,38 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
void UpdateServerWhitelist(); void UpdateServerWhitelist();
void UpdateDelegateWhitelist(); void UpdateDelegateWhitelist();
void ShutdownOnIOThread();
const CefRequestContextSettings settings_; const CefRequestContextSettings settings_;
net::NetLog* net_log_; // Guaranteed to outlive this object. bool shutting_down_ = false;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; // State that is only accessed on the IO thread and will be reset in
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; // ShutdownOnIOThread().
struct IOState {
net::NetLog* net_log_ = nullptr; // Guaranteed to outlive this object.
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
#if defined(OS_POSIX) && !defined(OS_ANDROID) #if defined(OS_POSIX) && !defined(OS_ANDROID)
std::string gsapi_library_name_; std::string gsapi_library_name_;
#endif #endif
std::unique_ptr<net::ProxyConfigService> proxy_config_service_; std::unique_ptr<net::ProxyConfigService> proxy_config_service_;
std::unique_ptr<net::URLRequestContextStorage> storage_; std::unique_ptr<net::URLRequestContextStorage> storage_;
std::unique_ptr<net::HttpAuthPreferences> http_auth_preferences_; std::unique_ptr<net::HttpAuthPreferences> http_auth_preferences_;
std::unique_ptr<CefURLRequestContextImpl> url_request_context_; std::unique_ptr<CefURLRequestContextImpl> url_request_context_;
std::unique_ptr<CefURLRequestManager> url_request_manager_; std::unique_ptr<CefURLRequestManager> url_request_manager_;
content::ProtocolHandlerMap protocol_handlers_; content::ProtocolHandlerMap protocol_handlers_;
content::URLRequestInterceptorScopedVector request_interceptors_; content::URLRequestInterceptorScopedVector request_interceptors_;
base::FilePath cookie_store_path_; base::FilePath cookie_store_path_;
std::vector<std::string> cookie_supported_schemes_; std::vector<std::string> cookie_supported_schemes_;
std::vector<CefRefPtr<CefRequestContextHandler> > handler_list_; std::vector<CefRefPtr<CefRequestContextHandler> > handler_list_;
};
std::unique_ptr<IOState> io_state_;
BooleanPrefMember quick_check_enabled_; BooleanPrefMember quick_check_enabled_;
BooleanPrefMember pac_https_url_stripping_enabled_; BooleanPrefMember pac_https_url_stripping_enabled_;

View File

@ -21,9 +21,26 @@ CefURLRequestContextGetterProxy::~CefURLRequestContextGetterProxy() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
} }
void CefURLRequestContextGetterProxy::ShutdownOnUIThread() {
CEF_REQUIRE_UIT();
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefURLRequestContextGetterProxy::ShutdownOnIOThread, this));
}
void CefURLRequestContextGetterProxy::ShutdownOnIOThread() {
CEF_REQUIRE_IOT();
shutting_down_ = true;
context_proxy_.reset();
NotifyContextShuttingDown();
}
net::URLRequestContext* net::URLRequestContext*
CefURLRequestContextGetterProxy::GetURLRequestContext() { CefURLRequestContextGetterProxy::GetURLRequestContext() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (shutting_down_)
return nullptr;
if (!context_proxy_) { if (!context_proxy_) {
context_proxy_.reset( context_proxy_.reset(
new CefURLRequestContextProxy(static_cast<CefURLRequestContextImpl*>( new CefURLRequestContextProxy(static_cast<CefURLRequestContextImpl*>(

View File

@ -24,6 +24,9 @@ class CefURLRequestContextGetterProxy : public CefURLRequestContextGetter {
scoped_refptr<CefURLRequestContextGetterImpl> parent); scoped_refptr<CefURLRequestContextGetterImpl> parent);
~CefURLRequestContextGetterProxy() override; ~CefURLRequestContextGetterProxy() override;
// Called when the StoragePartitionProxy is destroyed.
void ShutdownOnUIThread();
// net::URLRequestContextGetter implementation. // net::URLRequestContextGetter implementation.
net::URLRequestContext* GetURLRequestContext() override; net::URLRequestContext* GetURLRequestContext() override;
scoped_refptr<base::SingleThreadTaskRunner> scoped_refptr<base::SingleThreadTaskRunner>
@ -35,6 +38,8 @@ class CefURLRequestContextGetterProxy : public CefURLRequestContextGetter {
CefRefPtr<CefRequestContextHandler> handler() const { return handler_; } CefRefPtr<CefRequestContextHandler> handler() const { return handler_; }
private: private:
void ShutdownOnIOThread();
CefRefPtr<CefRequestContextHandler> handler_; CefRefPtr<CefRequestContextHandler> handler_;
// The CefURLRequestContextImpl owned by |parent_| is passed as a raw pointer // The CefURLRequestContextImpl owned by |parent_| is passed as a raw pointer
@ -44,6 +49,8 @@ class CefURLRequestContextGetterProxy : public CefURLRequestContextGetter {
std::unique_ptr<CefURLRequestContextProxy> context_proxy_; std::unique_ptr<CefURLRequestContextProxy> context_proxy_;
bool shutting_down_ = false;
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterProxy); DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterProxy);
}; };

View File

@ -150,7 +150,7 @@ class CefOriginWhitelistManager {
DISALLOW_COPY_AND_ASSIGN(CefOriginWhitelistManager); DISALLOW_COPY_AND_ASSIGN(CefOriginWhitelistManager);
}; };
base::LazyInstance<CefOriginWhitelistManager> g_manager = base::LazyInstance<CefOriginWhitelistManager>::Leaky g_manager =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
CefOriginWhitelistManager* CefOriginWhitelistManager::GetInstance() { CefOriginWhitelistManager* CefOriginWhitelistManager::GetInstance() {

View File

@ -28,8 +28,7 @@ void CefBrowserPlatformDelegateOsr::CreateViewForWebContents(
DCHECK(!view_osr_); DCHECK(!view_osr_);
// Use the OSR view instead of the default platform view. // Use the OSR view instead of the default platform view.
view_osr_ = new CefWebContentsViewOSR( view_osr_ = new CefWebContentsViewOSR(GetBackgroundColor());
!!native_delegate_->window_info().transparent_painting_enabled);
*view = view_osr_; *view = view_osr_;
*delegate_view = view_osr_; *delegate_view = view_osr_;
} }
@ -68,6 +67,10 @@ void CefBrowserPlatformDelegateOsr::BrowserDestroyed(
view_osr_ = nullptr; view_osr_ = nullptr;
} }
SkColor CefBrowserPlatformDelegateOsr::GetBackgroundColor() const {
return native_delegate_->GetBackgroundColor();
}
void CefBrowserPlatformDelegateOsr::WasResized() { void CefBrowserPlatformDelegateOsr::WasResized() {
CefRenderWidgetHostViewOSR* view = GetOSRHostView(); CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view) if (view)

View File

@ -27,6 +27,7 @@ class CefBrowserPlatformDelegateOsr :
void WebContentsCreated(content::WebContents* web_contents) override; void WebContentsCreated(content::WebContents* web_contents) override;
void BrowserCreated(CefBrowserHostImpl* browser) override; void BrowserCreated(CefBrowserHostImpl* browser) override;
void BrowserDestroyed(CefBrowserHostImpl* browser) override; void BrowserDestroyed(CefBrowserHostImpl* browser) override;
SkColor GetBackgroundColor() const override;
void WasResized() override; void WasResized() override;
void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override; void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override;
void SendMouseEvent(const blink::WebMouseEvent& event) override; void SendMouseEvent(const blink::WebMouseEvent& event) override;

View File

@ -28,7 +28,6 @@
#include "content/browser/renderer_host/render_widget_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h" #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/resize_lock.h"
#include "content/common/input_messages.h" #include "content/common/input_messages.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
@ -63,73 +62,6 @@ static content::ScreenInfo ScreenInfoFrom(const CefScreenInfo& src) {
return screenInfo; return screenInfo;
} }
#if !defined(OS_MACOSX)
// When accelerated compositing is enabled and a widget resize is pending,
// we delay further resizes of the UI. The following constant is the maximum
// length of time that we should delay further UI resizes while waiting for a
// resized frame from a renderer.
const int kResizeLockTimeoutMs = 67;
// Used to prevent further resizes while a resize is pending.
class CefResizeLock : public content::ResizeLock {
public:
CefResizeLock(CefRenderWidgetHostViewOSR* host,
const gfx::Size new_size,
bool defer_compositor_lock,
double timeout)
: ResizeLock(new_size, defer_compositor_lock),
host_(host),
cancelled_(false),
weak_ptr_factory_(this) {
DCHECK(host_);
host_->HoldResize();
CEF_POST_DELAYED_TASK(
CEF_UIT,
base::Bind(&CefResizeLock::CancelLock,
weak_ptr_factory_.GetWeakPtr()),
timeout);
}
~CefResizeLock() override {
CancelLock();
}
bool GrabDeferredLock() override {
return ResizeLock::GrabDeferredLock();
}
void UnlockCompositor() override {
ResizeLock::UnlockCompositor();
compositor_lock_ = NULL;
}
protected:
void LockCompositor() override {
ResizeLock::LockCompositor();
compositor_lock_ = host_->GetCompositor()->GetCompositorLock();
}
void CancelLock() {
if (cancelled_)
return;
cancelled_ = true;
UnlockCompositor();
host_->ReleaseResize();
}
private:
CefRenderWidgetHostViewOSR* host_;
scoped_refptr<ui::CompositorLock> compositor_lock_;
bool cancelled_;
base::WeakPtrFactory<CefResizeLock> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefResizeLock);
};
#endif // !defined(OS_MACOSX)
} // namespace } // namespace
// Used for managing copy requests when GPU compositing is enabled. Based on // Used for managing copy requests when GPU compositing is enabled. Based on
@ -450,11 +382,11 @@ class CefBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
bool transparent, SkColor background_color,
content::RenderWidgetHost* widget, content::RenderWidgetHost* widget,
CefRenderWidgetHostViewOSR* parent_host_view, CefRenderWidgetHostViewOSR* parent_host_view,
bool is_guest_view_hack) bool is_guest_view_hack)
: transparent_(transparent), : background_color_(background_color),
scale_factor_(kDefaultScaleFactor), scale_factor_(kDefaultScaleFactor),
frame_rate_threshold_ms_(0), frame_rate_threshold_ms_(0),
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
@ -493,6 +425,10 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
PlatformCreateCompositorWidget(is_guest_view_hack); PlatformCreateCompositorWidget(is_guest_view_hack);
bool opaque = SkColorGetA(background_color_) == SK_AlphaOPAQUE;
GetRootLayer()->SetFillsBoundsOpaquely(opaque);
GetRootLayer()->SetColor(background_color_);
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
// On macOS the ui::Compositor is created/owned by the platform view. // On macOS the ui::Compositor is created/owned by the platform view.
content::ImageTransportFactory* factory = content::ImageTransportFactory* factory =
@ -655,14 +591,20 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() const {
} }
void CefRenderWidgetHostViewOSR::SetBackgroundColor(SkColor color) { void CefRenderWidgetHostViewOSR::SetBackgroundColor(SkColor color) {
if (transparent_) // The renderer will feed its color back to us with the first CompositorFrame.
color = SkColorSetARGB(SK_AlphaTRANSPARENT, 0, 0, 0); // We short-cut here to show a sensible color before that happens.
UpdateBackgroundColorFromRenderer(color);
content::RenderWidgetHostViewBase::SetBackgroundColor(color); DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE ||
SkColorGetA(color) == SK_AlphaTRANSPARENT);
if (render_widget_host_) {
render_widget_host_->SetBackgroundOpaque(
SkColorGetA(color) == SK_AlphaOPAQUE);
}
}
const bool opaque = !transparent_ && GetBackgroundOpaque(); SkColor CefRenderWidgetHostViewOSR::background_color() const {
if (render_widget_host_) return background_color_;
render_widget_host_->SetBackgroundOpaque(opaque);
} }
bool CefRenderWidgetHostViewOSR::LockMouse() { bool CefRenderWidgetHostViewOSR::LockMouse() {
@ -672,8 +614,18 @@ bool CefRenderWidgetHostViewOSR::LockMouse() {
void CefRenderWidgetHostViewOSR::UnlockMouse() { void CefRenderWidgetHostViewOSR::UnlockMouse() {
} }
void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame( void CefRenderWidgetHostViewOSR::DidCreateNewRendererCompositorFrameSink(
uint32_t output_surface_id, cc::mojom::MojoCompositorFrameSinkClient*
renderer_compositor_frame_sink) {
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
if (GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->DidCreateNewRendererCompositorFrameSink(
renderer_compositor_frame_sink_);
}
}
void CefRenderWidgetHostViewOSR::SubmitCompositorFrame(
const cc::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) { cc::CompositorFrame frame) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnSwapCompositorFrame"); TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnSwapCompositorFrame");
@ -699,11 +651,11 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
// The compositor will draw directly to the SoftwareOutputDevice which // The compositor will draw directly to the SoftwareOutputDevice which
// then calls OnPaint. // then calls OnPaint.
// We would normally call BrowserCompositorMac::SwapCompositorFrame on // We would normally call BrowserCompositorMac::SubmitCompositorFrame on
// macOS, however it contains compositor resize logic that we don't want. // macOS, however it contains compositor resize logic that we don't want.
// Consequently we instead call the SwapDelegatedFrame method directly. // Consequently we instead call the SwapDelegatedFrame method directly.
GetDelegatedFrameHost()->SwapDelegatedFrame(output_surface_id, GetDelegatedFrameHost()->SubmitCompositorFrame(local_surface_id,
std::move(frame)); std::move(frame));
} else { } else {
if (!copy_frame_generator_.get()) { if (!copy_frame_generator_.get()) {
copy_frame_generator_.reset( copy_frame_generator_.reset(
@ -718,11 +670,11 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect)); gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
damage_rect.Intersect(gfx::Rect(frame_size)); damage_rect.Intersect(gfx::Rect(frame_size));
// We would normally call BrowserCompositorMac::SwapCompositorFrame on // We would normally call BrowserCompositorMac::SubmitCompositorFrame on
// macOS, however it contains compositor resize logic that we don't want. // macOS, however it contains compositor resize logic that we don't want.
// Consequently we instead call the SwapDelegatedFrame method directly. // Consequently we instead call the SwapDelegatedFrame method directly.
GetDelegatedFrameHost()->SwapDelegatedFrame(output_surface_id, GetDelegatedFrameHost()->SubmitCompositorFrame(local_surface_id,
std::move(frame)); std::move(frame));
// Request a copy of the last compositor frame which will eventually call // Request a copy of the last compositor frame which will eventually call
// OnPaint asynchronously. // OnPaint asynchronously.
@ -793,7 +745,7 @@ void CefRenderWidgetHostViewOSR::UpdateCursor(
if (!handler.get()) if (!handler.get())
return; return;
content::WebCursor::CursorInfo cursor_info; content::CursorInfo cursor_info;
cursor.GetCursorInfo(&cursor_info); cursor.GetCursorInfo(&cursor_info);
const cef_cursor_type_t cursor_type = const cef_cursor_type_t cursor_type =
@ -1067,7 +1019,7 @@ CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice(
DCHECK(!copy_frame_generator_); DCHECK(!copy_frame_generator_);
DCHECK(!software_output_device_); DCHECK(!software_output_device_);
software_output_device_ = new CefSoftwareOutputDeviceOSR( software_output_device_ = new CefSoftwareOutputDeviceOSR(
compositor, transparent_, compositor, background_color() == SK_ColorTRANSPARENT,
base::Bind(&CefRenderWidgetHostViewOSR::OnPaint, base::Bind(&CefRenderWidgetHostViewOSR::OnPaint,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
return base::WrapUnique(software_output_device_); return base::WrapUnique(software_output_device_);
@ -1104,33 +1056,15 @@ bool CefRenderWidgetHostViewOSR::DelegatedFrameCanCreateResizeLock() const {
return !render_widget_host_->auto_resize_enabled(); return !render_widget_host_->auto_resize_enabled();
} }
std::unique_ptr<content::ResizeLock> std::unique_ptr<content::CompositorResizeLock>
CefRenderWidgetHostViewOSR::DelegatedFrameHostCreateResizeLock( CefRenderWidgetHostViewOSR::DelegatedFrameHostCreateResizeLock() {
bool defer_compositor_lock) { HoldResize();
const gfx::Size& desired_size = GetRootLayer()->bounds().size(); const gfx::Size& desired_size = GetRootLayer()->bounds().size();
return std::unique_ptr<content::ResizeLock>(new CefResizeLock( return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
this,
desired_size,
defer_compositor_lock,
kResizeLockTimeoutMs));
} }
void CefRenderWidgetHostViewOSR::DelegatedFrameHostResizeLockWasReleased() { void CefRenderWidgetHostViewOSR::OnBeginFrame(const cc::BeginFrameArgs& args) {
return render_widget_host_->WasResized();
}
void
CefRenderWidgetHostViewOSR::DelegatedFrameHostSendReclaimCompositorResources(
int output_surface_id,
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) {
render_widget_host_->Send(new ViewMsg_ReclaimCompositorResources(
render_widget_host_->GetRoutingID(), output_surface_id, is_swap_ack,
resources));
}
void CefRenderWidgetHostViewOSR::SetBeginFrameSource(
cc::BeginFrameSource* source) {
// TODO(cef): Maybe we can use this method in combination with // TODO(cef): Maybe we can use this method in combination with
// OnSetNeedsBeginFrames() instead of using CefBeginFrameTimer. // OnSetNeedsBeginFrames() instead of using CefBeginFrameTimer.
// See https://codereview.chromium.org/1841083007. // See https://codereview.chromium.org/1841083007.
@ -1140,10 +1074,20 @@ bool CefRenderWidgetHostViewOSR::IsAutoResizeEnabled() const {
return render_widget_host_->auto_resize_enabled(); return render_widget_host_->auto_resize_enabled();
} }
std::unique_ptr<ui::CompositorLock>
CefRenderWidgetHostViewOSR::GetCompositorLock(
ui::CompositorLockClient* client) {
return GetCompositor()->GetCompositorLock(client);
}
void CefRenderWidgetHostViewOSR::CompositorResizeLockEnded() {
ReleaseResize();
}
#endif // !defined(OS_MACOSX) #endif // !defined(OS_MACOSX)
bool CefRenderWidgetHostViewOSR::InstallTransparency() { bool CefRenderWidgetHostViewOSR::InstallTransparency() {
if (transparent_) { if (background_color() == SK_ColorTRANSPARENT) {
SetBackgroundColor(SkColor()); SetBackgroundColor(SkColor());
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
browser_compositor_->SetHasTransparentBackground(true); browser_compositor_->SetHasTransparentBackground(true);
@ -1244,16 +1188,20 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent(
const blink::WebMouseEvent& event) { const blink::WebMouseEvent& event) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseEvent"); TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseEvent");
if (!IsPopupWidget()) { if (!IsPopupWidget()) {
if (browser_impl_.get() && event.type() == blink::WebMouseEvent::MouseDown) if (browser_impl_.get() &&
event.GetType() == blink::WebMouseEvent::kMouseDown) {
browser_impl_->CancelContextMenu(); browser_impl_->CancelContextMenu();
}
if (popup_host_view_ && if (popup_host_view_ &&
popup_host_view_->popup_position_.Contains(event.x, event.y)) { popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x, event.PositionInWidget().y)) {
blink::WebMouseEvent popup_event(event); blink::WebMouseEvent popup_event(event);
popup_event.x -= popup_host_view_->popup_position_.x(); popup_event.SetPositionInWidget(
popup_event.y -= popup_host_view_->popup_position_.y(); event.PositionInWidget().x - popup_host_view_->popup_position_.x(),
popup_event.windowX = popup_event.x; event.PositionInWidget().y - popup_host_view_->popup_position_.y());
popup_event.windowY = popup_event.y; popup_event.SetPositionInScreen(popup_event.PositionInWidget().x,
popup_event.PositionInWidget().y);
popup_host_view_->SendMouseEvent(popup_event); popup_host_view_->SendMouseEvent(popup_event);
return; return;
@ -1272,12 +1220,15 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
browser_impl_->CancelContextMenu(); browser_impl_->CancelContextMenu();
if (popup_host_view_) { if (popup_host_view_) {
if (popup_host_view_->popup_position_.Contains(event.x, event.y)) { if (popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x, event.PositionInWidget().y)) {
blink::WebMouseWheelEvent popup_event(event); blink::WebMouseWheelEvent popup_event(event);
popup_event.x -= popup_host_view_->popup_position_.x(); popup_event.SetPositionInWidget(
popup_event.y -= popup_host_view_->popup_position_.y(); event.PositionInWidget().x - popup_host_view_->popup_position_.x(),
popup_event.windowX = popup_event.x; event.PositionInWidget().y - popup_host_view_->popup_position_.y());
popup_event.windowY = popup_event.y; popup_event.SetPositionInScreen(popup_event.PositionInWidget().x,
popup_event.PositionInWidget().y);
popup_host_view_->SendMouseWheelEvent(popup_event); popup_host_view_->SendMouseWheelEvent(popup_event);
return; return;
} else { } else {
@ -1601,9 +1552,7 @@ void CefRenderWidgetHostViewOSR::RequestImeCompositionUpdate(
bool start_monitoring) { bool start_monitoring) {
if (!render_widget_host_) if (!render_widget_host_)
return; return;
render_widget_host_->Send( render_widget_host_->RequestCompositionUpdates(false, start_monitoring);
new InputMsg_RequestCompositionUpdate(render_widget_host_->GetRoutingID(),
false, start_monitoring));
} }
void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged( void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged(
@ -1644,3 +1593,13 @@ cc::FrameSinkId CefRenderWidgetHostViewOSR::AllocateFrameSinkId(
render_widget_host_->GetRoutingID())); render_widget_host_->GetRoutingID()));
} }
void CefRenderWidgetHostViewOSR::UpdateBackgroundColorFromRenderer(
SkColor color) {
if (color == background_color())
return;
background_color_ = color;
bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
GetRootLayer()->SetFillsBoundsOpaquely(opaque);
GetRootLayer()->SetColor(color);
}

View File

@ -16,6 +16,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/scheduler/begin_frame_source.h" #include "cc/scheduler/begin_frame_source.h"
#include "content/browser/renderer_host/compositor_resize_lock.h"
#include "content/browser/renderer_host/delegated_frame_host.h" #include "content/browser/renderer_host/delegated_frame_host.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
@ -85,11 +86,12 @@ class CefRenderWidgetHostViewOSR
: public content::RenderWidgetHostViewBase, : public content::RenderWidgetHostViewBase,
public ui::CompositorDelegate public ui::CompositorDelegate
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
, public content::DelegatedFrameHostClient , public content::DelegatedFrameHostClient,
public content::CompositorResizeLockClient
#endif #endif
{ {
public: public:
CefRenderWidgetHostViewOSR(const bool transparent, CefRenderWidgetHostViewOSR(SkColor background_color,
content::RenderWidgetHost* widget, content::RenderWidgetHost* widget,
CefRenderWidgetHostViewOSR* parent_host_view, CefRenderWidgetHostViewOSR* parent_host_view,
bool is_guest_view_hack); bool is_guest_view_hack);
@ -111,6 +113,7 @@ class CefRenderWidgetHostViewOSR
bool IsShowing() override; bool IsShowing() override;
gfx::Rect GetViewBounds() const override; gfx::Rect GetViewBounds() const override;
void SetBackgroundColor(SkColor color) override; void SetBackgroundColor(SkColor color) override;
SkColor background_color() const override;
bool LockMouse() override; bool LockMouse() override;
void UnlockMouse() override; void UnlockMouse() override;
@ -125,7 +128,10 @@ class CefRenderWidgetHostViewOSR
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
// RenderWidgetHostViewBase implementation. // RenderWidgetHostViewBase implementation.
void OnSwapCompositorFrame(uint32_t output_surface_id, void DidCreateNewRendererCompositorFrameSink(
cc::mojom::MojoCompositorFrameSinkClient*
renderer_compositor_frame_sink) override;
void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) override; cc::CompositorFrame frame) override;
void ClearCompositorFrame() override; void ClearCompositorFrame() override;
void InitAsPopup(content::RenderWidgetHostView* parent_host_view, void InitAsPopup(content::RenderWidgetHostView* parent_host_view,
@ -192,16 +198,16 @@ class CefRenderWidgetHostViewOSR
bool DelegatedFrameHostIsVisible() const override; bool DelegatedFrameHostIsVisible() const override;
SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override;
gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override;
bool DelegatedFrameCanCreateResizeLock() const override; bool DelegatedFrameCanCreateResizeLock() const override;
std::unique_ptr<content::ResizeLock> DelegatedFrameHostCreateResizeLock( std::unique_ptr<content::CompositorResizeLock>
bool defer_compositor_lock) override; DelegatedFrameHostCreateResizeLock() override;
void DelegatedFrameHostResizeLockWasReleased() override; void OnBeginFrame(const cc::BeginFrameArgs& args) override;
void DelegatedFrameHostSendReclaimCompositorResources(
int output_surface_id,
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) override;
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
bool IsAutoResizeEnabled() const override; bool IsAutoResizeEnabled() const override;
// CompositorResizeLockClient implementation.
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) override;
void CompositorResizeLockEnded() override;
#endif // !defined(OS_MACOSX) #endif // !defined(OS_MACOSX)
bool InstallTransparency(); bool InstallTransparency();
@ -225,7 +231,7 @@ class CefRenderWidgetHostViewOSR
void* bitmap_pixels); void* bitmap_pixels);
bool IsPopupWidget() const { bool IsPopupWidget() const {
return popup_type_ != blink::WebPopupTypeNone; return popup_type_ != blink::kWebPopupTypeNone;
} }
void ImeSetComposition( void ImeSetComposition(
@ -289,6 +295,10 @@ class CefRenderWidgetHostViewOSR
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack); cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
// Applies background color without notifying the RenderWidget about
// opaqueness changes.
void UpdateBackgroundColorFromRenderer(SkColor color);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
friend class MacHelper; friend class MacHelper;
#endif #endif
@ -300,7 +310,8 @@ class CefRenderWidgetHostViewOSR
ui::PlatformCursor GetPlatformCursor(blink::WebCursorInfo::Type type); ui::PlatformCursor GetPlatformCursor(blink::WebCursorInfo::Type type);
#endif #endif
const bool transparent_; // The background color of the web content.
SkColor background_color_;
float scale_factor_; float scale_factor_;
int frame_rate_threshold_ms_; int frame_rate_threshold_ms_;
@ -363,6 +374,9 @@ class CefRenderWidgetHostViewOSR
gfx::Vector2dF last_scroll_offset_; gfx::Vector2dF last_scroll_offset_;
bool is_scroll_offset_changed_pending_; bool is_scroll_offset_changed_pending_;
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink_ =
nullptr;
base::WeakPtrFactory<CefRenderWidgetHostViewOSR> weak_ptr_factory_; base::WeakPtrFactory<CefRenderWidgetHostViewOSR> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefRenderWidgetHostViewOSR); DISALLOW_COPY_AND_ASSIGN(CefRenderWidgetHostViewOSR);

View File

@ -23,92 +23,92 @@ using blink::WebCursorInfo;
int ToCursorID(WebCursorInfo::Type type) { int ToCursorID(WebCursorInfo::Type type) {
switch (type) { switch (type) {
case WebCursorInfo::TypePointer: case WebCursorInfo::kTypePointer:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeCross: case WebCursorInfo::kTypeCross:
return XC_crosshair; return XC_crosshair;
case WebCursorInfo::TypeHand: case WebCursorInfo::kTypeHand:
return XC_hand2; return XC_hand2;
case WebCursorInfo::TypeIBeam: case WebCursorInfo::kTypeIBeam:
return XC_xterm; return XC_xterm;
case WebCursorInfo::TypeWait: case WebCursorInfo::kTypeWait:
return XC_watch; return XC_watch;
case WebCursorInfo::TypeHelp: case WebCursorInfo::kTypeHelp:
return XC_question_arrow; return XC_question_arrow;
case WebCursorInfo::TypeEastResize: case WebCursorInfo::kTypeEastResize:
return XC_right_side; return XC_right_side;
case WebCursorInfo::TypeNorthResize: case WebCursorInfo::kTypeNorthResize:
return XC_top_side; return XC_top_side;
case WebCursorInfo::TypeNorthEastResize: case WebCursorInfo::kTypeNorthEastResize:
return XC_top_right_corner; return XC_top_right_corner;
case WebCursorInfo::TypeNorthWestResize: case WebCursorInfo::kTypeNorthWestResize:
return XC_top_left_corner; return XC_top_left_corner;
case WebCursorInfo::TypeSouthResize: case WebCursorInfo::kTypeSouthResize:
return XC_bottom_side; return XC_bottom_side;
case WebCursorInfo::TypeSouthEastResize: case WebCursorInfo::kTypeSouthEastResize:
return XC_bottom_right_corner; return XC_bottom_right_corner;
case WebCursorInfo::TypeSouthWestResize: case WebCursorInfo::kTypeSouthWestResize:
return XC_bottom_left_corner; return XC_bottom_left_corner;
case WebCursorInfo::TypeWestResize: case WebCursorInfo::kTypeWestResize:
return XC_left_side; return XC_left_side;
case WebCursorInfo::TypeNorthSouthResize: case WebCursorInfo::kTypeNorthSouthResize:
return XC_sb_v_double_arrow; return XC_sb_v_double_arrow;
case WebCursorInfo::TypeEastWestResize: case WebCursorInfo::kTypeEastWestResize:
return XC_sb_h_double_arrow; return XC_sb_h_double_arrow;
case WebCursorInfo::TypeNorthEastSouthWestResize: case WebCursorInfo::kTypeNorthEastSouthWestResize:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeNorthWestSouthEastResize: case WebCursorInfo::kTypeNorthWestSouthEastResize:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeColumnResize: case WebCursorInfo::kTypeColumnResize:
return XC_sb_h_double_arrow; return XC_sb_h_double_arrow;
case WebCursorInfo::TypeRowResize: case WebCursorInfo::kTypeRowResize:
return XC_sb_v_double_arrow; return XC_sb_v_double_arrow;
case WebCursorInfo::TypeMiddlePanning: case WebCursorInfo::kTypeMiddlePanning:
return XC_fleur; return XC_fleur;
case WebCursorInfo::TypeEastPanning: case WebCursorInfo::kTypeEastPanning:
return XC_sb_right_arrow; return XC_sb_right_arrow;
case WebCursorInfo::TypeNorthPanning: case WebCursorInfo::kTypeNorthPanning:
return XC_sb_up_arrow; return XC_sb_up_arrow;
case WebCursorInfo::TypeNorthEastPanning: case WebCursorInfo::kTypeNorthEastPanning:
return XC_top_right_corner; return XC_top_right_corner;
case WebCursorInfo::TypeNorthWestPanning: case WebCursorInfo::kTypeNorthWestPanning:
return XC_top_left_corner; return XC_top_left_corner;
case WebCursorInfo::TypeSouthPanning: case WebCursorInfo::kTypeSouthPanning:
return XC_sb_down_arrow; return XC_sb_down_arrow;
case WebCursorInfo::TypeSouthEastPanning: case WebCursorInfo::kTypeSouthEastPanning:
return XC_bottom_right_corner; return XC_bottom_right_corner;
case WebCursorInfo::TypeSouthWestPanning: case WebCursorInfo::kTypeSouthWestPanning:
return XC_bottom_left_corner; return XC_bottom_left_corner;
case WebCursorInfo::TypeWestPanning: case WebCursorInfo::kTypeWestPanning:
return XC_sb_left_arrow; return XC_sb_left_arrow;
case WebCursorInfo::TypeMove: case WebCursorInfo::kTypeMove:
return XC_fleur; return XC_fleur;
case WebCursorInfo::TypeVerticalText: case WebCursorInfo::kTypeVerticalText:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeCell: case WebCursorInfo::kTypeCell:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeContextMenu: case WebCursorInfo::kTypeContextMenu:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeAlias: case WebCursorInfo::kTypeAlias:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeProgress: case WebCursorInfo::kTypeProgress:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeNoDrop: case WebCursorInfo::kTypeNoDrop:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeCopy: case WebCursorInfo::kTypeCopy:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeNotAllowed: case WebCursorInfo::kTypeNotAllowed:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeZoomIn: case WebCursorInfo::kTypeZoomIn:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeZoomOut: case WebCursorInfo::kTypeZoomOut:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeGrab: case WebCursorInfo::kTypeGrab:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeGrabbing: case WebCursorInfo::kTypeGrabbing:
return XC_left_ptr; return XC_left_ptr;
case WebCursorInfo::TypeCustom: case WebCursorInfo::kTypeCustom:
case WebCursorInfo::TypeNone: case WebCursorInfo::kTypeNone:
break; break;
} }
NOTREACHED(); NOTREACHED();
@ -185,7 +185,7 @@ void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor( ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
blink::WebCursorInfo::Type type) { blink::WebCursorInfo::Type type) {
if (type == WebCursorInfo::TypeNone) { if (type == WebCursorInfo::kTypeNone) {
if (!invisible_cursor_) { if (!invisible_cursor_) {
invisible_cursor_.reset( invisible_cursor_.reset(
new ui::XScopedCursor(ui::CreateInvisibleCursor(), new ui::XScopedCursor(ui::CreateInvisibleCursor(),

View File

@ -17,8 +17,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/events/latency_info.h"
class MacHelper : class MacHelper :
public content::BrowserCompositorMacClient, public content::BrowserCompositorMacClient,
@ -49,15 +47,6 @@ class MacHelper :
return color; return color;
} }
void BrowserCompositorMacSendReclaimCompositorResources(
int output_surface_id,
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) override {
view_->render_widget_host()->Send(new ViewMsg_ReclaimCompositorResources(
view_->render_widget_host()->GetRoutingID(), output_surface_id,
is_swap_ack, resources));
}
void BrowserCompositorMacSendBeginFrame( void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override { const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send( view_->render_widget_host()->Send(

View File

@ -46,91 +46,91 @@ using blink::WebCursorInfo;
LPCWSTR ToCursorID(WebCursorInfo::Type type) { LPCWSTR ToCursorID(WebCursorInfo::Type type) {
switch (type) { switch (type) {
case WebCursorInfo::TypePointer: case WebCursorInfo::kTypePointer:
return IDC_ARROW; return IDC_ARROW;
case WebCursorInfo::TypeCross: case WebCursorInfo::kTypeCross:
return IDC_CROSS; return IDC_CROSS;
case WebCursorInfo::TypeHand: case WebCursorInfo::kTypeHand:
return IDC_HAND; return IDC_HAND;
case WebCursorInfo::TypeIBeam: case WebCursorInfo::kTypeIBeam:
return IDC_IBEAM; return IDC_IBEAM;
case WebCursorInfo::TypeWait: case WebCursorInfo::kTypeWait:
return IDC_WAIT; return IDC_WAIT;
case WebCursorInfo::TypeHelp: case WebCursorInfo::kTypeHelp:
return IDC_HELP; return IDC_HELP;
case WebCursorInfo::TypeEastResize: case WebCursorInfo::kTypeEastResize:
return IDC_SIZEWE; return IDC_SIZEWE;
case WebCursorInfo::TypeNorthResize: case WebCursorInfo::kTypeNorthResize:
return IDC_SIZENS; return IDC_SIZENS;
case WebCursorInfo::TypeNorthEastResize: case WebCursorInfo::kTypeNorthEastResize:
return IDC_SIZENESW; return IDC_SIZENESW;
case WebCursorInfo::TypeNorthWestResize: case WebCursorInfo::kTypeNorthWestResize:
return IDC_SIZENWSE; return IDC_SIZENWSE;
case WebCursorInfo::TypeSouthResize: case WebCursorInfo::kTypeSouthResize:
return IDC_SIZENS; return IDC_SIZENS;
case WebCursorInfo::TypeSouthEastResize: case WebCursorInfo::kTypeSouthEastResize:
return IDC_SIZENWSE; return IDC_SIZENWSE;
case WebCursorInfo::TypeSouthWestResize: case WebCursorInfo::kTypeSouthWestResize:
return IDC_SIZENESW; return IDC_SIZENESW;
case WebCursorInfo::TypeWestResize: case WebCursorInfo::kTypeWestResize:
return IDC_SIZEWE; return IDC_SIZEWE;
case WebCursorInfo::TypeNorthSouthResize: case WebCursorInfo::kTypeNorthSouthResize:
return IDC_SIZENS; return IDC_SIZENS;
case WebCursorInfo::TypeEastWestResize: case WebCursorInfo::kTypeEastWestResize:
return IDC_SIZEWE; return IDC_SIZEWE;
case WebCursorInfo::TypeNorthEastSouthWestResize: case WebCursorInfo::kTypeNorthEastSouthWestResize:
return IDC_SIZENESW; return IDC_SIZENESW;
case WebCursorInfo::TypeNorthWestSouthEastResize: case WebCursorInfo::kTypeNorthWestSouthEastResize:
return IDC_SIZENWSE; return IDC_SIZENWSE;
case WebCursorInfo::TypeColumnResize: case WebCursorInfo::kTypeColumnResize:
return MAKEINTRESOURCE(IDC_COLRESIZE); return MAKEINTRESOURCE(IDC_COLRESIZE);
case WebCursorInfo::TypeRowResize: case WebCursorInfo::kTypeRowResize:
return MAKEINTRESOURCE(IDC_ROWRESIZE); return MAKEINTRESOURCE(IDC_ROWRESIZE);
case WebCursorInfo::TypeMiddlePanning: case WebCursorInfo::kTypeMiddlePanning:
return MAKEINTRESOURCE(IDC_PAN_MIDDLE); return MAKEINTRESOURCE(IDC_PAN_MIDDLE);
case WebCursorInfo::TypeEastPanning: case WebCursorInfo::kTypeEastPanning:
return MAKEINTRESOURCE(IDC_PAN_EAST); return MAKEINTRESOURCE(IDC_PAN_EAST);
case WebCursorInfo::TypeNorthPanning: case WebCursorInfo::kTypeNorthPanning:
return MAKEINTRESOURCE(IDC_PAN_NORTH); return MAKEINTRESOURCE(IDC_PAN_NORTH);
case WebCursorInfo::TypeNorthEastPanning: case WebCursorInfo::kTypeNorthEastPanning:
return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST); return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST);
case WebCursorInfo::TypeNorthWestPanning: case WebCursorInfo::kTypeNorthWestPanning:
return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST); return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST);
case WebCursorInfo::TypeSouthPanning: case WebCursorInfo::kTypeSouthPanning:
return MAKEINTRESOURCE(IDC_PAN_SOUTH); return MAKEINTRESOURCE(IDC_PAN_SOUTH);
case WebCursorInfo::TypeSouthEastPanning: case WebCursorInfo::kTypeSouthEastPanning:
return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST); return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST);
case WebCursorInfo::TypeSouthWestPanning: case WebCursorInfo::kTypeSouthWestPanning:
return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST); return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST);
case WebCursorInfo::TypeWestPanning: case WebCursorInfo::kTypeWestPanning:
return MAKEINTRESOURCE(IDC_PAN_WEST); return MAKEINTRESOURCE(IDC_PAN_WEST);
case WebCursorInfo::TypeMove: case WebCursorInfo::kTypeMove:
return IDC_SIZEALL; return IDC_SIZEALL;
case WebCursorInfo::TypeVerticalText: case WebCursorInfo::kTypeVerticalText:
return MAKEINTRESOURCE(IDC_VERTICALTEXT); return MAKEINTRESOURCE(IDC_VERTICALTEXT);
case WebCursorInfo::TypeCell: case WebCursorInfo::kTypeCell:
return MAKEINTRESOURCE(IDC_CELL); return MAKEINTRESOURCE(IDC_CELL);
case WebCursorInfo::TypeContextMenu: case WebCursorInfo::kTypeContextMenu:
return IDC_ARROW; return IDC_ARROW;
case WebCursorInfo::TypeAlias: case WebCursorInfo::kTypeAlias:
return MAKEINTRESOURCE(IDC_ALIAS); return MAKEINTRESOURCE(IDC_ALIAS);
case WebCursorInfo::TypeProgress: case WebCursorInfo::kTypeProgress:
return IDC_APPSTARTING; return IDC_APPSTARTING;
case WebCursorInfo::TypeNoDrop: case WebCursorInfo::kTypeNoDrop:
return IDC_NO; return IDC_NO;
case WebCursorInfo::TypeCopy: case WebCursorInfo::kTypeCopy:
return MAKEINTRESOURCE(IDC_COPYCUR); return MAKEINTRESOURCE(IDC_COPYCUR);
case WebCursorInfo::TypeNone: case WebCursorInfo::kTypeNone:
return MAKEINTRESOURCE(IDC_CURSOR_NONE); return MAKEINTRESOURCE(IDC_CURSOR_NONE);
case WebCursorInfo::TypeNotAllowed: case WebCursorInfo::kTypeNotAllowed:
return IDC_NO; return IDC_NO;
case WebCursorInfo::TypeZoomIn: case WebCursorInfo::kTypeZoomIn:
return MAKEINTRESOURCE(IDC_ZOOMIN); return MAKEINTRESOURCE(IDC_ZOOMIN);
case WebCursorInfo::TypeZoomOut: case WebCursorInfo::kTypeZoomOut:
return MAKEINTRESOURCE(IDC_ZOOMOUT); return MAKEINTRESOURCE(IDC_ZOOMOUT);
case WebCursorInfo::TypeGrab: case WebCursorInfo::kTypeGrab:
return MAKEINTRESOURCE(IDC_HAND_GRAB); return MAKEINTRESOURCE(IDC_HAND_GRAB);
case WebCursorInfo::TypeGrabbing: case WebCursorInfo::kTypeGrabbing:
return MAKEINTRESOURCE(IDC_HAND_GRABBING); return MAKEINTRESOURCE(IDC_HAND_GRABBING);
} }
NOTREACHED(); NOTREACHED();

View File

@ -14,10 +14,9 @@
#include "content/browser/frame_host/render_widget_host_view_guest.h" #include "content/browser/frame_host/render_widget_host_view_guest.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host.h"
#include "content/public/browser/user_metrics.h"
CefWebContentsViewOSR::CefWebContentsViewOSR(bool transparent) CefWebContentsViewOSR::CefWebContentsViewOSR(SkColor background_color)
: transparent_(transparent), : background_color_(background_color),
web_contents_(NULL) { web_contents_(NULL) {
} }
@ -100,9 +99,8 @@ content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
} }
const bool is_guest_view_hack = !!embedder_render_widget_host; const bool is_guest_view_hack = !!embedder_render_widget_host;
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host, return new CefRenderWidgetHostViewOSR(background_color_, render_widget_host,
embedder_host_view, embedder_host_view, is_guest_view_hack);
is_guest_view_hack);
} }
// Called for popup and fullscreen widgets. // Called for popup and fullscreen widgets.
@ -112,8 +110,8 @@ content::RenderWidgetHostViewBase*
CefRenderWidgetHostViewOSR* view = GetView(); CefRenderWidgetHostViewOSR* view = GetView();
CHECK(view); CHECK(view);
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host, view, return new CefRenderWidgetHostViewOSR(background_color_, render_widget_host,
false); view, false);
} }
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) { void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {

View File

@ -8,6 +8,7 @@
#include "content/browser/renderer_host/render_view_host_delegate_view.h" #include "content/browser/renderer_host/render_view_host_delegate_view.h"
#include "content/browser/web_contents/web_contents_view.h" #include "content/browser/web_contents/web_contents_view.h"
#include "third_party/skia/include/core/SkColor.h"
namespace content { namespace content {
class BrowserPluginGuest; class BrowserPluginGuest;
@ -22,7 +23,7 @@ class CefRenderWidgetHostViewOSR;
class CefWebContentsViewOSR : public content::WebContentsView, class CefWebContentsViewOSR : public content::WebContentsView,
public content::RenderViewHostDelegateView { public content::RenderViewHostDelegateView {
public: public:
explicit CefWebContentsViewOSR(bool transparent); explicit CefWebContentsViewOSR(SkColor background_color);
~CefWebContentsViewOSR() override; ~CefWebContentsViewOSR() override;
void WebContentsCreated(content::WebContents* web_contents); void WebContentsCreated(content::WebContents* web_contents);
@ -74,7 +75,7 @@ class CefWebContentsViewOSR : public content::WebContentsView,
CefRenderWidgetHostViewOSR* GetView() const; CefRenderWidgetHostViewOSR* GetView() const;
CefBrowserHostImpl* GetBrowser() const; CefBrowserHostImpl* GetBrowser() const;
const bool transparent_; const SkColor background_color_;
content::WebContents* web_contents_; content::WebContents* web_contents_;

View File

@ -63,7 +63,7 @@ class ShutdownNotifierFactory
static ShutdownNotifierFactory* GetInstance(); static ShutdownNotifierFactory* GetInstance();
private: private:
friend struct base::DefaultLazyInstanceTraits<ShutdownNotifierFactory>; friend struct base::LazyInstanceTraitsBase<ShutdownNotifierFactory>;
ShutdownNotifierFactory() ShutdownNotifierFactory()
: BrowserContextKeyedServiceShutdownNotifierFactory( : BrowserContextKeyedServiceShutdownNotifierFactory(
@ -370,19 +370,6 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
DCHECK(plugin_setting != CONTENT_SETTING_ASK); DCHECK(plugin_setting != CONTENT_SETTING_ASK);
#if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION)
// Check if the plugin is outdated.
if (plugin_status == PluginMetadata::SECURITY_STATUS_OUT_OF_DATE &&
!allow_outdated_plugins_.GetValue()) {
if (allow_outdated_plugins_.IsManaged()) {
*status = CefViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed;
} else {
*status = CefViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked;
}
return;
}
#endif
// Check if the plugin is crashing too much. // Check if the plugin is crashing too much.
if (PluginService::GetInstance()->IsPluginUnstable(plugin.path) && if (PluginService::GetInstance()->IsPluginUnstable(plugin.path) &&
!always_authorize_plugins_.GetValue() && !always_authorize_plugins_.GetValue() &&

View File

@ -97,7 +97,8 @@ const char kUserPrefsFileName[] = "UserPrefs.json";
std::unique_ptr<PrefService> CreatePrefService( std::unique_ptr<PrefService> CreatePrefService(
Profile* profile, Profile* profile,
const base::FilePath& cache_path, const base::FilePath& cache_path,
bool persist_user_preferences) { bool persist_user_preferences,
bool is_pre_initialization) {
const base::CommandLine* command_line = const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
@ -114,7 +115,8 @@ std::unique_ptr<PrefService> CreatePrefService(
factory.set_command_line_prefs(command_line_pref_store); factory.set_command_line_prefs(command_line_pref_store);
// True if preferences will be stored on disk. // True if preferences will be stored on disk.
const bool store_on_disk = !cache_path.empty() && persist_user_preferences; const bool store_on_disk = !cache_path.empty() && persist_user_preferences &&
!is_pre_initialization;
scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner; scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner;
if (store_on_disk) { if (store_on_disk) {
@ -141,23 +143,27 @@ std::unique_ptr<PrefService> CreatePrefService(
} }
#if BUILDFLAG(ENABLE_SUPERVISED_USERS) #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
// Used to store supervised user preferences. // Don't access factories during pre-initialization.
SupervisedUserSettingsService* supervised_user_settings = if (!is_pre_initialization) {
SupervisedUserSettingsServiceFactory::GetForProfile(profile); // Used to store supervised user preferences.
SupervisedUserSettingsService* supervised_user_settings =
SupervisedUserSettingsServiceFactory::GetForProfile(profile);
if (store_on_disk) { if (store_on_disk) {
supervised_user_settings->Init( supervised_user_settings->Init(
cache_path, sequenced_task_runner.get(), true); cache_path, sequenced_task_runner.get(), true);
} else { } else {
scoped_refptr<TestingPrefStore> testing_pref_store = new TestingPrefStore(); scoped_refptr<TestingPrefStore> testing_pref_store =
testing_pref_store->SetInitializationCompleted(); new TestingPrefStore();
supervised_user_settings->Init(testing_pref_store); testing_pref_store->SetInitializationCompleted();
supervised_user_settings->Init(testing_pref_store);
}
scoped_refptr<PrefStore> supervised_user_prefs = make_scoped_refptr(
new SupervisedUserPrefStore(supervised_user_settings));
DCHECK(supervised_user_prefs->IsInitializationComplete());
factory.set_supervised_user_prefs(supervised_user_prefs);
} }
scoped_refptr<PrefStore> supervised_user_prefs = make_scoped_refptr(
new SupervisedUserPrefStore(supervised_user_settings));
DCHECK(supervised_user_prefs->IsInitializationComplete());
factory.set_supervised_user_prefs(supervised_user_prefs);
#endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
// Registry that will be populated with all known preferences. Preferences // Registry that will be populated with all known preferences. Preferences
@ -182,7 +188,7 @@ std::unique_ptr<PrefService> CreatePrefService(
// Spell checking preferences. // Spell checking preferences.
// Based on SpellcheckServiceFactory::RegisterProfilePrefs. // Based on SpellcheckServiceFactory::RegisterProfilePrefs.
registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries,
new base::ListValue); base::MakeUnique<base::ListValue>());
std::string spellcheck_lang = std::string spellcheck_lang =
command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang); command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang);
if (!spellcheck_lang.empty()) { if (!spellcheck_lang.empty()) {

View File

@ -19,11 +19,14 @@ namespace browser_prefs {
// Name for the user prefs JSON file. // Name for the user prefs JSON file.
extern const char kUserPrefsFileName[]; extern const char kUserPrefsFileName[];
// Create the PrefService used to manage pref registration and storage. // Create the PrefService used to manage pref registration and storage. If
// |is_pre_initialization| is true a non-persistent PrefService will be created
// for temporary usage during BrowserContextServices initialization.
std::unique_ptr<PrefService> CreatePrefService( std::unique_ptr<PrefService> CreatePrefService(
Profile* profile, Profile* profile,
const base::FilePath& cache_path, const base::FilePath& cache_path,
bool persist_user_preferences); bool persist_user_preferences,
bool is_pre_initialization);
} // namespace browser_prefs } // namespace browser_prefs

View File

@ -272,7 +272,7 @@ void SetString(CommandLinePrefStore* prefs,
const std::string& value) { const std::string& value) {
prefs->SetValue( prefs->SetValue(
key, key,
base::WrapUnique(new base::StringValue(value)), base::WrapUnique(new base::Value(value)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
} }
@ -284,28 +284,6 @@ void SetBool(CommandLinePrefStore* prefs,
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
} }
SkColor GetBaseBackgroundColor(CefRefPtr<CefBrowserHostImpl> browser) {
if (browser.get()) {
const CefBrowserSettings& browser_settings = browser->settings();
if (CefColorGetA(browser_settings.background_color) > 0) {
return SkColorSetRGB(
CefColorGetR(browser_settings.background_color),
CefColorGetG(browser_settings.background_color),
CefColorGetB(browser_settings.background_color));
}
}
const CefSettings& settings = CefContext::Get()->settings();
if (CefColorGetA(settings.background_color) > 0) {
return SkColorSetRGB(
CefColorGetR(settings.background_color),
CefColorGetG(settings.background_color),
CefColorGetB(settings.background_color));
}
return SK_ColorWHITE;
}
} // namespace } // namespace
void SetCommandLinePrefDefaults(CommandLinePrefStore* prefs) { void SetCommandLinePrefDefaults(CommandLinePrefStore* prefs) {
@ -368,7 +346,7 @@ void PopulateWebPreferences(content::RenderViewHost* rvh,
SetDefaultPrefs(web); SetDefaultPrefs(web);
// Set preferences based on the context's PrefService. // Set preferences based on the context's PrefService.
if (browser.get()) { if (browser) {
CefBrowserContext* profile = CefBrowserContext* profile =
static_cast<CefBrowserContext*>( static_cast<CefBrowserContext*>(
browser->web_contents()->GetBrowserContext()); browser->web_contents()->GetBrowserContext());
@ -379,11 +357,18 @@ void PopulateWebPreferences(content::RenderViewHost* rvh,
SetExtensionPrefs(rvh, web); SetExtensionPrefs(rvh, web);
// Set preferences based on CefBrowserSettings. // Set preferences based on CefBrowserSettings.
if (browser.get()) if (browser)
SetCefPrefs(browser->settings(), web); SetCefPrefs(browser->settings(), web);
// Set the background color for the WebView. // Set the background color for the WebView.
web.base_background_color = GetBaseBackgroundColor(browser); if (browser) {
web.base_background_color = browser->GetBackgroundColor();
} else {
// We don't know for sure that the browser will be windowless but assume
// that the global windowless state is likely to be accurate.
web.base_background_color =
CefContext::Get()->GetBackgroundColor(nullptr, STATE_DEFAULT);
}
} }
} // namespace renderer_prefs } // namespace renderer_prefs

View File

@ -50,6 +50,8 @@ void FillInDictionaryFromPdfPrintSettings(
print_settings.SetBoolean(kSettingRasterizePdf, false); print_settings.SetBoolean(kSettingRasterizePdf, false);
print_settings.SetBoolean(kSettingGenerateDraftData, false); print_settings.SetBoolean(kSettingGenerateDraftData, false);
print_settings.SetBoolean(kSettingPreviewModifiable, false); print_settings.SetBoolean(kSettingPreviewModifiable, false);
print_settings.SetInteger(kSettingDpiHorizontal, 0);
print_settings.SetInteger(kSettingDpiVertical, 0);
// User defined settings. // User defined settings.
print_settings.SetBoolean(kSettingLandscape, !!pdf_settings.landscape); print_settings.SetBoolean(kSettingLandscape, !!pdf_settings.landscape);

View File

@ -48,7 +48,7 @@ class ShutdownNotifierFactory
static ShutdownNotifierFactory* GetInstance(); static ShutdownNotifierFactory* GetInstance();
private: private:
friend struct base::DefaultLazyInstanceTraits<ShutdownNotifierFactory>; friend struct base::LazyInstanceTraitsBase<ShutdownNotifierFactory>;
ShutdownNotifierFactory() ShutdownNotifierFactory()
: BrowserContextKeyedServiceShutdownNotifierFactory( : BrowserContextKeyedServiceShutdownNotifierFactory(

View File

@ -37,26 +37,13 @@ bool ShouldProxyUserData(const void* key) {
CefResourceContext::CefResourceContext( CefResourceContext::CefResourceContext(
bool is_off_the_record, bool is_off_the_record,
extensions::InfoMap* extension_info_map,
CefRefPtr<CefRequestContextHandler> handler) CefRefPtr<CefRequestContextHandler> handler)
: parent_(nullptr), : parent_(nullptr),
is_off_the_record_(is_off_the_record), is_off_the_record_(is_off_the_record),
extension_info_map_(extension_info_map),
handler_(handler) { handler_(handler) {
} }
CefResourceContext::~CefResourceContext() { CefResourceContext::~CefResourceContext() {
if (getter_.get()) {
// When the parent object (ResourceContext) destructor executes all
// associated URLRequests should be destroyed. If there are no other
// references it should then be safe to destroy the URLRequestContextGetter
// which owns the URLRequestContext.
getter_->AddRef();
CefURLRequestContextGetter* raw_getter = getter_.get();
getter_ = NULL;
content::BrowserThread::ReleaseSoon(
content::BrowserThread::IO, FROM_HERE, raw_getter);
}
} }
base::SupportsUserData::Data* CefResourceContext::GetUserData(const void* key) base::SupportsUserData::Data* CefResourceContext::GetUserData(const void* key)
@ -117,6 +104,12 @@ std::unique_ptr<net::ClientCertStore>
#endif #endif
} }
void CefResourceContext::set_extensions_info_map(
extensions::InfoMap* extensions_info_map) {
DCHECK(!extension_info_map_);
extension_info_map_ = extensions_info_map;
}
void CefResourceContext::set_url_request_context_getter( void CefResourceContext::set_url_request_context_getter(
CefURLRequestContextGetter* getter) { CefURLRequestContextGetter* getter) {
DCHECK(!getter_.get()); DCHECK(!getter_.get());

View File

@ -28,7 +28,6 @@ enum class CefViewHostMsg_GetPluginInfo_Status;
class CefResourceContext : public content::ResourceContext { class CefResourceContext : public content::ResourceContext {
public: public:
CefResourceContext(bool is_off_the_record, CefResourceContext(bool is_off_the_record,
extensions::InfoMap* extension_info_map,
CefRefPtr<CefRequestContextHandler> handler); CefRefPtr<CefRequestContextHandler> handler);
~CefResourceContext() override; ~CefResourceContext() override;
@ -44,6 +43,7 @@ class CefResourceContext : public content::ResourceContext {
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(); std::unique_ptr<net::ClientCertStore> CreateClientCertStore();
void set_extensions_info_map(extensions::InfoMap* extensions_info_map);
void set_url_request_context_getter(CefURLRequestContextGetter* getter); void set_url_request_context_getter(CefURLRequestContextGetter* getter);
void set_parent(CefResourceContext* parent); void set_parent(CefResourceContext* parent);

View File

@ -11,6 +11,10 @@ CefStoragePartitionProxy::CefStoragePartitionProxy(
url_request_context_(url_request_context) { url_request_context_(url_request_context) {
} }
CefStoragePartitionProxy::~CefStoragePartitionProxy() {
url_request_context_->ShutdownOnUIThread();
}
base::FilePath CefStoragePartitionProxy::GetPath() { base::FilePath CefStoragePartitionProxy::GetPath() {
return parent_->GetPath(); return parent_->GetPath();
} }
@ -76,6 +80,11 @@ CefStoragePartitionProxy::GetPlatformNotificationContext() {
return parent_->GetPlatformNotificationContext(); return parent_->GetPlatformNotificationContext();
} }
content::BackgroundFetchContext*
CefStoragePartitionProxy::GetBackgroundFetchContext() {
return parent_->GetBackgroundFetchContext();
}
content::BackgroundSyncContext* content::BackgroundSyncContext*
CefStoragePartitionProxy::GetBackgroundSyncContext() { CefStoragePartitionProxy::GetBackgroundSyncContext() {
return parent_->GetBackgroundSyncContext(); return parent_->GetBackgroundSyncContext();
@ -130,6 +139,14 @@ void CefStoragePartitionProxy::ClearData(
cookie_matcher, begin, end, callback); cookie_matcher, begin, end, callback);
} }
void CefStoragePartitionProxy::ClearHttpAndMediaCaches(
const base::Time begin,
const base::Time end,
const base::Callback<bool(const GURL&)>& url_matcher,
const base::Closure& callback) {
parent_->ClearHttpAndMediaCaches(begin, end, url_matcher, callback);
}
void CefStoragePartitionProxy::Flush() { void CefStoragePartitionProxy::Flush() {
parent_->Flush(); parent_->Flush();
} }

View File

@ -18,6 +18,7 @@ class CefStoragePartitionProxy : public content::StoragePartition {
CefStoragePartitionProxy( CefStoragePartitionProxy(
content::StoragePartition* parent, content::StoragePartition* parent,
CefURLRequestContextGetterProxy* url_request_context); CefURLRequestContextGetterProxy* url_request_context);
~CefStoragePartitionProxy() override;
// StoragePartition methods: // StoragePartition methods:
base::FilePath GetPath() override; base::FilePath GetPath() override;
@ -36,6 +37,7 @@ class CefStoragePartitionProxy : public content::StoragePartition {
content::ZoomLevelDelegate* GetZoomLevelDelegate() override; content::ZoomLevelDelegate* GetZoomLevelDelegate() override;
content::PlatformNotificationContext* GetPlatformNotificationContext() content::PlatformNotificationContext* GetPlatformNotificationContext()
override; override;
content::BackgroundFetchContext* GetBackgroundFetchContext() override;
content::BackgroundSyncContext* GetBackgroundSyncContext() override; content::BackgroundSyncContext* GetBackgroundSyncContext() override;
content::PaymentAppContextImpl* GetPaymentAppContext() override; content::PaymentAppContextImpl* GetPaymentAppContext() override;
content::BroadcastChannelProvider* GetBroadcastChannelProvider() override; content::BroadcastChannelProvider* GetBroadcastChannelProvider() override;
@ -59,6 +61,11 @@ class CefStoragePartitionProxy : public content::StoragePartition {
const base::Time begin, const base::Time begin,
const base::Time end, const base::Time end,
const base::Closure& callback) override; const base::Closure& callback) override;
void ClearHttpAndMediaCaches(
const base::Time begin,
const base::Time end,
const base::Callback<bool(const GURL&)>& url_matcher,
const base::Closure& callback) override;
void Flush() override; void Flush() override;
void ClearBluetoothAllowedDevicesMapForTesting() override; void ClearBluetoothAllowedDevicesMapForTesting() override;
void Bind( void Bind(

View File

@ -166,6 +166,10 @@ void CefBrowserPlatformDelegateViews::PopupBrowserCreated(
} }
} }
SkColor CefBrowserPlatformDelegateViews::GetBackgroundColor() const {
return native_delegate_->GetBackgroundColor();
}
void CefBrowserPlatformDelegateViews::WasResized() { void CefBrowserPlatformDelegateViews::WasResized() {
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost(); content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host) if (host)

View File

@ -42,6 +42,7 @@ class CefBrowserPlatformDelegateViews :
void PopupBrowserCreated( void PopupBrowserCreated(
CefBrowserHostImpl* new_browser, CefBrowserHostImpl* new_browser,
bool is_devtools) override; bool is_devtools) override;
SkColor GetBackgroundColor() const override;
void WasResized() override; void WasResized() override;
void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override; void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override;
void SendMouseEvent(const blink::WebMouseEvent& event) override; void SendMouseEvent(const blink::WebMouseEvent& event) override;

View File

@ -181,22 +181,8 @@ void CefBrowserViewImpl::SetPendingBrowserCreateParams(
} }
void CefBrowserViewImpl::SetDefaults(const CefBrowserSettings& settings) { void CefBrowserViewImpl::SetDefaults(const CefBrowserSettings& settings) {
SkColor background_color = SK_ColorWHITE; SetBackgroundColor(
if (CefColorGetA(settings.background_color) > 0) { CefContext::Get()->GetBackgroundColor(&settings, STATE_DISABLED));
background_color = SkColorSetRGB(
CefColorGetR(settings.background_color),
CefColorGetG(settings.background_color),
CefColorGetB(settings.background_color));
} else {
const CefSettings& global_settings = CefContext::Get()->settings();
if (CefColorGetA(global_settings.background_color) > 0) {
background_color = SkColorSetRGB(
CefColorGetR(global_settings.background_color),
CefColorGetG(global_settings.background_color),
CefColorGetB(global_settings.background_color));
}
}
SetBackgroundColor(background_color);
} }
CefBrowserViewView* CefBrowserViewImpl::CreateRootView() { CefBrowserViewView* CefBrowserViewImpl::CreateRootView() {
@ -213,7 +199,8 @@ bool CefBrowserViewImpl::HandleAccelerator(
// Previous calls to TranslateMessage can generate Char events as well as // Previous calls to TranslateMessage can generate Char events as well as
// RawKeyDown events, even if the latter triggered an accelerator. In these // RawKeyDown events, even if the latter triggered an accelerator. In these
// cases, we discard the Char events. // cases, we discard the Char events.
if (event.type() == blink::WebInputEvent::Char && ignore_next_char_event_) { if (event.GetType() == blink::WebInputEvent::kChar &&
ignore_next_char_event_) {
ignore_next_char_event_ = false; ignore_next_char_event_ = false;
return true; return true;
} }
@ -222,7 +209,7 @@ bool CefBrowserViewImpl::HandleAccelerator(
// always generate a Char event. // always generate a Char event.
ignore_next_char_event_ = false; ignore_next_char_event_ = false;
if (event.type() == blink::WebInputEvent::RawKeyDown) { if (event.GetType() == blink::WebInputEvent::kRawKeyDown) {
ui::Accelerator accelerator = ui::Accelerator accelerator =
ui::GetAcceleratorFromNativeWebKeyboardEvent(event); ui::GetAcceleratorFromNativeWebKeyboardEvent(event);

View File

@ -111,7 +111,7 @@ CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetEnabledTextColors(
CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetFontList( CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetFontList(
const CefString& font_list) { const CefString& font_list) {
CEF_REQUIRE_VALID_RETURN_VOID(); CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::root_view()->SetFontListDeprecated(gfx::FontList(font_list)); ParentClass::root_view()->SetFontList(gfx::FontList(font_list));
} }
CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetHorizontalAlignment( CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetHorizontalAlignment(

View File

@ -91,7 +91,7 @@ bool ParamTraits<scoped_refptr<net::UploadData> >::Read(
return false; return false;
if (!has_object) if (!has_object)
return true; return true;
ScopedVector<net::UploadElement> elements; net::UploadData::ElementsVector elements;
if (!ReadParam(m, iter, &elements)) if (!ReadParam(m, iter, &elements))
return false; return false;
int64_t identifier; int64_t identifier;

View File

@ -5,6 +5,7 @@
#include "cef/libcef/common/net/upload_data.h" #include "cef/libcef/common/net/upload_data.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h"
namespace net { namespace net {
@ -17,7 +18,7 @@ UploadData::UploadData()
void UploadData::AppendBytes(const char* bytes, int bytes_len) { void UploadData::AppendBytes(const char* bytes, int bytes_len) {
DCHECK(!is_chunked_); DCHECK(!is_chunked_);
if (bytes_len > 0) { if (bytes_len > 0) {
elements_.push_back(new UploadElement()); elements_.push_back(base::MakeUnique<UploadElement>());
elements_.back()->SetToBytes(bytes, bytes_len); elements_.back()->SetToBytes(bytes, bytes_len);
} }
} }
@ -26,7 +27,7 @@ void UploadData::AppendFileRange(const base::FilePath& file_path,
uint64_t offset, uint64_t length, uint64_t offset, uint64_t length,
const base::Time& expected_modification_time) { const base::Time& expected_modification_time) {
DCHECK(!is_chunked_); DCHECK(!is_chunked_);
elements_.push_back(new UploadElement()); elements_.push_back(base::MakeUnique<UploadElement>());
elements_.back()->SetToFilePathRange(file_path, offset, length, elements_.back()->SetToFilePathRange(file_path, offset, length,
expected_modification_time); expected_modification_time);
} }

View File

@ -7,10 +7,12 @@
#include <stdint.h> #include <stdint.h>
#include <memory>
#include <vector>
#include "libcef/common/net/upload_element.h" #include "libcef/common/net/upload_element.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
@ -49,15 +51,17 @@ class UploadData
void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; }
bool last_chunk_appended() const { return last_chunk_appended_; } bool last_chunk_appended() const { return last_chunk_appended_; }
const ScopedVector<UploadElement>& elements() const { using ElementsVector = std::vector<std::unique_ptr<UploadElement>>;
const ElementsVector& elements() const {
return elements_; return elements_;
} }
ScopedVector<UploadElement>* elements_mutable() { ElementsVector* elements_mutable() {
return &elements_; return &elements_;
} }
void swap_elements(ScopedVector<UploadElement>* elements) { void swap_elements(ElementsVector* elements) {
elements_.swap(*elements); elements_.swap(*elements);
} }
@ -72,7 +76,7 @@ class UploadData
~UploadData() override; ~UploadData() override;
ScopedVector<UploadElement> elements_; ElementsVector elements_;
int64_t identifier_; int64_t identifier_;
bool is_chunked_; bool is_chunked_;
bool last_chunk_appended_; bool last_chunk_appended_;

View File

@ -99,20 +99,20 @@ net::URLRequest::ReferrerPolicy GetURLRequestReferrerPolicy(
net::URLRequest::ReferrerPolicy net_referrer_policy = net::URLRequest::ReferrerPolicy net_referrer_policy =
net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
switch (static_cast<blink::WebReferrerPolicy>(policy)) { switch (static_cast<blink::WebReferrerPolicy>(policy)) {
case blink::WebReferrerPolicyAlways: case blink::kWebReferrerPolicyAlways:
case blink::WebReferrerPolicyNever: case blink::kWebReferrerPolicyNever:
case blink::WebReferrerPolicyOrigin: case blink::kWebReferrerPolicyOrigin:
net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER; net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER;
break; break;
case blink::WebReferrerPolicyNoReferrerWhenDowngrade: case blink::kWebReferrerPolicyNoReferrerWhenDowngrade:
net_referrer_policy = net_referrer_policy =
net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
break; break;
case blink::WebReferrerPolicyOriginWhenCrossOrigin: case blink::kWebReferrerPolicyOriginWhenCrossOrigin:
net_referrer_policy = net_referrer_policy =
net::URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN; net::URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN;
break; break;
case blink::WebReferrerPolicyDefault: case blink::kWebReferrerPolicyDefault:
default: default:
net_referrer_policy = net_referrer_policy =
command_line->HasSwitch(switches::kReducedReferrerGranularity) command_line->HasSwitch(switches::kReducedReferrerGranularity)
@ -138,9 +138,9 @@ std::string GetURLRequestReferrer(const GURL& referrer_url) {
blink::WebString FilePathStringToWebString( blink::WebString FilePathStringToWebString(
const base::FilePath::StringType& str) { const base::FilePath::StringType& str) {
#if defined(OS_POSIX) #if defined(OS_POSIX)
return blink::WebString::fromUTF8(str); return blink::WebString::FromUTF8(str);
#elif defined(OS_WIN) #elif defined(OS_WIN)
return blink::WebString::fromUTF16(str); return blink::WebString::FromUTF16(str);
#endif #endif
} }
@ -176,10 +176,10 @@ void GetHeaderMap(const blink::WebURLRequest& request,
referrer_(referrer) { referrer_(referrer) {
} }
void visitHeader(const blink::WebString& name, void VisitHeader(const blink::WebString& name,
const blink::WebString& value) override { const blink::WebString& value) override {
const base::string16& nameStr = name.utf16(); const base::string16& nameStr = name.Utf16();
const base::string16& valueStr = value.utf16(); const base::string16& valueStr = value.Utf16();
if (base::LowerCaseEqualsASCII(nameStr, kReferrerLowerCase)) if (base::LowerCaseEqualsASCII(nameStr, kReferrerLowerCase))
*referrer_ = GURL(valueStr); *referrer_ = GURL(valueStr);
else else
@ -192,7 +192,7 @@ void GetHeaderMap(const blink::WebURLRequest& request,
}; };
HeaderVisitor visitor(&map, &referrer); HeaderVisitor visitor(&map, &referrer);
request.visitHTTPHeaderFields(&visitor); request.VisitHTTPHeaderFields(&visitor);
} }
// Read |source| into |map|. // Read |source| into |map|.
@ -215,8 +215,8 @@ void SetHeaderMap(const CefRequest::HeaderMap& map,
blink::WebURLRequest& request) { blink::WebURLRequest& request) {
CefRequest::HeaderMap::const_iterator it = map.begin(); CefRequest::HeaderMap::const_iterator it = map.begin();
for (; it != map.end(); ++it) { for (; it != map.end(); ++it) {
request.setHTTPHeaderField(blink::WebString::fromUTF16(it->first), request.SetHTTPHeaderField(blink::WebString::FromUTF16(it->first),
blink::WebString::fromUTF16(it->second)); blink::WebString::FromUTF16(it->second));
} }
} }
@ -494,8 +494,8 @@ void CefRequestImpl::Get(net::URLRequest* request, bool changed_only) const {
if (ShouldSet(kChangedPostData, changed_only)) { if (ShouldSet(kChangedPostData, changed_only)) {
if (postdata_.get()) { if (postdata_.get()) {
request->set_upload(base::WrapUnique( request->set_upload(
static_cast<CefPostDataImpl*>(postdata_.get())->Get())); static_cast<CefPostDataImpl*>(postdata_.get())->Get());
} else if (request->get_upload()) { } else if (request->get_upload()) {
request->set_upload(std::unique_ptr<net::UploadDataStream>()); request->set_upload(std::unique_ptr<net::UploadDataStream>());
} }
@ -530,33 +530,33 @@ void CefRequestImpl::Set(
} }
void CefRequestImpl::Set(const blink::WebURLRequest& request) { void CefRequestImpl::Set(const blink::WebURLRequest& request) {
DCHECK(!request.isNull()); DCHECK(!request.IsNull());
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
CHECK_READONLY_RETURN_VOID(); CHECK_READONLY_RETURN_VOID();
Reset(); Reset();
url_ = request.url(); url_ = request.Url();
method_ = request.httpMethod().utf8(); method_ = request.HttpMethod().Utf8();
::GetHeaderMap(request, headermap_, referrer_url_); ::GetHeaderMap(request, headermap_, referrer_url_);
referrer_policy_ = referrer_policy_ =
static_cast<cef_referrer_policy_t>(request.getReferrerPolicy()); static_cast<cef_referrer_policy_t>(request.GetReferrerPolicy());
const blink::WebHTTPBody& body = request.httpBody(); const blink::WebHTTPBody& body = request.HttpBody();
if (!body.isNull()) { if (!body.IsNull()) {
postdata_ = new CefPostDataImpl(); postdata_ = new CefPostDataImpl();
static_cast<CefPostDataImpl*>(postdata_.get())->Set(body); static_cast<CefPostDataImpl*>(postdata_.get())->Set(body);
} }
first_party_for_cookies_ = request.firstPartyForCookies(); first_party_for_cookies_ = request.FirstPartyForCookies();
if (request.getCachePolicy() == blink::WebCachePolicy::BypassingCache) if (request.GetCachePolicy() == blink::WebCachePolicy::kBypassingCache)
flags_ |= UR_FLAG_SKIP_CACHE; flags_ |= UR_FLAG_SKIP_CACHE;
if (request.allowStoredCredentials()) if (request.AllowStoredCredentials())
flags_ |= UR_FLAG_ALLOW_CACHED_CREDENTIALS; flags_ |= UR_FLAG_ALLOW_CACHED_CREDENTIALS;
if (request.reportUploadProgress()) if (request.ReportUploadProgress())
flags_ |= UR_FLAG_REPORT_UPLOAD_PROGRESS; flags_ |= UR_FLAG_REPORT_UPLOAD_PROGRESS;
} }
@ -564,18 +564,18 @@ void CefRequestImpl::Get(blink::WebURLRequest& request,
int64& upload_data_size) const { int64& upload_data_size) const {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
request.setRequestContext(blink::WebURLRequest::RequestContextInternal); request.SetRequestContext(blink::WebURLRequest::kRequestContextInternal);
request.setURL(url_); request.SetURL(url_);
request.setHTTPMethod(blink::WebString::fromUTF8(method_)); request.SetHTTPMethod(blink::WebString::FromUTF8(method_));
if (!referrer_url_.is_empty()) { if (!referrer_url_.is_empty()) {
const blink::WebString& referrer = const blink::WebString& referrer =
blink::WebSecurityPolicy::generateReferrerHeader( blink::WebSecurityPolicy::GenerateReferrerHeader(
static_cast<blink::WebReferrerPolicy>(referrer_policy_), static_cast<blink::WebReferrerPolicy>(referrer_policy_),
url_, url_,
blink::WebString::fromUTF8(referrer_url_.spec())); blink::WebString::FromUTF8(referrer_url_.spec()));
if (!referrer.isEmpty()) { if (!referrer.IsEmpty()) {
request.setHTTPReferrer( request.SetHTTPReferrer(
referrer, referrer,
static_cast<blink::WebReferrerPolicy>(referrer_policy_)); static_cast<blink::WebReferrerPolicy>(referrer_policy_));
} }
@ -583,9 +583,9 @@ void CefRequestImpl::Get(blink::WebURLRequest& request,
if (postdata_.get()) { if (postdata_.get()) {
blink::WebHTTPBody body; blink::WebHTTPBody body;
body.initialize(); body.Initialize();
static_cast<CefPostDataImpl*>(postdata_.get())->Get(body); static_cast<CefPostDataImpl*>(postdata_.get())->Get(body);
request.setHTTPBody(body); request.SetHTTPBody(body);
if (flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) { if (flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
// Attempt to determine the upload data size. // Attempt to determine the upload data size.
@ -602,33 +602,33 @@ void CefRequestImpl::Get(blink::WebURLRequest& request,
::SetHeaderMap(headermap_, request); ::SetHeaderMap(headermap_, request);
if (!first_party_for_cookies_.is_empty()) if (!first_party_for_cookies_.is_empty())
request.setFirstPartyForCookies(first_party_for_cookies_); request.SetFirstPartyForCookies(first_party_for_cookies_);
request.setCachePolicy((flags_ & UR_FLAG_SKIP_CACHE) ? request.SetCachePolicy((flags_ & UR_FLAG_SKIP_CACHE) ?
blink::WebCachePolicy::BypassingCache : blink::WebCachePolicy::kBypassingCache :
blink::WebCachePolicy::UseProtocolCachePolicy); blink::WebCachePolicy::kUseProtocolCachePolicy);
SETBOOLFLAG(request, flags_, setAllowStoredCredentials, SETBOOLFLAG(request, flags_, SetAllowStoredCredentials,
UR_FLAG_ALLOW_CACHED_CREDENTIALS); UR_FLAG_ALLOW_CACHED_CREDENTIALS);
SETBOOLFLAG(request, flags_, setReportUploadProgress, SETBOOLFLAG(request, flags_, SetReportUploadProgress,
UR_FLAG_REPORT_UPLOAD_PROGRESS); UR_FLAG_REPORT_UPLOAD_PROGRESS);
} }
// static // static
void CefRequestImpl::Get(const CefMsg_LoadRequest_Params& params, void CefRequestImpl::Get(const CefMsg_LoadRequest_Params& params,
blink::WebURLRequest& request) { blink::WebURLRequest& request) {
request.setURL(params.url); request.SetURL(params.url);
if (!params.method.empty()) if (!params.method.empty())
request.setHTTPMethod(blink::WebString::fromASCII(params.method)); request.SetHTTPMethod(blink::WebString::FromASCII(params.method));
if (params.referrer.is_valid()) { if (params.referrer.is_valid()) {
const blink::WebString& referrer = const blink::WebString& referrer =
blink::WebSecurityPolicy::generateReferrerHeader( blink::WebSecurityPolicy::GenerateReferrerHeader(
static_cast<blink::WebReferrerPolicy>(params.referrer_policy), static_cast<blink::WebReferrerPolicy>(params.referrer_policy),
params.url, params.url,
blink::WebString::fromUTF8(params.referrer.spec())); blink::WebString::FromUTF8(params.referrer.spec()));
if (!referrer.isEmpty()) { if (!referrer.IsEmpty()) {
request.setHTTPReferrer( request.SetHTTPReferrer(
referrer, referrer,
static_cast<blink::WebReferrerPolicy>(params.referrer_policy)); static_cast<blink::WebReferrerPolicy>(params.referrer_policy));
} }
@ -638,59 +638,54 @@ void CefRequestImpl::Get(const CefMsg_LoadRequest_Params& params,
for (net::HttpUtil::HeadersIterator i(params.headers.begin(), for (net::HttpUtil::HeadersIterator i(params.headers.begin(),
params.headers.end(), "\n"); params.headers.end(), "\n");
i.GetNext(); ) { i.GetNext(); ) {
request.addHTTPHeaderField(blink::WebString::fromUTF8(i.name()), request.AddHTTPHeaderField(blink::WebString::FromUTF8(i.name()),
blink::WebString::fromUTF8(i.values())); blink::WebString::FromUTF8(i.values()));
} }
} }
if (params.upload_data.get()) { if (params.upload_data.get()) {
const base::string16& method = request.httpMethod().utf16(); const base::string16& method = request.HttpMethod().Utf16();
if (method == base::ASCIIToUTF16("GET") || if (method == base::ASCIIToUTF16("GET") ||
method == base::ASCIIToUTF16("HEAD")) { method == base::ASCIIToUTF16("HEAD")) {
request.setHTTPMethod(blink::WebString::fromASCII("POST")); request.SetHTTPMethod(blink::WebString::FromASCII("POST"));
} }
// The comparison performed by httpHeaderField() is case insensitive. // The comparison performed by httpHeaderField() is case insensitive.
if (request.httpHeaderField(blink::WebString::fromASCII( if (request.HttpHeaderField(blink::WebString::FromASCII(
net::HttpRequestHeaders::kContentType)).length()== 0) { net::HttpRequestHeaders::kContentType)).length()== 0) {
request.setHTTPHeaderField( request.SetHTTPHeaderField(
blink::WebString::fromASCII(net::HttpRequestHeaders::kContentType), blink::WebString::FromASCII(net::HttpRequestHeaders::kContentType),
blink::WebString::fromASCII(kApplicationFormURLEncoded)); blink::WebString::FromASCII(kApplicationFormURLEncoded));
} }
blink::WebHTTPBody body; blink::WebHTTPBody body;
body.initialize(); body.Initialize();
const ScopedVector<net::UploadElement>& elements = for (const auto& element : params.upload_data->elements()) {
params.upload_data->elements(); if (element->type() == net::UploadElement::TYPE_BYTES) {
ScopedVector<net::UploadElement>::const_iterator it =
elements.begin();
for (; it != elements.end(); ++it) {
const net::UploadElement& element = **it;
if (element.type() == net::UploadElement::TYPE_BYTES) {
blink::WebData data; blink::WebData data;
data.assign(element.bytes(), element.bytes_length()); data.Assign(element->bytes(), element->bytes_length());
body.appendData(data); body.AppendData(data);
} else if (element.type() == net::UploadElement::TYPE_FILE) { } else if (element->type() == net::UploadElement::TYPE_FILE) {
body.appendFile(FilePathStringToWebString(element.file_path().value())); body.AppendFile(FilePathStringToWebString(element->file_path().value()));
} else { } else {
NOTREACHED(); NOTREACHED();
} }
} }
request.setHTTPBody(body); request.SetHTTPBody(body);
} }
if (params.first_party_for_cookies.is_valid()) if (params.first_party_for_cookies.is_valid())
request.setFirstPartyForCookies(params.first_party_for_cookies); request.SetFirstPartyForCookies(params.first_party_for_cookies);
request.setCachePolicy((params.load_flags & UR_FLAG_SKIP_CACHE) ? request.SetCachePolicy((params.load_flags & UR_FLAG_SKIP_CACHE) ?
blink::WebCachePolicy::BypassingCache : blink::WebCachePolicy::kBypassingCache :
blink::WebCachePolicy::UseProtocolCachePolicy); blink::WebCachePolicy::kUseProtocolCachePolicy);
SETBOOLFLAG(request, params.load_flags, setAllowStoredCredentials, SETBOOLFLAG(request, params.load_flags, SetAllowStoredCredentials,
UR_FLAG_ALLOW_CACHED_CREDENTIALS); UR_FLAG_ALLOW_CACHED_CREDENTIALS);
SETBOOLFLAG(request, params.load_flags, setReportUploadProgress, SETBOOLFLAG(request, params.load_flags, SetReportUploadProgress,
UR_FLAG_REPORT_UPLOAD_PROGRESS); UR_FLAG_REPORT_UPLOAD_PROGRESS);
} }
@ -984,11 +979,9 @@ void CefPostDataImpl::Set(const net::UploadData& data) {
CefRefPtr<CefPostDataElement> postelem; CefRefPtr<CefPostDataElement> postelem;
const ScopedVector<net::UploadElement>& elements = data.elements(); for (const auto& element : data.elements()) {
ScopedVector<net::UploadElement>::const_iterator it = elements.begin();
for (; it != elements.end(); ++it) {
postelem = CefPostDataElement::Create(); postelem = CefPostDataElement::Create();
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(**it); static_cast<CefPostDataElementImpl*>(postelem.get())->Set(*element);
AddElement(postelem); AddElement(postelem);
} }
} }
@ -1018,27 +1011,28 @@ void CefPostDataImpl::Set(const net::UploadDataStream& data_stream) {
void CefPostDataImpl::Get(net::UploadData& data) const { void CefPostDataImpl::Get(net::UploadData& data) const {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
ScopedVector<net::UploadElement> data_elements; net::UploadData::ElementsVector data_elements;
ElementVector::const_iterator it = elements_.begin(); for (const auto& element : elements_) {
for (; it != elements_.end(); ++it) { std::unique_ptr<net::UploadElement> data_element =
net::UploadElement* element = new net::UploadElement(); base::MakeUnique<net::UploadElement>();
static_cast<CefPostDataElementImpl*>(it->get())->Get(*element); static_cast<CefPostDataElementImpl*>(element.get())->Get(
data_elements.push_back(element); *data_element.get());
data_elements.push_back(std::move(data_element));
} }
data.swap_elements(&data_elements); data.swap_elements(&data_elements);
} }
net::UploadDataStream* CefPostDataImpl::Get() const { std::unique_ptr<net::UploadDataStream> CefPostDataImpl::Get() const {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
UploadElementReaders element_readers; UploadElementReaders element_readers;
ElementVector::const_iterator it = elements_.begin(); for (const auto& element : elements_) {
for (; it != elements_.end(); ++it) { element_readers.push_back(
element_readers.push_back(base::WrapUnique( static_cast<CefPostDataElementImpl*>(element.get())->Get());
static_cast<CefPostDataElementImpl*>(it->get())->Get()));
} }
return new net::ElementsUploadDataStream(std::move(element_readers), 0); return base::MakeUnique<net::ElementsUploadDataStream>(
std::move(element_readers), 0);
} }
void CefPostDataImpl::Set(const blink::WebHTTPBody& data) { void CefPostDataImpl::Set(const blink::WebHTTPBody& data) {
@ -1049,9 +1043,9 @@ void CefPostDataImpl::Set(const blink::WebHTTPBody& data) {
CefRefPtr<CefPostDataElement> postelem; CefRefPtr<CefPostDataElement> postelem;
blink::WebHTTPBody::Element element; blink::WebHTTPBody::Element element;
size_t size = data.elementCount(); size_t size = data.ElementCount();
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
if (data.elementAt(i, element)) { if (data.ElementAt(i, element)) {
postelem = CefPostDataElement::Create(); postelem = CefPostDataElement::Create();
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(element); static_cast<CefPostDataElementImpl*>(postelem.get())->Set(element);
AddElement(postelem); AddElement(postelem);
@ -1066,10 +1060,10 @@ void CefPostDataImpl::Get(blink::WebHTTPBody& data) const {
ElementVector::const_iterator it = elements_.begin(); ElementVector::const_iterator it = elements_.begin();
for (; it != elements_.end(); ++it) { for (; it != elements_.end(); ++it) {
static_cast<CefPostDataElementImpl*>(it->get())->Get(element); static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
if (element.type == blink::WebHTTPBody::Element::TypeData) { if (element.type == blink::WebHTTPBody::Element::kTypeData) {
data.appendData(element.data); data.AppendData(element.data);
} else if (element.type == blink::WebHTTPBody::Element::TypeFile) { } else if (element.type == blink::WebHTTPBody::Element::kTypeFile) {
data.appendFile(element.filePath); data.AppendFile(element.file_path);
} else { } else {
NOTREACHED(); NOTREACHED();
} }
@ -1284,22 +1278,22 @@ void CefPostDataElementImpl::Get(net::UploadElement& element) const {
} }
} }
net::UploadElementReader* CefPostDataElementImpl::Get() const { std::unique_ptr<net::UploadElementReader> CefPostDataElementImpl::Get() const {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
if (type_ == PDE_TYPE_BYTES) { if (type_ == PDE_TYPE_BYTES) {
net::UploadElement* element = new net::UploadElement(); net::UploadElement* element = new net::UploadElement();
element->SetToBytes(static_cast<char*>(data_.bytes.bytes), element->SetToBytes(static_cast<char*>(data_.bytes.bytes),
data_.bytes.size); data_.bytes.size);
return new BytesElementReader(base::WrapUnique(element)); return base::MakeUnique<BytesElementReader>(base::WrapUnique(element));
} else if (type_ == PDE_TYPE_FILE) { } else if (type_ == PDE_TYPE_FILE) {
net::UploadElement* element = new net::UploadElement(); net::UploadElement* element = new net::UploadElement();
base::FilePath path = base::FilePath(CefString(&data_.filename)); base::FilePath path = base::FilePath(CefString(&data_.filename));
element->SetToFilePath(path); element->SetToFilePath(path);
return new FileElementReader(base::WrapUnique(element)); return base::MakeUnique<FileElementReader>(base::WrapUnique(element));
} else { } else {
NOTREACHED(); NOTREACHED();
return NULL; return nullptr;
} }
} }
@ -1309,11 +1303,11 @@ void CefPostDataElementImpl::Set(const blink::WebHTTPBody::Element& element) {
CHECK_READONLY_RETURN_VOID(); CHECK_READONLY_RETURN_VOID();
} }
if (element.type == blink::WebHTTPBody::Element::TypeData) { if (element.type == blink::WebHTTPBody::Element::kTypeData) {
SetToBytes(element.data.size(), SetToBytes(element.data.size(),
static_cast<const void*>(element.data.data())); static_cast<const void*>(element.data.Data()));
} else if (element.type == blink::WebHTTPBody::Element::TypeFile) { } else if (element.type == blink::WebHTTPBody::Element::kTypeFile) {
SetToFile(element.filePath.utf16()); SetToFile(element.file_path.Utf16());
} else { } else {
NOTREACHED(); NOTREACHED();
} }
@ -1323,13 +1317,13 @@ void CefPostDataElementImpl::Get(blink::WebHTTPBody::Element& element) const {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
if (type_ == PDE_TYPE_BYTES) { if (type_ == PDE_TYPE_BYTES) {
element.type = blink::WebHTTPBody::Element::TypeData; element.type = blink::WebHTTPBody::Element::kTypeData;
element.data.assign( element.data.Assign(
static_cast<char*>(data_.bytes.bytes), data_.bytes.size); static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
} else if (type_ == PDE_TYPE_FILE) { } else if (type_ == PDE_TYPE_FILE) {
element.type = blink::WebHTTPBody::Element::TypeFile; element.type = blink::WebHTTPBody::Element::kTypeFile;
element.filePath.assign( element.file_path.Assign(
blink::WebString::fromUTF16(CefString(&data_.filename))); blink::WebString::FromUTF16(CefString(&data_.filename)));
} else { } else {
NOTREACHED(); NOTREACHED();
} }

View File

@ -8,6 +8,8 @@
#include <stdint.h> #include <stdint.h>
#include <memory>
#include "include/cef_request.h" #include "include/cef_request.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
@ -166,7 +168,7 @@ class CefPostDataImpl : public CefPostData {
void Set(const net::UploadData& data); void Set(const net::UploadData& data);
void Set(const net::UploadDataStream& data_stream); void Set(const net::UploadDataStream& data_stream);
void Get(net::UploadData& data) const; void Get(net::UploadData& data) const;
net::UploadDataStream* Get() const; std::unique_ptr<net::UploadDataStream> Get() const;
void Set(const blink::WebHTTPBody& data); void Set(const blink::WebHTTPBody& data);
void Get(blink::WebHTTPBody& data) const; void Get(blink::WebHTTPBody& data) const;
@ -217,7 +219,7 @@ class CefPostDataElementImpl : public CefPostDataElement {
void Set(const net::UploadElement& element); void Set(const net::UploadElement& element);
void Set(const net::UploadElementReader& element_reader); void Set(const net::UploadElementReader& element_reader);
void Get(net::UploadElement& element) const; void Get(net::UploadElement& element) const;
net::UploadElementReader* Get() const; std::unique_ptr<net::UploadElementReader> Get() const;
void Set(const blink::WebHTTPBody::Element& element); void Set(const blink::WebHTTPBody::Element& element);
void Get(blink::WebHTTPBody::Element& element) const; void Get(blink::WebHTTPBody::Element& element) const;

View File

@ -185,25 +185,25 @@ void CefResponseImpl::SetResponseHeaders(
} }
void CefResponseImpl::Set(const blink::WebURLResponse& response) { void CefResponseImpl::Set(const blink::WebURLResponse& response) {
DCHECK(!response.isNull()); DCHECK(!response.IsNull());
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
CHECK_READONLY_RETURN_VOID(); CHECK_READONLY_RETURN_VOID();
blink::WebString str; blink::WebString str;
status_code_ = response.httpStatusCode(); status_code_ = response.HttpStatusCode();
str = response.httpStatusText(); str = response.HttpStatusText();
status_text_ = str.utf16(); status_text_ = str.Utf16();
str = response.mimeType(); str = response.MimeType();
mime_type_ = str.utf16(); mime_type_ = str.Utf16();
class HeaderVisitor : public blink::WebHTTPHeaderVisitor { class HeaderVisitor : public blink::WebHTTPHeaderVisitor {
public: public:
explicit HeaderVisitor(HeaderMap* map) : map_(map) {} explicit HeaderVisitor(HeaderMap* map) : map_(map) {}
void visitHeader(const blink::WebString& name, void VisitHeader(const blink::WebString& name,
const blink::WebString& value) override { const blink::WebString& value) override {
map_->insert(std::make_pair(name.utf16(), value.utf16())); map_->insert(std::make_pair(name.Utf16(), value.Utf16()));
} }
private: private:
@ -211,7 +211,7 @@ void CefResponseImpl::Set(const blink::WebURLResponse& response) {
}; };
HeaderVisitor visitor(&header_map_); HeaderVisitor visitor(&header_map_);
response.visitHTTPHeaderFields(&visitor); response.VisitHTTPHeaderFields(&visitor);
} }
void CefResponseImpl::Set(const net::URLRequest* request) { void CefResponseImpl::Set(const net::URLRequest* request) {

View File

@ -199,3 +199,40 @@ void CefValueController::TakeFrom(CefValueController* other) {
} }
} }
} }
void CefValueController::Swap(void* old_value, void* new_value) {
DCHECK(old_value && new_value && old_value != new_value);
// Controller should already be locked.
DCHECK(locked());
if (owner_value_ == old_value)
owner_value_ = new_value;
if (!reference_map_.empty()) {
ReferenceMap::iterator it = reference_map_.find(old_value);
if (it != reference_map_.end()) {
// References should only be added once.
DCHECK(reference_map_.find(new_value) == reference_map_.end());
reference_map_.insert(std::make_pair(new_value, it->second));
reference_map_.erase(it);
}
}
if (!dependency_map_.empty()) {
DependencyMap::iterator it = dependency_map_.find(old_value);
if (it != dependency_map_.end()) {
dependency_map_.insert(std::make_pair(new_value, it->second));
dependency_map_.erase(it);
}
it = dependency_map_.begin();
for (; it != dependency_map_.end(); ++it) {
DependencySet::iterator dit = it->second.find(old_value);
if (dit != it->second.end()) {
it->second.insert(new_value);
it->second.erase(dit);
}
}
}
}

View File

@ -109,6 +109,11 @@ class CefValueController
// |other|. The |other| controller must already be locked. // |other|. The |other| controller must already be locked.
void TakeFrom(CefValueController* other); void TakeFrom(CefValueController* other);
// Replace all instances of |old_value| with |new_value|. Used in cases where
// move semantics may move the contents of an object without retaining the
// object pointer itself.
void Swap(void* old_value, void* new_value);
protected: protected:
friend class base::RefCountedThreadSafe<CefValueController>; friend class base::RefCountedThreadSafe<CefValueController>;

View File

@ -13,7 +13,7 @@
// static // static
CefRefPtr<CefValue> CefValue::Create() { CefRefPtr<CefValue> CefValue::Create() {
return new CefValueImpl(base::Value::CreateNullValue().release()); return new CefValueImpl(new base::Value());
} }
// static // static
@ -25,9 +25,8 @@ CefRefPtr<CefValue> CefValueImpl::GetOrCreateRefOrCopy(
DCHECK(value); DCHECK(value);
if (value->IsType(base::Value::Type::BINARY)) { if (value->IsType(base::Value::Type::BINARY)) {
base::BinaryValue* binary_value = static_cast<base::BinaryValue*>(value);
return new CefValueImpl(CefBinaryValueImpl::GetOrCreateRef( return new CefValueImpl(CefBinaryValueImpl::GetOrCreateRef(
binary_value, parent_value, controller)); value, parent_value, controller));
} }
if (value->IsType(base::Value::Type::DICTIONARY)) { if (value->IsType(base::Value::Type::DICTIONARY)) {
@ -73,42 +72,48 @@ void CefValueImpl::SetValue(base::Value* value) {
SetValueInternal(value); SetValueInternal(value);
} }
base::Value* CefValueImpl::CopyOrTransferValue( base::Value* CefValueImpl::CopyOrDetachValue(
void* new_parent_value,
bool new_read_only,
CefValueController* new_controller) { CefValueController* new_controller) {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
if (binary_value_) { if (binary_value_) {
base::BinaryValue* value = return static_cast<CefBinaryValueImpl*>(binary_value_.get())->
static_cast<CefBinaryValueImpl*>(binary_value_.get())-> CopyOrDetachValue(new_controller);
CopyOrDetachValue(new_controller);
binary_value_ = CefBinaryValueImpl::GetOrCreateRef(
value, new_parent_value, new_controller);
return value;
} }
if (dictionary_value_) { if (dictionary_value_) {
base::DictionaryValue* value = return static_cast<CefDictionaryValueImpl*>(dictionary_value_.get())->
static_cast<CefDictionaryValueImpl*>(dictionary_value_.get())-> CopyOrDetachValue(new_controller);
CopyOrDetachValue(new_controller);
dictionary_value_ = CefDictionaryValueImpl::GetOrCreateRef(
value, new_parent_value, new_read_only, new_controller);
return value;
} }
if (list_value_) { if (list_value_) {
base::ListValue* value = return static_cast<CefListValueImpl*>(list_value_.get())->
static_cast<CefListValueImpl*>(list_value_.get())-> CopyOrDetachValue(new_controller);
CopyOrDetachValue(new_controller);
list_value_ = CefListValueImpl::GetOrCreateRef(
value, new_parent_value, new_read_only, new_controller);
return value;
} }
return value_->DeepCopy(); return value_->DeepCopy();
} }
void CefValueImpl::SwapValue(
base::Value* new_value,
void* new_parent_value,
CefValueController* new_controller) {
base::AutoLock lock_scope(lock_);
if (binary_value_) {
binary_value_ = CefBinaryValueImpl::GetOrCreateRef(
new_value, new_parent_value, new_controller);
} else if (dictionary_value_) {
dictionary_value_ = CefDictionaryValueImpl::GetOrCreateRef(
static_cast<base::DictionaryValue*>(new_value), new_parent_value,
false, new_controller);
} else if (list_value_) {
list_value_ = CefListValueImpl::GetOrCreateRef(
static_cast<base::ListValue*>(new_value), new_parent_value,
false, new_controller);
}
}
bool CefValueImpl::IsValid() { bool CefValueImpl::IsValid() {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
@ -292,7 +297,7 @@ CefRefPtr<CefListValue> CefValueImpl::GetList() {
} }
bool CefValueImpl::SetNull() { bool CefValueImpl::SetNull() {
SetValue(base::Value::CreateNullValue().release()); SetValue(new base::Value());
return true; return true;
} }
@ -312,7 +317,7 @@ bool CefValueImpl::SetDouble(double value) {
} }
bool CefValueImpl::SetString(const CefString& value) { bool CefValueImpl::SetString(const CefString& value) {
SetValue(new base::StringValue(value.ToString())); SetValue(new base::Value(value.ToString()));
return true; return true;
} }
@ -348,8 +353,7 @@ void CefValueImpl::SetValueInternal(base::Value* value) {
if (value) { if (value) {
switch (value->GetType()) { switch (value->GetType()) {
case base::Value::Type::BINARY: case base::Value::Type::BINARY:
binary_value_ = new CefBinaryValueImpl( binary_value_ = new CefBinaryValueImpl(value, true);
static_cast<base::BinaryValue*>(value), true);
return; return;
case base::Value::Type::DICTIONARY: case base::Value::Type::DICTIONARY:
dictionary_value_ = new CefDictionaryValueImpl( dictionary_value_ = new CefDictionaryValueImpl(
@ -430,7 +434,7 @@ CefRefPtr<CefBinaryValue> CefBinaryValue::Create(const void* data,
// static // static
CefRefPtr<CefBinaryValue> CefBinaryValueImpl::GetOrCreateRef( CefRefPtr<CefBinaryValue> CefBinaryValueImpl::GetOrCreateRef(
base::BinaryValue* value, base::Value* value,
void* parent_value, void* parent_value,
CefValueController* controller) { CefValueController* controller) {
DCHECK(value); DCHECK(value);
@ -445,28 +449,28 @@ CefRefPtr<CefBinaryValue> CefBinaryValueImpl::GetOrCreateRef(
CefBinaryValueImpl::kReference, controller); CefBinaryValueImpl::kReference, controller);
} }
CefBinaryValueImpl::CefBinaryValueImpl(base::BinaryValue* value, CefBinaryValueImpl::CefBinaryValueImpl(base::Value* value,
bool will_delete) bool will_delete)
: CefValueBase<CefBinaryValue, base::BinaryValue>( : CefValueBase<CefBinaryValue, base::Value>(
value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete, value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete,
true, NULL) { true, NULL) {
} }
CefBinaryValueImpl::CefBinaryValueImpl(char* data, CefBinaryValueImpl::CefBinaryValueImpl(char* data,
size_t data_size) size_t data_size)
: CefValueBase<CefBinaryValue, base::BinaryValue>( : CefValueBase<CefBinaryValue, base::Value>(
new base::BinaryValue(std::vector<char>(data, data + data_size)), new base::Value(std::vector<char>(data, data + data_size)),
NULL, kOwnerWillDelete, true, NULL) { NULL, kOwnerWillDelete, true, NULL) {
} }
base::BinaryValue* CefBinaryValueImpl::CopyValue() { base::Value* CefBinaryValueImpl::CopyValue() {
CEF_VALUE_VERIFY_RETURN(false, NULL); CEF_VALUE_VERIFY_RETURN(false, NULL);
return const_value().DeepCopy(); return const_value().DeepCopy();
} }
base::BinaryValue* CefBinaryValueImpl::CopyOrDetachValue( base::Value* CefBinaryValueImpl::CopyOrDetachValue(
CefValueController* new_controller) { CefValueController* new_controller) {
base::BinaryValue* new_value; base::Value* new_value;
if (!will_delete()) { if (!will_delete()) {
// Copy the value. // Copy the value.
@ -480,21 +484,21 @@ base::BinaryValue* CefBinaryValueImpl::CopyOrDetachValue(
return new_value; return new_value;
} }
bool CefBinaryValueImpl::IsSameValue(const base::BinaryValue* that) { bool CefBinaryValueImpl::IsSameValue(const base::Value* that) {
CEF_VALUE_VERIFY_RETURN(false, false); CEF_VALUE_VERIFY_RETURN(false, false);
return (&const_value() == that); return (&const_value() == that);
} }
bool CefBinaryValueImpl::IsEqualValue(const base::BinaryValue* that) { bool CefBinaryValueImpl::IsEqualValue(const base::Value* that) {
CEF_VALUE_VERIFY_RETURN(false, false); CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().Equals(that); return const_value().Equals(that);
} }
base::BinaryValue* CefBinaryValueImpl::GetValueUnsafe() { base::Value* CefBinaryValueImpl::GetValueUnsafe() {
if (!VerifyAttached()) if (!VerifyAttached())
return NULL; return NULL;
controller()->AssertLockAcquired(); controller()->AssertLockAcquired();
return const_cast<base::BinaryValue*>(&const_value()); return const_cast<base::Value*>(&const_value());
} }
bool CefBinaryValueImpl::IsValid() { bool CefBinaryValueImpl::IsValid() {
@ -559,11 +563,11 @@ size_t CefBinaryValueImpl::GetData(void* buffer,
return size; return size;
} }
CefBinaryValueImpl::CefBinaryValueImpl(base::BinaryValue* value, CefBinaryValueImpl::CefBinaryValueImpl(base::Value* value,
void* parent_value, void* parent_value,
ValueMode value_mode, ValueMode value_mode,
CefValueController* controller) CefValueController* controller)
: CefValueBase<CefBinaryValue, base::BinaryValue>( : CefValueBase<CefBinaryValue, base::Value>(
value, parent_value, value_mode, true, controller) { value, parent_value, value_mode, true, controller) {
} }
@ -823,8 +827,7 @@ CefRefPtr<CefBinaryValue> CefDictionaryValueImpl::GetBinary(
if (const_value().GetWithoutPathExpansion(base::StringPiece(key), if (const_value().GetWithoutPathExpansion(base::StringPiece(key),
&out_value) && &out_value) &&
out_value->IsType(base::Value::Type::BINARY)) { out_value->IsType(base::Value::Type::BINARY)) {
base::BinaryValue* binary_value = base::Value* binary_value = const_cast<base::Value*>(out_value);
static_cast<base::BinaryValue*>(const_cast<base::Value*>(out_value));
return CefBinaryValueImpl::GetOrCreateRef(binary_value, return CefBinaryValueImpl::GetOrCreateRef(binary_value,
const_cast<base::DictionaryValue*>(&const_value()), controller()); const_cast<base::DictionaryValue*>(&const_value()), controller());
} }
@ -881,15 +884,15 @@ bool CefDictionaryValueImpl::SetValue(const CefString& key,
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get()); CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
DCHECK(impl); DCHECK(impl);
base::Value* new_value = base::Value* new_value = impl->CopyOrDetachValue(controller());
impl->CopyOrTransferValue(mutable_value(), false, controller()); base::Value* actual_value = SetInternal(key, new_value);
SetInternal(key, new_value); impl->SwapValue(actual_value, mutable_value(), controller());
return true; return true;
} }
bool CefDictionaryValueImpl::SetNull(const CefString& key) { bool CefDictionaryValueImpl::SetNull(const CefString& key) {
CEF_VALUE_VERIFY_RETURN(true, false); CEF_VALUE_VERIFY_RETURN(true, false);
SetInternal(key, base::Value::CreateNullValue().release()); SetInternal(key, new base::Value());
return true; return true;
} }
@ -914,7 +917,7 @@ bool CefDictionaryValueImpl::SetDouble(const CefString& key, double value) {
bool CefDictionaryValueImpl::SetString(const CefString& key, bool CefDictionaryValueImpl::SetString(const CefString& key,
const CefString& value) { const CefString& value) {
CEF_VALUE_VERIFY_RETURN(true, false); CEF_VALUE_VERIFY_RETURN(true, false);
SetInternal(key, new base::StringValue(value.ToString())); SetInternal(key, new base::Value(value.ToString()));
return true; return true;
} }
@ -971,11 +974,12 @@ bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) {
return true; return true;
} }
void CefDictionaryValueImpl::SetInternal(const CefString& key, base::Value* CefDictionaryValueImpl::SetInternal(const CefString& key,
base::Value* value) { base::Value* value) {
DCHECK(value); DCHECK(value);
RemoveInternal(key); RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(base::StringPiece(key), value); mutable_value()->SetWithoutPathExpansion(base::StringPiece(key), value);
return value;
} }
CefDictionaryValueImpl::CefDictionaryValueImpl( CefDictionaryValueImpl::CefDictionaryValueImpl(
@ -1107,7 +1111,7 @@ bool CefListValueImpl::SetSize(size_t size) {
RemoveInternal(i); RemoveInternal(i);
} else if (size > 0) { } else if (size > 0) {
// Expand the list size. // Expand the list size.
mutable_value()->Set(size-1, base::Value::CreateNullValue()); mutable_value()->Set(size-1, base::MakeUnique<base::Value>());
} }
return true; return true;
} }
@ -1230,8 +1234,7 @@ CefRefPtr<CefBinaryValue> CefListValueImpl::GetBinary(size_t index) {
if (const_value().Get(index, &out_value) && if (const_value().Get(index, &out_value) &&
out_value->IsType(base::Value::Type::BINARY)) { out_value->IsType(base::Value::Type::BINARY)) {
base::BinaryValue* binary_value = base::Value* binary_value = const_cast<base::Value*>(out_value);
static_cast<base::BinaryValue*>(const_cast<base::Value*>(out_value));
return CefBinaryValueImpl::GetOrCreateRef(binary_value, return CefBinaryValueImpl::GetOrCreateRef(binary_value,
const_cast<base::ListValue*>(&const_value()), controller()); const_cast<base::ListValue*>(&const_value()), controller());
} }
@ -1284,15 +1287,15 @@ bool CefListValueImpl::SetValue(size_t index, CefRefPtr<CefValue> value) {
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get()); CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
DCHECK(impl); DCHECK(impl);
base::Value* new_value = base::Value* new_value = impl->CopyOrDetachValue(controller());
impl->CopyOrTransferValue(mutable_value(), false, controller()); base::Value* actual_value = SetInternal(index, new_value);
SetInternal(index, new_value); impl->SwapValue(actual_value, mutable_value(), controller());
return true; return true;
} }
bool CefListValueImpl::SetNull(size_t index) { bool CefListValueImpl::SetNull(size_t index) {
CEF_VALUE_VERIFY_RETURN(true, false); CEF_VALUE_VERIFY_RETURN(true, false);
SetInternal(index, base::Value::CreateNullValue().release()); SetInternal(index, new base::Value());
return true; return true;
} }
@ -1316,7 +1319,7 @@ bool CefListValueImpl::SetDouble(size_t index, double value) {
bool CefListValueImpl::SetString(size_t index, const CefString& value) { bool CefListValueImpl::SetString(size_t index, const CefString& value) {
CEF_VALUE_VERIFY_RETURN(true, false); CEF_VALUE_VERIFY_RETURN(true, false);
SetInternal(index, new base::StringValue(value.ToString())); SetInternal(index, new base::Value(value.ToString()));
return true; return true;
} }
@ -1353,28 +1356,52 @@ bool CefListValueImpl::SetList(size_t index, CefRefPtr<CefListValue> value) {
} }
bool CefListValueImpl::RemoveInternal(size_t index) { bool CefListValueImpl::RemoveInternal(size_t index) {
// base::Value now uses move semantics which means that Remove() will return
// a new base::Value object with the moved contents of the base::Value that
// exists in the implementation std::vector. Consequently we use Get() to
// retrieve the actual base::Value pointer as it exists in the std::vector.
const base::Value* actual_value = nullptr;
if (!const_value().Get(index, &actual_value))
return false;
DCHECK(actual_value);
std::unique_ptr<base::Value> out_value; std::unique_ptr<base::Value> out_value;
if (!mutable_value()->Remove(index, &out_value)) if (!mutable_value()->Remove(index, &out_value))
return false; return false;
// Remove the value. // Remove the value.
controller()->Remove(out_value.get(), true); controller()->Remove(const_cast<base::Value*>(actual_value), true);
// Only list and dictionary types may have dependencies. // Only list and dictionary types may have dependencies.
if (out_value->IsType(base::Value::Type::LIST) || if (out_value->IsType(base::Value::Type::LIST) ||
out_value->IsType(base::Value::Type::DICTIONARY)) { out_value->IsType(base::Value::Type::DICTIONARY)) {
controller()->RemoveDependencies(out_value.get()); controller()->RemoveDependencies(const_cast<base::Value*>(actual_value));
} }
return true; return true;
} }
void CefListValueImpl::SetInternal(size_t index, base::Value* value) { base::Value* CefListValueImpl::SetInternal(size_t index, base::Value* value) {
DCHECK(value); DCHECK(value);
if (RemoveInternal(index)) if (RemoveInternal(index))
mutable_value()->Insert(index, base::WrapUnique(value)); mutable_value()->Insert(index, base::WrapUnique(value));
else else
mutable_value()->Set(index, value); mutable_value()->Set(index, base::WrapUnique(value));
// base::Value now uses move semantics which means that Insert()/Set() will
// move the contents of the passed-in base::Value instead of keeping the same
// object. Consequently we use Get() to retrieve the actual base::Value
// pointer as it exists in the std::vector.
const base::Value* actual_value = nullptr;
const_value().Get(index, &actual_value);
DCHECK(actual_value);
// |value| will have been deleted at this point. Update the controller to
// reference |actual_value| instead.
controller()->Swap(value, const_cast<base::Value*>(actual_value));
return const_cast<base::Value*>(actual_value);
} }
CefListValueImpl::CefListValueImpl( CefListValueImpl::CefListValueImpl(

View File

@ -44,10 +44,12 @@ class CefValueImpl : public CefValue {
// Copy a simple value or transfer ownership of a complex value. If ownership // Copy a simple value or transfer ownership of a complex value. If ownership
// of the value is tranferred then this object's internal reference to the // of the value is tranferred then this object's internal reference to the
// value will be updated and remain valid. // value will be updated and remain valid. base::Value now uses move semantics
base::Value* CopyOrTransferValue(void* new_parent_value, // so we need to perform the copy and swap in two steps.
bool new_read_only, base::Value* CopyOrDetachValue(CefValueController* new_controller);
CefValueController* new_controller); void SwapValue(base::Value* new_value,
void* new_parent_value,
CefValueController* new_controller);
// Returns a reference to the underlying data. Access must be protected by // Returns a reference to the underlying data. Access must be protected by
// calling AcquireLock/ReleaseLock. // calling AcquireLock/ReleaseLock.
@ -126,11 +128,11 @@ class CefValueImpl : public CefValue {
// CefBinaryValue implementation // CefBinaryValue implementation
class CefBinaryValueImpl class CefBinaryValueImpl
: public CefValueBase<CefBinaryValue, base::BinaryValue> { : public CefValueBase<CefBinaryValue, base::Value> {
public: public:
// Get or create a reference value. // Get or create a reference value.
static CefRefPtr<CefBinaryValue> GetOrCreateRef( static CefRefPtr<CefBinaryValue> GetOrCreateRef(
base::BinaryValue* value, base::Value* value,
void* parent_value, void* parent_value,
CefValueController* controller); CefValueController* controller);
@ -140,7 +142,7 @@ class CefBinaryValueImpl
// longer valid. Use GetOrCreateRef instead of this constructor if |value| is // longer valid. Use GetOrCreateRef instead of this constructor if |value| is
// owned by some other object and you do not plan to explicitly call // owned by some other object and you do not plan to explicitly call
// Detach(NULL). // Detach(NULL).
CefBinaryValueImpl(base::BinaryValue* value, CefBinaryValueImpl(base::Value* value,
bool will_delete); bool will_delete);
// The data will always be copied. // The data will always be copied.
@ -148,18 +150,18 @@ class CefBinaryValueImpl
size_t data_size); size_t data_size);
// Return a copy of the value. // Return a copy of the value.
base::BinaryValue* CopyValue(); base::Value* CopyValue();
// If this value is a reference then return a copy. Otherwise, detach and // If this value is a reference then return a copy. Otherwise, detach and
// transfer ownership of the value. // transfer ownership of the value.
base::BinaryValue* CopyOrDetachValue(CefValueController* new_controller); base::Value* CopyOrDetachValue(CefValueController* new_controller);
bool IsSameValue(const base::BinaryValue* that); bool IsSameValue(const base::Value* that);
bool IsEqualValue(const base::BinaryValue* that); bool IsEqualValue(const base::Value* that);
// Returns the underlying value. Access must be protected by calling // Returns the underlying value. Access must be protected by calling
// lock/unlock on the controller. // lock/unlock on the controller.
base::BinaryValue* GetValueUnsafe(); base::Value* GetValueUnsafe();
// CefBinaryValue methods. // CefBinaryValue methods.
bool IsValid() override; bool IsValid() override;
@ -175,7 +177,7 @@ class CefBinaryValueImpl
private: private:
// See the CefValueBase constructor for usage. Binary values are always // See the CefValueBase constructor for usage. Binary values are always
// read-only. // read-only.
CefBinaryValueImpl(base::BinaryValue* value, CefBinaryValueImpl(base::Value* value,
void* parent_value, void* parent_value,
ValueMode value_mode, ValueMode value_mode,
CefValueController* controller); CefValueController* controller);
@ -265,7 +267,7 @@ class CefDictionaryValueImpl
CefValueController* controller); CefValueController* controller);
bool RemoveInternal(const CefString& key); bool RemoveInternal(const CefString& key);
void SetInternal(const CefString& key, base::Value* value); base::Value* SetInternal(const CefString& key, base::Value* value);
DISALLOW_COPY_AND_ASSIGN(CefDictionaryValueImpl); DISALLOW_COPY_AND_ASSIGN(CefDictionaryValueImpl);
}; };
@ -346,7 +348,7 @@ class CefListValueImpl
CefValueController* controller); CefValueController* controller);
bool RemoveInternal(size_t index); bool RemoveInternal(size_t index);
void SetInternal(size_t index, base::Value* value); base::Value* SetInternal(size_t index, base::Value* value);
DISALLOW_COPY_AND_ASSIGN(CefListValueImpl); DISALLOW_COPY_AND_ASSIGN(CefListValueImpl);
}; };

View File

@ -47,7 +47,7 @@ class CefWidevineLoader {
#endif #endif
private: private:
friend struct base::DefaultLazyInstanceTraits<CefWidevineLoader>; friend struct base::LazyInstanceTraitsBase<CefWidevineLoader>;
// Members are only accessed before context initialization or on the UI // Members are only accessed before context initialization or on the UI
// thread. // thread.

View File

@ -46,7 +46,6 @@ using blink::WebString;
using blink::WebURL; using blink::WebURL;
using blink::WebView; using blink::WebView;
// CefBrowserImpl static methods. // CefBrowserImpl static methods.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -99,9 +98,9 @@ bool CefBrowserImpl::IsLoading() {
CEF_REQUIRE_RT_RETURN(false); CEF_REQUIRE_RT_RETURN(false);
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); blink::WebFrame* main_frame = render_view()->GetWebView()->MainFrame();
if (main_frame) if (main_frame)
return main_frame->toWebLocalFrame()->isLoading(); return main_frame->ToWebLocalFrame()->IsLoading();
} }
return false; return false;
} }
@ -109,26 +108,26 @@ bool CefBrowserImpl::IsLoading() {
void CefBrowserImpl::Reload() { void CefBrowserImpl::Reload() {
CEF_REQUIRE_RT_RETURN_VOID(); CEF_REQUIRE_RT_RETURN_VOID();
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { if (render_view()->GetWebView() && render_view()->GetWebView()->MainFrame()) {
render_view()->GetWebView()->mainFrame()->reload( render_view()->GetWebView()->MainFrame()->Reload(
blink::WebFrameLoadType::Reload); blink::WebFrameLoadType::kReload);
} }
} }
void CefBrowserImpl::ReloadIgnoreCache() { void CefBrowserImpl::ReloadIgnoreCache() {
CEF_REQUIRE_RT_RETURN_VOID(); CEF_REQUIRE_RT_RETURN_VOID();
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { if (render_view()->GetWebView() && render_view()->GetWebView()->MainFrame()) {
render_view()->GetWebView()->mainFrame()->reload( render_view()->GetWebView()->MainFrame()->Reload(
blink::WebFrameLoadType::ReloadBypassingCache); blink::WebFrameLoadType::kReloadBypassingCache);
} }
} }
void CefBrowserImpl::StopLoad() { void CefBrowserImpl::StopLoad() {
CEF_REQUIRE_RT_RETURN_VOID(); CEF_REQUIRE_RT_RETURN_VOID();
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) if (render_view()->GetWebView() && render_view()->GetWebView()->MainFrame())
render_view()->GetWebView()->mainFrame()->stopLoading(); render_view()->GetWebView()->MainFrame()->StopLoading();
} }
int CefBrowserImpl::GetIdentifier() { int CefBrowserImpl::GetIdentifier() {
@ -153,16 +152,16 @@ bool CefBrowserImpl::IsPopup() {
bool CefBrowserImpl::HasDocument() { bool CefBrowserImpl::HasDocument() {
CEF_REQUIRE_RT_RETURN(false); CEF_REQUIRE_RT_RETURN(false);
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) if (render_view()->GetWebView() && render_view()->GetWebView()->MainFrame())
return !render_view()->GetWebView()->mainFrame()->document().isNull(); return !render_view()->GetWebView()->MainFrame()->GetDocument().IsNull();
return false; return false;
} }
CefRefPtr<CefFrame> CefBrowserImpl::GetMainFrame() { CefRefPtr<CefFrame> CefBrowserImpl::GetMainFrame() {
CEF_REQUIRE_RT_RETURN(nullptr); CEF_REQUIRE_RT_RETURN(nullptr);
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) if (render_view()->GetWebView() && render_view()->GetWebView()->MainFrame())
return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()).get(); return GetWebFrameImpl(render_view()->GetWebView()->MainFrame()).get();
return nullptr; return nullptr;
} }
@ -170,8 +169,8 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFocusedFrame() {
CEF_REQUIRE_RT_RETURN(nullptr); CEF_REQUIRE_RT_RETURN(nullptr);
if (render_view()->GetWebView() && if (render_view()->GetWebView() &&
render_view()->GetWebView()->focusedFrame()) { render_view()->GetWebView()->FocusedFrame()) {
return GetWebFrameImpl(render_view()->GetWebView()->focusedFrame()).get(); return GetWebFrameImpl(render_view()->GetWebView()->FocusedFrame()).get();
} }
return nullptr; return nullptr;
} }
@ -187,14 +186,20 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name) {
blink::WebView* web_view = render_view()->GetWebView(); blink::WebView* web_view = render_view()->GetWebView();
if (web_view) { if (web_view) {
const blink::WebString& frame_name = blink::WebString::fromUTF16(name); const blink::WebString& frame_name = blink::WebString::FromUTF16(name);
// Search by assigned frame name (Frame::name). // Search by assigned frame name (Frame::name).
WebFrame* frame = web_view->findFrameByName(frame_name, WebFrame* frame = web_view->FindFrameByName(frame_name,
web_view->mainFrame()); web_view->MainFrame());
if (!frame) { if (!frame) {
// Search by unique frame name (Frame::uniqueName). // Search by unique frame name (Frame::uniqueName).
frame = webkit_glue::FindFrameByUniqueName(frame_name, const std::string& searchname = name;
web_view->mainFrame()); for (WebFrame* cur_frame = web_view->MainFrame(); cur_frame;
cur_frame = cur_frame->TraverseNext()) {
if (webkit_glue::GetUniqueName(cur_frame) == searchname) {
frame = cur_frame;
break;
}
}
} }
if (frame) if (frame)
return GetWebFrameImpl(frame).get(); return GetWebFrameImpl(frame).get();
@ -209,8 +214,8 @@ size_t CefBrowserImpl::GetFrameCount() {
int count = 0; int count = 0;
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; for (WebFrame* frame = render_view()->GetWebView()->MainFrame(); frame;
frame = frame->traverseNext()) { frame = frame->TraverseNext()) {
count++; count++;
} }
} }
@ -225,8 +230,8 @@ void CefBrowserImpl::GetFrameIdentifiers(std::vector<int64>& identifiers) {
identifiers.clear(); identifiers.clear();
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; for (WebFrame* frame = render_view()->GetWebView()->MainFrame(); frame;
frame = frame->traverseNext()) { frame = frame->TraverseNext()) {
identifiers.push_back(webkit_glue::GetIdentifier(frame)); identifiers.push_back(webkit_glue::GetIdentifier(frame));
} }
} }
@ -239,9 +244,9 @@ void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names) {
names.clear(); names.clear();
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; for (WebFrame* frame = render_view()->GetWebView()->MainFrame(); frame;
frame = frame->traverseNext()) { frame = frame->TraverseNext()) {
names.push_back(CefString(frame->uniqueName().utf8())); names.push_back(webkit_glue::GetUniqueName(frame));
} }
} }
} }
@ -287,7 +292,7 @@ void CefBrowserImpl::LoadRequest(const CefMsg_LoadRequest_Params& params) {
blink::WebURLRequest request; blink::WebURLRequest request;
CefRequestImpl::Get(params, request); CefRequestImpl::Get(params, request);
web_frame->loadRequest(request); web_frame->LoadRequest(request);
} }
bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process, bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process,
@ -322,10 +327,11 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(
CefRefPtr<CefFrameImpl> framePtr(new CefFrameImpl(this, frame)); CefRefPtr<CefFrameImpl> framePtr(new CefFrameImpl(this, frame));
frames_.insert(std::make_pair(frame_id, framePtr)); frames_.insert(std::make_pair(frame_id, framePtr));
int64_t parent_id = frame->parent() == NULL ? const int64_t parent_id = frame->Parent() == NULL ?
webkit_glue::kInvalidFrameId : webkit_glue::kInvalidFrameId :
webkit_glue::GetIdentifier(frame->parent()); webkit_glue::GetIdentifier(frame->Parent());
base::string16 name = frame->uniqueName().utf16(); const base::string16& name =
base::UTF8ToUTF16(webkit_glue::GetUniqueName(frame));
// Notify the browser that the frame has been identified. // Notify the browser that the frame has been identified.
Send(new CefHostMsg_FrameIdentified(routing_id(), frame_id, parent_id, name)); Send(new CefHostMsg_FrameIdentified(routing_id(), frame_id, parent_id, name));
@ -335,8 +341,8 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(
CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) { CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) {
if (frame_id == webkit_glue::kInvalidFrameId) { if (frame_id == webkit_glue::kInvalidFrameId) {
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) if (render_view()->GetWebView() && render_view()->GetWebView()->MainFrame())
return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()); return GetWebFrameImpl(render_view()->GetWebView()->MainFrame());
return nullptr; return nullptr;
} }
@ -347,8 +353,8 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) {
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
// Check if the frame exists but we don't know about it yet. // Check if the frame exists but we don't know about it yet.
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; for (WebFrame* frame = render_view()->GetWebView()->MainFrame(); frame;
frame = frame->traverseNext()) { frame = frame->TraverseNext()) {
if (webkit_glue::GetIdentifier(frame) == frame_id) if (webkit_glue::GetIdentifier(frame) == frame_id)
return GetWebFrameImpl(frame); return GetWebFrameImpl(frame);
} }
@ -416,12 +422,12 @@ void CefBrowserImpl::DidFailLoad(
} }
void CefBrowserImpl::DidFinishLoad(blink::WebLocalFrame* frame) { void CefBrowserImpl::DidFinishLoad(blink::WebLocalFrame* frame) {
blink::WebDataSource* ds = frame->dataSource(); blink::WebDataSource* ds = frame->DataSource();
Send(new CefHostMsg_DidFinishLoad(routing_id(), Send(new CefHostMsg_DidFinishLoad(routing_id(),
webkit_glue::GetIdentifier(frame), webkit_glue::GetIdentifier(frame),
ds->getRequest().url(), ds->GetRequest().Url(),
!frame->parent(), !frame->Parent(),
ds->response().httpStatusCode())); ds->GetResponse().HttpStatusCode()));
OnLoadEnd(frame); OnLoadEnd(frame);
} }
@ -468,12 +474,12 @@ void CefBrowserImpl::FocusedNodeChanged(const blink::WebNode& node) {
CefRefPtr<CefRenderProcessHandler> handler = CefRefPtr<CefRenderProcessHandler> handler =
app->GetRenderProcessHandler(); app->GetRenderProcessHandler();
if (handler.get()) { if (handler.get()) {
if (node.isNull()) { if (node.IsNull()) {
handler->OnFocusedNodeChanged(this, GetFocusedFrame(), NULL); handler->OnFocusedNodeChanged(this, GetFocusedFrame(), NULL);
} else { } else {
const blink::WebDocument& document = node.document(); const blink::WebDocument& document = node.GetDocument();
if (!document.isNull()) { if (!document.IsNull()) {
blink::WebFrame* frame = document.frame(); blink::WebFrame* frame = document.GetFrame();
CefRefPtr<CefDOMDocumentImpl> documentImpl = CefRefPtr<CefDOMDocumentImpl> documentImpl =
new CefDOMDocumentImpl(this, frame); new CefDOMDocumentImpl(this, frame);
handler->OnFocusedNodeChanged(this, handler->OnFocusedNodeChanged(this,
@ -489,7 +495,7 @@ void CefBrowserImpl::FocusedNodeChanged(const blink::WebNode& node) {
// Based on ExtensionHelper::DraggableRegionsChanged. // Based on ExtensionHelper::DraggableRegionsChanged.
void CefBrowserImpl::DraggableRegionsChanged(blink::WebFrame* frame) { void CefBrowserImpl::DraggableRegionsChanged(blink::WebFrame* frame) {
blink::WebVector<blink::WebDraggableRegion> webregions = blink::WebVector<blink::WebDraggableRegion> webregions =
frame->document().draggableRegions(); frame->GetDocument().DraggableRegions();
std::vector<Cef_DraggableRegion_Params> regions; std::vector<Cef_DraggableRegion_Params> regions;
for (size_t i = 0; i < webregions.size(); ++i) { for (size_t i = 0; i < webregions.size(); ++i) {
Cef_DraggableRegion_Params region; Cef_DraggableRegion_Params region;
@ -561,8 +567,8 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
DCHECK_GE(script_start_line, 0); DCHECK_GE(script_start_line, 0);
if (is_javascript) { if (is_javascript) {
web_frame->executeScript( web_frame->ExecuteScript(
WebScriptSource(blink::WebString::fromUTF8(code), WebScriptSource(blink::WebString::FromUTF8(code),
GURL(script_url), GURL(script_url),
script_start_line)); script_start_line));
success = true; success = true;
@ -586,17 +592,17 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
DCHECK(!command.empty()); DCHECK(!command.empty());
if (base::LowerCaseEqualsASCII(command, "getsource")) { if (base::LowerCaseEqualsASCII(command, "getsource")) {
if (web_frame->isWebLocalFrame()) { if (web_frame->IsWebLocalFrame()) {
response = blink::WebFrameContentDumper::dumpAsMarkup( response = blink::WebFrameContentDumper::DumpAsMarkup(
web_frame->toWebLocalFrame()).utf8(); web_frame->ToWebLocalFrame()).Utf8();
success = true; success = true;
} }
} else if (base::LowerCaseEqualsASCII(command, "gettext")) { } else if (base::LowerCaseEqualsASCII(command, "gettext")) {
response = webkit_glue::DumpDocumentText(web_frame); response = webkit_glue::DumpDocumentText(web_frame);
success = true; success = true;
} else if (web_frame->isWebLocalFrame() && } else if (web_frame->IsWebLocalFrame() &&
web_frame->toWebLocalFrame()->executeCommand( web_frame->ToWebLocalFrame()->ExecuteCommand(
blink::WebString::fromUTF8(command))) { blink::WebString::FromUTF8(command))) {
success = true; success = true;
} }
} }
@ -614,7 +620,7 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
params.arguments.GetString(0, &string); params.arguments.GetString(0, &string);
params.arguments.GetString(1, &url); params.arguments.GetString(1, &url);
web_frame->loadHTMLString(string, GURL(url)); web_frame->LoadHTMLString(string, GURL(url));
} }
} }
} else { } else {
@ -697,7 +703,8 @@ void CefBrowserImpl::OnLoadEnd(blink::WebLocalFrame* frame) {
CefRefPtr<CefLoadHandler> load_handler = handler->GetLoadHandler(); CefRefPtr<CefLoadHandler> load_handler = handler->GetLoadHandler();
if (load_handler.get()) { if (load_handler.get()) {
CefRefPtr<CefFrameImpl> cef_frame = GetWebFrameImpl(frame); CefRefPtr<CefFrameImpl> cef_frame = GetWebFrameImpl(frame);
int httpStatusCode = frame->dataSource()->response().httpStatusCode(); int httpStatusCode =
frame->DataSource()->GetResponse().HttpStatusCode();
load_handler->OnLoadEnd(this, cef_frame.get(), httpStatusCode); load_handler->OnLoadEnd(this, cef_frame.get(), httpStatusCode);
} }
} }
@ -719,8 +726,8 @@ void CefBrowserImpl::OnLoadError(blink::WebLocalFrame* frame,
CefRefPtr<CefFrameImpl> cef_frame = GetWebFrameImpl(frame); CefRefPtr<CefFrameImpl> cef_frame = GetWebFrameImpl(frame);
const cef_errorcode_t errorCode = const cef_errorcode_t errorCode =
static_cast<cef_errorcode_t>(error.reason); static_cast<cef_errorcode_t>(error.reason);
const std::string& errorText = error.localizedDescription.utf8(); const std::string& errorText = error.localized_description.Utf8();
const GURL& failedUrl = error.unreachableURL; const GURL& failedUrl = error.unreachable_url;
load_handler->OnLoadError(this, cef_frame.get(), errorCode, errorText, load_handler->OnLoadError(this, cef_frame.get(), errorCode, errorText,
failedUrl.spec()); failedUrl.spec());
} }

View File

@ -103,10 +103,10 @@ namespace {
// Stub implementation of blink::WebPrerenderingSupport. // Stub implementation of blink::WebPrerenderingSupport.
class CefPrerenderingSupport : public blink::WebPrerenderingSupport { class CefPrerenderingSupport : public blink::WebPrerenderingSupport {
private: private:
void add(const blink::WebPrerender& prerender) override {} void Add(const blink::WebPrerender& prerender) override {}
void cancel(const blink::WebPrerender& prerender) override {} void Cancel(const blink::WebPrerender& prerender) override {}
void abandon(const blink::WebPrerender& prerender) override {} void Abandon(const blink::WebPrerender& prerender) override {}
void prefetchFinished() override {} void PrefetchFinished() override {}
}; };
// Stub implementation of blink::WebPrerendererClient. // Stub implementation of blink::WebPrerendererClient.
@ -116,7 +116,7 @@ class CefPrerendererClient : public content::RenderViewObserver,
explicit CefPrerendererClient(content::RenderView* render_view) explicit CefPrerendererClient(content::RenderView* render_view)
: content::RenderViewObserver(render_view) { : content::RenderViewObserver(render_view) {
DCHECK(render_view); DCHECK(render_view);
render_view->GetWebView()->setPrerendererClient(this); render_view->GetWebView()->SetPrerendererClient(this);
} }
private: private:
@ -128,8 +128,8 @@ class CefPrerendererClient : public content::RenderViewObserver,
} }
// WebPrerendererClient methods: // WebPrerendererClient methods:
void willAddPrerender(blink::WebPrerender* prerender) override {} void WillAddPrerender(blink::WebPrerender* prerender) override {}
bool isPrefetchOnly() override { return false; } bool IsPrefetchOnly() override { return false; }
}; };
void AppendParams(const std::vector<base::string16>& additional_names, void AppendParams(const std::vector<base::string16>& additional_names,
@ -151,13 +151,13 @@ void AppendParams(const std::vector<base::string16>& additional_names,
} }
for (size_t i = 0; i < additional_names.size(); ++i) { for (size_t i = 0; i < additional_names.size(); ++i) {
names[existing_size + i] = blink::WebString::fromUTF16(additional_names[i]); names[existing_size + i] = blink::WebString::FromUTF16(additional_names[i]);
values[existing_size + i] = values[existing_size + i] =
blink::WebString::fromUTF16(additional_values[i]); blink::WebString::FromUTF16(additional_values[i]);
} }
existing_names->swap(names); existing_names->Swap(names);
existing_values->swap(values); existing_values->Swap(values);
} }
} // namespace } // namespace
@ -219,7 +219,7 @@ CefRefPtr<CefBrowserImpl> CefContentRendererClient::GetBrowserForMainFrame(
for (; it != browsers_.end(); ++it) { for (; it != browsers_.end(); ++it) {
content::RenderView* render_view = it->second->render_view(); content::RenderView* render_view = it->second->render_view();
if (render_view && render_view->GetWebView() && if (render_view && render_view->GetWebView() &&
render_view->GetWebView()->mainFrame() == frame) { render_view->GetWebView()->MainFrame() == frame) {
return it->second; return it->second;
} }
} }
@ -269,7 +269,7 @@ void CefContentRendererClient::WebKitInitialized() {
CefV8IsolateCreated(); CefV8IsolateCreated();
// TODO(cef): Enable these once the implementation supports it. // TODO(cef): Enable these once the implementation supports it.
blink::WebRuntimeFeatures::enableNotifications(false); blink::WebRuntimeFeatures::EnableNotifications(false);
const CefContentClient::SchemeInfoList* schemes = const CefContentClient::SchemeInfoList* schemes =
CefContentClient::Get()->GetCustomSchemes(); CefContentClient::Get()->GetCustomSchemes();
@ -280,15 +280,15 @@ void CefContentRendererClient::WebKitInitialized() {
for (; it != schemes->end(); ++it) { for (; it != schemes->end(); ++it) {
const CefContentClient::SchemeInfo& info = *it; const CefContentClient::SchemeInfo& info = *it;
const blink::WebString& scheme = const blink::WebString& scheme =
blink::WebString::fromUTF8(info.scheme_name); blink::WebString::FromUTF8(info.scheme_name);
if (info.is_local) if (info.is_local)
webkit_glue::registerURLSchemeAsLocal(scheme); webkit_glue::RegisterURLSchemeAsLocal(scheme);
if (info.is_display_isolated) if (info.is_display_isolated)
blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(scheme); blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
if (info.is_secure) if (info.is_secure)
webkit_glue::registerURLSchemeAsSecure(scheme); webkit_glue::RegisterURLSchemeAsSecure(scheme);
if (info.is_cors_enabled) if (info.is_cors_enabled)
webkit_glue::registerURLSchemeAsCORSEnabled(scheme); webkit_glue::RegisterURLSchemeAsCORSEnabled(scheme);
} }
} }
@ -298,10 +298,10 @@ void CefContentRendererClient::WebKitInitialized() {
const Cef_CrossOriginWhiteListEntry_Params& entry = const Cef_CrossOriginWhiteListEntry_Params& entry =
cross_origin_whitelist_entries_[i]; cross_origin_whitelist_entries_[i];
GURL gurl = GURL(entry.source_origin); GURL gurl = GURL(entry.source_origin);
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry( blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
gurl, gurl,
blink::WebString::fromUTF8(entry.target_protocol), blink::WebString::FromUTF8(entry.target_protocol),
blink::WebString::fromUTF8(entry.target_domain), blink::WebString::FromUTF8(entry.target_domain),
entry.allow_target_subdomains); entry.allow_target_subdomains);
} }
cross_origin_whitelist_entries_.clear(); cross_origin_whitelist_entries_.clear();
@ -411,7 +411,7 @@ void CefContentRendererClient::RenderThreadStarted() {
base::MessageLoop::current()->AddDestructionObserver(this); base::MessageLoop::current()->AddDestructionObserver(this);
} }
blink::WebPrerenderingSupport::initialize(new CefPrerenderingSupport()); blink::WebPrerenderingSupport::Initialize(new CefPrerenderingSupport());
// Retrieve the new render thread information synchronously. // Retrieve the new render thread information synchronously.
CefProcessHostMsg_GetNewRenderThreadInfo_Params params; CefProcessHostMsg_GetNewRenderThreadInfo_Params params;
@ -475,6 +475,11 @@ void CefContentRendererClient::RenderFrameCreated(
if (extensions::ExtensionsEnabled()) if (extensions::ExtensionsEnabled())
extensions_renderer_client_->RenderFrameCreated(render_frame); extensions_renderer_client_->RenderFrameCreated(render_frame);
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableSpellChecking))
new SpellCheckProvider(render_frame, spellcheck_.get());
BrowserCreated(render_frame->GetRenderView(), render_frame); BrowserCreated(render_frame->GetRenderView(), render_frame);
} }
@ -487,8 +492,16 @@ void CefContentRendererClient::RenderViewCreated(
const base::CommandLine* command_line = const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
new SpellCheckProvider(render_view, spellcheck_.get()); // This is a workaround keeping the behavior that, the Blink side spellcheck
// enabled state is initialized on RenderView creation.
// TODO(xiaochengh): Design better way to sync between Chrome-side and
// Blink-side spellcheck enabled states. See crbug.com/710097.
if (SpellCheckProvider* provider =
SpellCheckProvider::Get(render_view->GetMainRenderFrame())) {
provider->EnableSpellcheck(spellcheck_->IsSpellcheckEnabled());
}
}
BrowserCreated(render_view, render_view->GetMainRenderFrame()); BrowserCreated(render_view, render_view->GetMainRenderFrame());
} }
@ -498,7 +511,7 @@ bool CefContentRendererClient::OverrideCreatePlugin(
blink::WebLocalFrame* frame, blink::WebLocalFrame* frame,
const blink::WebPluginParams& params, const blink::WebPluginParams& params,
blink::WebPlugin** plugin) { blink::WebPlugin** plugin) {
std::string orig_mime_type = params.mimeType.utf8(); std::string orig_mime_type = params.mime_type.Utf8();
if (extensions::ExtensionsEnabled() && if (extensions::ExtensionsEnabled() &&
!extensions_renderer_client_->OverrideCreatePlugin(render_frame, !extensions_renderer_client_->OverrideCreatePlugin(render_frame,
params)) { params)) {
@ -509,7 +522,7 @@ bool CefContentRendererClient::OverrideCreatePlugin(
CefViewHostMsg_GetPluginInfo_Output output; CefViewHostMsg_GetPluginInfo_Output output;
render_frame->Send(new CefViewHostMsg_GetPluginInfo( render_frame->Send(new CefViewHostMsg_GetPluginInfo(
render_frame->GetRoutingID(), url, render_frame->IsMainFrame(), render_frame->GetRoutingID(), url, render_frame->IsMainFrame(),
frame->top()->getSecurityOrigin(), orig_mime_type, &output)); frame->Top()->GetSecurityOrigin(), orig_mime_type, &output));
*plugin = CreatePlugin(render_frame, frame, params, output); *plugin = CreatePlugin(render_frame, frame, params, output);
return true; return true;
@ -530,7 +543,7 @@ bool CefContentRendererClient::HandleNavigation(
application->GetRenderProcessHandler(); application->GetRenderProcessHandler();
if (handler.get()) { if (handler.get()) {
CefRefPtr<CefBrowserImpl> browserPtr = CefRefPtr<CefBrowserImpl> browserPtr =
CefBrowserImpl::GetBrowserForMainFrame(frame->top()); CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
if (browserPtr.get()) { if (browserPtr.get()) {
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame); CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
CefRefPtr<CefRequest> requestPtr(CefRequest::Create()); CefRefPtr<CefRequest> requestPtr(CefRequest::Create());
@ -541,22 +554,22 @@ bool CefContentRendererClient::HandleNavigation(
cef_navigation_type_t navigation_type = NAVIGATION_OTHER; cef_navigation_type_t navigation_type = NAVIGATION_OTHER;
switch (type) { switch (type) {
case blink::WebNavigationTypeLinkClicked: case blink::kWebNavigationTypeLinkClicked:
navigation_type = NAVIGATION_LINK_CLICKED; navigation_type = NAVIGATION_LINK_CLICKED;
break; break;
case blink::WebNavigationTypeFormSubmitted: case blink::kWebNavigationTypeFormSubmitted:
navigation_type = NAVIGATION_FORM_SUBMITTED; navigation_type = NAVIGATION_FORM_SUBMITTED;
break; break;
case blink::WebNavigationTypeBackForward: case blink::kWebNavigationTypeBackForward:
navigation_type = NAVIGATION_BACK_FORWARD; navigation_type = NAVIGATION_BACK_FORWARD;
break; break;
case blink::WebNavigationTypeReload: case blink::kWebNavigationTypeReload:
navigation_type = NAVIGATION_RELOAD; navigation_type = NAVIGATION_RELOAD;
break; break;
case blink::WebNavigationTypeFormResubmitted: case blink::kWebNavigationTypeFormResubmitted:
navigation_type = NAVIGATION_FORM_RESUBMITTED; navigation_type = NAVIGATION_FORM_RESUBMITTED;
break; break;
case blink::WebNavigationTypeOther: case blink::kWebNavigationTypeOther:
navigation_type = NAVIGATION_OTHER; navigation_type = NAVIGATION_OTHER;
break; break;
} }
@ -579,7 +592,7 @@ bool CefContentRendererClient::ShouldFork(blink::WebLocalFrame* frame,
bool is_initial_navigation, bool is_initial_navigation,
bool is_server_redirect, bool is_server_redirect,
bool* send_referrer) { bool* send_referrer) {
DCHECK(!frame->parent()); DCHECK(!frame->Parent());
// For now, we skip the rest for POST submissions. This is because // For now, we skip the rest for POST submissions. This is because
// http://crbug.com/101395 is more likely to cause compatibility issues // http://crbug.com/101395 is more likely to cause compatibility issues
@ -646,6 +659,12 @@ void CefContentRendererClient::RunScriptsAtDocumentEnd(
extensions_renderer_client_->RunScriptsAtDocumentEnd(render_frame); extensions_renderer_client_->RunScriptsAtDocumentEnd(render_frame);
} }
void CefContentRendererClient::RunScriptsAtDocumentIdle(
content::RenderFrame* render_frame) {
if (extensions::ExtensionsEnabled())
extensions_renderer_client_->RunScriptsAtDocumentIdle(render_frame);
}
void CefContentRendererClient::WillDestroyCurrentMessageLoop() { void CefContentRendererClient::WillDestroyCurrentMessageLoop() {
base::AutoLock lock_scope(single_process_cleanup_lock_); base::AutoLock lock_scope(single_process_cleanup_lock_);
single_process_cleanup_complete_ = true; single_process_cleanup_complete_ = true;
@ -663,7 +682,7 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin(
const std::string& identifier = output.group_identifier; const std::string& identifier = output.group_identifier;
CefViewHostMsg_GetPluginInfo_Status status = output.status; CefViewHostMsg_GetPluginInfo_Status status = output.status;
GURL url(original_params.url); GURL url(original_params.url);
std::string orig_mime_type = original_params.mimeType.utf8(); std::string orig_mime_type = original_params.mime_type.Utf8();
CefPluginPlaceholder* placeholder = NULL; CefPluginPlaceholder* placeholder = NULL;
// If the browser plugin is to be enabled, this should be handled by the // If the browser plugin is to be enabled, this should be handled by the
@ -680,16 +699,16 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin(
if (info.mime_types[i].mime_type == actual_mime_type) { if (info.mime_types[i].mime_type == actual_mime_type) {
AppendParams(info.mime_types[i].additional_param_names, AppendParams(info.mime_types[i].additional_param_names,
info.mime_types[i].additional_param_values, info.mime_types[i].additional_param_values,
&params.attributeNames, &params.attributeValues); &params.attribute_names, &params.attribute_values);
break; break;
} }
} }
if (params.mimeType.isNull() && (actual_mime_type.size() > 0)) { if (params.mime_type.IsNull() && (actual_mime_type.size() > 0)) {
// Webkit might say that mime type is null while we already know the // Webkit might say that mime type is null while we already know the
// actual mime type via CefViewHostMsg_GetPluginInfo. In that case // actual mime type via CefViewHostMsg_GetPluginInfo. In that case
// we should use what we know since WebpluginDelegateProxy does some // we should use what we know since WebpluginDelegateProxy does some
// specific initializations based on this information. // specific initializations based on this information.
params.mimeType = blink::WebString::fromUTF8(actual_mime_type.c_str()); params.mime_type = blink::WebString::FromUTF8(actual_mime_type);
} }
auto create_blocked_plugin = [&render_frame, &frame, &params, &info, auto create_blocked_plugin = [&render_frame, &frame, &params, &info,
@ -717,7 +736,7 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin(
PowerSaverInfo power_saver_info = PowerSaverInfo power_saver_info =
PowerSaverInfo::Get(render_frame, power_saver_setting_on, params, PowerSaverInfo::Get(render_frame, power_saver_setting_on, params,
info, frame->document().url()); info, frame->GetDocument().Url());
if (power_saver_info.blocked_for_background_tab || is_prerendering || if (power_saver_info.blocked_for_background_tab || is_prerendering ||
!power_saver_info.poster_attribute.empty()) { !power_saver_info.poster_attribute.empty()) {
placeholder = CefPluginPlaceholder::CreateBlockedPlugin( placeholder = CefPluginPlaceholder::CreateBlockedPlugin(
@ -848,7 +867,7 @@ void CefContentRendererClient::BrowserCreated(
// WebKit layer, or if it would be exposed as an WebView instance method; the // WebKit layer, or if it would be exposed as an WebView instance method; the
// current implementation uses a static variable, and WebKit needs to be // current implementation uses a static variable, and WebKit needs to be
// patched in order to make it work for each WebView instance // patched in order to make it work for each WebView instance
render_view->GetWebView()->setUseExternalPopupMenusThisInstance( render_view->GetWebView()->SetUseExternalPopupMenusThisInstance(
!params.is_windowless); !params.is_windowless);
#endif #endif

View File

@ -127,6 +127,7 @@ class CefContentRendererClient : public content::ContentRendererClient,
override; override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override; void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override; void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
// MessageLoop::DestructionObserver implementation. // MessageLoop::DestructionObserver implementation.
void WillDestroyCurrentMessageLoop() override; void WillDestroyCurrentMessageLoop() override;

View File

@ -29,8 +29,8 @@ CefDOMDocumentImpl::CefDOMDocumentImpl(CefBrowserImpl* browser,
WebFrame* frame) WebFrame* frame)
: browser_(browser), : browser_(browser),
frame_(frame) { frame_(frame) {
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
DCHECK(!document.isNull()); DCHECK(!document.IsNull());
} }
CefDOMDocumentImpl::~CefDOMDocumentImpl() { CefDOMDocumentImpl::~CefDOMDocumentImpl() {
@ -44,29 +44,29 @@ CefDOMDocumentImpl::Type CefDOMDocumentImpl::GetType() {
if (!VerifyContext()) if (!VerifyContext())
return DOM_DOCUMENT_TYPE_UNKNOWN; return DOM_DOCUMENT_TYPE_UNKNOWN;
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
if (document.isHTMLDocument()) if (document.IsHTMLDocument())
return DOM_DOCUMENT_TYPE_HTML; return DOM_DOCUMENT_TYPE_HTML;
if (document.isXHTMLDocument()) if (document.IsXHTMLDocument())
return DOM_DOCUMENT_TYPE_XHTML; return DOM_DOCUMENT_TYPE_XHTML;
if (document.isPluginDocument()) if (document.IsPluginDocument())
return DOM_DOCUMENT_TYPE_PLUGIN; return DOM_DOCUMENT_TYPE_PLUGIN;
return DOM_DOCUMENT_TYPE_UNKNOWN; return DOM_DOCUMENT_TYPE_UNKNOWN;
} }
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetDocument() { CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetDocument() {
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
return GetOrCreateNode(document.document()); return GetOrCreateNode(document.GetDocument());
} }
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetBody() { CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetBody() {
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
return GetOrCreateNode(document.body()); return GetOrCreateNode(document.Body());
} }
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetHead() { CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetHead() {
WebDocument document = frame_->document(); WebDocument document = frame_->GetDocument();
return GetOrCreateNode(document.head()); return GetOrCreateNode(document.Head());
} }
CefString CefDOMDocumentImpl::GetTitle() { CefString CefDOMDocumentImpl::GetTitle() {
@ -74,89 +74,89 @@ CefString CefDOMDocumentImpl::GetTitle() {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
const WebString& title = document.title(); const WebString& title = document.Title();
if (!title.isNull()) if (!title.IsNull())
str = title.utf16(); str = title.Utf16();
return str; return str;
} }
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetElementById(const CefString& id) { CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetElementById(const CefString& id) {
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
return GetOrCreateNode(document.getElementById(WebString::fromUTF16(id))); return GetOrCreateNode(document.GetElementById(WebString::FromUTF16(id)));
} }
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetFocusedNode() { CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetFocusedNode() {
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
return GetOrCreateNode(document.focusedElement()); return GetOrCreateNode(document.FocusedElement());
} }
bool CefDOMDocumentImpl::HasSelection() { bool CefDOMDocumentImpl::HasSelection() {
if (!VerifyContext() || !frame_->isWebLocalFrame()) if (!VerifyContext() || !frame_->IsWebLocalFrame())
return false; return false;
return frame_->toWebLocalFrame()->hasSelection(); return frame_->ToWebLocalFrame()->HasSelection();
} }
int CefDOMDocumentImpl::GetSelectionStartOffset() { int CefDOMDocumentImpl::GetSelectionStartOffset() {
if (!VerifyContext() || !frame_->isWebLocalFrame()) if (!VerifyContext() || !frame_->IsWebLocalFrame())
return 0; return 0;
blink::WebLocalFrame* local_frame = frame_->toWebLocalFrame(); blink::WebLocalFrame* local_frame = frame_->ToWebLocalFrame();
if (!!local_frame->hasSelection()) if (!!local_frame->HasSelection())
return 0; return 0;
const WebRange& range = local_frame->selectionRange(); const WebRange& range = local_frame->SelectionRange();
if (range.isNull()) if (range.IsNull())
return 0; return 0;
return range.startOffset(); return range.StartOffset();
} }
int CefDOMDocumentImpl::GetSelectionEndOffset() { int CefDOMDocumentImpl::GetSelectionEndOffset() {
if (!VerifyContext() || !frame_->isWebLocalFrame()) if (!VerifyContext() || !frame_->IsWebLocalFrame())
return 0; return 0;
blink::WebLocalFrame* local_frame = frame_->toWebLocalFrame(); blink::WebLocalFrame* local_frame = frame_->ToWebLocalFrame();
if (!!local_frame->hasSelection()) if (!!local_frame->HasSelection())
return 0; return 0;
const WebRange& range = local_frame->selectionRange(); const WebRange& range = local_frame->SelectionRange();
if (range.isNull()) if (range.IsNull())
return 0; return 0;
return range.endOffset(); return range.EndOffset();
} }
CefString CefDOMDocumentImpl::GetSelectionAsMarkup() { CefString CefDOMDocumentImpl::GetSelectionAsMarkup() {
CefString str; CefString str;
if (!VerifyContext() || !frame_->isWebLocalFrame()) if (!VerifyContext() || !frame_->IsWebLocalFrame())
return str; return str;
blink::WebLocalFrame* local_frame = frame_->toWebLocalFrame(); blink::WebLocalFrame* local_frame = frame_->ToWebLocalFrame();
if (!!local_frame->hasSelection()) if (!!local_frame->HasSelection())
return str; return str;
const WebString& markup = local_frame->selectionAsMarkup(); const WebString& markup = local_frame->SelectionAsMarkup();
if (!markup.isNull()) if (!markup.IsNull())
str = markup.utf16(); str = markup.Utf16();
return str; return str;
} }
CefString CefDOMDocumentImpl::GetSelectionAsText() { CefString CefDOMDocumentImpl::GetSelectionAsText() {
CefString str; CefString str;
if (!VerifyContext() || !frame_->isWebLocalFrame()) if (!VerifyContext() || !frame_->IsWebLocalFrame())
return str; return str;
blink::WebLocalFrame* local_frame = frame_->toWebLocalFrame(); blink::WebLocalFrame* local_frame = frame_->ToWebLocalFrame();
if (!!local_frame->hasSelection()) if (!!local_frame->HasSelection())
return str; return str;
const WebString& text = local_frame->selectionAsText(); const WebString& text = local_frame->SelectionAsText();
if (!text.isNull()) if (!text.IsNull())
str = text.utf16(); str = text.Utf16();
return str; return str;
} }
@ -166,9 +166,9 @@ CefString CefDOMDocumentImpl::GetBaseURL() {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
const WebURL& url = document.baseURL(); const WebURL& url = document.BaseURL();
if (!url.isNull()) { if (!url.IsNull()) {
GURL gurl = url; GURL gurl = url;
str = gurl.spec(); str = gurl.spec();
} }
@ -181,9 +181,9 @@ CefString CefDOMDocumentImpl::GetCompleteURL(const CefString& partialURL) {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
const WebDocument& document = frame_->document(); const WebDocument& document = frame_->GetDocument();
const WebURL& url = document.completeURL(WebString::fromUTF16(partialURL)); const WebURL& url = document.CompleteURL(WebString::FromUTF16(partialURL));
if (!url.isNull()) { if (!url.IsNull()) {
GURL gurl = url; GURL gurl = url;
str = gurl.spec(); str = gurl.spec();
} }
@ -197,7 +197,7 @@ CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetOrCreateNode(
return NULL; return NULL;
// Nodes may potentially be null. // Nodes may potentially be null.
if (node.isNull()) if (node.IsNull())
return NULL; return NULL;
if (!node_map_.empty()) { if (!node_map_.empty()) {

View File

@ -41,7 +41,7 @@ CefDOMNodeImpl::CefDOMNodeImpl(CefRefPtr<CefDOMDocumentImpl> document,
CefDOMNodeImpl::~CefDOMNodeImpl() { CefDOMNodeImpl::~CefDOMNodeImpl() {
CEF_REQUIRE_RT(); CEF_REQUIRE_RT();
if (document_.get() && !node_.isNull()) { if (document_.get() && !node_.IsNull()) {
// Remove the node from the document. // Remove the node from the document.
document_->RemoveNode(node_); document_->RemoveNode(node_);
} }
@ -58,14 +58,14 @@ bool CefDOMNodeImpl::IsText() {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
return node_.isTextNode(); return node_.IsTextNode();
} }
bool CefDOMNodeImpl::IsElement() { bool CefDOMNodeImpl::IsElement() {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
return node_.isElementNode(); return node_.IsElementNode();
} }
// Logic copied from RenderViewImpl::IsEditableNode. // Logic copied from RenderViewImpl::IsEditableNode.
@ -73,19 +73,19 @@ bool CefDOMNodeImpl::IsEditable() {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
if (node_.isContentEditable()) if (node_.IsContentEditable())
return true; return true;
if (node_.isElementNode()) { if (node_.IsElementNode()) {
const WebElement& element = node_.toConst<WebElement>(); const WebElement& element = node_.ToConst<WebElement>();
if (webkit_glue::IsTextControlElement(element)) if (webkit_glue::IsTextControlElement(element))
return true; return true;
// Also return true if it has an ARIA role of 'textbox'. // Also return true if it has an ARIA role of 'textbox'.
for (unsigned i = 0; i < element.attributeCount(); ++i) { for (unsigned i = 0; i < element.AttributeCount(); ++i) {
if (base::LowerCaseEqualsASCII(element.attributeLocalName(i).utf8(), if (base::LowerCaseEqualsASCII(element.AttributeLocalName(i).Utf8(),
"role")) { "role")) {
if (base::LowerCaseEqualsASCII(element.attributeValue(i).utf8(), if (base::LowerCaseEqualsASCII(element.AttributeValue(i).Utf8(),
"textbox")) { "textbox")) {
return true; return true;
} }
@ -101,9 +101,9 @@ bool CefDOMNodeImpl::IsFormControlElement() {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
if (node_.isElementNode()) { if (node_.IsElementNode()) {
const WebElement& element = node_.toConst<WebElement>(); const WebElement& element = node_.ToConst<WebElement>();
return element.isFormControlElement(); return element.IsFormControlElement();
} }
return false; return false;
@ -114,15 +114,15 @@ CefString CefDOMNodeImpl::GetFormControlElementType() {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
if (node_.isElementNode()) { if (node_.IsElementNode()) {
const WebElement& element = node_.toConst<WebElement>(); const WebElement& element = node_.ToConst<WebElement>();
if (element.isFormControlElement()) { if (element.IsFormControlElement()) {
// Retrieve the type from the form control element. // Retrieve the type from the form control element.
const WebFormControlElement& formElement = const WebFormControlElement& formElement =
node_.toConst<WebFormControlElement>(); node_.ToConst<WebFormControlElement>();
const base::string16& form_control_type = const base::string16& form_control_type =
formElement.formControlType().utf16(); formElement.FormControlType().Utf16();
str = form_control_type; str = form_control_type;
} }
} }
@ -138,7 +138,7 @@ bool CefDOMNodeImpl::IsSame(CefRefPtr<CefDOMNode> that) {
if (!impl || !impl->VerifyContext()) if (!impl || !impl->VerifyContext())
return false; return false;
return node_.equals(impl->node_); return node_.Equals(impl->node_);
} }
CefString CefDOMNodeImpl::GetName() { CefString CefDOMNodeImpl::GetName() {
@ -147,8 +147,8 @@ CefString CefDOMNodeImpl::GetName() {
return str; return str;
const WebString& name = webkit_glue::GetNodeName(node_); const WebString& name = webkit_glue::GetNodeName(node_);
if (!name.isNull()) if (!name.IsNull())
str = name.utf16(); str = name.Utf16();
return str; return str;
} }
@ -158,24 +158,24 @@ CefString CefDOMNodeImpl::GetValue() {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
if (node_.isElementNode()) { if (node_.IsElementNode()) {
const WebElement& element = node_.toConst<WebElement>(); const WebElement& element = node_.ToConst<WebElement>();
if (element.isFormControlElement()) { if (element.IsFormControlElement()) {
// Retrieve the value from the form control element. // Retrieve the value from the form control element.
const WebFormControlElement& formElement = const WebFormControlElement& formElement =
node_.toConst<WebFormControlElement>(); node_.ToConst<WebFormControlElement>();
base::string16 value; base::string16 value;
const base::string16& form_control_type = const base::string16& form_control_type =
formElement.formControlType().utf16(); formElement.FormControlType().Utf16();
if (form_control_type == base::ASCIIToUTF16("text")) { if (form_control_type == base::ASCIIToUTF16("text")) {
const WebInputElement& input_element = const WebInputElement& input_element =
formElement.toConst<WebInputElement>(); formElement.ToConst<WebInputElement>();
value = input_element.value().utf16(); value = input_element.Value().Utf16();
} else if (form_control_type == base::ASCIIToUTF16("select-one")) { } else if (form_control_type == base::ASCIIToUTF16("select-one")) {
const WebSelectElement& select_element = const WebSelectElement& select_element =
formElement.toConst<WebSelectElement>(); formElement.ToConst<WebSelectElement>();
value = select_element.value().utf16(); value = select_element.Value().Utf16();
} }
base::TrimWhitespace(value, base::TRIM_LEADING, &value); base::TrimWhitespace(value, base::TRIM_LEADING, &value);
@ -184,9 +184,9 @@ CefString CefDOMNodeImpl::GetValue() {
} }
if (str.empty()) { if (str.empty()) {
const WebString& value = node_.nodeValue(); const WebString& value = node_.NodeValue();
if (!value.isNull()) if (!value.IsNull())
str = value.utf16(); str = value.Utf16();
} }
return str; return str;
@ -196,10 +196,10 @@ bool CefDOMNodeImpl::SetValue(const CefString& value) {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
if (node_.isElementNode()) if (node_.IsElementNode())
return false; return false;
return webkit_glue::SetNodeValue(node_, WebString::fromUTF16(value)); return webkit_glue::SetNodeValue(node_, WebString::FromUTF16(value));
} }
CefString CefDOMNodeImpl::GetAsMarkup() { CefString CefDOMNodeImpl::GetAsMarkup() {
@ -208,8 +208,8 @@ CefString CefDOMNodeImpl::GetAsMarkup() {
return str; return str;
const WebString& markup = webkit_glue::CreateNodeMarkup(node_); const WebString& markup = webkit_glue::CreateNodeMarkup(node_);
if (!markup.isNull()) if (!markup.IsNull())
str = markup.utf16(); str = markup.Utf16();
return str; return str;
} }
@ -225,42 +225,42 @@ CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetParent() {
if (!VerifyContext()) if (!VerifyContext())
return NULL; return NULL;
return document_->GetOrCreateNode(node_.parentNode()); return document_->GetOrCreateNode(node_.ParentNode());
} }
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetPreviousSibling() { CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetPreviousSibling() {
if (!VerifyContext()) if (!VerifyContext())
return NULL; return NULL;
return document_->GetOrCreateNode(node_.previousSibling()); return document_->GetOrCreateNode(node_.PreviousSibling());
} }
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetNextSibling() { CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetNextSibling() {
if (!VerifyContext()) if (!VerifyContext())
return NULL; return NULL;
return document_->GetOrCreateNode(node_.nextSibling()); return document_->GetOrCreateNode(node_.NextSibling());
} }
bool CefDOMNodeImpl::HasChildren() { bool CefDOMNodeImpl::HasChildren() {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
return !node_.firstChild().isNull(); return !node_.FirstChild().IsNull();
} }
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetFirstChild() { CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetFirstChild() {
if (!VerifyContext()) if (!VerifyContext())
return NULL; return NULL;
return document_->GetOrCreateNode(node_.firstChild()); return document_->GetOrCreateNode(node_.FirstChild());
} }
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetLastChild() { CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetLastChild() {
if (!VerifyContext()) if (!VerifyContext())
return NULL; return NULL;
return document_->GetOrCreateNode(node_.lastChild()); return document_->GetOrCreateNode(node_.LastChild());
} }
CefString CefDOMNodeImpl::GetElementTagName() { CefString CefDOMNodeImpl::GetElementTagName() {
@ -268,15 +268,15 @@ CefString CefDOMNodeImpl::GetElementTagName() {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return str; return str;
} }
const WebElement& element = node_.toConst<blink::WebElement>(); const WebElement& element = node_.ToConst<blink::WebElement>();
const WebString& tagname = element.tagName(); const WebString& tagname = element.TagName();
if (!tagname.isNull()) if (!tagname.IsNull())
str = tagname.utf16(); str = tagname.Utf16();
return str; return str;
} }
@ -285,26 +285,26 @@ bool CefDOMNodeImpl::HasElementAttributes() {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return false; return false;
} }
const WebElement& element = node_.toConst<blink::WebElement>(); const WebElement& element = node_.ToConst<blink::WebElement>();
return (element.attributeCount() > 0); return (element.AttributeCount() > 0);
} }
bool CefDOMNodeImpl::HasElementAttribute(const CefString& attrName) { bool CefDOMNodeImpl::HasElementAttribute(const CefString& attrName) {
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return false; return false;
} }
const WebElement& element = node_.toConst<blink::WebElement>(); const WebElement& element = node_.ToConst<blink::WebElement>();
return element.hasAttribute(WebString::fromUTF16(attrName)); return element.HasAttribute(WebString::FromUTF16(attrName));
} }
CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) { CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) {
@ -312,15 +312,15 @@ CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return str; return str;
} }
const WebElement& element = node_.toConst<blink::WebElement>(); const WebElement& element = node_.ToConst<blink::WebElement>();
const WebString& attr = element.getAttribute(WebString::fromUTF16(attrName)); const WebString& attr = element.GetAttribute(WebString::FromUTF16(attrName));
if (!attr.isNull()) if (!attr.IsNull())
str = attr.utf16(); str = attr.Utf16();
return str; return str;
} }
@ -329,19 +329,19 @@ void CefDOMNodeImpl::GetElementAttributes(AttributeMap& attrMap) {
if (!VerifyContext()) if (!VerifyContext())
return; return;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return; return;
} }
const WebElement& element = node_.toConst<blink::WebElement>(); const WebElement& element = node_.ToConst<blink::WebElement>();
unsigned int len = element.attributeCount(); unsigned int len = element.AttributeCount();
if (len == 0) if (len == 0)
return; return;
for (unsigned int i = 0; i < len; ++i) { for (unsigned int i = 0; i < len; ++i) {
base::string16 name = element.attributeLocalName(i).utf16(); base::string16 name = element.AttributeLocalName(i).Utf16();
base::string16 value = element.attributeValue(i).utf16(); base::string16 value = element.AttributeValue(i).Utf16();
attrMap.insert(std::make_pair(name, value)); attrMap.insert(std::make_pair(name, value));
} }
} }
@ -351,14 +351,14 @@ bool CefDOMNodeImpl::SetElementAttribute(const CefString& attrName,
if (!VerifyContext()) if (!VerifyContext())
return false; return false;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return false; return false;
} }
WebElement element = node_.to<blink::WebElement>(); WebElement element = node_.To<blink::WebElement>();
element.setAttribute(WebString::fromUTF16(attrName), element.SetAttribute(WebString::FromUTF16(attrName),
WebString::fromUTF16(value)); WebString::FromUTF16(value));
return true; return true;
} }
@ -367,15 +367,15 @@ CefString CefDOMNodeImpl::GetElementInnerText() {
if (!VerifyContext()) if (!VerifyContext())
return str; return str;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return str; return str;
} }
WebElement element = node_.to<blink::WebElement>(); WebElement element = node_.To<blink::WebElement>();
const WebString& text = element.textContent(); const WebString& text = element.TextContent();
if (!text.isNull()) if (!text.IsNull())
str = text.utf16(); str = text.Utf16();
return str; return str;
} }
@ -385,13 +385,13 @@ CefRect CefDOMNodeImpl::GetElementBounds() {
if (!VerifyContext()) if (!VerifyContext())
return rect; return rect;
if (!node_.isElementNode()) { if (!node_.IsElementNode()) {
NOTREACHED(); NOTREACHED();
return rect; return rect;
} }
WebElement element = node_.to<blink::WebElement>(); WebElement element = node_.To<blink::WebElement>();
blink::WebRect rc = element.boundsInViewport(); blink::WebRect rc = element.BoundsInViewport();
rect.Set(rc.x, rc.y, rc.width, rc.height); rect.Set(rc.x, rc.y, rc.width, rc.height);
return rect; return rect;
@ -399,7 +399,7 @@ CefRect CefDOMNodeImpl::GetElementBounds() {
void CefDOMNodeImpl::Detach() { void CefDOMNodeImpl::Detach() {
document_ = NULL; document_ = NULL;
node_.assign(WebNode()); node_.Assign(WebNode());
} }
bool CefDOMNodeImpl::VerifyContext() { bool CefDOMNodeImpl::VerifyContext() {
@ -409,7 +409,7 @@ bool CefDOMNodeImpl::VerifyContext() {
} }
if (!document_->VerifyContext()) if (!document_->VerifyContext())
return false; return false;
if (node_.isNull()) { if (node_.IsNull()) {
NOTREACHED(); NOTREACHED();
return false; return false;
} }

View File

@ -53,8 +53,8 @@ bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
const GURL& new_url, const GURL& new_url,
bool is_extension_url, bool is_extension_url,
bool is_initial_navigation) { bool is_initial_navigation) {
DCHECK(!frame->parent()); DCHECK(!frame->Parent());
GURL old_url(frame->document().url()); GURL old_url(frame->GetDocument().Url());
extensions::RendererExtensionRegistry* extension_registry = extensions::RendererExtensionRegistry* extension_registry =
extensions::RendererExtensionRegistry::Get(); extensions::RendererExtensionRegistry::Get();
@ -62,8 +62,9 @@ bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
// If old_url is still empty and this is an initial navigation, then this is // If old_url is still empty and this is an initial navigation, then this is
// a window.open operation. We should look at the opener URL. Note that the // a window.open operation. We should look at the opener URL. Note that the
// opener is a local frame in this case. // opener is a local frame in this case.
if (is_initial_navigation && old_url.is_empty() && frame->opener()) { if (is_initial_navigation && old_url.is_empty() && frame->Opener() &&
blink::WebLocalFrame* opener_frame = frame->opener()->toWebLocalFrame(); frame->Opener()->IsWebLocalFrame()) {
blink::WebLocalFrame* opener_frame = frame->Opener()->ToWebLocalFrame();
// We usually want to compare against the URL that determines the type of // We usually want to compare against the URL that determines the type of
// process. In default Chrome, that's the URL of the opener's top frame and // process. In default Chrome, that's the URL of the opener's top frame and
@ -74,19 +75,19 @@ bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kSitePerProcess) || ::switches::kSitePerProcess) ||
extensions::IsIsolateExtensionsEnabled()) extensions::IsIsolateExtensionsEnabled())
old_url = opener_frame->document().url(); old_url = opener_frame->GetDocument().Url();
else else
old_url = opener_frame->top()->document().url(); old_url = opener_frame->Top()->GetDocument().Url();
// If we're about to open a normal web page from a same-origin opener stuck // If we're about to open a normal web page from a same-origin opener stuck
// in an extension process (other than the Chrome Web Store), we want to // in an extension process (other than the Chrome Web Store), we want to
// keep it in process to allow the opener to script it. // keep it in process to allow the opener to script it.
blink::WebDocument opener_document = opener_frame->document(); blink::WebDocument opener_document = opener_frame->GetDocument();
blink::WebSecurityOrigin opener_origin = blink::WebSecurityOrigin opener_origin =
opener_document.getSecurityOrigin(); opener_document.GetSecurityOrigin();
bool opener_is_extension_url = !opener_origin.isUnique() && bool opener_is_extension_url = !opener_origin.IsUnique() &&
extension_registry->GetExtensionOrAppByURL( extension_registry->GetExtensionOrAppByURL(
opener_document.url()) != nullptr; opener_document.Url()) != nullptr;
const extensions::Extension* opener_top_extension = const extensions::Extension* opener_top_extension =
extension_registry->GetExtensionOrAppByURL(old_url); extension_registry->GetExtensionOrAppByURL(old_url);
bool opener_is_web_store = bool opener_is_web_store =
@ -94,14 +95,14 @@ bool CrossesExtensionExtents(blink::WebLocalFrame* frame,
opener_top_extension->id() == extensions::kWebStoreAppId; opener_top_extension->id() == extensions::kWebStoreAppId;
if (!is_extension_url && !opener_is_extension_url && !opener_is_web_store && if (!is_extension_url && !opener_is_extension_url && !opener_is_web_store &&
IsStandaloneExtensionProcess() && IsStandaloneExtensionProcess() &&
opener_origin.canRequest(blink::WebURL(new_url))) opener_origin.CanRequest(blink::WebURL(new_url)))
return false; return false;
} }
// Only consider keeping non-app URLs in an app process if this window // Only consider keeping non-app URLs in an app process if this window
// has an opener (in which case it might be an OAuth popup that tries to // has an opener (in which case it might be an OAuth popup that tries to
// script an iframe within the app). // script an iframe within the app).
bool should_consider_workaround = !!frame->opener(); bool should_consider_workaround = !!frame->Opener();
return extensions::CrossesExtensionProcessBoundary( return extensions::CrossesExtensionProcessBoundary(
*extension_registry->GetMainThreadExtensionSet(), old_url, new_url, *extension_registry->GetMainThreadExtensionSet(), old_url, new_url,
@ -157,7 +158,7 @@ void CefExtensionsRendererClient::RenderViewCreated(
bool CefExtensionsRendererClient::OverrideCreatePlugin( bool CefExtensionsRendererClient::OverrideCreatePlugin(
content::RenderFrame* render_frame, content::RenderFrame* render_frame,
const blink::WebPluginParams& params) { const blink::WebPluginParams& params) {
if (params.mimeType.utf8() != content::kBrowserPluginMimeType) if (params.mime_type.Utf8() != content::kBrowserPluginMimeType)
return true; return true;
bool guest_view_api_available = false; bool guest_view_api_available = false;
@ -174,7 +175,7 @@ bool CefExtensionsRendererClient::WillSendRequest(
GURL* new_url) { GURL* new_url) {
// Check whether the request should be allowed. If not allowed, we reset the // Check whether the request should be allowed. If not allowed, we reset the
// URL to something invalid to prevent the request and cause an error. // URL to something invalid to prevent the request and cause an error.
if (url.protocolIs(extensions::kExtensionScheme) && if (url.ProtocolIs(extensions::kExtensionScheme) &&
!resource_request_policy_->CanRequestResource(GURL(url), frame, !resource_request_policy_->CanRequestResource(GURL(url), frame,
transition_type)) { transition_type)) {
*new_url = GURL(chrome::kExtensionInvalidRequestURL); *new_url = GURL(chrome::kExtensionInvalidRequestURL);
@ -194,6 +195,11 @@ void CefExtensionsRendererClient::RunScriptsAtDocumentEnd(
extension_dispatcher_->RunScriptsAtDocumentEnd(render_frame); extension_dispatcher_->RunScriptsAtDocumentEnd(render_frame);
} }
void CefExtensionsRendererClient::RunScriptsAtDocumentIdle(
content::RenderFrame* render_frame) {
extension_dispatcher_->RunScriptsAtDocumentIdle(render_frame);
}
// static // static
bool CefExtensionsRendererClient::ShouldFork(blink::WebLocalFrame* frame, bool CefExtensionsRendererClient::ShouldFork(blink::WebLocalFrame* frame,
const GURL& url, const GURL& url,
@ -232,7 +238,7 @@ bool CefExtensionsRendererClient::ShouldFork(blink::WebLocalFrame* frame,
// for subframes, so this check only makes sense for top-level frames. // for subframes, so this check only makes sense for top-level frames.
// TODO(alexmos,nasko): Figure out how this check should work when reloading // TODO(alexmos,nasko): Figure out how this check should work when reloading
// subframes in --site-per-process mode. // subframes in --site-per-process mode.
if (!frame->parent() && GURL(frame->document().url()) == url) { if (!frame->Parent() && GURL(frame->GetDocument().Url()) == url) {
if (is_extension_url != IsStandaloneExtensionProcess()) if (is_extension_url != IsStandaloneExtensionProcess())
return true; return true;
} }

View File

@ -55,6 +55,7 @@ class CefExtensionsRendererClient : public ExtensionsRendererClient {
GURL* new_url); GURL* new_url);
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame); void RunScriptsAtDocumentStart(content::RenderFrame* render_frame);
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame); void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame);
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame);
static bool ShouldFork(blink::WebLocalFrame* frame, static bool ShouldFork(blink::WebLocalFrame* frame,
const GURL& url, const GURL& url,

View File

@ -29,13 +29,13 @@ bool CefPrintWebViewHelperDelegate::CancelPrerender(
// Return the PDF object element if |frame| is the out of process PDF extension. // Return the PDF object element if |frame| is the out of process PDF extension.
blink::WebElement CefPrintWebViewHelperDelegate::GetPdfElement( blink::WebElement CefPrintWebViewHelperDelegate::GetPdfElement(
blink::WebLocalFrame* frame) { blink::WebLocalFrame* frame) {
GURL url = frame->document().url(); GURL url = frame->GetDocument().Url();
if (url.SchemeIs(extensions::kExtensionScheme) && if (url.SchemeIs(extensions::kExtensionScheme) &&
url.host() == extension_misc::kPdfExtensionId) { url.host() == extension_misc::kPdfExtensionId) {
// <object> with id="plugin" is created in // <object> with id="plugin" is created in
// chrome/browser/resources/pdf/pdf.js. // chrome/browser/resources/pdf/pdf.js.
auto plugin_element = frame->document().getElementById("plugin"); auto plugin_element = frame->GetDocument().GetElementById("plugin");
if (!plugin_element.isNull()) { if (!plugin_element.IsNull()) {
return plugin_element; return plugin_element;
} }
NOTREACHED(); NOTREACHED();
@ -49,7 +49,7 @@ bool CefPrintWebViewHelperDelegate::IsPrintPreviewEnabled() {
bool CefPrintWebViewHelperDelegate::OverridePrint( bool CefPrintWebViewHelperDelegate::OverridePrint(
blink::WebLocalFrame* frame) { blink::WebLocalFrame* frame) {
if (!frame->document().isPluginDocument()) if (!frame->GetDocument().IsPluginDocument())
return false; return false;
std::vector<extensions::MimeHandlerViewContainer*> mime_handlers = std::vector<extensions::MimeHandlerViewContainer*> mime_handlers =

View File

@ -84,10 +84,10 @@ void CefFrameImpl::ViewSource() {
void CefFrameImpl::GetSource(CefRefPtr<CefStringVisitor> visitor) { void CefFrameImpl::GetSource(CefRefPtr<CefStringVisitor> visitor) {
CEF_REQUIRE_RT_RETURN_VOID(); CEF_REQUIRE_RT_RETURN_VOID();
if (frame_ && frame_->isWebLocalFrame()) { if (frame_ && frame_->IsWebLocalFrame()) {
const CefString& content = const CefString& content =
std::string(blink::WebFrameContentDumper::dumpAsMarkup( std::string(blink::WebFrameContentDumper::DumpAsMarkup(
frame_->toWebLocalFrame()).utf8()); frame_->ToWebLocalFrame()).Utf8());
visitor->Visit(content); visitor->Visit(content);
} }
} }
@ -151,7 +151,7 @@ void CefFrameImpl::LoadString(const CefString& string,
if (frame_) { if (frame_) {
GURL gurl = GURL(url.ToString()); GURL gurl = GURL(url.ToString());
frame_->loadHTMLString(string.ToString(), gurl); frame_->LoadHTMLString(string.ToString(), gurl);
} }
} }
@ -167,8 +167,8 @@ void CefFrameImpl::ExecuteJavaScript(const CefString& jsCode,
if (frame_) { if (frame_) {
GURL gurl = GURL(scriptUrl.ToString()); GURL gurl = GURL(scriptUrl.ToString());
frame_->executeScript( frame_->ExecuteScript(
blink::WebScriptSource(WebString::fromUTF16(jsCode.ToString16()), gurl, blink::WebScriptSource(WebString::FromUTF16(jsCode.ToString16()), gurl,
startLine)); startLine));
} }
} }
@ -177,15 +177,15 @@ bool CefFrameImpl::IsMain() {
CEF_REQUIRE_RT_RETURN(false); CEF_REQUIRE_RT_RETURN(false);
if (frame_) if (frame_)
return (frame_->parent() == NULL); return (frame_->Parent() == NULL);
return false; return false;
} }
bool CefFrameImpl::IsFocused() { bool CefFrameImpl::IsFocused() {
CEF_REQUIRE_RT_RETURN(false); CEF_REQUIRE_RT_RETURN(false);
if (frame_ && frame_->view()) if (frame_ && frame_->View())
return (frame_->view()->focusedFrame() == frame_); return (frame_->View()->FocusedFrame() == frame_);
return false; return false;
} }
@ -194,7 +194,7 @@ CefString CefFrameImpl::GetName() {
CEF_REQUIRE_RT_RETURN(name); CEF_REQUIRE_RT_RETURN(name);
if (frame_) if (frame_)
name = frame_->uniqueName().utf16(); name = webkit_glue::GetUniqueName(frame_);
return name; return name;
} }
@ -208,7 +208,7 @@ CefRefPtr<CefFrame> CefFrameImpl::GetParent() {
CEF_REQUIRE_RT_RETURN(NULL); CEF_REQUIRE_RT_RETURN(NULL);
if (frame_) { if (frame_) {
blink::WebFrame* parent = frame_->parent(); blink::WebFrame* parent = frame_->Parent();
if (parent) if (parent)
return browser_->GetWebFrameImpl(parent).get(); return browser_->GetWebFrameImpl(parent).get();
} }
@ -221,7 +221,7 @@ CefString CefFrameImpl::GetURL() {
CEF_REQUIRE_RT_RETURN(url); CEF_REQUIRE_RT_RETURN(url);
if (frame_) { if (frame_) {
GURL gurl = frame_->document().url(); GURL gurl = frame_->GetDocument().Url();
url = gurl.spec(); url = gurl.spec();
} }
return url; return url;
@ -237,9 +237,9 @@ CefRefPtr<CefV8Context> CefFrameImpl::GetV8Context() {
CEF_REQUIRE_RT_RETURN(NULL); CEF_REQUIRE_RT_RETURN(NULL);
if (frame_) { if (frame_) {
v8::Isolate* isolate = blink::mainThreadIsolate(); v8::Isolate* isolate = blink::MainThreadIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
return new CefV8ContextImpl(isolate, frame_->mainWorldScriptContext()); return new CefV8ContextImpl(isolate, frame_->MainWorldScriptContext());
} else { } else {
return NULL; return NULL;
} }
@ -254,8 +254,8 @@ void CefFrameImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
// Create a CefDOMDocumentImpl object that is valid only for the scope of this // Create a CefDOMDocumentImpl object that is valid only for the scope of this
// method. // method.
CefRefPtr<CefDOMDocumentImpl> documentImpl; CefRefPtr<CefDOMDocumentImpl> documentImpl;
const blink::WebDocument& document = frame_->document(); const blink::WebDocument& document = frame_->GetDocument();
if (!document.isNull()) if (!document.IsNull())
documentImpl = new CefDOMDocumentImpl(browser_, frame_); documentImpl = new CefDOMDocumentImpl(browser_, frame_);
visitor->Visit(documentImpl.get()); visitor->Visit(documentImpl.get());
@ -271,8 +271,8 @@ void CefFrameImpl::Detach() {
void CefFrameImpl::ExecuteCommand(const std::string& command) { void CefFrameImpl::ExecuteCommand(const std::string& command) {
CEF_REQUIRE_RT_RETURN_VOID(); CEF_REQUIRE_RT_RETURN_VOID();
if (frame_ && frame_->isWebLocalFrame()) if (frame_ && frame_->IsWebLocalFrame())
frame_->toWebLocalFrame()->executeCommand(WebString::fromUTF8(command)); frame_->ToWebLocalFrame()->ExecuteCommand(WebString::FromUTF8(command));
} }

View File

@ -115,13 +115,13 @@ void AddPepperBasedWidevine(
for (size_t i = 0; i < codecs.size(); ++i) { for (size_t i = 0; i < codecs.size(); ++i) {
if (codecs[i] == kCdmSupportedCodecVp8) if (codecs[i] == kCdmSupportedCodecVp8)
supported_codecs |= media::EME_CODEC_WEBM_VP8; supported_codecs |= media::EME_CODEC_WEBM_VP8;
if (codecs[i] == kCdmSupportedCodecVp9) if (codecs[i] == kCdmSupportedCodecVp9) {
supported_codecs |= media::EME_CODEC_WEBM_VP9; supported_codecs |= media::EME_CODEC_WEBM_VP9;
supported_codecs |= media::EME_CODEC_COMMON_VP9;
}
#if BUILDFLAG(USE_PROPRIETARY_CODECS) #if BUILDFLAG(USE_PROPRIETARY_CODECS)
if (codecs[i] == kCdmSupportedCodecAvc1) if (codecs[i] == kCdmSupportedCodecAvc1)
supported_codecs |= media::EME_CODEC_MP4_AVC1; supported_codecs |= media::EME_CODEC_MP4_AVC1;
if (codecs[i] == kCdmSupportedCodecVp9)
supported_codecs |= media::EME_CODEC_MP4_VP9;
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
} }

View File

@ -28,6 +28,7 @@
#include "third_party/WebKit/public/platform/WebMouseEvent.h" #include "third_party/WebKit/public/platform/WebMouseEvent.h"
#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
#include "third_party/WebKit/public/web/WebScriptSource.h" #include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h" #include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
@ -87,7 +88,7 @@ CefPluginPlaceholder* CefPluginPlaceholder::CreateLoadableMissingPlugin(
// Will destroy itself when its WebViewPlugin is going away. // Will destroy itself when its WebViewPlugin is going away.
return new CefPluginPlaceholder(render_frame, frame, params, html_data, return new CefPluginPlaceholder(render_frame, frame, params, html_data,
params.mimeType.utf16()); params.mime_type.Utf16());
} }
// static // static
@ -106,8 +107,8 @@ CefPluginPlaceholder* CefPluginPlaceholder::CreateBlockedPlugin(
values.SetString("name", name); values.SetString("name", name);
values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
values.SetString("pluginType", values.SetString("pluginType",
frame->view()->mainFrame()->isWebLocalFrame() && frame->View()->MainFrame()->IsWebLocalFrame() &&
frame->view()->mainFrame()->document().isPluginDocument() frame->View()->MainFrame()->GetDocument().IsPluginDocument()
? "document" ? "document"
: "embedded"); : "embedded");
@ -117,7 +118,7 @@ CefPluginPlaceholder* CefPluginPlaceholder::CreateBlockedPlugin(
if (!power_saver_info.custom_poster_size.IsEmpty()) { if (!power_saver_info.custom_poster_size.IsEmpty()) {
float zoom_factor = float zoom_factor =
blink::WebView::zoomLevelToZoomFactor(frame->view()->zoomLevel()); blink::WebView::ZoomLevelToZoomFactor(frame->View()->ZoomLevel());
int width = int width =
roundf(power_saver_info.custom_poster_size.width() / zoom_factor); roundf(power_saver_info.custom_poster_size.width() / zoom_factor);
int height = int height =
@ -174,16 +175,16 @@ void CefPluginPlaceholder::ShowPermissionBubbleCallback() {
void CefPluginPlaceholder::PluginListChanged() { void CefPluginPlaceholder::PluginListChanged() {
if (!GetFrame() || !plugin()) if (!GetFrame() || !plugin())
return; return;
blink::WebDocument document = GetFrame()->top()->document(); blink::WebDocument document = GetFrame()->Top()->GetDocument();
if (document.isNull()) if (document.IsNull())
return; return;
CefViewHostMsg_GetPluginInfo_Output output; CefViewHostMsg_GetPluginInfo_Output output;
std::string mime_type(GetPluginParams().mimeType.utf8()); std::string mime_type(GetPluginParams().mime_type.Utf8());
render_frame()->Send(new CefViewHostMsg_GetPluginInfo( render_frame()->Send(new CefViewHostMsg_GetPluginInfo(
routing_id(), GURL(GetPluginParams().url), routing_id(), GURL(GetPluginParams().url),
GetFrame()->parent() == nullptr, GetFrame()->Parent() == nullptr,
GetFrame()->top()->getSecurityOrigin(), mime_type, &output)); GetFrame()->Top()->GetSecurityOrigin(), mime_type, &output));
if (output.status == status_) if (output.status == status_)
return; return;
blink::WebPlugin* new_plugin = CefContentRendererClient::CreatePlugin( blink::WebPlugin* new_plugin = CefContentRendererClient::CreatePlugin(
@ -252,14 +253,18 @@ void CefPluginPlaceholder::ShowContextMenu(
content::MenuItem hide_item; content::MenuItem hide_item;
hide_item.action = chrome::MENU_COMMAND_PLUGIN_HIDE; hide_item.action = chrome::MENU_COMMAND_PLUGIN_HIDE;
bool is_main_frame_plugin_document = bool is_main_frame_plugin_document =
GetFrame()->view()->mainFrame()->isWebLocalFrame() && GetFrame()->View()->MainFrame()->IsWebLocalFrame() &&
GetFrame()->view()->mainFrame()->document().isPluginDocument(); GetFrame()->View()->MainFrame()->GetDocument().IsPluginDocument();
hide_item.enabled = !is_main_frame_plugin_document; hide_item.enabled = !is_main_frame_plugin_document;
hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE);
params.custom_items.push_back(hide_item); params.custom_items.push_back(hide_item);
params.x = event.windowX; blink::WebPoint point(event.PositionInWidget().x, event.PositionInWidget().y);
params.y = event.windowY; if (plugin() && plugin()->Container())
point = plugin()->Container()->LocalToRootFramePoint(point);
params.x = point.x;
params.y = point.y;
context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); context_menu_request_id_ = render_frame()->ShowContextMenu(this, params);
g_last_active_menu = this; g_last_active_menu = this;

View File

@ -76,14 +76,14 @@ void CefPluginPreroller::OnThrottleStateChange() {
placeholder->AllowLoading(); placeholder->AllowLoading();
blink::WebPluginContainer* container = blink::WebPluginContainer* container =
throttler_->GetWebPlugin()->container(); throttler_->GetWebPlugin()->Container();
container->setPlugin(placeholder->plugin()); container->SetPlugin(placeholder->plugin());
bool success = placeholder->plugin()->initialize(container); bool success = placeholder->plugin()->Initialize(container);
DCHECK(success); DCHECK(success);
container->invalidate(); container->Invalidate();
container->reportGeometry(); container->ReportGeometry();
delete this; delete this;
} }

View File

@ -39,7 +39,7 @@ void CefRenderFrameObserver::DidCreateScriptContext(
blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
CefRefPtr<CefBrowserImpl> browserPtr = CefRefPtr<CefBrowserImpl> browserPtr =
CefBrowserImpl::GetBrowserForMainFrame(frame->top()); CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
if (!browserPtr.get()) if (!browserPtr.get())
return; return;
@ -52,7 +52,7 @@ void CefRenderFrameObserver::DidCreateScriptContext(
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame); CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
v8::Isolate* isolate = blink::mainThreadIsolate(); v8::Isolate* isolate = blink::MainThreadIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Context::Scope scope(context); v8::Context::Scope scope(context);
v8::MicrotasksScope microtasks_scope(isolate, v8::MicrotasksScope microtasks_scope(isolate,
@ -69,7 +69,7 @@ void CefRenderFrameObserver::WillReleaseScriptContext(
blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
CefRefPtr<CefBrowserImpl> browserPtr = CefRefPtr<CefBrowserImpl> browserPtr =
CefBrowserImpl::GetBrowserForMainFrame(frame->top()); CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
if (browserPtr.get()) { if (browserPtr.get()) {
CefRefPtr<CefApp> application = CefContentClient::Get()->application(); CefRefPtr<CefApp> application = CefContentClient::Get()->application();
if (application.get()) { if (application.get()) {
@ -78,7 +78,7 @@ void CefRenderFrameObserver::WillReleaseScriptContext(
if (handler.get()) { if (handler.get()) {
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame); CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
v8::Isolate* isolate = blink::mainThreadIsolate(); v8::Isolate* isolate = blink::MainThreadIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
// The released context should not be used for script execution. // The released context should not be used for script execution.

View File

@ -60,20 +60,20 @@ void CefRenderThreadObserver::OnModifyCrossOriginWhitelistEntry(
const Cef_CrossOriginWhiteListEntry_Params& params) { const Cef_CrossOriginWhiteListEntry_Params& params) {
GURL gurl = GURL(params.source_origin); GURL gurl = GURL(params.source_origin);
if (add) { if (add) {
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry( blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
gurl, gurl,
blink::WebString::fromUTF8(params.target_protocol), blink::WebString::FromUTF8(params.target_protocol),
blink::WebString::fromUTF8(params.target_domain), blink::WebString::FromUTF8(params.target_domain),
params.allow_target_subdomains); params.allow_target_subdomains);
} else { } else {
blink::WebSecurityPolicy::removeOriginAccessWhitelistEntry( blink::WebSecurityPolicy::RemoveOriginAccessWhitelistEntry(
gurl, gurl,
blink::WebString::fromUTF8(params.target_protocol), blink::WebString::FromUTF8(params.target_protocol),
blink::WebString::fromUTF8(params.target_domain), blink::WebString::FromUTF8(params.target_domain),
params.allow_target_subdomains); params.allow_target_subdomains);
} }
} }
void CefRenderThreadObserver::OnClearCrossOriginWhitelist() { void CefRenderThreadObserver::OnClearCrossOriginWhitelist() {
blink::WebSecurityPolicy::resetOriginAccessWhitelists(); blink::WebSecurityPolicy::ResetOriginAccessWhitelists();
} }

View File

@ -37,24 +37,24 @@ class CefWebURLLoaderClient : public blink::WebURLLoaderClient {
~CefWebURLLoaderClient() override; ~CefWebURLLoaderClient() override;
// blink::WebURLLoaderClient methods. // blink::WebURLLoaderClient methods.
bool willFollowRedirect( bool WillFollowRedirect(
WebURLRequest& newRequest, WebURLRequest& newRequest,
const WebURLResponse& redirectResponse) override; const WebURLResponse& redirectResponse) override;
void didSendData( void DidSendData(
unsigned long long bytesSent, unsigned long long bytesSent,
unsigned long long totalBytesToBeSent) override; unsigned long long totalBytesToBeSent) override;
void didReceiveResponse( void DidReceiveResponse(
const WebURLResponse& response) override; const WebURLResponse& response) override;
void didDownloadData(int dataLength, void DidDownloadData(int dataLength,
int encodedDataLength) override; int encodedDataLength) override;
void didReceiveData(const char* data, void DidReceiveData(const char* data,
int dataLength) override; int dataLength) override;
void didReceiveCachedMetadata(const char* data, void DidReceiveCachedMetadata(const char* data,
int dataLength) override; int dataLength) override;
void didFinishLoading(double finishTime, void DidFinishLoading(double finishTime,
int64_t totalEncodedDataLength, int64_t totalEncodedDataLength,
int64_t totalEncodedBodyLength) override; int64_t totalEncodedBodyLength) override;
void didFail(const WebURLError& error, void DidFail(const WebURLError& error,
int64_t totalEncodedDataLength, int64_t totalEncodedDataLength,
int64_t totalEncodedBodyLength) override; int64_t totalEncodedBodyLength) override;
@ -100,14 +100,14 @@ class CefRenderURLRequest::Context
if (!url.is_valid()) if (!url.is_valid())
return false; return false;
loader_.reset(blink::Platform::current()->createURLLoader()); loader_.reset(blink::Platform::Current()->CreateURLLoader());
url_client_.reset(new CefWebURLLoaderClient(this, request_->GetFlags())); url_client_.reset(new CefWebURLLoaderClient(this, request_->GetFlags()));
WebURLRequest urlRequest; WebURLRequest urlRequest;
static_cast<CefRequestImpl*>(request_.get())->Get(urlRequest, static_cast<CefRequestImpl*>(request_.get())->Get(urlRequest,
upload_data_size_); upload_data_size_);
loader_->loadAsynchronously(urlRequest, url_client_.get()); loader_->LoadAsynchronously(urlRequest, url_client_.get());
return true; return true;
} }
@ -122,7 +122,7 @@ class CefRenderURLRequest::Context
error_code_ = ERR_ABORTED; error_code_ = ERR_ABORTED;
// Will result in a call to OnError(). // Will result in a call to OnError().
loader_->cancel(); loader_->Cancel();
} }
void OnResponse(const WebURLResponse& response) { void OnResponse(const WebURLResponse& response) {
@ -134,7 +134,7 @@ class CefRenderURLRequest::Context
responseImpl->Set(response); responseImpl->Set(response);
responseImpl->SetReadOnly(true); responseImpl->SetReadOnly(true);
download_data_total_ = response.expectedContentLength(); download_data_total_ = response.ExpectedContentLength();
} }
void OnError(const WebURLError& error) { void OnError(const WebURLError& error) {
@ -244,29 +244,29 @@ CefWebURLLoaderClient::CefWebURLLoaderClient(
CefWebURLLoaderClient::~CefWebURLLoaderClient() { CefWebURLLoaderClient::~CefWebURLLoaderClient() {
} }
bool CefWebURLLoaderClient::willFollowRedirect( bool CefWebURLLoaderClient::WillFollowRedirect(
WebURLRequest& newRequest, WebURLRequest& newRequest,
const WebURLResponse& redirectResponse) { const WebURLResponse& redirectResponse) {
return true; return true;
} }
void CefWebURLLoaderClient::didSendData( void CefWebURLLoaderClient::DidSendData(
unsigned long long bytesSent, unsigned long long bytesSent,
unsigned long long totalBytesToBeSent) { unsigned long long totalBytesToBeSent) {
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS)
context_->OnUploadProgress(bytesSent, totalBytesToBeSent); context_->OnUploadProgress(bytesSent, totalBytesToBeSent);
} }
void CefWebURLLoaderClient::didReceiveResponse( void CefWebURLLoaderClient::DidReceiveResponse(
const WebURLResponse& response) { const WebURLResponse& response) {
context_->OnResponse(response); context_->OnResponse(response);
} }
void CefWebURLLoaderClient::didDownloadData(int dataLength, void CefWebURLLoaderClient::DidDownloadData(int dataLength,
int encodedDataLength) { int encodedDataLength) {
} }
void CefWebURLLoaderClient::didReceiveData(const char* data, void CefWebURLLoaderClient::DidReceiveData(const char* data,
int dataLength) { int dataLength) {
context_->OnDownloadProgress(dataLength); context_->OnDownloadProgress(dataLength);
@ -274,17 +274,17 @@ void CefWebURLLoaderClient::didReceiveData(const char* data,
context_->OnDownloadData(data, dataLength); context_->OnDownloadData(data, dataLength);
} }
void CefWebURLLoaderClient::didReceiveCachedMetadata(const char* data, void CefWebURLLoaderClient::DidReceiveCachedMetadata(const char* data,
int dataLength) { int dataLength) {
} }
void CefWebURLLoaderClient::didFinishLoading(double finishTime, void CefWebURLLoaderClient::DidFinishLoading(double finishTime,
int64_t totalEncodedDataLength, int64_t totalEncodedDataLength,
int64_t totalEncodedBodyLength) { int64_t totalEncodedBodyLength) {
context_->OnComplete(); context_->OnComplete();
} }
void CefWebURLLoaderClient::didFail(const WebURLError& error, void CefWebURLLoaderClient::DidFail(const WebURLError& error,
int64_t totalEncodedDataLength, int64_t totalEncodedDataLength,
int64_t totalEncodedBodyLength) { int64_t totalEncodedBodyLength) {
context_->OnError(error); context_->OnError(error);

View File

@ -290,7 +290,8 @@ public:
base::ThreadLocalPointer<CefV8IsolateManager> current_tls_; base::ThreadLocalPointer<CefV8IsolateManager> current_tls_;
}; };
base::LazyInstance<CefV8StateManager> g_v8_state = LAZY_INSTANCE_INITIALIZER; base::LazyInstance<CefV8StateManager>::Leaky g_v8_state =
LAZY_INSTANCE_INITIALIZER;
CefV8IsolateManager* GetIsolateManager() { CefV8IsolateManager* GetIsolateManager() {
return g_v8_state.Pointer()->GetIsolateManager(); return g_v8_state.Pointer()->GetIsolateManager();
@ -1005,7 +1006,7 @@ CefRefPtr<CefBrowser> CefV8ContextImpl::GetBrowser() {
blink::WebFrame* webframe = GetWebFrame(); blink::WebFrame* webframe = GetWebFrame();
if (webframe) if (webframe)
browser = CefBrowserImpl::GetBrowserForMainFrame(webframe->top()); browser = CefBrowserImpl::GetBrowserForMainFrame(webframe->Top());
return browser; return browser;
} }
@ -1017,7 +1018,7 @@ CefRefPtr<CefFrame> CefV8ContextImpl::GetFrame() {
blink::WebFrame* webframe = GetWebFrame(); blink::WebFrame* webframe = GetWebFrame();
if (webframe) { if (webframe) {
CefRefPtr<CefBrowserImpl> browser = CefRefPtr<CefBrowserImpl> browser =
CefBrowserImpl::GetBrowserForMainFrame(webframe->top()); CefBrowserImpl::GetBrowserForMainFrame(webframe->Top());
frame = browser->GetFrame(webkit_glue::GetIdentifier(webframe)); frame = browser->GetFrame(webkit_glue::GetIdentifier(webframe));
} }
@ -1116,8 +1117,8 @@ bool CefV8ContextImpl::Eval(const CefString& code,
v8::Local<v8::Context> context = GetV8Context(); v8::Local<v8::Context> context = GetV8Context();
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
const blink::WebString& source = blink::WebString::fromUTF16(code); const blink::WebString& source = blink::WebString::FromUTF16(code);
const blink::WebString& source_url = blink::WebString::fromUTF16(script_url); const blink::WebString& source_url = blink::WebString::FromUTF16(script_url);
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
try_catch.SetVerbose(true); try_catch.SetVerbose(true);
@ -1125,7 +1126,7 @@ bool CefV8ContextImpl::Eval(const CefString& code,
v8::MaybeLocal<v8::Value> func_rv = v8::MaybeLocal<v8::Value> func_rv =
webkit_glue::ExecuteV8ScriptAndReturnValue(source, source_url, start_line, webkit_glue::ExecuteV8ScriptAndReturnValue(source, source_url, start_line,
context, isolate, try_catch, context, isolate, try_catch,
blink::AccessControlStatus::NotSharableCrossOrigin); blink::AccessControlStatus::kNotSharableCrossOrigin);
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
exception = new CefV8ExceptionImpl(context, try_catch.Message()); exception = new CefV8ExceptionImpl(context, try_catch.Message());
@ -1152,7 +1153,7 @@ blink::WebFrame* CefV8ContextImpl::GetWebFrame() {
v8::HandleScope handle_scope(handle_->isolate()); v8::HandleScope handle_scope(handle_->isolate());
v8::Local<v8::Context> context = GetV8Context(); v8::Local<v8::Context> context = GetV8Context();
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
return blink::WebLocalFrame::frameForContext(context); return blink::WebLocalFrame::FrameForContext(context);
} }

View File

@ -40,7 +40,7 @@ MSVC_POP_WARNING();
#undef LOG #undef LOG
#include "base/logging.h" #include "base/logging.h"
#include "content/public/renderer/render_frame.h" #include "content/renderer/render_frame_impl.h"
namespace webkit_glue { namespace webkit_glue {
@ -50,45 +50,45 @@ bool CanGoBack(blink::WebView* view) {
if (!view) if (!view)
return false; return false;
blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view); blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view);
return (impl->client()->historyBackListCount() > 0); return (impl->Client()->HistoryBackListCount() > 0);
} }
bool CanGoForward(blink::WebView* view) { bool CanGoForward(blink::WebView* view) {
if (!view) if (!view)
return false; return false;
blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view); blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view);
return (impl->client()->historyForwardListCount() > 0); return (impl->Client()->HistoryForwardListCount() > 0);
} }
void GoBack(blink::WebView* view) { void GoBack(blink::WebView* view) {
if (!view) if (!view)
return; return;
blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view); blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view);
if (impl->client()->historyBackListCount() > 0) if (impl->Client()->HistoryBackListCount() > 0)
impl->client()->navigateBackForwardSoon(-1); impl->Client()->NavigateBackForwardSoon(-1);
} }
void GoForward(blink::WebView* view) { void GoForward(blink::WebView* view) {
if (!view) if (!view)
return; return;
blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view); blink::WebViewImpl* impl = reinterpret_cast<blink::WebViewImpl*>(view);
if (impl->client()->historyForwardListCount() > 0) if (impl->Client()->HistoryForwardListCount() > 0)
impl->client()->navigateBackForwardSoon(1); impl->Client()->NavigateBackForwardSoon(1);
} }
std::string DumpDocumentText(blink::WebFrame* frame) { std::string DumpDocumentText(blink::WebFrame* frame) {
// We use the document element's text instead of the body text here because // We use the document element's text instead of the body text here because
// not all documents have a body, such as XML documents. // not all documents have a body, such as XML documents.
blink::WebElement document_element = frame->document().documentElement(); blink::WebElement document_element = frame->GetDocument().DocumentElement();
if (document_element.isNull()) if (document_element.IsNull())
return std::string(); return std::string();
blink::Element* web_element = document_element.unwrap<blink::Element>(); blink::Element* web_element = document_element.Unwrap<blink::Element>();
return blink::WebString(web_element->innerText()).utf8(); return blink::WebString(web_element->innerText()).Utf8();
} }
cef_dom_node_type_t GetNodeType(const blink::WebNode& node) { cef_dom_node_type_t GetNodeType(const blink::WebNode& node) {
const blink::Node* web_node = node.constUnwrap<blink::Node>(); const blink::Node* web_node = node.ConstUnwrap<blink::Node>();
switch (web_node->getNodeType()) { switch (web_node->getNodeType()) {
case blink::Node::kElementNode: case blink::Node::kElementNode:
return DOM_NODE_TYPE_ELEMENT; return DOM_NODE_TYPE_ELEMENT;
@ -113,17 +113,17 @@ cef_dom_node_type_t GetNodeType(const blink::WebNode& node) {
} }
blink::WebString GetNodeName(const blink::WebNode& node) { blink::WebString GetNodeName(const blink::WebNode& node) {
const blink::Node* web_node = node.constUnwrap<blink::Node>(); const blink::Node* web_node = node.ConstUnwrap<blink::Node>();
return web_node->nodeName(); return web_node->nodeName();
} }
blink::WebString CreateNodeMarkup(const blink::WebNode& node) { blink::WebString CreateNodeMarkup(const blink::WebNode& node) {
const blink::Node* web_node = node.constUnwrap<blink::Node>(); const blink::Node* web_node = node.ConstUnwrap<blink::Node>();
return blink::createMarkup(web_node); return blink::CreateMarkup(web_node);
} }
bool SetNodeValue(blink::WebNode& node, const blink::WebString& value) { bool SetNodeValue(blink::WebNode& node, const blink::WebString& value) {
blink::Node* web_node = node.unwrap<blink::Node>(); blink::Node* web_node = node.Unwrap<blink::Node>();
web_node->setNodeValue(value); web_node->setNodeValue(value);
return true; return true;
} }
@ -139,30 +139,13 @@ int64_t GetIdentifier(blink::WebFrame* frame) {
return kInvalidFrameId; return kInvalidFrameId;
} }
// Based on WebViewImpl::findFrameByName and FrameTree::find. std::string GetUniqueName(blink::WebFrame* frame) {
blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name, content::RenderFrameImpl* render_frame =
blink::WebFrame* relative_to_frame) { content::RenderFrameImpl::FromWebFrame(frame);
blink::Frame* start_frame = toWebLocalFrameImpl(relative_to_frame)->frame(); DCHECK(render_frame);
if (!start_frame) if (render_frame)
return NULL; return render_frame->unique_name();
return std::string();
const AtomicString& atomic_name = unique_name;
blink::Frame* found_frame = NULL;
// Search the subtree starting with |start_frame|.
for (blink::Frame* frame = start_frame;
frame;
frame = frame->tree().traverseNext(start_frame)) {
if (frame->tree().uniqueName() == atomic_name) {
found_frame = frame;
break;
}
}
if (found_frame && found_frame->isLocalFrame())
return blink::WebLocalFrameImpl::fromFrame(toLocalFrame(found_frame));
return NULL;
} }
v8::MaybeLocal<v8::Value> CallV8Function(v8::Local<v8::Context> context, v8::MaybeLocal<v8::Value> CallV8Function(v8::Local<v8::Context> context,
@ -175,21 +158,20 @@ v8::MaybeLocal<v8::Value> CallV8Function(v8::Local<v8::Context> context,
// Execute the function call using the V8ScriptRunner so that inspector // Execute the function call using the V8ScriptRunner so that inspector
// instrumentation works. // instrumentation works.
blink::LocalFrame* frame = blink::LocalFrame* frame = blink::ToLocalFrameIfNotDetached(context);
toLocalFrame(blink::toFrameIfNotDetached(context));
DCHECK(frame); DCHECK(frame);
if (frame && if (frame &&
frame->document()->canExecuteScripts(blink::AboutToExecuteScript)) { frame->GetDocument()->CanExecuteScripts(blink::kAboutToExecuteScript)) {
func_rv = blink::V8ScriptRunner::callFunction( func_rv = blink::V8ScriptRunner::CallFunction(
function, frame->document(), receiver, argc, args, isolate); function, frame->GetDocument(), receiver, argc, args, isolate);
} }
return func_rv; return func_rv;
} }
bool IsTextControlElement(const blink::WebElement& element) { bool IsTextControlElement(const blink::WebElement& element) {
const blink::Element* web_element = element.constUnwrap<blink::Element>(); const blink::Element* web_element = element.ConstUnwrap<blink::Element>();
return web_element->isTextControl(); return web_element->IsTextControl();
} }
v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue( v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
@ -206,51 +188,50 @@ v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
if (start_line < 1) if (start_line < 1)
start_line = 1; start_line = 1;
const blink::KURL kurl = source_url.isEmpty() ? const blink::KURL kurl = source_url.IsEmpty() ?
blink::KURL() : blink::KURL(blink::ParsedURLString, source_url); blink::KURL() : blink::KURL(blink::kParsedURLString, source_url);
const blink::ScriptSourceCode ssc = blink::ScriptSourceCode(source, kurl, const blink::ScriptSourceCode ssc = blink::ScriptSourceCode(source, kurl,
WTF::TextPosition(WTF::OrdinalNumber::fromOneBasedInt(start_line), WTF::TextPosition(WTF::OrdinalNumber::FromOneBasedInt(start_line),
WTF::OrdinalNumber::fromZeroBasedInt(0))); WTF::OrdinalNumber::FromZeroBasedInt(0)));
v8::MaybeLocal<v8::Value> result; v8::MaybeLocal<v8::Value> result;
blink::LocalFrame* frame = blink::LocalFrame* frame = blink::ToLocalFrameIfNotDetached(context);
toLocalFrame(blink::toFrameIfNotDetached(context));
DCHECK(frame); DCHECK(frame);
if (frame) { if (frame) {
blink::V8CacheOptions v8CacheOptions(blink::V8CacheOptionsDefault); blink::V8CacheOptions v8CacheOptions(blink::kV8CacheOptionsDefault);
if (frame && frame->settings()) if (frame && frame->GetSettings())
v8CacheOptions = frame->settings()->getV8CacheOptions(); v8CacheOptions = frame->GetSettings()->GetV8CacheOptions();
v8::Local<v8::Script> script; v8::Local<v8::Script> script;
if (!blink::v8Call(blink::V8ScriptRunner::compileScript(ssc, isolate, if (!blink::V8Call(blink::V8ScriptRunner::CompileScript(ssc, isolate,
accessControlStatus, v8CacheOptions), script, tryCatch)) { accessControlStatus, v8CacheOptions), script, tryCatch)) {
return result; return result;
} }
result = blink::V8ScriptRunner::runCompiledScript(isolate, script, result = blink::V8ScriptRunner::RunCompiledScript(isolate, script,
blink::toExecutionContext(context)); blink::ToExecutionContext(context));
} }
return result; return result;
} }
bool IsScriptForbidden() { bool IsScriptForbidden() {
return blink::ScriptForbiddenScope::isScriptForbidden(); return blink::ScriptForbiddenScope::IsScriptForbidden();
} }
void registerURLSchemeAsLocal(const blink::WebString& scheme) { void RegisterURLSchemeAsLocal(const blink::WebString& scheme) {
blink::SchemeRegistry::registerURLSchemeAsLocal(scheme); blink::SchemeRegistry::RegisterURLSchemeAsLocal(scheme);
} }
void registerURLSchemeAsSecure(const blink::WebString& scheme) { void RegisterURLSchemeAsSecure(const blink::WebString& scheme) {
blink::SchemeRegistry::registerURLSchemeAsSecure(scheme); blink::SchemeRegistry::RegisterURLSchemeAsSecure(scheme);
} }
void registerURLSchemeAsCORSEnabled(const blink::WebString& scheme) { void RegisterURLSchemeAsCORSEnabled(const blink::WebString& scheme) {
blink::SchemeRegistry::registerURLSchemeAsCORSEnabled(scheme); blink::SchemeRegistry::RegisterURLSchemeAsCORSEnabled(scheme);
} }
} // webkit_glue } // webkit_glue

View File

@ -41,11 +41,7 @@ blink::WebString CreateNodeMarkup(const blink::WebNode& node);
bool SetNodeValue(blink::WebNode& node, const blink::WebString& value); bool SetNodeValue(blink::WebNode& node, const blink::WebString& value);
int64_t GetIdentifier(blink::WebFrame* frame); int64_t GetIdentifier(blink::WebFrame* frame);
std::string GetUniqueName(blink::WebFrame* frame);
// Find the frame with the specified |unique_name| relative to
// |relative_to_frame| in the frame hierarchy.
blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name,
blink::WebFrame* relative_to_frame);
bool IsTextControlElement(const blink::WebElement& element); bool IsTextControlElement(const blink::WebElement& element);
@ -67,9 +63,9 @@ v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
bool IsScriptForbidden(); bool IsScriptForbidden();
void registerURLSchemeAsLocal(const blink::WebString& scheme); void RegisterURLSchemeAsLocal(const blink::WebString& scheme);
void registerURLSchemeAsSecure(const blink::WebString& scheme); void RegisterURLSchemeAsSecure(const blink::WebString& scheme);
void registerURLSchemeAsCORSEnabled(const blink::WebString& scheme); void RegisterURLSchemeAsCORSEnabled(const blink::WebString& scheme);
} // webkit_glue } // webkit_glue

View File

@ -68,15 +68,12 @@ patches = [
# #
# Support creation of captionless windows with resizable borders. # Support creation of captionless windows with resizable borders.
# https://bitbucket.org/chromiumembedded/cef/issues/1749 # https://bitbucket.org/chromiumembedded/cef/issues/1749
#
# Remove console spam from RenderWidgetHostViewBase::IsInVR.
# https://codereview.chromium.org/2822223002
'name': 'views_widget_180_1481_1565_1677_1749', 'name': 'views_widget_180_1481_1565_1677_1749',
'path': '../', 'path': '../',
}, },
{
# Allow continued use of ContentRendererClient::HandleNavigation.
# https://bitbucket.org/chromiumembedded/cef/issues/1129
'name': 'content_nav_1129',
'path': '../content/',
},
{ {
# Allow specification of a custom WebContentsView. # Allow specification of a custom WebContentsView.
# https://bitbucket.org/chromiumembedded/cef/issues/1257 # https://bitbucket.org/chromiumembedded/cef/issues/1257
@ -152,10 +149,13 @@ patches = [
'path': '../', 'path': '../',
}, },
{ {
# Split service_manager::Main into the separate steps required by CEF.
# https://bugs.chromium.org/p/chromium/issues/detail?id=654986#c17
#
# Remove DCHECK on Linux when initialized CEF from a non-main thread. # Remove DCHECK on Linux when initialized CEF from a non-main thread.
# https://bitbucket.org/chromiumembedded/cef/issue/1639 # https://bitbucket.org/chromiumembedded/cef/issue/1639
'name': 'process_title_1639', 'name': 'service_manager_654986',
'path': '../content/common/', 'path': '../',
}, },
{ {
# Fix rendering of the PDF extension with OSR when the device scale factor # Fix rendering of the PDF extension with OSR when the device scale factor
@ -206,8 +206,20 @@ patches = [
# Modify views::View to extend SupportsUserData. # Modify views::View to extend SupportsUserData.
# Modify views::MenuButton behavior. # Modify views::MenuButton behavior.
# https://bitbucket.org/chromiumembedded/cef/issues/1749 # https://bitbucket.org/chromiumembedded/cef/issues/1749
#
# Don't add TestDesktopScreenX11 dependency on Linux.
# Reverts ui_controls_factory_desktop_aurax11.cc changes from
# https://codereview.chromium.org/2327623002
#
# Add InkDropHostView::ink_drop_mode method.
# Reverts ink_drop_host_view.h changes from
# https://codereview.chromium.org/2723843002
#
# Make LabelButton::SetFontList method public.
# Reverts label_button.h changes from
# https://codereview.chromium.org/2793283002
'name': 'views_1749', 'name': 'views_1749',
'path': '../ui/views/', 'path': '../',
}, },
{ {
# Expose RenderViewHostImpl swapped-out state. # Expose RenderViewHostImpl swapped-out state.
@ -248,13 +260,6 @@ patches = [
'name': 'storage_partition_1973', 'name': 'storage_partition_1973',
'path': '../', 'path': '../',
}, },
{
# Don't add TestDesktopScreenX11 dependency on Linux.
# Revert ui_controls_factory_desktop_aurax11.cc changes from
# https://codereview.chromium.org/2327623002
'name': 'ui_views_test_640741',
'path': '../',
},
{ {
# Fix plugin placeholder blocked message. # Fix plugin placeholder blocked message.
# https://bitbucket.org/chromiumembedded/cef/issues/2020/ # https://bitbucket.org/chromiumembedded/cef/issues/2020/
@ -293,9 +298,6 @@ patches = [
# #
# Implement better rate-limiting/retry logic. # Implement better rate-limiting/retry logic.
# https://bugs.chromium.org/p/crashpad/issues/detail?id=23 # https://bugs.chromium.org/p/crashpad/issues/detail?id=23
#
# Windows: Support crash upload URLs with query component.
# https://bugs.chromium.org/p/crashpad/issues/detail?id=163
'name': 'crashpad_tp_1995', 'name': 'crashpad_tp_1995',
'path': '../third_party/crashpad/', 'path': '../third_party/crashpad/',
}, },
@ -306,18 +308,25 @@ patches = [
'path': '../', 'path': '../',
}, },
{ {
# Allow continued use of ContentRendererClient::HandleNavigation.
# https://bitbucket.org/chromiumembedded/cef/issues/1129
#
# Pass is_main_frame to PluginServiceFilter::IsPluginAvailable. # Pass is_main_frame to PluginServiceFilter::IsPluginAvailable.
# https://bitbucket.org/chromiumembedded/cef/issues/2015 # https://bitbucket.org/chromiumembedded/cef/issues/2015
# #
# Pass the render process id to PluginServiceFilter::IsPluginAvailable. # Pass the render process id to PluginServiceFilter::IsPluginAvailable.
# https://bugs.chromium.org/p/chromium/issues/detail?id=626728#c15 # https://bugs.chromium.org/p/chromium/issues/detail?id=626728#c15
'name': 'plugin_info_2015', #
# Expose RFH via NavigationHandle for retrieval in DidFinishNavigation on
# network error.
# https://groups.google.com/a/chromium.org/d/msg/chromium-dev/6iAQPx_hwh8/gaTR5f1GAQAJ
'name': 'content_1129_2015',
'path': '../', 'path': '../',
}, },
{ {
# Pass is_main_frame to PluginServiceFilter::IsPluginAvailable. # Pass is_main_frame to PluginServiceFilter::IsPluginAvailable.
# https://bitbucket.org/chromiumembedded/cef/issues/2015 # https://bitbucket.org/chromiumembedded/cef/issues/2015
'name': 'plugin_info_webkit_2015', 'name': 'webkit_plugin_info_2015',
'path': '../third_party/WebKit/', 'path': '../third_party/WebKit/',
}, },
{ {
@ -328,10 +337,15 @@ patches = [
'path': '../', 'path': '../',
}, },
{ {
# Expose RFH via NavigationHandle for retrieval in DidFinishNavigation on # Mac: Fix build error when including openssl/opensslconf.h.
# network error. # https://bugs.chromium.org/p/chromium/issues/detail?id=711670
# https://groups.google.com/a/chromium.org/d/msg/chromium-dev/6iAQPx_hwh8/gaTR5f1GAQAJ 'name': 'mac_build_711670',
'name': 'navigation_handle', 'path': '../',
},
{
# Linux: Remove DCHECK during GPU feature info detection.
# https://bugs.chromium.org/p/chromium/issues/detail?id=699278
'name': 'gpu_feature_info_699278',
'path': '../', 'path': '../',
}, },
] ]

View File

@ -1,8 +1,8 @@
diff --git content/browser/renderer_host/browser_compositor_view_mac.h content/browser/renderer_host/browser_compositor_view_mac.h diff --git content/browser/renderer_host/browser_compositor_view_mac.h content/browser/renderer_host/browser_compositor_view_mac.h
index d0ecb71..84c20b4 100644 index 1c73b7f..606f29c 100644
--- content/browser/renderer_host/browser_compositor_view_mac.h --- content/browser/renderer_host/browser_compositor_view_mac.h
+++ content/browser/renderer_host/browser_compositor_view_mac.h +++ content/browser/renderer_host/browser_compositor_view_mac.h
@@ -56,9 +56,11 @@ class BrowserCompositorMac : public cc::BeginFrameObserver, @@ -51,9 +51,11 @@ class BrowserCompositorMac : public DelegatedFrameHostClient {
// These will not return nullptr until Destroy is called. // These will not return nullptr until Destroy is called.
DelegatedFrameHost* GetDelegatedFrameHost(); DelegatedFrameHost* GetDelegatedFrameHost();
@ -13,12 +13,12 @@ index d0ecb71..84c20b4 100644
+ ui::Compositor* GetCompositor(); + ui::Compositor* GetCompositor();
ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac();
void SwapCompositorFrame(uint32_t compositor_frame_sink_id, void DidCreateNewRendererCompositorFrameSink(
diff --git content/browser/renderer_host/browser_compositor_view_mac.mm content/browser/renderer_host/browser_compositor_view_mac.mm diff --git content/browser/renderer_host/browser_compositor_view_mac.mm content/browser/renderer_host/browser_compositor_view_mac.mm
index e4c25e73..e2f789e 100644 index fba983b..8cf9629 100644
--- content/browser/renderer_host/browser_compositor_view_mac.mm --- content/browser/renderer_host/browser_compositor_view_mac.mm
+++ content/browser/renderer_host/browser_compositor_view_mac.mm +++ content/browser/renderer_host/browser_compositor_view_mac.mm
@@ -201,6 +201,12 @@ BrowserCompositorMac::~BrowserCompositorMac() { @@ -202,6 +202,12 @@ BrowserCompositorMac::~BrowserCompositorMac() {
g_spare_recyclable_compositors.Get().clear(); g_spare_recyclable_compositors.Get().clear();
} }
@ -31,7 +31,7 @@ index e4c25e73..e2f789e 100644
ui::AcceleratedWidgetMac* BrowserCompositorMac::GetAcceleratedWidgetMac() { ui::AcceleratedWidgetMac* BrowserCompositorMac::GetAcceleratedWidgetMac() {
if (recyclable_compositor_) if (recyclable_compositor_)
return recyclable_compositor_->accelerated_widget_mac(); return recyclable_compositor_->accelerated_widget_mac();
@@ -417,8 +423,13 @@ SkColor BrowserCompositorMac::DelegatedFrameHostGetGutterColor( @@ -421,8 +427,13 @@ SkColor BrowserCompositorMac::DelegatedFrameHostGetGutterColor(
} }
gfx::Size BrowserCompositorMac::DelegatedFrameHostDesiredSizeInDIP() const { gfx::Size BrowserCompositorMac::DelegatedFrameHostDesiredSizeInDIP() const {

View File

@ -1,5 +1,5 @@
diff --git render_widget_host_view_guest.cc render_widget_host_view_guest.cc diff --git render_widget_host_view_guest.cc render_widget_host_view_guest.cc
index 2197f73a..ab100b6 100644 index fc720a7..1c30365 100644
--- render_widget_host_view_guest.cc --- render_widget_host_view_guest.cc
+++ render_widget_host_view_guest.cc +++ render_widget_host_view_guest.cc
@@ -247,13 +247,14 @@ void RenderWidgetHostViewGuest::Destroy() { @@ -247,13 +247,14 @@ void RenderWidgetHostViewGuest::Destroy() {

Some files were not shown because too many files have changed in this diff Show More