diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index ec495fc6c..c0b32ab80 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -7,5 +7,5 @@ # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding { - 'chromium_checkout': 'c78c0ad7cca1b37761b488e9499d619b21c8016d', + 'chromium_checkout': 'd7d5682a0953188e49a31505303665ff916c1080', } diff --git a/cef.gyp b/cef.gyp index 11f151c26..eed54ea7a 100644 --- a/cef.gyp +++ b/cef.gyp @@ -1382,6 +1382,8 @@ '<(DEPTH)/chrome/browser/plugins/plugin_finder.h', '<(DEPTH)/chrome/browser/plugins/plugin_metadata.cc', '<(DEPTH)/chrome/browser/plugins/plugin_metadata.h', + '<(DEPTH)/chrome/renderer/plugins/power_saver_info.cc', + '<(DEPTH)/chrome/renderer/plugins/power_saver_info.h', '<(DEPTH)/components/nacl/common/nacl_constants.cc', '<(DEPTH)/components/nacl/common/nacl_constants.h', # Include sources for preferences support. @@ -1425,8 +1427,13 @@ 'libcef/browser/native/file_dialog_runner_win.h', 'libcef/browser/native/javascript_dialog_runner_win.cc', 'libcef/browser/native/javascript_dialog_runner_win.h', + 'libcef/browser/native/menu_2.cc', + 'libcef/browser/native/menu_2.h', 'libcef/browser/native/menu_runner_win.cc', 'libcef/browser/native/menu_runner_win.h', + 'libcef/browser/native/menu_wrapper.h', + 'libcef/browser/native/native_menu_win.cc', + 'libcef/browser/native/native_menu_win.h', 'libcef/browser/osr/browser_platform_delegate_osr_win.cc', 'libcef/browser/osr/browser_platform_delegate_osr_win.h', 'libcef/browser/osr/render_widget_host_view_osr_win.cc', diff --git a/include/base/cef_basictypes.h b/include/base/cef_basictypes.h index a53c295ea..193e910f8 100644 --- a/include/base/cef_basictypes.h +++ b/include/base/cef_basictypes.h @@ -32,14 +32,6 @@ #define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ #pragma once -#if defined(BUILDING_CEF_SHARED) -// When building CEF include the Chromium header directly. -#include "base/basictypes.h" -#else // !BUILDING_CEF_SHARED -// The following is substantially similar to the Chromium implementation. -// If the Chromium implementation diverges the below implementation should be -// updated to match. - #include // For UINT_MAX #include // For size_t @@ -72,8 +64,6 @@ typedef int int32; typedef unsigned int uint32; #endif -#endif // !BUILDING_CEF_SHARED - // UTF-16 character type. // This should be kept synchronized with base/strings/string16.h #ifndef char16 diff --git a/include/base/cef_build.h b/include/base/cef_build.h index a1a709f7a..0451913bf 100644 --- a/include/base/cef_build.h +++ b/include/base/cef_build.h @@ -135,7 +135,7 @@ // Annotate a function indicating the caller must examine the return value. // Use like: // int foo() WARN_UNUSED_RESULT; -// To explicitly ignore a result, see |ignore_result()| in . +// To explicitly ignore a result, see |ignore_result()| in . #ifndef WARN_UNUSED_RESULT #if defined(COMPILER_GCC) #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) diff --git a/libcef/browser/browser_context_impl.cc b/libcef/browser/browser_context_impl.cc index 83586a486..80124e34a 100644 --- a/libcef/browser/browser_context_impl.cc +++ b/libcef/browser/browser_context_impl.cc @@ -5,6 +5,7 @@ #include "libcef/browser/browser_context_impl.h" #include +#include #include "libcef/browser/browser_context_proxy.h" #include "libcef/browser/context.h" @@ -368,8 +369,8 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext( BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), protocol_handlers, - proxy_config_service.Pass(), - request_interceptors.Pass()); + std::move(proxy_config_service), + std::move(request_interceptors)); resource_context()->set_url_request_context_getter(url_request_getter_.get()); return url_request_getter_.get(); } diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index 5b6eaccfe..7e4274219 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -293,7 +293,7 @@ CefRefPtr CefBrowserHostImpl::Create( CefRefPtr browser = CefBrowserHostImpl::CreateInternal(settings, client, NULL, info, opener, request_context, - platform_delegate.Pass()); + std::move(platform_delegate)); if (browser.get() && !url.empty()) { browser->LoadURL(CefFrameHostImpl::kMainFrameId, url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); @@ -343,7 +343,7 @@ CefRefPtr CefBrowserHostImpl::CreateInternal( CefRefPtr browser = new CefBrowserHostImpl(settings, client, web_contents, browser_info, opener, request_context, - platform_delegate.Pass()); + std::move(platform_delegate)); if (!browser->CreateHostWindow()) return nullptr; @@ -654,7 +654,7 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) { scoped_ptr params( content::DownloadUrlParameters::FromWebContents(web_contents(), gurl)); - manager->DownloadUrl(params.Pass()); + manager->DownloadUrl(std::move(params)); } void CefBrowserHostImpl::Print() { @@ -1947,9 +1947,9 @@ void CefBrowserHostImpl::UpdateTargetURL(content::WebContents* source, } bool CefBrowserHostImpl::AddMessageToConsole(content::WebContents* source, - int32 level, + int32_t level, const base::string16& message, - int32 line_no, + int32_t line_no, const base::string16& source_id) { if (client_.get()) { CefRefPtr handler = client_->GetDisplayHandler(); @@ -2118,7 +2118,7 @@ void CefBrowserHostImpl::WebContentsCreated( CefRefPtr browser = CefBrowserHostImpl::CreateInternal( settings, client, new_contents, info, opener, request_context, - platform_delegate.Pass()); + std::move(platform_delegate)); } void CefBrowserHostImpl::DidNavigateMainFramePostCommit( @@ -2133,7 +2133,7 @@ content::JavaScriptDialogManager* if (!javascript_dialog_manager_.get()) { javascript_dialog_manager_.reset( new CefJavaScriptDialogManager(this, - platform_delegate_->CreateJavaScriptDialogRunner().Pass())); + platform_delegate_->CreateJavaScriptDialogRunner())); } return javascript_dialog_manager_.get(); } @@ -2152,7 +2152,7 @@ bool CefBrowserHostImpl::HandleContextMenu( if (!menu_manager_.get()) { menu_manager_.reset( new CefMenuManager(this, - platform_delegate_->CreateMenuRunner().Pass())); + platform_delegate_->CreateMenuRunner())); } return menu_manager_->CreateContextMenu(params); } @@ -2606,7 +2606,7 @@ CefBrowserHostImpl::CefBrowserHostImpl( browser_info_(browser_info), opener_(kNullWindowHandle), request_context_(request_context), - platform_delegate_(platform_delegate.Pass()), + platform_delegate_(std::move(platform_delegate)), is_loading_(false), can_go_back_(false), can_go_forward_(false), @@ -2871,6 +2871,6 @@ void CefBrowserHostImpl::EnsureFileDialogManager() { if (!file_dialog_manager_.get()) { file_dialog_manager_.reset( new CefFileDialogManager(this, - platform_delegate_->CreateFileDialogRunner().Pass())); + platform_delegate_->CreateFileDialogRunner())); } } diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index 2fb710ede..ebf038a10 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -304,9 +304,9 @@ class CefBrowserHostImpl : public CefBrowserHost, void UpdateTargetURL(content::WebContents* source, const GURL& url) override; bool AddMessageToConsole(content::WebContents* source, - int32 level, + int32_t level, const base::string16& message, - int32 line_no, + int32_t line_no, const base::string16& source_id) override; void BeforeUnloadFired(content::WebContents* source, bool proceed, diff --git a/libcef/browser/browser_info_manager.cc b/libcef/browser/browser_info_manager.cc index 60037212d..2ee0515fa 100644 --- a/libcef/browser/browser_info_manager.cc +++ b/libcef/browser/browser_info_manager.cc @@ -4,6 +4,8 @@ #include "libcef/browser/browser_info_manager.h" +#include + #include "libcef/browser/browser_platform_delegate.h" #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/thread_util.h" @@ -148,7 +150,7 @@ void CefBrowserInfoManager::OnCreateWindow( pending_popup->opener_frame_id = params.opener_render_frame_id; pending_popup->target_url = params.target_url; pending_popup->target_frame_name = params.frame_name; - PushPendingPopup(pending_popup.Pass()); + PushPendingPopup(std::move(pending_popup)); } bool CefBrowserInfoManager::CanCreateWindow( @@ -282,7 +284,7 @@ void CefBrowserInfoManager::ShouldCreateWebContents( pending_popup->step = CefBrowserInfoManager::PendingPopup::SHOULD_CREATE_WEB_CONTENTS; - PushPendingPopup(pending_popup.Pass()); + PushPendingPopup(std::move(pending_popup)); } void CefBrowserInfoManager::WebContentsCreated( @@ -306,7 +308,7 @@ void CefBrowserInfoManager::WebContentsCreated( settings = pending_popup->settings; client = pending_popup->client; - platform_delegate = pending_popup->platform_delegate.Pass(); + platform_delegate = std::move(pending_popup->platform_delegate); } void CefBrowserInfoManager::OnGetNewBrowserInfo( @@ -358,7 +360,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo( pending->render_view_routing_id = render_view_routing_id; pending->render_frame_routing_id = render_frame_routing_id; pending->reply_msg = reply_msg; - pending_new_browser_info_list_.push_back(pending.Pass()); + pending_new_browser_info_list_.push_back(std::move(pending)); } void CefBrowserInfoManager::RemoveBrowserInfo( @@ -448,12 +450,12 @@ void CefBrowserInfoManager::FilterPendingPopupURL( DCHECK(rph); rph->FilterURL(false, &pending_popup->target_url); - GetInstance()->PushPendingPopup(pending_popup.Pass()); + GetInstance()->PushPendingPopup(std::move(pending_popup)); } void CefBrowserInfoManager::PushPendingPopup(scoped_ptr popup) { base::AutoLock lock_scope(pending_popup_lock_); - pending_popup_list_.push_back(popup.Pass()); + pending_popup_list_.push_back(std::move(popup)); } scoped_ptr diff --git a/libcef/browser/browser_main.cc b/libcef/browser/browser_main.cc index f56ee1da2..0420ddbfc 100644 --- a/libcef/browser/browser_main.cc +++ b/libcef/browser/browser_main.cc @@ -4,6 +4,8 @@ #include "libcef/browser/browser_main.h" +#include + #include #include "libcef/browser/browser_context_impl.h" @@ -155,7 +157,7 @@ void CefBrowserMainParts::PreMainMessageLoopRun() { int port; if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { devtools_delegate_ = - new CefDevToolsDelegate(static_cast(port)); + new CefDevToolsDelegate(static_cast(port)); } else { LOG(WARNING) << "Invalid http debugger port number " << port; } diff --git a/libcef/browser/browser_main.h b/libcef/browser/browser_main.h index b8d6c939c..789da068a 100644 --- a/libcef/browser/browser_main.h +++ b/libcef/browser/browser_main.h @@ -9,11 +9,12 @@ #include "libcef/browser/browser_context_impl.h" #include "libcef/browser/net/url_request_context_getter_impl.h" -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/prefs/pref_service.h" #include "base/strings/string_piece.h" +#include "build/build_config.h" #include "content/public/browser/browser_main_parts.h" #include "net/url_request/url_request_context_getter.h" diff --git a/libcef/browser/browser_message_filter.cc b/libcef/browser/browser_message_filter.cc index ae4e6b859..fff2f931d 100644 --- a/libcef/browser/browser_message_filter.cc +++ b/libcef/browser/browser_message_filter.cc @@ -103,7 +103,7 @@ void CefBrowserMessageFilter::OnCreateWindow( delete reply_msg; } -void CefBrowserMessageFilter::OnFrameFocused(int32 render_frame_routing_id) { +void CefBrowserMessageFilter::OnFrameFocused(int32_t render_frame_routing_id) { if (!CEF_CURRENTLY_ON_UIT()) { CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserMessageFilter::OnFrameFocused, this, diff --git a/libcef/browser/browser_message_filter.h b/libcef/browser/browser_message_filter.h index 634ab099d..bb80feba3 100644 --- a/libcef/browser/browser_message_filter.h +++ b/libcef/browser/browser_message_filter.h @@ -6,7 +6,10 @@ #ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_ #define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_ +#include + #include + #include "ipc/ipc_channel_proxy.h" #include "ipc/message_filter.h" @@ -41,7 +44,7 @@ class CefBrowserMessageFilter : public IPC::MessageFilter { IPC::Message* reply_msg); void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params, IPC::Message* reply_msg); - void OnFrameFocused(int32 render_frame_routing_id); + void OnFrameFocused(int32_t render_frame_routing_id); content::RenderProcessHost* host_; IPC::Sender* sender_; diff --git a/libcef/browser/browser_message_loop.h b/libcef/browser/browser_message_loop.h index 23cfcc429..80972b0b9 100644 --- a/libcef/browser/browser_message_loop.h +++ b/libcef/browser/browser_message_loop.h @@ -6,7 +6,7 @@ #define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ #pragma once -#include "base/basictypes.h" +#include "base/macros.h" #include "base/message_loop/message_loop.h" // Class used to process events on the current message loop. diff --git a/libcef/browser/browser_platform_delegate_create.cc b/libcef/browser/browser_platform_delegate_create.cc index f0ffd2062..4ada1d70a 100644 --- a/libcef/browser/browser_platform_delegate_create.cc +++ b/libcef/browser/browser_platform_delegate_create.cc @@ -4,6 +4,10 @@ #include "libcef/browser/browser_platform_delegate.h" +#include + +#include "build/build_config.h" + #if defined(OS_WIN) #include "libcef/browser/native/browser_platform_delegate_native_win.h" #include "libcef/browser/osr/browser_platform_delegate_osr_win.h" @@ -35,13 +39,13 @@ scoped_ptr CreateOSRDelegate( scoped_ptr native_delegate) { #if defined(OS_WIN) return make_scoped_ptr( - new CefBrowserPlatformDelegateOsrWin(native_delegate.Pass())); + new CefBrowserPlatformDelegateOsrWin(std::move(native_delegate))); #elif defined(OS_MACOSX) return make_scoped_ptr( - new CefBrowserPlatformDelegateOsrMac(native_delegate.Pass())); + new CefBrowserPlatformDelegateOsrMac(std::move(native_delegate))); #elif defined(OS_LINUX) return make_scoped_ptr( - new CefBrowserPlatformDelegateOsrLinux(native_delegate.Pass())); + new CefBrowserPlatformDelegateOsrLinux(std::move(native_delegate))); #endif } @@ -56,7 +60,7 @@ scoped_ptr CefBrowserPlatformDelegate::Create( CreateNativeDelegate(window_info); if (window_info.windowless_rendering_enabled && client->GetRenderHandler().get()) { - return CreateOSRDelegate(native_delegate.Pass()); + return CreateOSRDelegate(std::move(native_delegate)); } - return native_delegate.Pass(); + return std::move(native_delegate); } diff --git a/libcef/browser/browser_urlrequest_impl.cc b/libcef/browser/browser_urlrequest_impl.cc index 61a29ae74..4ccd042b2 100644 --- a/libcef/browser/browser_urlrequest_impl.cc +++ b/libcef/browser/browser_urlrequest_impl.cc @@ -5,6 +5,7 @@ #include "libcef/browser/browser_urlrequest_impl.h" #include +#include #include "libcef/browser/browser_context.h" #include "libcef/browser/content_browser_client.h" @@ -228,7 +229,7 @@ class CefBrowserURLRequest::Context response_writer.reset( new CefURLFetcherResponseWriter(url_request_, task_runner_)); } - fetcher_->SaveResponseWithWriter(response_writer.Pass()); + fetcher_->SaveResponseWithWriter(std::move(response_writer)); fetcher_->Start(); } diff --git a/libcef/browser/chrome_browser_process_stub.cc b/libcef/browser/chrome_browser_process_stub.cc index 9d67815f7..749beb108 100644 --- a/libcef/browser/chrome_browser_process_stub.cc +++ b/libcef/browser/chrome_browser_process_stub.cc @@ -129,7 +129,7 @@ GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() { void ChromeBrowserProcessStub::CreateDevToolsHttpProtocolHandler( chrome::HostDesktopType host_desktop_type, const std::string& ip, - uint16 port) { + uint16_t port) { } unsigned int ChromeBrowserProcessStub::AddRefModule() { diff --git a/libcef/browser/chrome_browser_process_stub.h b/libcef/browser/chrome_browser_process_stub.h index 75aa48779..8535edbab 100644 --- a/libcef/browser/chrome_browser_process_stub.h +++ b/libcef/browser/chrome_browser_process_stub.h @@ -55,7 +55,7 @@ class ChromeBrowserProcessStub : public BrowserProcess { void CreateDevToolsHttpProtocolHandler( chrome::HostDesktopType host_desktop_type, const std::string& ip, - uint16 port) override; + uint16_t port) override; unsigned int AddRefModule() override; unsigned int ReleaseModule() override; bool IsShuttingDown() override; diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index c359c3ef8..4d53fa2f9 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -5,6 +5,7 @@ #include "libcef/browser/content_browser_client.h" #include +#include #include "libcef/browser/browser_info.h" #include "libcef/browser/browser_info_manager.h" @@ -515,7 +516,7 @@ net::URLRequestContextGetter* CefContentBrowserClient::CreateRequestContext( return context->CreateRequestContext( protocol_handlers, - request_interceptors.Pass()); + std::move(request_interceptors)); } net::URLRequestContextGetter* @@ -531,7 +532,7 @@ CefContentBrowserClient::CreateRequestContextForStoragePartition( partition_path, in_memory, protocol_handlers, - request_interceptors.Pass()); + std::move(request_interceptors)); } bool CefContentBrowserClient::IsHandledURL(const GURL& url) { @@ -847,7 +848,7 @@ CefContentBrowserClient::CreateThrottlesForNavigation( true); throttles.push_back(throttle); - return throttles.Pass(); + return throttles; } #if defined(OS_POSIX) && !defined(OS_MACOSX) diff --git a/libcef/browser/content_browser_client.h b/libcef/browser/content_browser_client.h index ede9b2c63..ff16d4e60 100644 --- a/libcef/browser/content_browser_client.h +++ b/libcef/browser/content_browser_client.h @@ -13,9 +13,10 @@ #include "libcef/browser/browser_context_impl.h" #include "libcef/browser/net/url_request_context_getter_impl.h" -#include "base/compiler_specific.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "build/build_config.h" #include "content/public/browser/content_browser_client.h" #include "third_party/skia/include/core/SkColor.h" diff --git a/libcef/browser/devtools_delegate.cc b/libcef/browser/devtools_delegate.cc index e01fab65b..016637444 100644 --- a/libcef/browser/devtools_delegate.cc +++ b/libcef/browser/devtools_delegate.cc @@ -3,12 +3,13 @@ // governed by a BSD-style license that can be found in the LICENSE file. #include "libcef/browser/devtools_delegate.h" -#include "libcef/browser/net/devtools_scheme_handler.h" -#include "libcef/common/content_client.h" #include #include +#include "libcef/browser/net/devtools_scheme_handler.h" +#include "libcef/common/content_client.h" + #include "base/command_line.h" #include "base/md5.h" #include "base/rand_util.h" @@ -41,7 +42,7 @@ const int kBackLog = 10; class TCPServerSocketFactory : public devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory { public: - TCPServerSocketFactory(const std::string& address, uint16 port) + TCPServerSocketFactory(const std::string& address, uint16_t port) : address_(address), port_(port) { } @@ -57,13 +58,13 @@ class TCPServerSocketFactory } std::string address_; - uint16 port_; + uint16_t port_; DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); }; scoped_ptr - CreateSocketFactory(uint16 port) { + CreateSocketFactory(uint16_t port) { return scoped_ptr< devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory>( new TCPServerSocketFactory("127.0.0.1", port)); @@ -73,7 +74,7 @@ scoped_ptr // CefDevToolsDelegate -CefDevToolsDelegate::CefDevToolsDelegate(uint16 port) { +CefDevToolsDelegate::CefDevToolsDelegate(uint16_t port) { devtools_http_handler_.reset(new devtools_http_handler::DevToolsHttpHandler( CreateSocketFactory(port), std::string(), diff --git a/libcef/browser/devtools_delegate.h b/libcef/browser/devtools_delegate.h index bdb483e29..2839d6b8d 100644 --- a/libcef/browser/devtools_delegate.h +++ b/libcef/browser/devtools_delegate.h @@ -6,10 +6,11 @@ #define CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_ #pragma once +#include + #include #include -#include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "components/devtools_http_handler/devtools_http_handler.h" @@ -24,7 +25,7 @@ class RenderViewHost; class CefDevToolsDelegate : public devtools_http_handler::DevToolsHttpHandlerDelegate { public: - explicit CefDevToolsDelegate(uint16 port); + explicit CefDevToolsDelegate(uint16_t port); ~CefDevToolsDelegate() override; // Stops http server. diff --git a/libcef/browser/devtools_frontend.h b/libcef/browser/devtools_frontend.h index 731806dda..e7b185c69 100644 --- a/libcef/browser/devtools_frontend.h +++ b/libcef/browser/devtools_frontend.h @@ -7,7 +7,6 @@ #include "libcef/browser/browser_host_impl.h" -#include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" diff --git a/libcef/browser/extensions/api/streams_private/streams_private_api.cc b/libcef/browser/extensions/api/streams_private/streams_private_api.cc index 3ac05efbd..39d0659fb 100644 --- a/libcef/browser/extensions/api/streams_private/streams_private_api.cc +++ b/libcef/browser/extensions/api/streams_private/streams_private_api.cc @@ -4,6 +4,9 @@ #include "libcef/browser/extensions/api/streams_private/streams_private_api.h" +#include +#include + #include "base/lazy_instance.h" #include "base/values.h" #include "cef/libcef/common/extensions/api/streams_private.h" @@ -64,7 +67,7 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler( int tab_id, scoped_ptr stream, const std::string& view_id, - int64 expected_content_size, + int64_t expected_content_size, bool embedded, int render_process_id, int render_frame_id) { @@ -82,9 +85,9 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler( GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() + handler->handler_url()); scoped_ptr stream_container(new StreamContainer( - stream.Pass(), tab_id, embedded, handler_url, extension_id)); + std::move(stream), tab_id, embedded, handler_url, extension_id)); MimeHandlerStreamManager::Get(browser_context_) - ->AddStream(view_id, stream_container.Pass(), render_process_id, + ->AddStream(view_id, std::move(stream_container), render_process_id, render_frame_id); return; } @@ -114,7 +117,7 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler( streams_private::OnExecuteMimeTypeHandler::Create(info))); EventRouter::Get(browser_context_) - ->DispatchEventToExtension(extension_id, event.Pass()); + ->DispatchEventToExtension(extension_id, std::move(event)); GURL url = stream->handle->GetURL(); streams_[extension_id][url] = make_linked_ptr(stream->handle.release()); diff --git a/libcef/browser/extensions/api/streams_private/streams_private_api.h b/libcef/browser/extensions/api/streams_private/streams_private_api.h index 19cdcdbfe..a46f6c108 100644 --- a/libcef/browser/extensions/api/streams_private/streams_private_api.h +++ b/libcef/browser/extensions/api/streams_private/streams_private_api.h @@ -5,6 +5,8 @@ #ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ #define CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ +#include + #include #include @@ -41,7 +43,7 @@ class StreamsPrivateAPI : public BrowserContextKeyedAPI, int tab_id, scoped_ptr stream, const std::string& view_id, - int64 expected_content_size, + int64_t expected_content_size, bool embedded, int render_process_id, int render_frame_id); diff --git a/libcef/browser/extensions/component_extension_resource_manager.h b/libcef/browser/extensions/component_extension_resource_manager.h index e2e0eb4dd..d23ecf83c 100644 --- a/libcef/browser/extensions/component_extension_resource_manager.h +++ b/libcef/browser/extensions/component_extension_resource_manager.h @@ -7,7 +7,6 @@ #include -#include "base/basictypes.h" #include "base/files/file_path.h" #include "extensions/browser/component_extension_resource_manager.h" diff --git a/libcef/browser/extensions/event_router_forwarder.cc b/libcef/browser/extensions/event_router_forwarder.cc index 3fa166ce4..a9e703789 100644 --- a/libcef/browser/extensions/event_router_forwarder.cc +++ b/libcef/browser/extensions/event_router_forwarder.cc @@ -4,10 +4,14 @@ #include "libcef/browser/extensions/event_router_forwarder.h" +#include +#include + #include "libcef/browser/browser_context_impl.h" #include "base/bind.h" #include "base/values.h" +#include "build/build_config.h" #include "content/public/browser/browser_thread.h" #include "extensions/browser/event_router.h" #include "url/gurl.h" @@ -27,8 +31,8 @@ void EventRouterForwarder::BroadcastEventToRenderers( const std::string& event_name, scoped_ptr event_args, const GURL& event_url) { - HandleEvent(std::string(), histogram_value, event_name, event_args.Pass(), 0, - true, event_url); + HandleEvent(std::string(), histogram_value, event_name, std::move(event_args), + 0, true, event_url); } void EventRouterForwarder::DispatchEventToRenderers( @@ -40,7 +44,7 @@ void EventRouterForwarder::DispatchEventToRenderers( const GURL& event_url) { if (!profile) return; - HandleEvent(std::string(), histogram_value, event_name, event_args.Pass(), + HandleEvent(std::string(), histogram_value, event_name, std::move(event_args), profile, use_profile_to_restrict_events, event_url); } @@ -50,8 +54,8 @@ void EventRouterForwarder::BroadcastEventToExtension( const std::string& event_name, scoped_ptr event_args, const GURL& event_url) { - HandleEvent(extension_id, histogram_value, event_name, event_args.Pass(), 0, - true, event_url); + HandleEvent(extension_id, histogram_value, event_name, std::move(event_args), + 0, true, event_url); } void EventRouterForwarder::DispatchEventToExtension( @@ -64,7 +68,7 @@ void EventRouterForwarder::DispatchEventToExtension( const GURL& event_url) { if (!profile) return; - HandleEvent(extension_id, histogram_value, event_name, event_args.Pass(), + HandleEvent(extension_id, histogram_value, event_name, std::move(event_args), profile, use_profile_to_restrict_events, event_url); } @@ -92,7 +96,7 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id, } if (profile) { CallEventRouter(profile, extension_id, histogram_value, event_name, - event_args.Pass(), + std::move(event_args), use_profile_to_restrict_events ? profile : NULL, event_url); } else { std::vector profiles( @@ -101,7 +105,7 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id, scoped_ptr per_profile_event_args( event_args->DeepCopy()); CallEventRouter(profiles[i], extension_id, histogram_value, event_name, - per_profile_event_args.Pass(), + std::move(per_profile_event_args), use_profile_to_restrict_events ? profiles[i] : NULL, event_url); } @@ -117,14 +121,14 @@ void EventRouterForwarder::CallEventRouter( content::BrowserContext* restrict_to_profile, const GURL& event_url) { scoped_ptr event( - new Event(histogram_value, event_name, event_args.Pass())); + new Event(histogram_value, event_name, std::move(event_args))); event->restrict_to_browser_context = restrict_to_profile; event->event_url = event_url; if (extension_id.empty()) { - extensions::EventRouter::Get(profile)->BroadcastEvent(event.Pass()); + extensions::EventRouter::Get(profile)->BroadcastEvent(std::move(event)); } else { extensions::EventRouter::Get(profile) - ->DispatchEventToExtension(extension_id, event.Pass()); + ->DispatchEventToExtension(extension_id, std::move(event)); } } diff --git a/libcef/browser/extensions/event_router_forwarder.h b/libcef/browser/extensions/event_router_forwarder.h index e9d4fadf8..e15766774 100644 --- a/libcef/browser/extensions/event_router_forwarder.h +++ b/libcef/browser/extensions/event_router_forwarder.h @@ -7,7 +7,7 @@ #include -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/values.h" #include "extensions/browser/extension_event_histogram_value.h" diff --git a/libcef/browser/extensions/extensions_browser_client.cc b/libcef/browser/extensions/extensions_browser_client.cc index 3c796f67a..585e32402 100644 --- a/libcef/browser/extensions/extensions_browser_client.cc +++ b/libcef/browser/extensions/extensions_browser_client.cc @@ -5,6 +5,8 @@ #include "libcef/browser/extensions/extensions_browser_client.h" +#include + #include "libcef/browser/browser_context_impl.h" #include "libcef/browser/extensions/component_extension_resource_manager.h" #include "libcef/browser/extensions/extension_system_factory.h" @@ -204,7 +206,7 @@ void CefExtensionsBrowserClient::BroadcastEventToRenderers( const std::string& event_name, scoped_ptr args) { event_router_forwarder_->BroadcastEventToRenderers( - histogram_value, event_name, args.Pass(), GURL()); + histogram_value, event_name, std::move(args), GURL()); } net::NetLog* CefExtensionsBrowserClient::GetNetLog() { diff --git a/libcef/browser/extensions/pdf_extension_util.cc b/libcef/browser/extensions/pdf_extension_util.cc index 8a2e7bf93..de5b460b1 100644 --- a/libcef/browser/extensions/pdf_extension_util.cc +++ b/libcef/browser/extensions/pdf_extension_util.cc @@ -5,7 +5,6 @@ #include "libcef/browser/extensions/pdf_extension_util.h" #include "base/strings/string_util.h" -#include "chrome/common/chrome_switches.h" #include "grit/cef_resources.h" #include "ui/base/resource/resource_bundle.h" @@ -16,12 +15,6 @@ namespace { // Tags in the manifest to be replaced. const char kNameTag[] = ""; -const char kIndexTag[] = ""; - -// The index html pages to load for the material and non-material version of -// the viewer. -const char kRegularIndex[] = "index.html"; -const char kMaterialIndex[] = "index-material.html"; } // namespace @@ -43,10 +36,6 @@ std::string GetManifest() { base::ReplaceFirstSubstringAfterOffset( &manifest_contents, 0, kNameTag, kPdfPluginName); - DCHECK(manifest_contents.find(kIndexTag) != std::string::npos); - std::string index = switches::PdfMaterialUIEnabled() ? - kMaterialIndex : kRegularIndex; - base::ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index); return manifest_contents; } diff --git a/libcef/browser/file_dialog_manager.cc b/libcef/browser/file_dialog_manager.cc index 8a2ad4f6b..d806c2efc 100644 --- a/libcef/browser/file_dialog_manager.cc +++ b/libcef/browser/file_dialog_manager.cc @@ -5,6 +5,8 @@ #include "libcef/browser/file_dialog_manager.h" +#include + #include "include/cef_dialog_handler.h" #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/thread_util.h" @@ -153,7 +155,7 @@ CefFileDialogManager::CefFileDialogManager( scoped_ptr runner) : content::WebContentsObserver(browser->web_contents()), browser_(browser), - runner_(runner.Pass()), + runner_(std::move(runner)), file_chooser_pending_(false), weak_ptr_factory_(this) { DCHECK(web_contents()); diff --git a/libcef/browser/javascript_dialog_manager.cc b/libcef/browser/javascript_dialog_manager.cc index 82922393d..68232729b 100644 --- a/libcef/browser/javascript_dialog_manager.cc +++ b/libcef/browser/javascript_dialog_manager.cc @@ -4,6 +4,9 @@ // found in the LICENSE file. #include "libcef/browser/javascript_dialog_manager.h" + +#include + #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/thread_util.h" @@ -70,7 +73,7 @@ CefJavaScriptDialogManager::CefJavaScriptDialogManager( CefBrowserHostImpl* browser, scoped_ptr runner) : browser_(browser), - runner_(runner.Pass()), + runner_(std::move(runner)), dialog_running_(false), weak_ptr_factory_(this) { } diff --git a/libcef/browser/menu_manager.cc b/libcef/browser/menu_manager.cc index c137eb91c..d647b6e1a 100644 --- a/libcef/browser/menu_manager.cc +++ b/libcef/browser/menu_manager.cc @@ -4,6 +4,8 @@ #include "libcef/browser/menu_manager.h" +#include + #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/context_menu_params_impl.h" #include "libcef/browser/menu_runner.h" @@ -91,7 +93,7 @@ CefMenuManager::CefMenuManager(CefBrowserHostImpl* browser, scoped_ptr runner) : content::WebContentsObserver(browser->web_contents()), browser_(browser), - runner_(runner.Pass()), + runner_(std::move(runner)), custom_menu_callback_(NULL), weak_ptr_factory_(this) { DCHECK(web_contents()); diff --git a/libcef/browser/native/menu_2.cc b/libcef/browser/native/menu_2.cc new file mode 100644 index 000000000..d57abd727 --- /dev/null +++ b/libcef/browser/native/menu_2.cc @@ -0,0 +1,60 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/native/menu_2.h" + +#include "ui/base/models/menu_model.h" +#include "ui/views/controls/menu/menu_listener.h" + +namespace views { + +Menu2::Menu2(ui::MenuModel* model) + : model_(model), + wrapper_(MenuWrapper::CreateWrapper(model)) { + Rebuild(); +} + +Menu2::~Menu2() {} + +HMENU Menu2::GetNativeMenu() const { + return wrapper_->GetNativeMenu(); +} + +void Menu2::RunMenuAt(const gfx::Point& point, Alignment alignment) { + wrapper_->RunMenuAt(point, alignment); +} + +void Menu2::RunContextMenuAt(const gfx::Point& point) { + RunMenuAt(point, ALIGN_TOPLEFT); +} + +void Menu2::CancelMenu() { + wrapper_->CancelMenu(); +} + +void Menu2::Rebuild() { + wrapper_->Rebuild(NULL); +} + +void Menu2::UpdateStates() { + wrapper_->UpdateStates(); +} + +MenuWrapper::MenuAction Menu2::GetMenuAction() const { + return wrapper_->GetMenuAction(); +} + +void Menu2::AddMenuListener(MenuListener* listener) { + wrapper_->AddMenuListener(listener); +} + +void Menu2::RemoveMenuListener(MenuListener* listener) { + wrapper_->RemoveMenuListener(listener); +} + +void Menu2::SetMinimumWidth(int width) { + wrapper_->SetMinimumWidth(width); +} + +} // namespace diff --git a/libcef/browser/native/menu_2.h b/libcef/browser/native/menu_2.h new file mode 100644 index 000000000..df8b0567b --- /dev/null +++ b/libcef/browser/native/menu_2.h @@ -0,0 +1,96 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_NATIVE_MENU_2_H_ +#define CEF_LIBCEF_BROWSER_NATIVE_MENU_2_H_ + +#include "libcef/browser/native/menu_wrapper.h" + +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "ui/gfx/native_widget_types.h" + +namespace gfx { +class Point; +} + +namespace ui { +class MenuModel; +} + +namespace views { + +// A menu. Populated from a model, and relies on a delegate to execute commands. +// +// WARNING: do NOT create and use Menu2 on the stack. Menu2 notifies the model +// of selection AFTER a delay. This means that if use a Menu2 on the stack +// ActivatedAt is never invoked. +class Menu2 { + public: + // How the menu is aligned relative to the point it is shown at. + // The alignment is reversed by menu if text direction is right to left. + enum Alignment { + ALIGN_TOPLEFT, + ALIGN_TOPRIGHT + }; + + // Creates a new menu populated with the contents of |model|. + // WARNING: this populates the menu on construction by invoking methods on + // the model. As such, it is typically not safe to use this as the model + // from the constructor. EG: + // MyClass : menu_(this) {} + // is likely to have problems. + explicit Menu2(ui::MenuModel* model); + virtual ~Menu2(); + + // Runs the menu at the specified point. This method blocks until done. + // RunContextMenuAt is the same, but the alignment is the default for a + // context menu. + void RunMenuAt(const gfx::Point& point, Alignment alignment); + void RunContextMenuAt(const gfx::Point& point); + + // Cancels the active menu. + void CancelMenu(); + + // Called when the model supplying data to this menu has changed, and the menu + // must be rebuilt. + void Rebuild(); + + // Called when the states of the menu items in the menu should be refreshed + // from the model. + void UpdateStates(); + + // For submenus. + HMENU GetNativeMenu() const; + + // Get the result of the last call to RunMenuAt to determine whether an + // item was selected, the user navigated to a next or previous menu, or + // nothing. + MenuWrapper::MenuAction GetMenuAction() const; + + // Add a listener to receive a callback when the menu opens. + void AddMenuListener(MenuListener* listener); + + // Remove a menu listener. + void RemoveMenuListener(MenuListener* listener); + + // Accessors. + ui::MenuModel* model() const { return model_; } + + // Sets the minimum width of the menu. + void SetMinimumWidth(int width); + + private: + + ui::MenuModel* model_; + + // The object that actually implements the menu. + scoped_ptr wrapper_; + + DISALLOW_COPY_AND_ASSIGN(Menu2); +}; + +} // namespace views + +#endif // CEF_LIBCEF_BROWSER_NATIVE_MENU_2_H_ diff --git a/libcef/browser/native/menu_runner_win.cc b/libcef/browser/native/menu_runner_win.cc index 60866fef7..8cbf850d6 100644 --- a/libcef/browser/native/menu_runner_win.cc +++ b/libcef/browser/native/menu_runner_win.cc @@ -5,10 +5,10 @@ #include "libcef/browser/native/menu_runner_win.h" #include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/native/menu_2.h" #include "base/message_loop/message_loop.h" #include "ui/gfx/geometry/point.h" -#include "ui/views/controls/menu/menu_2.h" CefMenuRunnerWin::CefMenuRunnerWin() { } diff --git a/libcef/browser/native/menu_runner_win.h b/libcef/browser/native/menu_runner_win.h index ea9391f5b..dff06e9cc 100644 --- a/libcef/browser/native/menu_runner_win.h +++ b/libcef/browser/native/menu_runner_win.h @@ -8,8 +8,9 @@ #include "libcef/browser/menu_runner.h" +#include "libcef/browser/native/native_menu_win.h" + #include "base/memory/scoped_ptr.h" -#include "ui/views/controls/menu/native_menu_win.h" class CefMenuRunnerWin : public CefMenuRunner { public: diff --git a/libcef/browser/native/menu_wrapper.h b/libcef/browser/native/menu_wrapper.h new file mode 100644 index 000000000..9302d7d65 --- /dev/null +++ b/libcef/browser/native/menu_wrapper.h @@ -0,0 +1,73 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_NATIVE_MENU_WRAPPER_H_ +#define CEF_LIBCEF_BROWSER_NATIVE_MENU_WRAPPER_H_ + +#include "ui/gfx/native_widget_types.h" + +namespace gfx { +class Point; +} + +namespace ui { +class MenuModel; +} + +namespace views { + +class MenuInsertionDelegateWin; +class MenuListener; + +// An interface that wraps an object that implements a menu. +class MenuWrapper { + public: + // All of the possible actions that can result from RunMenuAt. + enum MenuAction { + MENU_ACTION_NONE, // Menu cancelled, or never opened. + MENU_ACTION_SELECTED, // An item was selected. + MENU_ACTION_PREVIOUS, // User wants to navigate to the previous menu. + MENU_ACTION_NEXT, // User wants to navigate to the next menu. + }; + + virtual ~MenuWrapper() {} + + // Creates the appropriate instance of this wrapper for the current platform. + static MenuWrapper* CreateWrapper(ui::MenuModel* model); + + // Runs the menu at the specified point. This blocks until done. + virtual void RunMenuAt(const gfx::Point& point, int alignment) = 0; + + // Cancels the active menu. + virtual void CancelMenu() = 0; + + // Called when the model supplying data to this menu has changed, and the menu + // must be rebuilt. + virtual void Rebuild(MenuInsertionDelegateWin* delegate) = 0; + + // Called when the states of the items in the menu must be updated from the + // model. + virtual void UpdateStates() = 0; + + // Retrieve a native menu handle. + virtual HMENU GetNativeMenu() const = 0; + + // Get the result of the last call to RunMenuAt to determine whether an + // item was selected, the user navigated to a next or previous menu, or + // nothing. + virtual MenuAction GetMenuAction() const = 0; + + // Add a listener to receive a callback when the menu opens. + virtual void AddMenuListener(MenuListener* listener) = 0; + + // Remove a menu listener. + virtual void RemoveMenuListener(MenuListener* listener) = 0; + + // Sets the minimum width of the menu. + virtual void SetMinimumWidth(int width) = 0; +}; + +} // namespace views + +#endif // CEF_LIBCEF_BROWSER_NATIVE_MENU_WRAPPER_H_ diff --git a/libcef/browser/native/native_menu_win.cc b/libcef/browser/native/native_menu_win.cc new file mode 100644 index 000000000..ee12f6fa8 --- /dev/null +++ b/libcef/browser/native/native_menu_win.cc @@ -0,0 +1,759 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/native/native_menu_win.h" + +#include "libcef/browser/native/menu_2.h" + +#include "base/bind.h" +#include "base/logging.h" +#include "base/message_loop/message_loop.h" +#include "base/stl_util.h" +#include "base/strings/string_util.h" +#include "base/win/wrapped_window_proc.h" +#include "ui/base/accelerators/accelerator.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/l10n/l10n_util_win.h" +#include "ui/base/models/menu_model.h" +#include "ui/events/keycodes/keyboard_codes.h" +#include "ui/gfx/canvas.h" +#include "ui/gfx/font_list.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" +#include "ui/gfx/text_utils.h" +#include "ui/gfx/win/hwnd_util.h" +#include "ui/native_theme/native_theme.h" +#include "ui/native_theme/native_theme_win.h" +#include "ui/views/controls/menu/menu_config.h" +#include "ui/views/controls/menu/menu_insertion_delegate_win.h" +#include "ui/views/controls/menu/menu_listener.h" +#include "ui/views/layout/layout_constants.h" + +using ui::NativeTheme; + +namespace views { + +// The width of an icon, including the pixels between the icon and +// the item label. +static const int kIconWidth = 23; +// Margins between the top of the item and the label. +static const int kItemTopMargin = 3; +// Margins between the bottom of the item and the label. +static const int kItemBottomMargin = 4; +// Margins between the left of the item and the icon. +static const int kItemLeftMargin = 4; +// The width for displaying the sub-menu arrow. +static const int kArrowWidth = 10; + +struct NativeMenuWin::ItemData { + // The Windows API requires that whoever creates the menus must own the + // strings used for labels, and keep them around for the lifetime of the + // created menu. So be it. + base::string16 label; + + // Someone needs to own submenus, it may as well be us. + scoped_ptr submenu; + + // We need a pointer back to the containing menu in various circumstances. + NativeMenuWin* native_menu_win; + + // The index of the item within the menu's model. + int model_index; +}; + +// Returns the NativeMenuWin for a particular HMENU. +static NativeMenuWin* GetNativeMenuWinFromHMENU(HMENU hmenu) { + MENUINFO mi = {0}; + mi.cbSize = sizeof(mi); + mi.fMask = MIM_MENUDATA | MIM_STYLE; + GetMenuInfo(hmenu, &mi); + return reinterpret_cast(mi.dwMenuData); +} + +// A window that receives messages from Windows relevant to the native menu +// structure we have constructed in NativeMenuWin. +class NativeMenuWin::MenuHostWindow { + public: + explicit MenuHostWindow(NativeMenuWin* parent) : parent_(parent) { + RegisterClass(); + hwnd_ = CreateWindowEx(l10n_util::GetExtendedStyles(), kWindowClassName, + L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); + gfx::CheckWindowCreated(hwnd_); + gfx::SetWindowUserData(hwnd_, this); + } + + ~MenuHostWindow() { + DestroyWindow(hwnd_); + } + + HWND hwnd() const { return hwnd_; } + + private: + static const wchar_t* kWindowClassName; + + void RegisterClass() { + static bool registered = false; + if (registered) + return; + + WNDCLASSEX window_class; + base::win::InitializeWindowClass( + kWindowClassName, + &base::win::WrappedWindowProc, + CS_DBLCLKS, + 0, + 0, + NULL, + reinterpret_cast(COLOR_WINDOW+1), + NULL, + NULL, + NULL, + &window_class); + ATOM clazz = RegisterClassEx(&window_class); + CHECK(clazz); + registered = true; + } + + // Converts the WPARAM value passed to WM_MENUSELECT into an index + // corresponding to the menu item that was selected. + int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const { + int count = GetMenuItemCount(menu); + // For normal command menu items, Windows passes a command id as the LOWORD + // of WPARAM for WM_MENUSELECT. We need to walk forward through the menu + // items to find an item with a matching ID. Ugh! + for (int i = 0; i < count; ++i) { + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_ID; + GetMenuItemInfo(menu, i, MF_BYPOSITION, &mii); + if (mii.wID == w_param) + return i; + } + // If we didn't find a matching command ID, this means a submenu has been + // selected instead, and rather than passing a command ID in + // LOWORD(w_param), Windows has actually passed us a position, so we just + // return it. + return w_param; + } + + NativeMenuWin::ItemData* GetItemData(ULONG_PTR item_data) { + return reinterpret_cast(item_data); + } + + // Called when the user selects a specific item. + void OnMenuCommand(int position, HMENU menu) { + NativeMenuWin* menu_win = GetNativeMenuWinFromHMENU(menu); + ui::MenuModel* model = menu_win->model_; + NativeMenuWin* root_menu = menu_win; + while (root_menu->parent_) + root_menu = root_menu->parent_; + + // Only notify the model if it didn't already send out notification. + // See comment in MenuMessageHook for details. + if (root_menu->menu_action_ == MenuWrapper::MENU_ACTION_NONE) + model->ActivatedAt(position); + } + + // Called as the user moves their mouse or arrows through the contents of the + // menu. + void OnMenuSelect(WPARAM w_param, HMENU menu) { + if (!menu) + return; // menu is null when closing on XP. + + int position = GetMenuItemIndexFromWPARAM(menu, w_param); + if (position >= 0) + GetNativeMenuWinFromHMENU(menu)->model_->HighlightChangedTo(position); + } + + // Called by Windows to measure the size of an owner-drawn menu item. + void OnMeasureItem(WPARAM w_param, MEASUREITEMSTRUCT* measure_item_struct) { + NativeMenuWin::ItemData* data = GetItemData(measure_item_struct->itemData); + if (data) { + gfx::FontList font_list; + measure_item_struct->itemWidth = + gfx::GetStringWidth(data->label, font_list) + + kIconWidth + kItemLeftMargin + views::kItemLabelSpacing - + GetSystemMetrics(SM_CXMENUCHECK); + if (data->submenu.get()) + measure_item_struct->itemWidth += kArrowWidth; + // If the label contains an accelerator, make room for tab. + if (data->label.find(L'\t') != base::string16::npos) + measure_item_struct->itemWidth += gfx::GetStringWidth(L" ", font_list); + measure_item_struct->itemHeight = + font_list.GetHeight() + kItemBottomMargin + kItemTopMargin; + } else { + // Measure separator size. + measure_item_struct->itemHeight = GetSystemMetrics(SM_CYMENU) / 2; + measure_item_struct->itemWidth = 0; + } + } + + // Called by Windows to paint an owner-drawn menu item. + void OnDrawItem(UINT w_param, DRAWITEMSTRUCT* draw_item_struct) { + HDC dc = draw_item_struct->hDC; + COLORREF prev_bg_color, prev_text_color; + + // Set background color and text color + if (draw_item_struct->itemState & ODS_SELECTED) { + prev_bg_color = SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT)); + prev_text_color = SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + } else { + prev_bg_color = SetBkColor(dc, GetSysColor(COLOR_MENU)); + if (draw_item_struct->itemState & ODS_DISABLED) + prev_text_color = SetTextColor(dc, GetSysColor(COLOR_GRAYTEXT)); + else + prev_text_color = SetTextColor(dc, GetSysColor(COLOR_MENUTEXT)); + } + + if (draw_item_struct->itemData) { + NativeMenuWin::ItemData* data = GetItemData(draw_item_struct->itemData); + // Draw the background. + HBRUSH hbr = CreateSolidBrush(GetBkColor(dc)); + FillRect(dc, &draw_item_struct->rcItem, hbr); + DeleteObject(hbr); + + // Draw the label. + RECT rect = draw_item_struct->rcItem; + rect.top += kItemTopMargin; + // Should we add kIconWidth only when icon.width() != 0 ? + rect.left += kItemLeftMargin + kIconWidth; + rect.right -= views::kItemLabelSpacing; + UINT format = DT_TOP | DT_SINGLELINE; + // Check whether the mnemonics should be underlined. + BOOL underline_mnemonics; + SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0); + if (!underline_mnemonics) + format |= DT_HIDEPREFIX; + gfx::FontList font_list; + HGDIOBJ old_font = static_cast( + SelectObject(dc, font_list.GetPrimaryFont().GetNativeFont())); + + // If an accelerator is specified (with a tab delimiting the rest of the + // label from the accelerator), we have to justify the fist part on the + // left and the accelerator on the right. + // TODO(jungshik): This will break in RTL UI. Currently, he/ar use the + // window system UI font and will not hit here. + base::string16 label = data->label; + base::string16 accel; + base::string16::size_type tab_pos = label.find(L'\t'); + if (tab_pos != base::string16::npos) { + accel = label.substr(tab_pos); + label = label.substr(0, tab_pos); + } + DrawTextEx(dc, const_cast(label.data()), + static_cast(label.size()), &rect, format | DT_LEFT, NULL); + if (!accel.empty()) + DrawTextEx(dc, const_cast(accel.data()), + static_cast(accel.size()), &rect, + format | DT_RIGHT, NULL); + SelectObject(dc, old_font); + + ui::MenuModel::ItemType type = + data->native_menu_win->model_->GetTypeAt(data->model_index); + + // Draw the icon after the label, otherwise it would be covered + // by the label. + gfx::Image icon; + if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { + // We currently don't support items with both icons and checkboxes. + const gfx::ImageSkia* skia_icon = icon.ToImageSkia(); + DCHECK(type != ui::MenuModel::TYPE_CHECK); + gfx::Canvas canvas( + skia_icon->GetRepresentation(1.0f), + false); + skia::DrawToNativeContext( + canvas.sk_canvas(), dc, + draw_item_struct->rcItem.left + kItemLeftMargin, + draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - + draw_item_struct->rcItem.top - skia_icon->height()) / 2, NULL); + } else if (type == ui::MenuModel::TYPE_CHECK && + data->native_menu_win->model_->IsItemCheckedAt( + data->model_index)) { + // Manually render a checkbox. + const MenuConfig& config = MenuConfig::instance(); + NativeTheme::State state; + if (draw_item_struct->itemState & ODS_DISABLED) { + state = NativeTheme::kDisabled; + } else { + state = draw_item_struct->itemState & ODS_SELECTED ? + NativeTheme::kHovered : NativeTheme::kNormal; + } + gfx::Canvas canvas(gfx::Size(config.check_width, config.check_height), + 1.0f, + false); + NativeTheme::ExtraParams extra; + extra.menu_check.is_radio = false; + gfx::Rect bounds(0, 0, config.check_width, config.check_height); + + // Draw the background and the check. + ui::NativeThemeWin* native_theme = ui::NativeThemeWin::instance(); + native_theme->Paint( + canvas.sk_canvas(), NativeTheme::kMenuCheckBackground, + state, bounds, extra); + native_theme->Paint( + canvas.sk_canvas(), NativeTheme::kMenuCheck, state, bounds, extra); + + // Draw checkbox to menu. + skia::DrawToNativeContext(canvas.sk_canvas(), dc, + draw_item_struct->rcItem.left + kItemLeftMargin, + draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - + draw_item_struct->rcItem.top - config.check_height) / 2, NULL); + } + + } else { + // Draw the separator + draw_item_struct->rcItem.top += + (draw_item_struct->rcItem.bottom - draw_item_struct->rcItem.top) / 3; + DrawEdge(dc, &draw_item_struct->rcItem, EDGE_ETCHED, BF_TOP); + } + + SetBkColor(dc, prev_bg_color); + SetTextColor(dc, prev_text_color); + } + + bool ProcessWindowMessage(HWND window, + UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* l_result) { + switch (message) { + case WM_MENUCOMMAND: + OnMenuCommand(w_param, reinterpret_cast(l_param)); + *l_result = 0; + return true; + case WM_MENUSELECT: + OnMenuSelect(LOWORD(w_param), reinterpret_cast(l_param)); + *l_result = 0; + return true; + case WM_MEASUREITEM: + OnMeasureItem(w_param, reinterpret_cast(l_param)); + *l_result = 0; + return true; + case WM_DRAWITEM: + OnDrawItem(w_param, reinterpret_cast(l_param)); + *l_result = 0; + return true; + // TODO(beng): bring over owner draw from old menu system. + } + return false; + } + + static LRESULT CALLBACK MenuHostWindowProc(HWND window, + UINT message, + WPARAM w_param, + LPARAM l_param) { + MenuHostWindow* host = + reinterpret_cast(gfx::GetWindowUserData(window)); + // host is null during initial construction. + LRESULT l_result = 0; + if (!host || !host->ProcessWindowMessage(window, message, w_param, l_param, + &l_result)) { + return DefWindowProc(window, message, w_param, l_param); + } + return l_result; + } + + HWND hwnd_; + NativeMenuWin* parent_; + + DISALLOW_COPY_AND_ASSIGN(MenuHostWindow); +}; + +struct NativeMenuWin::HighlightedMenuItemInfo { + HighlightedMenuItemInfo() + : has_parent(false), + has_submenu(false), + menu(NULL), + position(-1) { + } + + bool has_parent; + bool has_submenu; + + // The menu and position. These are only set for non-disabled menu items. + NativeMenuWin* menu; + int position; +}; + +// static +const wchar_t* NativeMenuWin::MenuHostWindow::kWindowClassName = + L"ViewsMenuHostWindow"; + +//////////////////////////////////////////////////////////////////////////////// +// NativeMenuWin, public: + +NativeMenuWin::NativeMenuWin(ui::MenuModel* model, HWND system_menu_for) + : model_(model), + menu_(NULL), + owner_draw_(l10n_util::NeedOverrideDefaultUIFont(NULL, NULL) && + !system_menu_for), + system_menu_for_(system_menu_for), + first_item_index_(0), + menu_action_(MENU_ACTION_NONE), + menu_to_select_(NULL), + position_to_select_(-1), + parent_(NULL), + destroyed_flag_(NULL), + menu_to_select_factory_(this) { +} + +NativeMenuWin::~NativeMenuWin() { + if (destroyed_flag_) + *destroyed_flag_ = true; + STLDeleteContainerPointers(items_.begin(), items_.end()); + DestroyMenu(menu_); +} + +//////////////////////////////////////////////////////////////////////////////// +// NativeMenuWin, MenuWrapper implementation: + +void NativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) { + CreateHostWindow(); + UpdateStates(); + UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RECURSE; + flags |= GetAlignmentFlags(alignment); + menu_action_ = MENU_ACTION_NONE; + + // Set a hook function so we can listen for keyboard events while the + // menu is open, and store a pointer to this object in a static + // variable so the hook has access to it (ugly, but it's the + // only way). + open_native_menu_win_ = this; + HHOOK hhook = SetWindowsHookEx(WH_MSGFILTER, MenuMessageHook, + GetModuleHandle(NULL), ::GetCurrentThreadId()); + + // Mark that any registered listeners have not been called for this particular + // opening of the menu. + listeners_called_ = false; + + // Command dispatch is done through WM_MENUCOMMAND, handled by the host + // window. + menu_to_select_ = NULL; + position_to_select_ = -1; + menu_to_select_factory_.InvalidateWeakPtrs(); + bool destroyed = false; + destroyed_flag_ = &destroyed; + model_->MenuWillShow(); + TrackPopupMenu(menu_, flags, point.x(), point.y(), 0, host_window_->hwnd(), + NULL); + UnhookWindowsHookEx(hhook); + open_native_menu_win_ = NULL; + if (destroyed) + return; + destroyed_flag_ = NULL; + if (menu_to_select_) { + // Folks aren't too happy if we notify immediately. In particular, notifying + // the delegate can cause destruction leaving the stack in a weird + // state. Instead post a task, then notify. This mirrors what WM_MENUCOMMAND + // does. + menu_to_select_factory_.InvalidateWeakPtrs(); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&NativeMenuWin::DelayedSelect, + menu_to_select_factory_.GetWeakPtr())); + menu_action_ = MENU_ACTION_SELECTED; + } + // Send MenuClosed after we schedule the select, otherwise MenuClosed is + // processed after the select (MenuClosed posts a delayed task too). + model_->MenuClosed(); +} + +void NativeMenuWin::CancelMenu() { + EndMenu(); +} + +void NativeMenuWin::Rebuild(MenuInsertionDelegateWin* delegate) { + ResetNativeMenu(); + items_.clear(); + + owner_draw_ = model_->HasIcons() || owner_draw_; + first_item_index_ = delegate ? delegate->GetInsertionIndex(menu_) : 0; + for (int menu_index = first_item_index_; + menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) { + int model_index = menu_index - first_item_index_; + if (model_->GetTypeAt(model_index) == ui::MenuModel::TYPE_SEPARATOR) + AddSeparatorItemAt(menu_index, model_index); + else + AddMenuItemAt(menu_index, model_index); + } +} + +void NativeMenuWin::UpdateStates() { + // A depth-first walk of the menu items, updating states. + int model_index = 0; + std::vector::const_iterator it; + for (it = items_.begin(); it != items_.end(); ++it, ++model_index) { + int menu_index = model_index + first_item_index_; + SetMenuItemState(menu_index, model_->IsEnabledAt(model_index), + model_->IsItemCheckedAt(model_index), false); + if (model_->IsItemDynamicAt(model_index)) { + // TODO(atwilson): Update the icon as well (http://crbug.com/66508). + SetMenuItemLabel(menu_index, model_index, + model_->GetLabelAt(model_index)); + } + Menu2* submenu = (*it)->submenu.get(); + if (submenu) + submenu->UpdateStates(); + } +} + +HMENU NativeMenuWin::GetNativeMenu() const { + return menu_; +} + +NativeMenuWin::MenuAction NativeMenuWin::GetMenuAction() const { + return menu_action_; +} + +void NativeMenuWin::AddMenuListener(MenuListener* listener) { + listeners_.AddObserver(listener); +} + +void NativeMenuWin::RemoveMenuListener(MenuListener* listener) { + listeners_.RemoveObserver(listener); +} + +void NativeMenuWin::SetMinimumWidth(int width) { + NOTIMPLEMENTED(); +} + +//////////////////////////////////////////////////////////////////////////////// +// NativeMenuWin, private: + +// static +NativeMenuWin* NativeMenuWin::open_native_menu_win_ = NULL; + +void NativeMenuWin::DelayedSelect() { + if (menu_to_select_) + menu_to_select_->model_->ActivatedAt(position_to_select_); +} + +// static +bool NativeMenuWin::GetHighlightedMenuItemInfo( + HMENU menu, + HighlightedMenuItemInfo* info) { + for (int i = 0; i < ::GetMenuItemCount(menu); i++) { + UINT state = ::GetMenuState(menu, i, MF_BYPOSITION); + if (state & MF_HILITE) { + if (state & MF_POPUP) { + HMENU submenu = GetSubMenu(menu, i); + if (GetHighlightedMenuItemInfo(submenu, info)) + info->has_parent = true; + else + info->has_submenu = true; + } else if (!(state & MF_SEPARATOR) && !(state & MF_DISABLED)) { + info->menu = GetNativeMenuWinFromHMENU(menu); + info->position = i; + } + return true; + } + } + return false; +} + +// static +LRESULT CALLBACK NativeMenuWin::MenuMessageHook( + int n_code, WPARAM w_param, LPARAM l_param) { + LRESULT result = CallNextHookEx(NULL, n_code, w_param, l_param); + + NativeMenuWin* this_ptr = open_native_menu_win_; + if (!this_ptr) + return result; + + // The first time this hook is called, that means the menu has successfully + // opened, so call the callback function on all of our listeners. + if (!this_ptr->listeners_called_) { + FOR_EACH_OBSERVER(MenuListener, this_ptr->listeners_, OnMenuOpened()); + this_ptr->listeners_called_ = true; + } + + MSG* msg = reinterpret_cast(l_param); + if (msg->message == WM_LBUTTONUP || msg->message == WM_RBUTTONUP) { + HighlightedMenuItemInfo info; + if (GetHighlightedMenuItemInfo(this_ptr->menu_, &info) && info.menu) { + // It appears that when running a menu by way of TrackPopupMenu(Ex) win32 + // gets confused if the underlying window paints itself. As its very easy + // for the underlying window to repaint itself (especially since some menu + // items trigger painting of the tabstrip on mouse over) we have this + // workaround. When the mouse is released on a menu item we remember the + // menu item and end the menu. When the nested message loop returns we + // schedule a task to notify the model. It's still possible to get a + // WM_MENUCOMMAND, so we have to be careful that we don't notify the model + // twice. + this_ptr->menu_to_select_ = info.menu; + this_ptr->position_to_select_ = info.position; + EndMenu(); + } + } else if (msg->message == WM_KEYDOWN) { + HighlightedMenuItemInfo info; + if (GetHighlightedMenuItemInfo(this_ptr->menu_, &info)) { + if (msg->wParam == VK_LEFT && !info.has_parent) { + this_ptr->menu_action_ = MENU_ACTION_PREVIOUS; + ::EndMenu(); + } else if (msg->wParam == VK_RIGHT && !info.has_parent && + !info.has_submenu) { + this_ptr->menu_action_ = MENU_ACTION_NEXT; + ::EndMenu(); + } + } + } + + return result; +} + +bool NativeMenuWin::IsSeparatorItemAt(int menu_index) const { + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_FTYPE; + GetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii); + return !!(mii.fType & MF_SEPARATOR); +} + +void NativeMenuWin::AddMenuItemAt(int menu_index, int model_index) { + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_DATA; + if (!owner_draw_) + mii.fType = MFT_STRING; + else + mii.fType = MFT_OWNERDRAW; + + ItemData* item_data = new ItemData; + item_data->label = base::string16(); + ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); + if (type == ui::MenuModel::TYPE_SUBMENU) { + item_data->submenu.reset(new Menu2(model_->GetSubmenuModelAt(model_index))); + mii.fMask |= MIIM_SUBMENU; + mii.hSubMenu = item_data->submenu->GetNativeMenu(); + GetNativeMenuWinFromHMENU(mii.hSubMenu)->parent_ = this; + } else { + if (type == ui::MenuModel::TYPE_RADIO) + mii.fType |= MFT_RADIOCHECK; + mii.wID = model_->GetCommandIdAt(model_index); + } + item_data->native_menu_win = this; + item_data->model_index = model_index; + items_.insert(items_.begin() + model_index, item_data); + mii.dwItemData = reinterpret_cast(item_data); + UpdateMenuItemInfoForString(&mii, model_index, + model_->GetLabelAt(model_index)); + InsertMenuItem(menu_, menu_index, TRUE, &mii); +} + +void NativeMenuWin::AddSeparatorItemAt(int menu_index, int model_index) { + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_FTYPE; + mii.fType = MFT_SEPARATOR; + // Insert a dummy entry into our label list so we can index directly into it + // using item indices if need be. + items_.insert(items_.begin() + model_index, new ItemData); + InsertMenuItem(menu_, menu_index, TRUE, &mii); +} + +void NativeMenuWin::SetMenuItemState(int menu_index, bool enabled, bool checked, + bool is_default) { + if (IsSeparatorItemAt(menu_index)) + return; + + UINT state = enabled ? MFS_ENABLED : MFS_DISABLED; + if (checked) + state |= MFS_CHECKED; + if (is_default) + state |= MFS_DEFAULT; + + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STATE; + mii.fState = state; + SetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii); +} + +void NativeMenuWin::SetMenuItemLabel(int menu_index, + int model_index, + const base::string16& label) { + if (IsSeparatorItemAt(menu_index)) + return; + + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + UpdateMenuItemInfoForString(&mii, model_index, label); + SetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii); +} + +void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, + int model_index, + const base::string16& label) { + base::string16 formatted = label; + ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); + // Strip out any tabs, otherwise they get interpreted as accelerators and can + // lead to weird behavior. + base::ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); + if (type != ui::MenuModel::TYPE_SUBMENU) { + // Add accelerator details to the label if provided. + ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); + if (model_->GetAcceleratorAt(model_index, &accelerator)) { + formatted += L"\t"; + formatted += accelerator.GetShortcutText(); + } + } + + // Update the owned string, since Windows will want us to keep this new + // version around. + items_[model_index]->label = formatted; + + // Give Windows a pointer to the label string. + mii->fMask |= MIIM_STRING; + mii->dwTypeData = + const_cast(items_[model_index]->label.c_str()); +} + +UINT NativeMenuWin::GetAlignmentFlags(int alignment) const { + UINT alignment_flags = TPM_TOPALIGN; + if (alignment == Menu2::ALIGN_TOPLEFT) + alignment_flags |= TPM_LEFTALIGN; + else if (alignment == Menu2::ALIGN_TOPRIGHT) + alignment_flags |= TPM_RIGHTALIGN; + return alignment_flags; +} + +void NativeMenuWin::ResetNativeMenu() { + if (IsWindow(system_menu_for_)) { + if (menu_) + GetSystemMenu(system_menu_for_, TRUE); + menu_ = GetSystemMenu(system_menu_for_, FALSE); + } else { + if (menu_) + DestroyMenu(menu_); + menu_ = CreatePopupMenu(); + // Rather than relying on the return value of TrackPopupMenuEx, which is + // always a command identifier, instead we tell the menu to notify us via + // our host window and the WM_MENUCOMMAND message. + MENUINFO mi = {0}; + mi.cbSize = sizeof(mi); + mi.fMask = MIM_STYLE | MIM_MENUDATA; + mi.dwStyle = MNS_NOTIFYBYPOS; + mi.dwMenuData = reinterpret_cast(this); + SetMenuInfo(menu_, &mi); + } +} + +void NativeMenuWin::CreateHostWindow() { + // This only gets called from RunMenuAt, and as such there is only ever one + // host window per menu hierarchy, no matter how many NativeMenuWin objects + // exist wrapping submenus. + if (!host_window_.get()) + host_window_.reset(new MenuHostWindow(this)); +} + +//////////////////////////////////////////////////////////////////////////////// +// MenuWrapper, public: + +// static +MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { + return new NativeMenuWin(model, NULL); +} + +} // namespace views diff --git a/libcef/browser/native/native_menu_win.h b/libcef/browser/native/native_menu_win.h new file mode 100644 index 000000000..9df7a7bdf --- /dev/null +++ b/libcef/browser/native/native_menu_win.h @@ -0,0 +1,170 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_ +#define CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_ + +#include + +#include "libcef/browser/native/menu_wrapper.h" + +#include "base/macros.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" +#include "base/observer_list.h" +#include "base/strings/string16.h" + +namespace ui { +class MenuModel; +} + +namespace views { + +// A Windows implementation of MenuWrapper. +// TODO(beng): rename to MenuWin once the old class is dead. +class NativeMenuWin : public MenuWrapper { + public: + // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for| + // is non-NULL, the NativeMenuWin wraps the system menu for that window. + // The caller owns the model and the delegate. + NativeMenuWin(ui::MenuModel* model, HWND system_menu_for); + ~NativeMenuWin() override; + + // Overridden from MenuWrapper: + void RunMenuAt(const gfx::Point& point, int alignment) override; + void CancelMenu() override; + void Rebuild(MenuInsertionDelegateWin* delegate) override; + void UpdateStates() override; + HMENU GetNativeMenu() const override; + MenuAction GetMenuAction() const override; + void AddMenuListener(MenuListener* listener) override; + void RemoveMenuListener(MenuListener* listener) override; + void SetMinimumWidth(int width) override; + + private: + // IMPORTANT: Note about indices. + // Functions in this class deal in two index spaces: + // 1. menu_index - the index of an item within the actual Windows + // native menu. + // 2. model_index - the index of the item within our model. + // These two are most often but not always the same value! The + // notable exception is when this object is used to wrap the + // Windows System Menu. In this instance, the model indices start + // at 0, but the insertion index into the existing menu is not. + // It is important to take this into consideration when editing the + // code in the functions in this class. + + struct HighlightedMenuItemInfo; + + // Returns true if the item at the specified index is a separator. + bool IsSeparatorItemAt(int menu_index) const; + + // Add items. See note above about indices. + void AddMenuItemAt(int menu_index, int model_index); + void AddSeparatorItemAt(int menu_index, int model_index); + + // Sets the state of the item at the specified index. + void SetMenuItemState(int menu_index, + bool enabled, + bool checked, + bool is_default); + + // Sets the label of the item at the specified index. + void SetMenuItemLabel(int menu_index, + int model_index, + const base::string16& label); + + // Updates the local data structure with the correctly formatted version of + // |label| at the specified model_index, and adds string data to |mii| if + // the menu is not owner-draw. That's a mouthful. This function exists because + // of the peculiarities of the Windows menu API. + void UpdateMenuItemInfoForString(MENUITEMINFO* mii, + int model_index, + const base::string16& label); + + // Returns the alignment flags to be passed to TrackPopupMenuEx, based on the + // supplied alignment and the UI text direction. + UINT GetAlignmentFlags(int alignment) const; + + // Resets the native menu stored in |menu_| by destroying any old menu then + // creating a new empty one. + void ResetNativeMenu(); + + // Creates the host window that receives notifications from the menu. + void CreateHostWindow(); + + // Callback from task to notify menu it was selected. + void DelayedSelect(); + + // Given a menu that's currently popped-up, find the currently highlighted + // item. Returns true if a highlighted item was found. + static bool GetHighlightedMenuItemInfo(HMENU menu, + HighlightedMenuItemInfo* info); + + // Hook to receive keyboard events while the menu is open. + static LRESULT CALLBACK MenuMessageHook( + int n_code, WPARAM w_param, LPARAM l_param); + + // Our attached model and delegate. + ui::MenuModel* model_; + + HMENU menu_; + + // True if the contents of menu items in this menu are drawn by the menu host + // window, rather than Windows. + bool owner_draw_; + + // An object that collects all of the data associated with an individual menu + // item. + struct ItemData; + std::vector items_; + + // The window that receives notifications from the menu. + class MenuHostWindow; + friend MenuHostWindow; + scoped_ptr host_window_; + + // The HWND this menu is the system menu for, or NULL if the menu is not a + // system menu. + HWND system_menu_for_; + + // The index of the first item in the model in the menu. + int first_item_index_; + + // The action that took place during the call to RunMenuAt. + MenuAction menu_action_; + + // A list of listeners to call when the menu opens. + base::ObserverList listeners_; + + // Keep track of whether the listeners have already been called at least + // once. + bool listeners_called_; + + // See comment in MenuMessageHook for details on these. + NativeMenuWin* menu_to_select_; + int position_to_select_; + + // If we're a submenu, this is our parent. + NativeMenuWin* parent_; + + // If non-null the destructor sets this to true. This is set to non-null while + // the menu is showing. It is used to detect if the menu was deleted while + // running. + bool* destroyed_flag_; + + base::WeakPtrFactory menu_to_select_factory_; + + // Ugly: a static pointer to the instance of this class that currently + // has a menu open, because our hook function that receives keyboard + // events doesn't have a mechanism to get a user data pointer. + static NativeMenuWin* open_native_menu_win_; + + DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); +}; + +} // namespace views + +#endif // CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_ diff --git a/libcef/browser/navigate_params.h b/libcef/browser/navigate_params.h index 692a50d31..cda2619b5 100644 --- a/libcef/browser/navigate_params.h +++ b/libcef/browser/navigate_params.h @@ -34,7 +34,7 @@ struct CefNavigateParams { content::Referrer referrer; // The frame that the request should be loaded in or -1 to use the main frame. - int64 frame_id; + int64_t frame_id; // Usually the URL of the document in the top-level window, which may be // checked by the third-party cookie blocking policy. Leaving it empty may diff --git a/libcef/browser/net/chrome_scheme_handler.cc b/libcef/browser/net/chrome_scheme_handler.cc index e26b98eba..0d504e731 100644 --- a/libcef/browser/net/chrome_scheme_handler.cc +++ b/libcef/browser/net/chrome_scheme_handler.cc @@ -7,6 +7,7 @@ #include #include +#include #include "include/cef_version.h" #include "include/cef_web_plugin.h" @@ -413,7 +414,7 @@ class ChromeProtocolHandlerWrapper : scoped_ptr chrome_protocol_handler) : request_manager_(request_manager), - chrome_protocol_handler_(chrome_protocol_handler.Pass()) { + chrome_protocol_handler_(std::move(chrome_protocol_handler)) { DCHECK(request_manager_); } @@ -482,8 +483,8 @@ WrapChromeProtocolHandler( chrome_protocol_handler) { scoped_ptr ret( new ChromeProtocolHandlerWrapper(request_manager, - chrome_protocol_handler.Pass())); - return ret.Pass(); + std::move(chrome_protocol_handler))); + return ret; } } // namespace scheme diff --git a/libcef/browser/net/internal_scheme_handler.cc b/libcef/browser/net/internal_scheme_handler.cc index 389d71d21..d0683b797 100644 --- a/libcef/browser/net/internal_scheme_handler.cc +++ b/libcef/browser/net/internal_scheme_handler.cc @@ -6,6 +6,7 @@ #include "libcef/browser/net/internal_scheme_handler.h" #include +#include #include "libcef/common/content_client.h" @@ -130,7 +131,7 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory { public: explicit InternalHandlerFactory( scoped_ptr delegate) - : delegate_(delegate.Pass()) { + : delegate_(std::move(delegate)) { } CefRefPtr Create( @@ -188,7 +189,7 @@ InternalHandlerDelegate::Action::Action() CefRefPtr CreateInternalHandlerFactory( scoped_ptr delegate) { DCHECK(delegate.get()); - return new InternalHandlerFactory(delegate.Pass()); + return new InternalHandlerFactory(std::move(delegate)); } } // namespace scheme diff --git a/libcef/browser/net/network_delegate.cc b/libcef/browser/net/network_delegate.cc index 2a6b508ac..ec771a6a8 100644 --- a/libcef/browser/net/network_delegate.cc +++ b/libcef/browser/net/network_delegate.cc @@ -5,6 +5,7 @@ #include "libcef/browser/net/network_delegate.h" #include +#include #include "include/cef_urlrequest.h" #include "libcef/browser/browser_host_impl.h" @@ -458,7 +459,7 @@ net::Filter* CefNetworkDelegate::SetupFilter(net::URLRequest* request, net::Filter* last_filter = filter_list; do { if (!last_filter->next_filter_.get()) { - last_filter->next_filter_ = wrapper.Pass(); + last_filter->next_filter_ = std::move(wrapper); break; } last_filter = last_filter->next_filter_.get(); diff --git a/libcef/browser/net/network_delegate.h b/libcef/browser/net/network_delegate.h index d72a9254e..16c821e22 100644 --- a/libcef/browser/net/network_delegate.h +++ b/libcef/browser/net/network_delegate.h @@ -6,6 +6,7 @@ #define CEF_LIBCEF_BROWSER_NET_NETWORK_DELEGATE_H_ #pragma once +#include "base/macros.h" #include "net/base/network_delegate_impl.h" // Used for intercepting resource requests, redirects and responses. The single diff --git a/libcef/browser/net/resource_request_job.h b/libcef/browser/net/resource_request_job.h index c1d4410c5..42fa71dd5 100644 --- a/libcef/browser/net/resource_request_job.h +++ b/libcef/browser/net/resource_request_job.h @@ -6,6 +6,8 @@ #ifndef CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_ #define CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_ +#include + #include #include "include/cef_browser.h" @@ -66,8 +68,8 @@ class CefResourceRequestJob : public net::URLRequestJob { bool done_; CefRefPtr response_; GURL redirect_url_; - int64 remaining_bytes_; - int64 sent_bytes_; + int64_t remaining_bytes_; + int64_t sent_bytes_; CefRefPtr cef_request_; CefRefPtr callback_; scoped_refptr response_headers_; diff --git a/libcef/browser/net/response_filter_wrapper.h b/libcef/browser/net/response_filter_wrapper.h index d0e82e6d4..a925911ad 100644 --- a/libcef/browser/net/response_filter_wrapper.h +++ b/libcef/browser/net/response_filter_wrapper.h @@ -8,7 +8,7 @@ #include "include/cef_response_filter.h" -#include "base/basictypes.h" +#include "base/macros.h" #include "net/filter/filter.h" class CefResponseFilterWrapper : public net::Filter { diff --git a/libcef/browser/net/url_request_context_getter_impl.cc b/libcef/browser/net/url_request_context_getter_impl.cc index 23b7d0da5..c9306c169 100644 --- a/libcef/browser/net/url_request_context_getter_impl.cc +++ b/libcef/browser/net/url_request_context_getter_impl.cc @@ -4,10 +4,8 @@ #include "libcef/browser/net/url_request_context_getter_impl.h" -#if defined(OS_WIN) -#include -#endif #include +#include #include #include "libcef/browser/cookie_manager_impl.h" @@ -26,6 +24,7 @@ #include "base/strings/string_util.h" #include "base/threading/thread_restrictions.h" #include "base/threading/worker_pool.h" +#include "build/build_config.h" #include "chrome/browser/net/proxy_service_factory.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" @@ -56,6 +55,10 @@ #include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_job_manager.h" +#if defined(OS_WIN) +#include +#endif + #if defined(USE_NSS_CERTS) #include "net/cert_net/nss_ocsp.h" #endif @@ -109,8 +112,8 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl( : settings_(settings), io_loop_(io_loop), file_loop_(file_loop), - proxy_config_service_(proxy_config_service.Pass()), - request_interceptors_(request_interceptors.Pass()) { + proxy_config_service_(std::move(proxy_config_service)), + request_interceptors_(std::move(request_interceptors)) { // Must first be created on the UI thread. CEF_REQUIRE_UIT(); @@ -173,10 +176,10 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() { NULL, url_request_context_.get(), url_request_context_->network_delegate(), - proxy_config_service_.Pass(), + std::move(proxy_config_service_), *command_line, true); - storage_->set_proxy_service(system_proxy_service.Pass()); + storage_->set_proxy_service(std::move(system_proxy_service)); storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); @@ -236,7 +239,7 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() { make_scoped_ptr(new net::HttpNetworkSession(network_session_params))); storage_->set_http_transaction_factory(make_scoped_ptr( new net::HttpCache(storage_->http_network_session(), - main_backend.Pass(), + std::move(main_backend), true /* set_up_quic_server_info */))); #if !defined(DISABLE_FTP_SUPPORT) @@ -262,17 +265,17 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() { // Set up interceptors in the reverse order. scoped_ptr top_job_factory = - job_factory.Pass(); + std::move(job_factory); for (content::URLRequestInterceptorScopedVector::reverse_iterator i = request_interceptors_.rbegin(); i != request_interceptors_.rend(); ++i) { top_job_factory.reset(new net::URLRequestInterceptingJobFactory( - top_job_factory.Pass(), make_scoped_ptr(*i))); + std::move(top_job_factory), make_scoped_ptr(*i))); } request_interceptors_.weak_clear(); - storage_->set_job_factory(top_job_factory.Pass()); + storage_->set_job_factory(std::move(top_job_factory)); #if defined(USE_NSS_CERTS) // Only do this for the first (global) request context. diff --git a/libcef/browser/osr/browser_platform_delegate_osr.cc b/libcef/browser/osr/browser_platform_delegate_osr.cc index bd9ccd864..9751e0a01 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr.cc @@ -4,6 +4,8 @@ #include "libcef/browser/osr/browser_platform_delegate_osr.h" +#include + #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/osr/render_widget_host_view_osr.h" #include "libcef/browser/osr/web_contents_view_osr.h" @@ -13,7 +15,7 @@ CefBrowserPlatformDelegateOsr::CefBrowserPlatformDelegateOsr( scoped_ptr native_delegate) - : native_delegate_(native_delegate.Pass()), + : native_delegate_(std::move(native_delegate)), view_osr_(nullptr) { native_delegate_->set_windowless_handler(this); } @@ -97,7 +99,6 @@ void CefBrowserPlatformDelegateOsr::SendFocusEvent(bool setFocus) { view->SendFocusEvent(setFocus); } - gfx::Point CefBrowserPlatformDelegateOsr::GetScreenPoint( const gfx::Point& view) const { CefRefPtr handler = browser_->client()->GetRenderHandler(); diff --git a/libcef/browser/osr/browser_platform_delegate_osr_linux.cc b/libcef/browser/osr/browser_platform_delegate_osr_linux.cc index 81cd14c2a..40dbe0b5e 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_linux.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr_linux.cc @@ -4,11 +4,13 @@ #include "libcef/browser/osr/browser_platform_delegate_osr_linux.h" +#include + #include "libcef/browser/browser_host_impl.h" CefBrowserPlatformDelegateOsrLinux::CefBrowserPlatformDelegateOsrLinux( scoped_ptr native_delegate) - : CefBrowserPlatformDelegateOsr(native_delegate.Pass()) { + : CefBrowserPlatformDelegateOsr(std::move(native_delegate)) { } CefWindowHandle diff --git a/libcef/browser/osr/browser_platform_delegate_osr_mac.mm b/libcef/browser/osr/browser_platform_delegate_osr_mac.mm index d9681aec0..8c8c065ea 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_mac.mm +++ b/libcef/browser/osr/browser_platform_delegate_osr_mac.mm @@ -4,12 +4,14 @@ #include "libcef/browser/osr/browser_platform_delegate_osr_mac.h" +#include + #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/osr/render_widget_host_view_osr.h" CefBrowserPlatformDelegateOsrMac::CefBrowserPlatformDelegateOsrMac( scoped_ptr native_delegate) - : CefBrowserPlatformDelegateOsr(native_delegate.Pass()) { + : CefBrowserPlatformDelegateOsr(std::move(native_delegate)) { } CefWindowHandle CefBrowserPlatformDelegateOsrMac::GetHostWindowHandle() const { diff --git a/libcef/browser/osr/browser_platform_delegate_osr_win.cc b/libcef/browser/osr/browser_platform_delegate_osr_win.cc index e0219b2be..92f7ce988 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_win.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr_win.cc @@ -4,11 +4,13 @@ #include "libcef/browser/osr/browser_platform_delegate_osr_win.h" +#include + #include "libcef/browser/browser_host_impl.h" CefBrowserPlatformDelegateOsrWin::CefBrowserPlatformDelegateOsrWin( scoped_ptr native_delegate) - : CefBrowserPlatformDelegateOsr(native_delegate.Pass()) { + : CefBrowserPlatformDelegateOsr(std::move(native_delegate)) { } CefWindowHandle CefBrowserPlatformDelegateOsrWin::GetHostWindowHandle() const { diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index 02d1f35d4..bffd0b4e2 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -5,6 +5,10 @@ #include "libcef/browser/osr/render_widget_host_view_osr.h" +#include + +#include + #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/osr/osr_util.h" #include "libcef/browser/osr/software_output_device_osr.h" @@ -155,7 +159,7 @@ class CefCopyFrameGenerator { frame_in_progress_ = true; // Don't exceed the frame rate threshold. - const int64 frame_rate_delta = + const int64_t frame_rate_delta = (base::TimeTicks::Now() - frame_start_time_).InMilliseconds(); if (frame_rate_delta < frame_rate_threshold_ms_) { // Generate the frame after the necessary time has passed. @@ -196,7 +200,8 @@ class CefCopyFrameGenerator { damage_rect)); request->set_area(gfx::Rect(view_->GetPhysicalBackingSize())); - view_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(request.Pass()); + view_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( + std::move(request)); } void CopyFromCompositingSurfaceHasResult( @@ -209,12 +214,12 @@ class CefCopyFrameGenerator { } if (result->HasTexture()) { - PrepareTextureCopyOutputResult(damage_rect, result.Pass()); + PrepareTextureCopyOutputResult(damage_rect, std::move(result)); return; } DCHECK(result->HasBitmap()); - PrepareBitmapCopyOutputResult(damage_rect, result.Pass()); + PrepareBitmapCopyOutputResult(damage_rect, std::move(result)); } void PrepareTextureCopyOutputResult( @@ -251,7 +256,7 @@ class CefCopyFrameGenerator { scoped_ptr bitmap_pixels_lock( new SkAutoLockPixels(*bitmap_)); - uint8* pixels = static_cast(bitmap_->getPixels()); + uint8_t* pixels = static_cast(bitmap_->getPixels()); cc::TextureMailbox texture_mailbox; scoped_ptr release_callback; @@ -300,7 +305,8 @@ class CefCopyFrameGenerator { if (generator) { generator->CopyFromCompositingSurfaceFinished( - damage_rect, bitmap.Pass(), bitmap_pixels_lock.Pass(), result); + damage_rect, std::move(bitmap), std::move(bitmap_pixels_lock), + result); } else { bitmap_pixels_lock.reset(); bitmap.reset(); @@ -314,11 +320,11 @@ class CefCopyFrameGenerator { bool result) { // Restore ownership of the bitmap to the view. DCHECK(!bitmap_); - bitmap_ = bitmap.Pass(); + bitmap_ = std::move(bitmap); if (result) { OnCopyFrameCaptureSuccess(damage_rect, *bitmap_, - bitmap_pixels_lock.Pass()); + std::move(bitmap_pixels_lock)); } else { bitmap_pixels_lock.reset(); OnCopyFrameCaptureFailure(damage_rect); @@ -335,7 +341,7 @@ class CefCopyFrameGenerator { scoped_ptr bitmap_pixels_lock( new SkAutoLockPixels(*source)); OnCopyFrameCaptureSuccess(damage_rect, *source, - bitmap_pixels_lock.Pass()); + std::move(bitmap_pixels_lock)); } else { OnCopyFrameCaptureFailure(damage_rect); } @@ -632,7 +638,7 @@ void CefRenderWidgetHostViewOSR::UnlockMouse() { } void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame( - uint32 output_surface_id, + uint32_t output_surface_id, scoped_ptr frame) { TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnSwapCompositorFrame"); @@ -659,7 +665,7 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame( // The compositor will draw directly to the SoftwareOutputDevice which // then calls OnPaint. delegated_frame_host_->SwapDelegatedFrame(output_surface_id, - frame.Pass()); + std::move(frame)); } else { if (!copy_frame_generator_.get()) { copy_frame_generator_.reset( @@ -676,7 +682,7 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame( damage_rect.Intersect(gfx::Rect(frame_size)); delegated_frame_host_->SwapDelegatedFrame(output_surface_id, - frame.Pass()); + std::move(frame)); // Request a copy of the last compositor frame which will eventually call // OnPaint asynchronously. @@ -869,7 +875,7 @@ bool CefRenderWidgetHostViewOSR::CanCopyToVideoFrame() const { void CefRenderWidgetHostViewOSR::BeginFrameSubscription( scoped_ptr subscriber) { - delegated_frame_host_->BeginFrameSubscription(subscriber.Pass()); + delegated_frame_host_->BeginFrameSubscription(std::move(subscriber)); } void CefRenderWidgetHostViewOSR::EndFrameSubscription() { @@ -1428,7 +1434,7 @@ void CefRenderWidgetHostViewOSR::CancelWidget() { if (render_widget_host_ && !is_destroyed_) { is_destroyed_ = true; // Results in a call to Destroy(). - render_widget_host_->Shutdown(); + render_widget_host_->ShutdownAndDestroyWidget(true); } } diff --git a/libcef/browser/osr/render_widget_host_view_osr.h b/libcef/browser/osr/render_widget_host_view_osr.h index 6ebe95185..b106a98a2 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.h +++ b/libcef/browser/osr/render_widget_host_view_osr.h @@ -14,6 +14,7 @@ #include "include/cef_browser.h" #include "base/memory/weak_ptr.h" +#include "build/build_config.h" #include "content/browser/compositor/delegated_frame_host.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "ui/compositor/compositor.h" @@ -122,7 +123,7 @@ class CefRenderWidgetHostViewOSR // RenderWidgetHostViewBase implementation. void OnSwapCompositorFrame( - uint32 output_surface_id, + uint32_t output_surface_id, scoped_ptr frame) override; void ClearCompositorFrame() override; void InitAsPopup(content::RenderWidgetHostView* parent_host_view, diff --git a/libcef/browser/osr/render_widget_host_view_osr_mac.mm b/libcef/browser/osr/render_widget_host_view_osr_mac.mm index aaa5c5fba..4d50347b2 100644 --- a/libcef/browser/osr/render_widget_host_view_osr_mac.mm +++ b/libcef/browser/osr/render_widget_host_view_osr_mac.mm @@ -5,6 +5,9 @@ #include "libcef/browser/osr/render_widget_host_view_osr.h" +#include +#include + #import #include "libcef/browser/browser_host_impl.h" @@ -266,7 +269,7 @@ bool CefRenderWidgetHostViewOSR::GetLineBreakIndex( // 75% of maximum height. const size_t loop_end_idx = std::min(bounds.size(), range.end()); int max_height = 0; - int min_y_offset = kint32max; + int min_y_offset = std::numeric_limits::max(); for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { max_height = std::max(max_height, bounds[idx].height()); min_y_offset = std::min(min_y_offset, bounds[idx].y()); @@ -337,5 +340,5 @@ void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() { browser_compositor_->compositor()->SetVisible(false); browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); browser_compositor_->compositor()->SetRootLayer(NULL); - content::BrowserCompositorMac::Recycle(browser_compositor_.Pass()); + content::BrowserCompositorMac::Recycle(std::move(browser_compositor_)); } diff --git a/libcef/browser/pepper/device_id_fetcher.cc b/libcef/browser/pepper/device_id_fetcher.cc index f35c953d8..bd3f52278 100644 --- a/libcef/browser/pepper/device_id_fetcher.cc +++ b/libcef/browser/pepper/device_id_fetcher.cc @@ -5,8 +5,10 @@ #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" #include "base/files/file_util.h" +#include "base/macros.h" #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" +#include "build/build_config.h" #include "chrome/common/pref_names.h" #if defined(OS_CHROMEOS) #include "chromeos/cryptohome/system_salt_getter.h" @@ -149,7 +151,7 @@ void DeviceIDFetcher::ComputeOnUIThread(const std::string& salt, // Build the identifier as follows: // SHA256(machine-id||service||SHA256(machine-id||service||salt)) - std::vector salt_bytes; + std::vector salt_bytes; if (!base::HexStringToBytes(salt, &salt_bytes)) salt_bytes.clear(); if (salt_bytes.size() != kSaltLength) { diff --git a/libcef/browser/pepper/pepper_flash_browser_host.cc b/libcef/browser/pepper/pepper_flash_browser_host.cc index 2ef7fce11..4aaf557a5 100644 --- a/libcef/browser/pepper/pepper_flash_browser_host.cc +++ b/libcef/browser/pepper/pepper_flash_browser_host.cc @@ -5,6 +5,7 @@ #include "libcef/browser/pepper/pepper_flash_browser_host.h" #include "base/time/time.h" +#include "build/build_config.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_thread.h" diff --git a/libcef/browser/pepper/pepper_flash_browser_host.h b/libcef/browser/pepper/pepper_flash_browser_host.h index 11897a408..b48d83c67 100644 --- a/libcef/browser/pepper/pepper_flash_browser_host.h +++ b/libcef/browser/pepper/pepper_flash_browser_host.h @@ -5,7 +5,9 @@ #ifndef CEF_LIBCEF_BROWSER_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_ #define CEF_LIBCEF_BROWSER_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_ -#include "base/basictypes.h" +#include + +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "ppapi/host/host_message_context.h" diff --git a/libcef/browser/pepper/pepper_isolated_file_system_message_filter.cc b/libcef/browser/pepper/pepper_isolated_file_system_message_filter.cc index 41b057a37..55c1d1248 100644 --- a/libcef/browser/pepper/pepper_isolated_file_system_message_filter.cc +++ b/libcef/browser/pepper/pepper_isolated_file_system_message_filter.cc @@ -4,6 +4,8 @@ #include "libcef/browser/pepper/pepper_isolated_file_system_message_filter.h" +#include + #include "libcef/browser/browser_context_impl.h" #include "chrome/common/chrome_switches.h" diff --git a/libcef/browser/pepper/pepper_isolated_file_system_message_filter.h b/libcef/browser/pepper/pepper_isolated_file_system_message_filter.h index 37cbfe96f..290acf19a 100644 --- a/libcef/browser/pepper/pepper_isolated_file_system_message_filter.h +++ b/libcef/browser/pepper/pepper_isolated_file_system_message_filter.h @@ -5,10 +5,13 @@ #ifndef CEF_LIBCEF_BROWSER_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_ #define CEF_LIBCEF_BROWSER_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_ +#include + #include #include #include "base/files/file_path.h" +#include "base/macros.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/private/ppb_isolated_file_system_private.h" diff --git a/libcef/browser/plugins/plugin_info_message_filter.cc b/libcef/browser/plugins/plugin_info_message_filter.cc index f3c3df537..fb0537c39 100644 --- a/libcef/browser/plugins/plugin_info_message_filter.cc +++ b/libcef/browser/plugins/plugin_info_message_filter.cc @@ -5,6 +5,8 @@ #include "libcef/browser/plugins/plugin_info_message_filter.h" +#include + #include "libcef/browser/browser_context.h" #include "libcef/browser/plugins/plugin_service_filter.h" #include "libcef/browser/web_plugin_impl.h" @@ -16,6 +18,7 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" +#include "build/build_config.h" #include "chrome/browser/plugins/plugin_finder.h" #include "chrome/common/pref_names.h" #include "components/content_settings/core/browser/content_settings_utils.h" @@ -533,10 +536,10 @@ void CefPluginInfoMessageFilter::Context::GetPluginContentSetting( !legacy_ask_user; uses_plugin_specific_setting = specific_setting && !use_policy; if (uses_plugin_specific_setting) { - value = specific_setting.Pass(); + value = std::move(specific_setting); info = specific_info; } else { - value = general_setting.Pass(); + value = std::move(general_setting); info = general_info; } } diff --git a/libcef/browser/printing/print_view_manager.cc b/libcef/browser/printing/print_view_manager.cc index 1d6004f91..dba92d95d 100644 --- a/libcef/browser/printing/print_view_manager.cc +++ b/libcef/browser/printing/print_view_manager.cc @@ -5,7 +5,10 @@ #include "include/internal/cef_types_wrappers.h" #include "libcef/browser/printing/print_view_manager.h" +#include + #include +#include #include "base/bind.h" #include "base/lazy_instance.h" @@ -67,7 +70,7 @@ void FillInDictionaryFromPdfPrintSettings( scoped_ptr dict(new base::DictionaryValue); dict->SetInteger(kSettingMediaSizeWidthMicrons, pdf_settings.page_width); dict->SetInteger(kSettingMediaSizeHeightMicrons, pdf_settings.page_height); - print_settings.Set(kSettingMediaSize, dict.Pass()); + print_settings.Set(kSettingMediaSize, std::move(dict)); } int margin_type = DEFAULT_MARGINS; @@ -92,7 +95,7 @@ void FillInDictionaryFromPdfPrintSettings( dict->SetDouble(kSettingMarginRight, pdf_settings.margin_right); dict->SetDouble(kSettingMarginBottom, pdf_settings.margin_bottom); dict->SetDouble(kSettingMarginLeft, pdf_settings.margin_left); - print_settings.Set(kSettingMarginsCustom, dict.Pass()); + print_settings.Set(kSettingMarginsCustom, std::move(dict)); } // Service settings. @@ -116,7 +119,7 @@ void StopWorker(int document_cookie) { } scoped_refptr -GetDataFromHandle(base::SharedMemoryHandle handle, uint32 data_size) { +GetDataFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) { scoped_ptr shared_buf( new base::SharedMemory(handle, true)); diff --git a/libcef/browser/printing/print_view_manager.h b/libcef/browser/printing/print_view_manager.h index 30bbeafa0..985621f95 100644 --- a/libcef/browser/printing/print_view_manager.h +++ b/libcef/browser/printing/print_view_manager.h @@ -6,6 +6,8 @@ #define CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ #include "libcef/browser/printing/print_view_manager_base.h" + +#include "base/macros.h" #include "content/public/browser/web_contents_user_data.h" struct PrintHostMsg_DidPreviewDocument_Params; diff --git a/libcef/browser/printing/print_view_manager_base.cc b/libcef/browser/printing/print_view_manager_base.cc index 6230977d3..7a2239082 100644 --- a/libcef/browser/printing/print_view_manager_base.cc +++ b/libcef/browser/printing/print_view_manager_base.cc @@ -4,6 +4,8 @@ #include "libcef/browser/printing/print_view_manager_base.h" +#include + #include "libcef/browser/content_browser_client.h" #include "base/auto_reset.h" @@ -172,7 +174,7 @@ void PrintViewManagerBase::OnDidPrintPage( #else // Update the rendered document. It will send notifications to the listener. document->SetPage(params.page_number, - metafile.Pass(), + std::move(metafile), params.page_size, params.content_area); diff --git a/libcef/browser/printing/print_view_manager_base.h b/libcef/browser/printing/print_view_manager_base.h index 101a4588b..e28761828 100644 --- a/libcef/browser/printing/print_view_manager_base.h +++ b/libcef/browser/printing/print_view_manager_base.h @@ -5,9 +5,11 @@ #ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ #define CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/prefs/pref_member.h" #include "base/strings/string16.h" +#include "build/build_config.h" #include "components/printing/browser/print_manager.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" diff --git a/libcef/browser/printing/printing_message_filter.cc b/libcef/browser/printing/printing_message_filter.cc index f245c4cf3..610553dff 100644 --- a/libcef/browser/printing/printing_message_filter.cc +++ b/libcef/browser/printing/printing_message_filter.cc @@ -5,6 +5,7 @@ #include "libcef/browser/printing/printing_message_filter.h" #include +#include #include "base/bind.h" #include "chrome/browser/browser_process.h" @@ -204,7 +205,7 @@ void PrintingMessageFilter::OnUpdatePrintSettings( printer_query = queue_->CreatePrinterQuery(host_id, routing_id); } printer_query->SetSettings( - new_settings.Pass(), + std::move(new_settings), base::Bind(&PrintingMessageFilter::OnUpdatePrintSettingsReply, this, printer_query, reply_msg)); } @@ -237,7 +238,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply( } } -void PrintingMessageFilter::OnCheckForCancel(int32 preview_ui_id, +void PrintingMessageFilter::OnCheckForCancel(int32_t preview_ui_id, int preview_request_id, bool* cancel) { *cancel = false; diff --git a/libcef/browser/printing/printing_message_filter.h b/libcef/browser/printing/printing_message_filter.h index 61426cac2..4a179c06e 100644 --- a/libcef/browser/printing/printing_message_filter.h +++ b/libcef/browser/printing/printing_message_filter.h @@ -5,9 +5,13 @@ #ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINTING_MESSAGE_FILTER_H_ #define CEF_LIBCEF_BROWSER_PRINTING_PRINTING_MESSAGE_FILTER_H_ +#include + #include #include "base/compiler_specific.h" +#include "base/macros.h" +#include "build/build_config.h" #include "content/public/browser/browser_message_filter.h" #if defined(OS_WIN) @@ -82,7 +86,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter { void OnUpdatePrintSettingsReply(scoped_refptr printer_query, IPC::Message* reply_msg); - void OnCheckForCancel(int32 preview_ui_id, + void OnCheckForCancel(int32_t preview_ui_id, int preview_request_id, bool* cancel); diff --git a/libcef/browser/resource_dispatcher_host_delegate.cc b/libcef/browser/resource_dispatcher_host_delegate.cc index 95a2000b5..57fe64f0e 100644 --- a/libcef/browser/resource_dispatcher_host_delegate.cc +++ b/libcef/browser/resource_dispatcher_host_delegate.cc @@ -4,6 +4,11 @@ // found in the LICENSE file. #include "libcef/browser/resource_dispatcher_host_delegate.h" + +#include + +#include + #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/extensions/api/streams_private/streams_private_api.h" #include "libcef/browser/origin_whitelist_impl.h" @@ -13,6 +18,7 @@ #include "base/guid.h" #include "base/memory/scoped_vector.h" +#include "build/build_config.h" #include "content/public/browser/plugin_service.h" #include "content/public/browser/plugin_service_filter.h" #include "content/public/browser/resource_request_info.h" @@ -28,7 +34,7 @@ namespace { void SendExecuteMimeTypeHandlerEvent(scoped_ptr stream, - int64 expected_content_size, + int64_t expected_content_size, int render_process_id, int render_frame_id, const std::string& extension_id, @@ -59,7 +65,7 @@ void SendExecuteMimeTypeHandlerEvent(scoped_ptr stream, int tab_id = -1; streams_private->ExecuteMimeTypeHandler( - extension_id, tab_id, stream.Pass(), view_id, expected_content_size, + extension_id, tab_id, std::move(stream), view_id, expected_content_size, embedded, render_process_id, render_frame_id); } diff --git a/libcef/browser/resource_dispatcher_host_delegate.h b/libcef/browser/resource_dispatcher_host_delegate.h index 92cc8ec13..c84634891 100644 --- a/libcef/browser/resource_dispatcher_host_delegate.h +++ b/libcef/browser/resource_dispatcher_host_delegate.h @@ -10,6 +10,7 @@ #include #include "base/compiler_specific.h" +#include "base/macros.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" // Implements ResourceDispatcherHostDelegate. diff --git a/libcef/browser/trace_subscriber.cc b/libcef/browser/trace_subscriber.cc index 000e0424c..940ea826a 100644 --- a/libcef/browser/trace_subscriber.cc +++ b/libcef/browser/trace_subscriber.cc @@ -24,6 +24,28 @@ void CreateTemporaryFileOnFileThread( message_loop_proxy->PostTask(FROM_HERE, base::Bind(callback, file_path)); } +// Release the wrapped callback object after completion. +class CefCompletionCallbackWrapper : public CefCompletionCallback { + public: + explicit CefCompletionCallbackWrapper( + CefRefPtr callback) + : callback_(callback) { + } + + void OnComplete() override { + if (callback_) { + callback_->OnComplete(); + callback_ = nullptr; + } + } + + private: + CefRefPtr callback_; + + IMPLEMENT_REFCOUNTING(CefCompletionCallbackWrapper); + DISALLOW_COPY_AND_ASSIGN(CefCompletionCallbackWrapper); +}; + } // namespace using content::TracingController; @@ -52,6 +74,9 @@ bool CefTraceSubscriber::BeginTracing( TracingController::StartTracingDoneCallback done_callback; if (callback.get()) { + // Work around a bug introduced in http://crbug.com/542390#c22 that keeps a + // reference to |done_callback| after execution. + callback = new CefCompletionCallbackWrapper(callback); done_callback = base::Bind(&CefCompletionCallback::OnComplete, callback.get()); } diff --git a/libcef/common/cef_messages.cc b/libcef/common/cef_messages.cc index 487d504e8..698c02e1f 100644 --- a/libcef/common/cef_messages.cc +++ b/libcef/common/cef_messages.cc @@ -49,7 +49,7 @@ struct ParamTraits { default: { DCHECK(type == net::UploadElement::TYPE_FILE); base::FilePath file_path; - uint64 offset, length; + uint64_t offset, length; base::Time expected_modification_time; if (!ReadParam(m, iter, &file_path)) return false; @@ -94,7 +94,7 @@ bool ParamTraits >::Read( ScopedVector elements; if (!ReadParam(m, iter, &elements)) return false; - int64 identifier; + int64_t identifier; if (!ReadParam(m, iter, &identifier)) return false; bool is_chunked = false; diff --git a/libcef/common/cef_messages.h b/libcef/common/cef_messages.h index 3c6541e92..ffc0a7108 100644 --- a/libcef/common/cef_messages.h +++ b/libcef/common/cef_messages.h @@ -6,6 +6,8 @@ // IPC messages for CEF. // Multiply-included message file, hence no include guard. +#include + #include "libcef/common/net/upload_data.h" #include "base/memory/shared_memory.h" @@ -63,7 +65,7 @@ IPC_STRUCT_BEGIN(Cef_Request_Params) IPC_STRUCT_MEMBER(int, request_id) // Unique id of the target frame. -1 if unknown / invalid. - IPC_STRUCT_MEMBER(int64, frame_id) + IPC_STRUCT_MEMBER(int64_t, frame_id) // True if the request is user-initiated instead of internal. IPC_STRUCT_MEMBER(bool, user_initiated) @@ -126,7 +128,7 @@ IPC_STRUCT_BEGIN(CefMsg_LoadRequest_Params) // Identifies the frame within the RenderView that sent the request. // -1 if unknown / invalid. - IPC_STRUCT_MEMBER(int64, frame_id) + IPC_STRUCT_MEMBER(int64_t, frame_id) // Usually the URL of the document in the top-level window, which may be // checked by the third-party cookie blocking policy. Leaving it empty may @@ -251,13 +253,13 @@ IPC_SYNC_MESSAGE_CONTROL1_3( // Sent when a frame is identified for the first time. IPC_MESSAGE_ROUTED3(CefHostMsg_FrameIdentified, - int64 /* frame_id */, - int64 /* parent_frame_id */, + int64_t /* frame_id */, + int64_t /* parent_frame_id */, base::string16 /* frame_name */) // Sent when a frame has finished loading. Based on ViewHostMsg_DidFinishLoad. IPC_MESSAGE_ROUTED4(CefHostMsg_DidFinishLoad, - int64 /* frame_id */, + int64_t /* frame_id */, GURL /* validated_url */, bool /* is_main_frame */, int /* http_status_code */) diff --git a/libcef/common/content_client.cc b/libcef/common/content_client.cc index 4ae0690af..da59831ef 100644 --- a/libcef/common/content_client.cc +++ b/libcef/common/content_client.cc @@ -4,6 +4,9 @@ // found in the LICENSE file. #include "libcef/common/content_client.h" + +#include + #include "include/cef_stream.h" #include "include/cef_version.h" #include "libcef/browser/content_browser_client.h" @@ -53,8 +56,8 @@ const char kPDFPluginExtension[] = "pdf"; const char kPDFPluginDescription[] = "Portable Document Format"; const char kPDFPluginOutOfProcessMimeType[] = "application/x-google-chrome-pdf"; -const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | - ppapi::PERMISSION_DEV; +const uint32_t kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | + ppapi::PERMISSION_DEV; content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; diff --git a/libcef/common/crash_reporter_client.h b/libcef/common/crash_reporter_client.h index 07286f1a4..106dc19aa 100644 --- a/libcef/common/crash_reporter_client.h +++ b/libcef/common/crash_reporter_client.h @@ -5,7 +5,8 @@ #ifndef CEF_LIBCEF_COMMON_CRASH_REPORTER_CLIENT_H_ #define CEF_LIBCEF_COMMON_CRASH_REPORTER_CLIENT_H_ -#include "base/compiler_specific.h" +#include "base/macros.h" +#include "build/build_config.h" #include "components/crash/content/app/crash_reporter_client.h" class CefCrashReporterClient : public crash_reporter::CrashReporterClient { diff --git a/libcef/common/extensions/extensions_client.cc b/libcef/common/extensions/extensions_client.cc index 8edc6ccb1..a717de492 100644 --- a/libcef/common/extensions/extensions_client.cc +++ b/libcef/common/extensions/extensions_client.cc @@ -5,6 +5,8 @@ #include "libcef/common/extensions/extensions_client.h" +#include + #include "libcef/common/cef_switches.h" #include "base/lazy_instance.h" @@ -118,7 +120,7 @@ scoped_ptr CefExtensionsClient::CreateFeatureProvider( } else { NOTREACHED(); } - return provider.Pass(); + return provider; } scoped_ptr @@ -142,7 +144,7 @@ CefExtensionsClient::CreateFeatureProviderSource( NOTREACHED(); source.reset(); } - return source.Pass(); + return source; } void CefExtensionsClient::FilterHostPermissions( diff --git a/libcef/common/extensions/extensions_client.h b/libcef/common/extensions/extensions_client.h index 61a55e138..32c66f281 100644 --- a/libcef/common/extensions/extensions_client.h +++ b/libcef/common/extensions/extensions_client.h @@ -6,8 +6,8 @@ #ifndef CEF_LIBCEF_COMMON_EXTENSIONS_EXTENSIONS_CLIENT_H_ #define CEF_LIBCEF_COMMON_EXTENSIONS_EXTENSIONS_CLIENT_H_ -#include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "extensions/common/extensions_client.h" #include "extensions/common/permissions/extensions_api_permissions.h" diff --git a/libcef/common/net/upload_data.cc b/libcef/common/net/upload_data.cc index 580f99b31..a4351480e 100644 --- a/libcef/common/net/upload_data.cc +++ b/libcef/common/net/upload_data.cc @@ -23,7 +23,7 @@ void UploadData::AppendBytes(const char* bytes, int bytes_len) { } void UploadData::AppendFileRange(const base::FilePath& file_path, - uint64 offset, uint64 length, + uint64_t offset, uint64_t length, const base::Time& expected_modification_time) { DCHECK(!is_chunked_); elements_.push_back(new UploadElement()); diff --git a/libcef/common/net/upload_data.h b/libcef/common/net/upload_data.h index 198ffb65f..79d55edef 100644 --- a/libcef/common/net/upload_data.h +++ b/libcef/common/net/upload_data.h @@ -5,9 +5,10 @@ #ifndef CEF_LIBCEF_COMMON_NET_UPLOAD_DATA_H_ #define CEF_LIBCEF_COMMON_NET_UPLOAD_DATA_H_ +#include + #include "libcef/common/net/upload_element.h" -#include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_vector.h" #include "base/supports_user_data.h" @@ -36,7 +37,7 @@ class NET_EXPORT UploadData void AppendBytes(const char* bytes, int bytes_len); void AppendFileRange(const base::FilePath& file_path, - uint64 offset, uint64 length, + uint64_t offset, uint64_t length, const base::Time& expected_modification_time); // Initializes the object to send chunks of upload data over time rather @@ -63,8 +64,8 @@ class NET_EXPORT UploadData // Identifies a particular upload instance, which is used by the cache to // formulate a cache key. This value should be unique across browser // sessions. A value of 0 is used to indicate an unspecified identifier. - void set_identifier(int64 id) { identifier_ = id; } - int64 identifier() const { return identifier_; } + void set_identifier(int64_t id) { identifier_ = id; } + int64_t identifier() const { return identifier_; } private: friend class base::RefCounted; @@ -72,7 +73,7 @@ class NET_EXPORT UploadData ~UploadData() override; ScopedVector elements_; - int64 identifier_; + int64_t identifier_; bool is_chunked_; bool last_chunk_appended_; diff --git a/libcef/common/net/upload_element.cc b/libcef/common/net/upload_element.cc index c034a7937..c0848b65a 100644 --- a/libcef/common/net/upload_element.cc +++ b/libcef/common/net/upload_element.cc @@ -4,8 +4,6 @@ #include "libcef/common/net/upload_element.h" -#include - #include "net/base/file_stream.h" #include "net/base/net_errors.h" @@ -16,7 +14,7 @@ UploadElement::UploadElement() bytes_start_(NULL), bytes_length_(0), file_range_offset_(0), - file_range_length_(kuint64max) { + file_range_length_(std::numeric_limits::max()) { } UploadElement::~UploadElement() { diff --git a/libcef/common/net/upload_element.h b/libcef/common/net/upload_element.h index 530846ad1..a7465ef4d 100644 --- a/libcef/common/net/upload_element.h +++ b/libcef/common/net/upload_element.h @@ -5,9 +5,11 @@ #ifndef CEF_LIBCEF_COMMON_NET_UPLOAD_ELEMENT_H_ #define CEF_LIBCEF_COMMON_NET_UPLOAD_ELEMENT_H_ +#include + +#include #include -#include "base/basictypes.h" #include "base/files/file_path.h" #include "base/time/time.h" #include "net/base/net_export.h" @@ -28,10 +30,10 @@ class NET_EXPORT UploadElement { Type type() const { return type_; } const char* bytes() const { return bytes_start_ ? bytes_start_ : &buf_[0]; } - uint64 bytes_length() const { return buf_.size() + bytes_length_; } + uint64_t bytes_length() const { return buf_.size() + bytes_length_; } const base::FilePath& file_path() const { return file_path_; } - uint64 file_range_offset() const { return file_range_offset_; } - uint64 file_range_length() const { return file_range_length_; } + uint64_t file_range_offset() const { return file_range_offset_; } + uint64_t file_range_length() const { return file_range_length_; } // If NULL time is returned, we do not do the check. const base::Time& expected_file_modification_time() const { return expected_file_modification_time_; @@ -52,14 +54,15 @@ class NET_EXPORT UploadElement { } void SetToFilePath(const base::FilePath& path) { - SetToFilePathRange(path, 0, kuint64max, base::Time()); + SetToFilePathRange(path, 0, std::numeric_limits::max(), + base::Time()); } // If expected_modification_time is NULL, we do not check for the file // change. Also note that the granularity for comparison is time_t, not // the full precision. void SetToFilePathRange(const base::FilePath& path, - uint64 offset, uint64 length, + uint64_t offset, uint64_t length, const base::Time& expected_modification_time) { type_ = TYPE_FILE; file_path_ = path; @@ -72,10 +75,10 @@ class NET_EXPORT UploadElement { Type type_; std::vector buf_; const char* bytes_start_; - uint64 bytes_length_; + uint64_t bytes_length_; base::FilePath file_path_; - uint64 file_range_offset_; - uint64 file_range_length_; + uint64_t file_range_offset_; + uint64_t file_range_length_; base::Time expected_file_modification_time_; DISALLOW_COPY_AND_ASSIGN(UploadElement); diff --git a/libcef/common/request_impl.cc b/libcef/common/request_impl.cc index 951ed428a..82d0c3e9a 100644 --- a/libcef/common/request_impl.cc +++ b/libcef/common/request_impl.cc @@ -2,7 +2,9 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. +#include #include +#include #include #include "libcef/common/cef_messages.h" @@ -51,7 +53,7 @@ class BytesElementReader : public net::UploadBytesElementReader { explicit BytesElementReader(scoped_ptr element) : net::UploadBytesElementReader(element->bytes(), element->bytes_length()), - element_(element.Pass()) { + element_(std::move(element)) { DCHECK_EQ(net::UploadElement::TYPE_BYTES, element_->type()); } @@ -77,7 +79,7 @@ class FileElementReader : public net::UploadFileElementReader { element->file_range_offset(), element->file_range_length(), element->expected_file_modification_time()), - element_(element.Pass()) { + element_(std::move(element)) { DCHECK_EQ(net::UploadElement::TYPE_FILE, element_->type()); } @@ -518,7 +520,7 @@ void CefRequestImpl::Set(const blink::WebURLRequest& request) { Reset(); - url_ = request.url().spec().utf16(); + url_ = request.url().string(); method_ = request.httpMethod(); ::GetHeaderMap(request, headermap_, referrer_url_); @@ -531,7 +533,7 @@ void CefRequestImpl::Set(const blink::WebURLRequest& request) { static_cast(postdata_.get())->Set(body); } - first_party_for_cookies_ = request.firstPartyForCookies().spec().utf16(); + first_party_for_cookies_ = request.firstPartyForCookies().string(); if (request.cachePolicy() == blink::WebURLRequest::ReloadIgnoringCacheData) flags_ |= UR_FLAG_SKIP_CACHE; @@ -757,7 +759,7 @@ void CefRequestImpl::Get(net::URLFetcher& fetcher, fetcher.SetUploadFilePath( content_type, base::FilePath(impl->GetFile()), - 0, kuint64max, + 0, std::numeric_limits::max(), GetFileTaskRunner()); break; case PDE_TYPE_EMPTY: @@ -815,10 +817,10 @@ void CefRequestImpl::SetTrackChanges(bool track_changes) { } } -uint8 CefRequestImpl::GetChanges() const { +uint8_t CefRequestImpl::GetChanges() const { base::AutoLock lock_scope(lock_); - uint8 changes = changes_; + uint8_t changes = changes_; if (postdata_.get() && static_cast(postdata_.get())->HasChanges()) { changes |= kChangedPostData; @@ -826,13 +828,13 @@ uint8 CefRequestImpl::GetChanges() const { return changes; } -void CefRequestImpl::Changed(uint8 changes) { +void CefRequestImpl::Changed(uint8_t changes) { lock_.AssertAcquired(); if (track_changes_) changes_ |= changes; } -bool CefRequestImpl::ShouldSet(uint8 changes, bool changed_only) const { +bool CefRequestImpl::ShouldSet(uint8_t changes, bool changed_only) const { lock_.AssertAcquired(); // Always change if changes are not being tracked. diff --git a/libcef/common/request_impl.h b/libcef/common/request_impl.h index 5a53e019e..7c8e7e6ec 100644 --- a/libcef/common/request_impl.h +++ b/libcef/common/request_impl.h @@ -6,6 +6,8 @@ #define CEF_LIBCEF_COMMON_REQUEST_IMPL_H_ #pragma once +#include + #include "include/cef_request.h" #include "base/synchronization/lock.h" @@ -111,11 +113,11 @@ class CefRequestImpl : public CefRequest { void SetReadOnly(bool read_only); void SetTrackChanges(bool track_changes); - uint8 GetChanges() const; + uint8_t GetChanges() const; private: - void Changed(uint8 changes); - bool ShouldSet(uint8 changes, bool changed_only) const; + void Changed(uint8_t changes); + bool ShouldSet(uint8_t changes, bool changed_only) const; void Reset(); @@ -140,7 +142,7 @@ class CefRequestImpl : public CefRequest { bool track_changes_; // Bitmask of |Changes| values which indicate which fields have changed. - uint8 changes_; + uint8_t changes_; mutable base::Lock lock_; diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index bdd087fa1..86d205d60 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -319,7 +319,7 @@ bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process, CefRefPtr CefBrowserImpl::GetWebFrameImpl( blink::WebFrame* frame) { DCHECK(frame); - int64 frame_id = webkit_glue::GetIdentifier(frame); + int64_t frame_id = webkit_glue::GetIdentifier(frame); // Frames are re-used between page loads. Only add the frame to the map once. FrameMap::const_iterator it = frames_.find(frame_id); @@ -329,7 +329,7 @@ CefRefPtr CefBrowserImpl::GetWebFrameImpl( CefRefPtr framePtr(new CefFrameImpl(this, frame)); frames_.insert(std::make_pair(frame_id, framePtr)); - int64 parent_id = frame->parent() == NULL ? + int64_t parent_id = frame->parent() == NULL ? webkit_glue::kInvalidFrameId : webkit_glue::GetIdentifier(frame->parent()); base::string16 name = frame->uniqueName(); @@ -340,7 +340,7 @@ CefRefPtr CefBrowserImpl::GetWebFrameImpl( return framePtr; } -CefRefPtr CefBrowserImpl::GetWebFrameImpl(int64 frame_id) { +CefRefPtr CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) { if (frame_id == webkit_glue::kInvalidFrameId) { if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()); @@ -368,7 +368,7 @@ CefRefPtr CefBrowserImpl::GetWebFrameImpl(int64 frame_id) { return NULL; } -void CefBrowserImpl::AddFrameObject(int64 frame_id, +void CefBrowserImpl::AddFrameObject(int64_t frame_id, CefTrackNode* tracked_object) { CefRefPtr manager; @@ -453,7 +453,7 @@ void CefBrowserImpl::DidCommitProvisionalLoad(blink::WebLocalFrame* frame, } void CefBrowserImpl::FrameDetached(WebFrame* frame) { - int64 frame_id = webkit_glue::GetIdentifier(frame); + int64_t frame_id = webkit_glue::GetIdentifier(frame); if (!frames_.empty()) { // Remove the frame from the map. diff --git a/libcef/renderer/browser_impl.h b/libcef/renderer/browser_impl.h index cdd4cacb7..188d5eb4b 100644 --- a/libcef/renderer/browser_impl.h +++ b/libcef/renderer/browser_impl.h @@ -7,6 +7,8 @@ #define CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_ #pragma once +#include + #include #include #include @@ -89,10 +91,10 @@ class CefBrowserImpl : public CefBrowser, // Returns the matching CefFrameImpl reference or creates a new one. CefRefPtr GetWebFrameImpl(blink::WebFrame* frame); - CefRefPtr GetWebFrameImpl(int64 frame_id); + CefRefPtr GetWebFrameImpl(int64_t frame_id); // Frame objects will be deleted immediately before the frame is closed. - void AddFrameObject(int64 frame_id, CefTrackNode* tracked_object); + void AddFrameObject(int64_t frame_id, CefTrackNode* tracked_object); int browser_id() const { return browser_id_; } bool is_popup() const { return is_popup_; } diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index 2ba8265c0..3b3f494a8 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -5,6 +5,8 @@ #include "libcef/renderer/content_renderer_client.h" +#include + #include "libcef/browser/context.h" #include "libcef/common/cef_messages.h" #include "libcef/common/cef_switches.h" @@ -28,11 +30,13 @@ #include "libcef/renderer/webkit_glue.h" #include "base/command_line.h" +#include "base/macros.h" #include "base/metrics/user_metrics_action.h" #include "base/path_service.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "build/build_config.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pepper_permission_util.h" #include "chrome/common/url_constants.h" @@ -40,13 +44,13 @@ #include "chrome/renderer/content_settings_observer.h" #include "chrome/renderer/loadtimes_extension_bindings.h" #include "chrome/renderer/pepper/chrome_pdf_print_client.h" +#include "chrome/renderer/plugins/power_saver_info.h" #include "chrome/renderer/spellchecker/spellcheck.h" #include "chrome/renderer/spellchecker/spellcheck_provider.h" #include "components/content_settings/core/common/content_settings_types.h" #include "components/nacl/common/nacl_constants.h" #include "components/printing/renderer/print_web_view_helper.h" #include "components/web_cache/renderer/web_cache_render_process_observer.h" -#include "content/child/worker_task_runner.h" #include "content/common/frame_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" @@ -135,19 +139,6 @@ void AppendParams(const std::vector& additional_names, existing_values->swap(values); } -std::string GetPluginInstancePosterAttribute( - const blink::WebPluginParams& params) { - DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); - - for (size_t i = 0; i < params.attributeNames.size(); ++i) { - if (params.attributeNames[i].utf8() == "poster" && - !params.attributeValues[i].isEmpty()) { - return params.attributeValues[i].utf8(); - } - } - return std::string(); -} - } // namespace // Placeholder object for guest views. @@ -676,14 +667,13 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin( params.mimeType = blink::WebString::fromUTF8(actual_mime_type.c_str()); } - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - auto create_blocked_plugin = - [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( - int template_id, const base::string16& message) { - return CefPluginPlaceholder::CreateBlockedPlugin( - render_frame, frame, params, info, identifier, group_name, - template_id, message, PlaceholderPosterInfo()); - }; + auto create_blocked_plugin = [&render_frame, &frame, ¶ms, &info, + &identifier, &group_name]( + int template_id, const base::string16& message) { + return CefPluginPlaceholder::CreateBlockedPlugin( + render_frame, frame, params, info, identifier, group_name, + template_id, message, PowerSaverInfo()); + }; switch (status) { case CefViewHostMsg_GetPluginInfo_Status::kNotFound: { NOTREACHED(); @@ -696,52 +686,29 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin( // CefContentRendererClient::CreatePlugin instead, to // reduce the chance of future regressions. bool is_prerendering = false; - bool is_flash = - info.name == base::ASCIIToUTF16(content::kFlashPluginName); - - std::string override_for_testing = command_line->GetSwitchValueASCII( - switches::kOverridePluginPowerSaverForTesting); - - // This feature has only been tested throughly with Flash thus far. - // It is also enabled for the Power Saver test plugin for browser tests. - bool can_throttle_plugin_type = - is_flash || override_for_testing == "ignore-list"; - bool power_saver_setting_on = status == CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; - bool power_saver_enabled = - override_for_testing == "always" || - (power_saver_setting_on && can_throttle_plugin_type); - bool blocked_for_background_tab = - power_saver_enabled && render_frame->IsHidden(); - - PlaceholderPosterInfo poster_info; - if (power_saver_enabled) { - poster_info.poster_attribute = - GetPluginInstancePosterAttribute(params); - poster_info.base_url = frame->document().url(); - } - - if (blocked_for_background_tab || is_prerendering || - !poster_info.poster_attribute.empty()) { + PowerSaverInfo power_saver_info = + PowerSaverInfo::Get(render_frame, power_saver_setting_on, params, + info, frame->document().url()); + if (power_saver_info.blocked_for_background_tab || is_prerendering || + !power_saver_info.poster_attribute.empty()) { placeholder = CefPluginPlaceholder::CreateBlockedPlugin( render_frame, frame, params, info, identifier, group_name, - poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML - : IDR_PLUGIN_POSTER_HTML, + power_saver_info.poster_attribute.empty() + ? IDR_BLOCKED_PLUGIN_HTML + : IDR_PLUGIN_POSTER_HTML, l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), - poster_info); - placeholder->set_blocked_for_background_tab( - blocked_for_background_tab); + power_saver_info); placeholder->set_blocked_for_prerendering(is_prerendering); - placeholder->set_power_saver_enabled(power_saver_enabled); placeholder->AllowLoading(); break; } scoped_ptr throttler; - if (power_saver_enabled) { + if (power_saver_info.power_saver_enabled) { throttler = content::PluginInstanceThrottler::Create(); // PluginPreroller manages its own lifetime. new CefPluginPreroller( @@ -751,7 +718,7 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin( } return render_frame->CreatePlugin(frame, info, params, - throttler.Pass()); + std::move(throttler)); } case CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { content::RenderThread::Get()->RecordAction( @@ -815,6 +782,9 @@ blink::WebPlugin* CefContentRendererClient::CreatePlugin( void CefContentRendererClient::BrowserCreated( content::RenderView* render_view, content::RenderFrame* render_frame) { + if (!render_view || !render_frame) + return; + // Swapped out RenderWidgets will be created in the parent/owner process for // frames that are hosted in a separate process (e.g. guest views or OOP // frames). Don't create any CEF objects for swapped out RenderWidgets. diff --git a/libcef/renderer/pepper/renderer_pepper_host_factory.h b/libcef/renderer/pepper/renderer_pepper_host_factory.h index 1d2f83155..c26e6cc9c 100644 --- a/libcef/renderer/pepper/renderer_pepper_host_factory.h +++ b/libcef/renderer/pepper/renderer_pepper_host_factory.h @@ -5,8 +5,7 @@ #ifndef LIBCEF_RENDERER_PEPPER_RENDERER_PEPPER_HOST_FACTORY_H_ #define LIBCEF_RENDERER_PEPPER_RENDERER_PEPPER_HOST_FACTORY_H_ -#include "base/basictypes.h" -#include "base/compiler_specific.h" +#include "base/macros.h" #include "ppapi/host/host_factory.h" namespace content { diff --git a/libcef/renderer/plugins/cef_plugin_placeholder.cc b/libcef/renderer/plugins/cef_plugin_placeholder.cc index bebc07ffe..64331aeea 100644 --- a/libcef/renderer/plugins/cef_plugin_placeholder.cc +++ b/libcef/renderer/plugins/cef_plugin_placeholder.cc @@ -4,6 +4,8 @@ #include "libcef/renderer/plugins/cef_plugin_placeholder.h" +#include + #include "libcef/common/cef_messages.h" #include "libcef/renderer/content_renderer_client.h" #include "libcef/renderer/plugins/plugin_preroller.h" @@ -95,7 +97,7 @@ CefPluginPlaceholder* CefPluginPlaceholder::CreateBlockedPlugin( const base::string16& name, int template_id, const base::string16& message, - const PlaceholderPosterInfo& poster_info) { + const PowerSaverInfo& power_saver_info) { base::DictionaryValue values; values.SetString("message", message); values.SetString("name", name); @@ -106,16 +108,17 @@ CefPluginPlaceholder* CefPluginPlaceholder::CreateBlockedPlugin( ? "document" : "embedded"); - if (!poster_info.poster_attribute.empty()) { - values.SetString("poster", poster_info.poster_attribute); - values.SetString("baseurl", poster_info.base_url.spec()); + if (!power_saver_info.poster_attribute.empty()) { + values.SetString("poster", power_saver_info.poster_attribute); + values.SetString("baseurl", power_saver_info.base_url.spec()); - if (!poster_info.custom_poster_size.IsEmpty()) { + if (!power_saver_info.custom_poster_size.IsEmpty()) { float zoom_factor = blink::WebView::zoomLevelToZoomFactor(frame->view()->zoomLevel()); - int width = roundf(poster_info.custom_poster_size.width() / zoom_factor); + int width = + roundf(power_saver_info.custom_poster_size.width() / zoom_factor); int height = - roundf(poster_info.custom_poster_size.height() / zoom_factor); + roundf(power_saver_info.custom_poster_size.height() / zoom_factor); values.SetString("visibleWidth", base::IntToString(width) + "px"); values.SetString("visibleHeight", base::IntToString(height) + "px"); } @@ -132,10 +135,15 @@ CefPluginPlaceholder* CefPluginPlaceholder::CreateBlockedPlugin( CefPluginPlaceholder* blocked_plugin = new CefPluginPlaceholder( render_frame, frame, params, html_data, name); - if (!poster_info.poster_attribute.empty()) + if (!power_saver_info.poster_attribute.empty()) blocked_plugin->BlockForPowerSaverPoster(); blocked_plugin->SetPluginInfo(info); blocked_plugin->SetIdentifier(identifier); + + blocked_plugin->set_power_saver_enabled(power_saver_info.power_saver_enabled); + blocked_plugin->set_blocked_for_background_tab( + power_saver_info.blocked_for_background_tab); + return blocked_plugin; } @@ -271,7 +279,7 @@ blink::WebPlugin* CefPluginPlaceholder::CreatePlugin() { throttler.get()); } return render_frame()->CreatePlugin(GetFrame(), GetPluginInfo(), - GetPluginParams(), throttler.Pass()); + GetPluginParams(), std::move(throttler)); } gin::ObjectTemplateBuilder CefPluginPlaceholder::GetObjectTemplateBuilder( diff --git a/libcef/renderer/plugins/cef_plugin_placeholder.h b/libcef/renderer/plugins/cef_plugin_placeholder.h index 47e244adc..4956eb78d 100644 --- a/libcef/renderer/plugins/cef_plugin_placeholder.h +++ b/libcef/renderer/plugins/cef_plugin_placeholder.h @@ -5,29 +5,16 @@ #ifndef CEF_LIBCEF_RENDERER_PLUGINS_CEF_PLUGIN_PLACEHOLDER_H_ #define CEF_LIBCEF_RENDERER_PLUGINS_CEF_PLUGIN_PLACEHOLDER_H_ +#include + +#include "base/macros.h" +#include "chrome/renderer/plugins/power_saver_info.h" #include "components/plugins/renderer/loadable_plugin_placeholder.h" #include "content/public/renderer/context_menu_client.h" #include "content/public/renderer/render_process_observer.h" -namespace gfx { -class Size; -} - enum class CefViewHostMsg_GetPluginInfo_Status; -// This contains information specifying the poster image of plugin placeholders. -// The default constructor specifies no poster image. -struct PlaceholderPosterInfo { - // The poster image specified in image 'srcset' attribute format. - std::string poster_attribute; - - // Used to resolve relative paths in |poster_attribute|. - GURL base_url; - - // Specify this to provide partially obscured plugins a centered poster image. - gfx::Size custom_poster_size; -}; - class CefPluginPlaceholder final : public plugins::LoadablePluginPlaceholder, public content::RenderProcessObserver, @@ -45,7 +32,7 @@ class CefPluginPlaceholder final const base::string16& name, int resource_id, const base::string16& message, - const PlaceholderPosterInfo& poster_info); + const PowerSaverInfo& power_saver_info); // Creates a new WebViewPlugin with a MissingPlugin as a delegate. static CefPluginPlaceholder* CreateLoadableMissingPlugin( diff --git a/libcef/renderer/plugins/plugin_preroller.cc b/libcef/renderer/plugins/plugin_preroller.cc index 7870232d5..60fc3cce9 100644 --- a/libcef/renderer/plugins/plugin_preroller.cc +++ b/libcef/renderer/plugins/plugin_preroller.cc @@ -8,6 +8,7 @@ #include "base/base64.h" #include "chrome/grit/generated_resources.h" +#include "chrome/renderer/plugins/power_saver_info.h" #include "third_party/WebKit/public/platform/WebRect.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebPlugin.h" @@ -60,14 +61,15 @@ void CefPluginPreroller::OnThrottleStateChange() { if (!throttler_->IsThrottled()) return; - PlaceholderPosterInfo poster_info; - poster_info.poster_attribute = keyframe_data_url_.spec(); - poster_info.custom_poster_size = throttler_->GetSize(); + PowerSaverInfo power_saver_info; + power_saver_info.power_saver_enabled = true; + power_saver_info.poster_attribute = keyframe_data_url_.spec(); + power_saver_info.custom_poster_size = throttler_->GetSize(); CefPluginPlaceholder* placeholder = CefPluginPlaceholder::CreateBlockedPlugin( render_frame(), frame_, params_, info_, identifier_, name_, - IDR_PLUGIN_POSTER_HTML, message_, poster_info); + IDR_PLUGIN_POSTER_HTML, message_, power_saver_info); placeholder->SetPremadePlugin(throttler_); placeholder->set_power_saver_enabled(true); placeholder->AllowLoading(); diff --git a/libcef/renderer/render_message_filter.cc b/libcef/renderer/render_message_filter.cc index 76498ff06..1e467bad3 100644 --- a/libcef/renderer/render_message_filter.cc +++ b/libcef/renderer/render_message_filter.cc @@ -54,7 +54,7 @@ void CefRenderMessageFilter::OnDevToolsAgentAttach( base::Bind(&CefRenderMessageFilter::OnDevToolsAgentAttach_RT, this)); } -void CefRenderMessageFilter::OnDevToolsAgentDetach(int32 routing_id) { +void CefRenderMessageFilter::OnDevToolsAgentDetach(int32_t routing_id) { CEF_POST_TASK_RT( base::Bind(&CefRenderMessageFilter::OnDevToolsAgentDetach_RT, this, routing_id)); @@ -65,7 +65,7 @@ void CefRenderMessageFilter::OnDevToolsAgentAttach_RT() { CefContentRendererClient::Get()->DevToolsAgentAttached(); } -void CefRenderMessageFilter::OnDevToolsAgentDetach_RT(int32 routing_id) { +void CefRenderMessageFilter::OnDevToolsAgentDetach_RT(int32_t routing_id) { CEF_REQUIRE_RT(); // Wait for the DevToolsAgent to detach. It would be better to receive diff --git a/libcef/renderer/render_message_filter.h b/libcef/renderer/render_message_filter.h index f30a0a92e..70a1c9141 100644 --- a/libcef/renderer/render_message_filter.h +++ b/libcef/renderer/render_message_filter.h @@ -6,7 +6,10 @@ #ifndef CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_ #define CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_ +#include + #include + #include "ipc/ipc_channel_proxy.h" #include "ipc/message_filter.h" @@ -24,10 +27,10 @@ class CefRenderMessageFilter : public IPC::MessageFilter { private: // Message handlers called on the IO thread. void OnDevToolsAgentAttach(const std::string& host_id, int session_id); - void OnDevToolsAgentDetach(int32 routing_id); + void OnDevToolsAgentDetach(int32_t routing_id); void OnDevToolsAgentAttach_RT(); - void OnDevToolsAgentDetach_RT(int32 routing_id); + void OnDevToolsAgentDetach_RT(int32_t routing_id); IPC::Sender* sender_; diff --git a/libcef/renderer/render_urlrequest_impl.cc b/libcef/renderer/render_urlrequest_impl.cc index bfa5994bc..96a28304d 100644 --- a/libcef/renderer/render_urlrequest_impl.cc +++ b/libcef/renderer/render_urlrequest_impl.cc @@ -3,6 +3,9 @@ // be found in the LICENSE file. #include "libcef/renderer/render_urlrequest_impl.h" + +#include + #include "libcef/common/request_impl.h" #include "libcef/common/response_impl.h" @@ -169,7 +172,7 @@ class CefRenderURLRequest::Context url_request_ = NULL; } - void OnDownloadProgress(int64 current) { + void OnDownloadProgress(int64_t current) { DCHECK(CalledOnValidThread()); DCHECK(url_request_.get()); @@ -186,7 +189,7 @@ class CefRenderURLRequest::Context client_->OnDownloadData(url_request_.get(), data, dataLength); } - void OnUploadProgress(int64 current, int64 total) { + void OnUploadProgress(int64_t current, int64_t total) { DCHECK(CalledOnValidThread()); DCHECK(url_request_.get()); if (current == total) @@ -226,10 +229,10 @@ class CefRenderURLRequest::Context CefRefPtr response_; scoped_ptr loader_; scoped_ptr url_client_; - int64 upload_data_size_; + int64_t upload_data_size_; bool got_upload_progress_complete_; - int64 download_data_received_; - int64 download_data_total_; + int64_t download_data_received_; + int64_t download_data_total_; }; diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index fb11d81e3..bb4379abc 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -212,12 +212,12 @@ class CefV8IsolateManager { return; if (!message_listener_registered_) { - v8::V8::AddMessageListener(&MessageListenerCallbackImpl); + isolate_->AddMessageListener(&MessageListenerCallbackImpl); message_listener_registered_ = true; } - v8::V8::SetCaptureStackTraceForUncaughtExceptions(true, - stack_size, v8::StackTrace::kDetailed); + isolate_->SetCaptureStackTraceForUncaughtExceptions(true, + stack_size, v8::StackTrace::kDetailed); } void SetWorkerAttributes(int worker_id, const GURL& worker_url) { @@ -477,18 +477,20 @@ void GetCefString(v8::Local str, CefString& out) { // V8 function callback. void FunctionCallbackImpl(const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); + v8::Local context = isolate->GetCurrentContext(); CefV8Handler* handler = static_cast(v8::External::Cast(*info.Data())->Value()); CefV8ValueList params; for (int i = 0; i < info.Length(); i++) - params.push_back(new CefV8ValueImpl(isolate, info[i])); + params.push_back(new CefV8ValueImpl(isolate, context, info[i])); CefString func_name; GetCefString(v8::Handle::Cast(info.Callee()->GetName()), func_name); - CefRefPtr object = new CefV8ValueImpl(isolate, info.This()); + CefRefPtr object = + new CefV8ValueImpl(isolate, context, info.This()); CefRefPtr retval; CefString exception; @@ -511,8 +513,8 @@ void FunctionCallbackImpl(const v8::FunctionCallbackInfo& info) { } // V8 Accessor callbacks -void AccessorGetterCallbackImpl( - v8::Local property, +void AccessorNameGetterCallbackImpl( + v8::Local property, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); @@ -527,9 +529,9 @@ void AccessorGetterCallbackImpl( if (accessorPtr.get()) { CefRefPtr retval; - CefRefPtr object = new CefV8ValueImpl(isolate, obj); + CefRefPtr object = new CefV8ValueImpl(isolate, context, obj); CefString name, exception; - GetCefString(property, name); + GetCefString(v8::Local::Cast(property), name); if (accessorPtr->Get(name, object, retval, exception)) { if (!exception.empty()) { info.GetReturnValue().Set( @@ -549,8 +551,8 @@ void AccessorGetterCallbackImpl( return info.GetReturnValue().SetUndefined(); } -void AccessorSetterCallbackImpl( - v8::Local property, +void AccessorNameSetterCallbackImpl( + v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); @@ -565,10 +567,11 @@ void AccessorSetterCallbackImpl( accessorPtr = tracker->GetAccessor(); if (accessorPtr.get()) { - CefRefPtr object = new CefV8ValueImpl(isolate, obj); - CefRefPtr cefValue = new CefV8ValueImpl(isolate, value); + CefRefPtr object = new CefV8ValueImpl(isolate, context, obj); + CefRefPtr cefValue = + new CefV8ValueImpl(isolate, context, value); CefString name, exception; - GetCefString(property, name); + GetCefString(v8::Local::Cast(property), name); accessorPtr->Set(name, object, cefValue, exception); if (!exception.empty()) { isolate->ThrowException( @@ -633,7 +636,8 @@ class ExtensionWrapper : public v8::Extension { class CefV8ExceptionImpl : public CefV8Exception { public: - explicit CefV8ExceptionImpl(v8::Local message) + CefV8ExceptionImpl(v8::Local context, + v8::Local message) : line_number_(0), start_position_(0), end_position_(0), @@ -651,8 +655,8 @@ class CefV8ExceptionImpl : public CefV8Exception { line_number_ = message->GetLineNumber(); start_position_ = message->GetStartPosition(); end_position_ = message->GetEndPosition(); - start_column_ = message->GetStartColumn(); - end_column_ = message->GetEndColumn(); + start_column_ = message->GetStartColumn(context).FromJust(); + end_column_ = message->GetEndColumn(context).FromJust(); } CefString GetMessage() override { return message_; } @@ -694,7 +698,8 @@ void MessageListenerCallbackImpl(v8::Handle message, CefRefPtr stackTrace = new CefV8StackTraceImpl(isolate, v8Stack); - CefRefPtr exception = new CefV8ExceptionImpl(message); + CefRefPtr exception = new CefV8ExceptionImpl( + static_cast(context.get())->GetV8Context(), message); if (CEF_CURRENTLY_ON_RT()) { handler->OnUncaughtException(context->GetBrowser(), context->GetFrame(), @@ -917,7 +922,7 @@ CefRefPtr CefV8ContextImpl::GetGlobal() { v8::HandleScope handle_scope(isolate); v8::Local context = GetV8Context(); v8::Context::Scope context_scope(context); - return new CefV8ValueImpl(isolate, context->Global()); + return new CefV8ValueImpl(isolate, context, context->Global()); } bool CefV8ContextImpl::Enter() { @@ -994,10 +999,10 @@ bool CefV8ContextImpl::Eval(const CefString& code, CallV8Function(context, func, obj, 1, &code_val, handle_->isolate()); if (try_catch.HasCaught()) { - exception = new CefV8ExceptionImpl(try_catch.Message()); + exception = new CefV8ExceptionImpl(context, try_catch.Message()); return false; } else if (!func_rv.IsEmpty()) { - retval = new CefV8ValueImpl(isolate, func_rv.ToLocalChecked()); + retval = new CefV8ValueImpl(isolate, context, func_rv.ToLocalChecked()); } return true; } @@ -1100,13 +1105,13 @@ void CefV8ValueImpl::Handle::SetWeakIfNecessary() { // The added reference will be released in Destructor. AddRef(); - handle_.SetWeak(this, Destructor); + handle_.SetWeak(this, Destructor, v8::WeakCallbackType::kParameter); } } // static void CefV8ValueImpl::Handle::Destructor( - const v8::WeakCallbackData& data) { + const v8::WeakCallbackInfo& data) { data.GetParameter()->Release(); } @@ -1307,12 +1312,13 @@ CefV8ValueImpl::CefV8ValueImpl(v8::Isolate* isolate) } CefV8ValueImpl::CefV8ValueImpl(v8::Isolate* isolate, + v8::Local context, v8::Local value) : isolate_(isolate), type_(TYPE_INVALID), rethrow_exceptions_(false) { DCHECK(isolate_); - InitFromV8Value(value); + InitFromV8Value(context, value); } CefV8ValueImpl::~CefV8ValueImpl() { @@ -1322,7 +1328,8 @@ CefV8ValueImpl::~CefV8ValueImpl() { handle_->SetWeakIfNecessary(); } -void CefV8ValueImpl::InitFromV8Value(v8::Local value) { +void CefV8ValueImpl::InitFromV8Value(v8::Local context, + v8::Local value) { if (value->IsUndefined()) { InitUndefined(); } else if (value->IsNull()) { @@ -1332,16 +1339,17 @@ void CefV8ValueImpl::InitFromV8Value(v8::Local value) { } else if (value->IsFalse()) { InitBool(false); } else if (value->IsBoolean()) { - InitBool(value->ToBoolean()->Value()); + InitBool(value->ToBoolean(context).ToLocalChecked()->Value()); } else if (value->IsInt32()) { - InitInt(value->ToInt32()->Value()); + InitInt(value->ToInt32(context).ToLocalChecked()->Value()); } else if (value->IsUint32()) { - InitUInt(value->ToUint32()->Value()); + InitUInt(value->ToUint32(context).ToLocalChecked()->Value()); } else if (value->IsNumber()) { - InitDouble(value->ToNumber()->Value()); + InitDouble(value->ToNumber(context).ToLocalChecked()->Value()); } else if (value->IsDate()) { // Convert from milliseconds to seconds. - InitDate(CefTime(value->ToNumber()->Value() / 1000)); + InitDate( + CefTime(value->ToNumber(context).ToLocalChecked()->Value() / 1000)); } else if (value->IsString()) { CefString rv; GetCefString(value->ToString(), rv); @@ -1655,9 +1663,16 @@ bool CefV8ValueImpl::HasValue(const CefString& key) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return false; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); - return obj->Has(GetV8String(isolate, key)); + return obj->Has(context, GetV8String(isolate, key)).FromJust(); } bool CefV8ValueImpl::HasValue(int index) { @@ -1668,10 +1683,18 @@ bool CefV8ValueImpl::HasValue(int index) { return false; } - v8::HandleScope handle_scope(handle_->isolate()); + v8::Isolate* isolate = handle_->isolate(); + v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return false; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); - return obj->Has(index); + return obj->Has(context, index).FromJust(); } bool CefV8ValueImpl::DeleteValue(const CefString& key) { @@ -1679,13 +1702,20 @@ bool CefV8ValueImpl::DeleteValue(const CefString& key) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return false; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); bool del = obj->Delete(GetV8String(isolate, key)); - return (!HasCaught(try_catch) && del); + return (!HasCaught(context, try_catch) && del); } bool CefV8ValueImpl::DeleteValue(int index) { @@ -1698,13 +1728,20 @@ bool CefV8ValueImpl::DeleteValue(int index) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return false; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); - bool del = obj->Delete(index); - return (!HasCaught(try_catch) && del); + v8::Maybe del = obj->Delete(context, index); + return (!HasCaught(context, try_catch) && del.FromJust()); } CefRefPtr CefV8ValueImpl::GetValue(const CefString& key) { @@ -1712,14 +1749,21 @@ CefRefPtr CefV8ValueImpl::GetValue(const CefString& key) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return NULL; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); v8::Local ret_value = obj->Get(GetV8String(isolate, key)); - if (!HasCaught(try_catch) && !ret_value.IsEmpty()) - return new CefV8ValueImpl(isolate, ret_value); + if (!HasCaught(context, try_catch) && !ret_value.IsEmpty()) + return new CefV8ValueImpl(isolate, context, ret_value); return NULL; } @@ -1733,14 +1777,21 @@ CefRefPtr CefV8ValueImpl::GetValue(int index) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return NULL; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); v8::Local ret_value = obj->Get(v8::Number::New(isolate, index)); - if (!HasCaught(try_catch) && !ret_value.IsEmpty()) - return new CefV8ValueImpl(isolate, ret_value); + if (!HasCaught(context, try_catch) && !ret_value.IsEmpty()) + return new CefV8ValueImpl(isolate, context, ret_value); return NULL; } @@ -1753,23 +1804,35 @@ bool CefV8ValueImpl::SetValue(const CefString& key, if (impl && impl->IsValid()) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return false; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); - bool set; // TODO(cef): This usage may not exactly match the previous implementation. - // Set will trigger interceptors and/or accessors whereas ForceSet will not. - // It might be better to split this functionality into separate methods. + // Set will trigger interceptors and/or accessors whereas DefineOwnProperty + // will not. It might be better to split this functionality into separate + // methods. if (attribute == V8_PROPERTY_ATTRIBUTE_NONE) { - set = obj->Set(GetV8String(isolate, key), impl->GetV8Value(true)); + v8::Maybe set = obj->Set(context, + GetV8String(isolate, key), + impl->GetV8Value(true)); + return (!HasCaught(context, try_catch) && set.FromJust()); } else { - set = obj->ForceSet(GetV8String(isolate, key), - impl->GetV8Value(true), - static_cast(attribute)); + v8::Maybe set = obj->DefineOwnProperty( + context, + GetV8String(isolate, key), + impl->GetV8Value(true), + static_cast(attribute)); + return (!HasCaught(context, try_catch) && set.FromJust()); } - return (!HasCaught(try_catch) && set); } else { NOTREACHED() << "invalid input parameter"; return false; @@ -1788,13 +1851,20 @@ bool CefV8ValueImpl::SetValue(int index, CefRefPtr value) { if (impl && impl->IsValid()) { v8::Isolate* isolate = handle_->isolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return false; + } + v8::Local value = handle_->GetNewV8Handle(false); v8::Local obj = value->ToObject(); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); - bool set = obj->Set(index, impl->GetV8Value(true)); - return (!HasCaught(try_catch) && set); + v8::Maybe set = obj->Set(context, index, impl->GetV8Value(true)); + return (!HasCaught(context, try_catch) && set.FromJust()); } else { NOTREACHED() << "invalid input parameter"; return false; @@ -1827,17 +1897,18 @@ bool CefV8ValueImpl::SetValue(const CefString& key, AccessControl settings, if (!accessorPtr.get()) return false; - v8::AccessorGetterCallback getter = AccessorGetterCallbackImpl; - v8::AccessorSetterCallback setter = + v8::AccessorNameGetterCallback getter = AccessorNameGetterCallbackImpl; + v8::AccessorNameSetterCallback setter = (attribute & V8_PROPERTY_ATTRIBUTE_READONLY) ? - NULL : AccessorSetterCallbackImpl; + NULL : AccessorNameSetterCallbackImpl; v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); - bool set = obj->SetAccessor(GetV8String(isolate, key), getter, setter, obj, - static_cast(settings), - static_cast(attribute)); - return (!HasCaught(try_catch) && set); + v8::Maybe set = obj->SetAccessor( + context, GetV8String(isolate, key), getter, setter, obj, + static_cast(settings), + static_cast(attribute)); + return (!HasCaught(context, try_catch) && set.FromJust()); } bool CefV8ValueImpl::GetKeys(std::vector& keys) { @@ -2090,8 +2161,10 @@ CefRefPtr CefV8ValueImpl::ExecuteFunctionWithContext( CallV8Function(context_local, func, recv, argc, argv, handle_->isolate()); - if (!HasCaught(try_catch) && !func_rv.IsEmpty()) - retval = new CefV8ValueImpl(isolate, func_rv.ToLocalChecked()); + if (!HasCaught(context_local, try_catch) && !func_rv.IsEmpty()) { + retval = new CefV8ValueImpl(isolate, context_local, + func_rv.ToLocalChecked()); + } } if (argv) @@ -2100,9 +2173,10 @@ CefRefPtr CefV8ValueImpl::ExecuteFunctionWithContext( return retval; } -bool CefV8ValueImpl::HasCaught(v8::TryCatch& try_catch) { +bool CefV8ValueImpl::HasCaught(v8::Local context, + v8::TryCatch& try_catch) { if (try_catch.HasCaught()) { - last_exception_ = new CefV8ExceptionImpl(try_catch.Message()); + last_exception_ = new CefV8ExceptionImpl(context, try_catch.Message()); if (rethrow_exceptions_) try_catch.ReThrow(); return true; diff --git a/libcef/renderer/v8_impl.h b/libcef/renderer/v8_impl.h index e773cbb20..9956b4f77 100644 --- a/libcef/renderer/v8_impl.h +++ b/libcef/renderer/v8_impl.h @@ -205,12 +205,14 @@ class CefV8ValueImpl : public CefV8Value { public: explicit CefV8ValueImpl(v8::Isolate* isolate); CefV8ValueImpl(v8::Isolate* isolate, + v8::Local context, v8::Local value); ~CefV8ValueImpl() override; // Used for initializing the CefV8ValueImpl. Should be called a single time // after the CefV8ValueImpl is created. - void InitFromV8Value(v8::Local value); + void InitFromV8Value(v8::Local context, + v8::Local value); void InitUndefined(); void InitNull(); void InitBool(bool value); @@ -279,7 +281,7 @@ class CefV8ValueImpl : public CefV8Value { protected: // Test for and record any exception. - bool HasCaught(v8::TryCatch& try_catch); + bool HasCaught(v8::Local context, v8::TryCatch& try_catch); class Handle : public CefV8HandleBase { public: @@ -302,7 +304,7 @@ class CefV8ValueImpl : public CefV8Value { private: // Callback for weak persistent reference destruction. - static void Destructor(const v8::WeakCallbackData& data); + static void Destructor(const v8::WeakCallbackInfo& data); persistentType handle_; diff --git a/libcef/renderer/webkit_glue.cc b/libcef/renderer/webkit_glue.cc index 09663850a..55f7c4057 100644 --- a/libcef/renderer/webkit_glue.cc +++ b/libcef/renderer/webkit_glue.cc @@ -39,7 +39,7 @@ MSVC_POP_WARNING(); namespace webkit_glue { -const int64 kInvalidFrameId = -1; +const int64_t kInvalidFrameId = -1; bool CanGoBack(blink::WebView* view) { if (!view) @@ -123,7 +123,7 @@ bool SetNodeValue(blink::WebNode& node, const blink::WebString& value) { return true; } -int64 GetIdentifier(blink::WebFrame* frame) { +int64_t GetIdentifier(blink::WebFrame* frame) { // Each WebFrame will have an associated RenderFrame. The RenderFrame // routing IDs are unique within a given renderer process. content::RenderFrame* render_frame = diff --git a/libcef/renderer/webkit_glue.h b/libcef/renderer/webkit_glue.h index ee2d0baaf..959093ae1 100644 --- a/libcef/renderer/webkit_glue.h +++ b/libcef/renderer/webkit_glue.h @@ -6,8 +6,10 @@ #ifndef CEF_LIBCEF_RENDERER_WEBKIT_GLUE_H_ #define CEF_LIBCEF_RENDERER_WEBKIT_GLUE_H_ +#include + #include -#include "base/basictypes.h" + #include "third_party/skia/include/core/SkColor.h" #include "include/internal/cef_types.h" @@ -21,7 +23,7 @@ class WebView; namespace webkit_glue { -extern const int64 kInvalidFrameId; +extern const int64_t kInvalidFrameId; bool CanGoBack(blink::WebView* view); bool CanGoForward(blink::WebView* view); @@ -37,7 +39,7 @@ blink::WebString GetNodeName(const blink::WebNode& node); blink::WebString CreateNodeMarkup(const blink::WebNode& node); bool SetNodeValue(blink::WebNode& node, const blink::WebString& value); -int64 GetIdentifier(blink::WebFrame* frame); +int64_t GetIdentifier(blink::WebFrame* frame); // Find the frame with the specified |unique_name| relative to // |relative_to_frame| in the frame hierarchy. diff --git a/libcef/utility/content_utility_client.cc b/libcef/utility/content_utility_client.cc index 918c335bb..150379b4b 100644 --- a/libcef/utility/content_utility_client.cc +++ b/libcef/utility/content_utility_client.cc @@ -5,6 +5,9 @@ #include "libcef/utility/content_utility_client.h" +#include + +#include "build/build_config.h" #include "chrome/common/chrome_utility_messages.h" #include "chrome/utility/utility_message_handler.h" #include "content/public/common/service_registry.h" @@ -28,7 +31,7 @@ void CreateProxyResolverFactory( // is connected to. When that message pipe is closed, either explicitly on the // other end (in the browser process), or by a connection error, this object // will be destroyed. - new net::MojoProxyResolverFactoryImpl(request.Pass()); + new net::MojoProxyResolverFactoryImpl(std::move(request)); } } // namespace diff --git a/libcef/utility/printing_handler.cc b/libcef/utility/printing_handler.cc index b00f71727..fe0b77735 100644 --- a/libcef/utility/printing_handler.cc +++ b/libcef/utility/printing_handler.cc @@ -4,10 +4,15 @@ #include "libcef/utility/printing_handler.h" +#include + +#include + #include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/path_service.h" #include "base/scoped_native_library.h" +#include "build/build_config.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_utility_printing_messages.h" #include "content/public/utility/utility_thread.h" @@ -58,7 +63,7 @@ void PrintingHandler::OnRenderPDFPagesToMetafile( const printing::PdfRenderSettings& settings) { pdf_rendering_settings_ = settings; base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit); - int page_count = LoadPDF(pdf_file.Pass()); + int page_count = LoadPDF(std::move(pdf_file)); Send( new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount(page_count)); } @@ -69,7 +74,7 @@ void PrintingHandler::OnRenderPDFPagesToMetafileGetPage( base::File emf_file = IPC::PlatformFileForTransitToFile(output_file); double scale_factor = 1.0; bool success = - RenderPdfPageToMetafile(page_number, emf_file.Pass(), &scale_factor); + RenderPdfPageToMetafile(page_number, std::move(emf_file), &scale_factor); Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone( success, scale_factor)); } @@ -79,7 +84,7 @@ void PrintingHandler::OnRenderPDFPagesToMetafileStop() { } int PrintingHandler::LoadPDF(base::File pdf_file) { - int64 length = pdf_file.GetLength(); + int64_t length = pdf_file.GetLength(); if (length < 0) return 0; diff --git a/patch/patch.cfg b/patch/patch.cfg index 4c7fc4ac6..87e779b55 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -36,13 +36,14 @@ patches = [ { # Fix ninja output for localization directories on OS X. # http://code.google.com/p/gyp/issues/detail?id=331 - # Improve error reporting when MSVS configuration fails on Windows. - # https://code.google.com/p/gyp/issues/detail?id=471 'name': 'gyp_331', 'path': '../tools/gyp/pylib/', }, { # Enable popups in offscreen rendering on OS X. + # + # Fix dismissal of select popups on blur with OSR. + # https://codereview.chromium.org/1565053002 'name': 'webkit_popups', 'path': '../third_party/WebKit/', }, diff --git a/patch/patches/browser_frame_host_guest_1687.patch b/patch/patches/browser_frame_host_guest_1687.patch index 73dc02fd8..93880b6aa 100644 --- a/patch/patches/browser_frame_host_guest_1687.patch +++ b/patch/patches/browser_frame_host_guest_1687.patch @@ -1,8 +1,8 @@ diff --git render_widget_host_view_guest.cc render_widget_host_view_guest.cc -index 8971b07f..f37aa2a 100644 +index 6d4a181..952a058 100644 --- render_widget_host_view_guest.cc +++ render_widget_host_view_guest.cc -@@ -191,6 +191,9 @@ void RenderWidgetHostViewGuest::Destroy() { +@@ -218,6 +218,9 @@ void RenderWidgetHostViewGuest::Destroy() { } gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { diff --git a/patch/patches/browser_plugin_guest_1565.patch b/patch/patches/browser_plugin_guest_1565.patch index f06f89d4a..3712fd5e9 100644 --- a/patch/patches/browser_plugin_guest_1565.patch +++ b/patch/patches/browser_plugin_guest_1565.patch @@ -1,8 +1,8 @@ diff --git browser/browser_plugin/browser_plugin_guest.cc browser/browser_plugin/browser_plugin_guest.cc -index 61dbe6c..59d1673 100644 +index 33262a8..5da1220 100644 --- browser/browser_plugin/browser_plugin_guest.cc +++ browser/browser_plugin/browser_plugin_guest.cc -@@ -23,7 +23,7 @@ +@@ -27,7 +27,7 @@ #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/web_contents/web_contents_impl.h" @@ -11,7 +11,7 @@ index 61dbe6c..59d1673 100644 #include "content/common/browser_plugin/browser_plugin_constants.h" #include "content/common/browser_plugin/browser_plugin_messages.h" #include "content/common/content_constants_internal.h" -@@ -290,20 +290,19 @@ void BrowserPluginGuest::InitInternal( +@@ -294,20 +294,19 @@ void BrowserPluginGuest::InitInternal( guest_window_rect_ = params.view_rect; if (owner_web_contents_ != owner_web_contents) { @@ -36,7 +36,7 @@ index 61dbe6c..59d1673 100644 } RendererPreferences* renderer_prefs = -@@ -787,11 +786,10 @@ void BrowserPluginGuest::OnWillAttachComplete( +@@ -791,11 +790,10 @@ void BrowserPluginGuest::OnWillAttachComplete( static_cast(GetWebContents()->GetRenderViewHost()) ->GetWidget() ->Init(); diff --git a/patch/patches/browser_web_contents_1257.patch b/patch/patches/browser_web_contents_1257.patch index f27671eb7..9221c3d9b 100644 --- a/patch/patches/browser_web_contents_1257.patch +++ b/patch/patches/browser_web_contents_1257.patch @@ -1,8 +1,8 @@ diff --git web_contents_impl.cc web_contents_impl.cc -index 18589f1..85f57e4 100644 +index 88f58a7..9e454db 100644 --- web_contents_impl.cc +++ web_contents_impl.cc -@@ -1383,30 +1383,38 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -1366,32 +1366,40 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { main_frame_widget_routing_id); frame_tree_.root()->SetFrameName(params.main_frame_name); @@ -12,54 +12,57 @@ index 18589f1..85f57e4 100644 + view_.reset(params.view); + render_view_host_delegate_view_ = params.delegate_view; + } - -- view_.reset( -- CreateWebContentsView(this, delegate, &render_view_host_delegate_view_)); ++ + if (!view_) { + WebContentsViewDelegate* delegate = + GetContentClient()->browser()->GetWebContentsViewDelegate(this); -- if (browser_plugin_guest_ && -- !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { -- view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), -- view_.Pass(), -- &render_view_host_delegate_view_)); -- } -+ view_.reset( -+ CreateWebContentsView(this, delegate, -+ &render_view_host_delegate_view_)); -+ -+ if (browser_plugin_guest_ && -+ !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { -+ view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), -+ view_.Pass(), -+ &render_view_host_delegate_view_)); -+ } - #if defined(MOJO_SHELL_CLIENT) - if (MojoShellConnection::Get() && - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseMusInRenderer)) { -- mus::Window* window = aura::GetMusWindow(params.context); -- if (window) { -- view_.reset(new WebContentsViewMus(this, window, view_.Pass(), +- mus::Window* mus_window = aura::GetMusWindow(params.context); +- if (mus_window) { +- view_.reset(new WebContentsViewMus(mus_window, this, delegate, - &render_view_host_delegate_view_)); + if (MojoShellConnection::Get() && + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUseMusInRenderer)) { -+ mus::Window* window = aura::GetMusWindow(params.context); -+ if (window) { -+ view_.reset(new WebContentsViewMus(this, window, view_.Pass(), ++ mus::Window* mus_window = aura::GetMusWindow(params.context); ++ if (mus_window) { ++ view_.reset(new WebContentsViewMus(mus_window, this, delegate, + &render_view_host_delegate_view_)); + } } - } #endif -+ } +- if (!view_) { +- view_.reset(CreateWebContentsView(this, delegate, +- &render_view_host_delegate_view_)); +- } ++ if (!view_) { ++ view_.reset(CreateWebContentsView(this, delegate, ++ &render_view_host_delegate_view_)); ++ } + +- if (browser_plugin_guest_ && +- !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { +- view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), +- std::move(view_), +- &render_view_host_delegate_view_)); ++ if (browser_plugin_guest_ && ++ !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { ++ view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), ++ std::move(view_), ++ &render_view_host_delegate_view_)); ++ } + } ++ CHECK(render_view_host_delegate_view_); CHECK(view_.get()); -@@ -1810,11 +1818,14 @@ void WebContentsImpl::CreateNewWindow( + +@@ -1806,11 +1814,14 @@ void WebContentsImpl::CreateNewWindow( static_cast(session_storage_namespace); CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); @@ -75,7 +78,7 @@ index 18589f1..85f57e4 100644 if (route_id != MSG_ROUTING_NONE && !RenderViewHost::FromID(render_process_id, route_id)) { // If the embedder didn't create a WebContents for this route, we need to -@@ -1839,6 +1850,8 @@ void WebContentsImpl::CreateNewWindow( +@@ -1831,6 +1842,8 @@ void WebContentsImpl::CreateNewWindow( create_params.opener_render_process_id = render_process_id; create_params.opener_render_frame_id = params.opener_render_frame_id; create_params.opener_suppressed = params.opener_suppressed; diff --git a/patch/patches/build.patch b/patch/patches/build.patch index d6073e66f..db601ae1e 100644 --- a/patch/patches/build.patch +++ b/patch/patches/build.patch @@ -1,5 +1,5 @@ diff --git common.gypi common.gypi -index 6b2cb0a..2bc614d 100644 +index 577a95c..4c1cbfe 100644 --- common.gypi +++ common.gypi @@ -9,6 +9,9 @@ diff --git a/patch/patches/chrome_browser_1257.patch b/patch/patches/chrome_browser_1257.patch index 766a10d0c..ea72277a7 100644 --- a/patch/patches/chrome_browser_1257.patch +++ b/patch/patches/chrome_browser_1257.patch @@ -1,8 +1,8 @@ diff --git ui/browser.cc ui/browser.cc -index c633924..b93d698 100644 +index 1f41d7c..7ebcc2d 100644 --- ui/browser.cc +++ ui/browser.cc -@@ -1677,7 +1677,9 @@ bool Browser::ShouldCreateWebContents( +@@ -1708,7 +1708,9 @@ bool Browser::ShouldCreateWebContents( const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -14,10 +14,10 @@ index c633924..b93d698 100644 // If a BackgroundContents is created, suppress the normal WebContents. return !MaybeCreateBackgroundContents( diff --git ui/browser.h ui/browser.h -index 1511788..23ffe53 100644 +index e3f6b883..1861b68 100644 --- ui/browser.h +++ ui/browser.h -@@ -591,7 +591,9 @@ class Browser : public TabStripModelObserver, +@@ -598,7 +598,9 @@ class Browser : public TabStripModelObserver, const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/patch/patches/chrome_pepper_flash_1586.patch b/patch/patches/chrome_pepper_flash_1586.patch index 8b8c9efc4..782e10792 100644 --- a/patch/patches/chrome_pepper_flash_1586.patch +++ b/patch/patches/chrome_pepper_flash_1586.patch @@ -1,8 +1,8 @@ diff --git pepper_flash.cc pepper_flash.cc -index 16b4328..63b21c1 100644 +index 3b6cbd9..d4ba7ed 100644 --- pepper_flash.cc +++ pepper_flash.cc -@@ -119,8 +119,15 @@ bool CheckPepperFlashManifest(const base::DictionaryValue& manifest, +@@ -121,8 +121,15 @@ bool CheckPepperFlashManifest(const base::DictionaryValue& manifest, std::string arch; manifest.GetStringASCII("x-ppapi-arch", &arch); diff --git a/patch/patches/compositor_1368.patch b/patch/patches/compositor_1368.patch index fa47c9787..21de67cf6 100644 --- a/patch/patches/compositor_1368.patch +++ b/patch/patches/compositor_1368.patch @@ -1,8 +1,8 @@ diff --git content/browser/compositor/gpu_process_transport_factory.cc content/browser/compositor/gpu_process_transport_factory.cc -index 1ae2b11..2379d27 100644 +index 51099ca..af38404 100644 --- content/browser/compositor/gpu_process_transport_factory.cc +++ content/browser/compositor/gpu_process_transport_factory.cc -@@ -136,6 +136,13 @@ GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { +@@ -138,6 +138,13 @@ GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { scoped_ptr GpuProcessTransportFactory::CreateSoftwareOutputDevice( ui::Compositor* compositor) { @@ -17,10 +17,10 @@ index 1ae2b11..2379d27 100644 if (IsRunningInMojoShell()) { return scoped_ptr( diff --git ui/compositor/compositor.h ui/compositor/compositor.h -index 1602d30..3dd3e3e 100644 +index 5222b41..04856b6 100644 --- ui/compositor/compositor.h +++ ui/compositor/compositor.h -@@ -14,6 +14,7 @@ +@@ -17,6 +17,7 @@ #include "base/single_thread_task_runner.h" #include "base/time/time.h" #include "cc/output/begin_frame_args.h" @@ -28,7 +28,7 @@ index 1602d30..3dd3e3e 100644 #include "cc/surfaces/surface_sequence.h" #include "cc/trees/layer_tree_host_client.h" #include "cc/trees/layer_tree_host_single_thread_client.h" -@@ -148,6 +149,17 @@ class COMPOSITOR_EXPORT CompositorBeginFrameObserver { +@@ -152,6 +153,17 @@ class COMPOSITOR_EXPORT CompositorBeginFrameObserver { virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) = 0; }; @@ -46,7 +46,7 @@ index 1602d30..3dd3e3e 100644 // Compositor object to take care of GPU painting. // A Browser compositor object is responsible for generating the final // displayable form of pixels comprising a single widget's contents. It draws an -@@ -168,6 +180,9 @@ class COMPOSITOR_EXPORT Compositor +@@ -172,6 +184,9 @@ class COMPOSITOR_EXPORT Compositor // Schedules a redraw of the layer tree associated with this compositor. void ScheduleDraw(); @@ -56,7 +56,7 @@ index 1602d30..3dd3e3e 100644 // Sets the root of the layer tree drawn by this Compositor. The root layer // must have no parent. The compositor's root layer is reset if the root layer // is destroyed. NULL can be passed to reset the root layer, in which case the -@@ -338,6 +353,8 @@ class COMPOSITOR_EXPORT Compositor +@@ -344,6 +359,8 @@ class COMPOSITOR_EXPORT Compositor ui::ContextFactory* context_factory_; diff --git a/patch/patches/content_nav_1129.patch b/patch/patches/content_nav_1129.patch index 1785b1225..2d7294611 100644 --- a/patch/patches/content_nav_1129.patch +++ b/patch/patches/content_nav_1129.patch @@ -22,10 +22,10 @@ index 32004d1..ccd1f58 100644 const GURL& url, const std::string& http_method, diff --git public/renderer/content_renderer_client.h public/renderer/content_renderer_client.h -index 59d448c..ef15ff1 100644 +index fd2f3af..40cca1d 100644 --- public/renderer/content_renderer_client.h +++ public/renderer/content_renderer_client.h -@@ -16,6 +16,8 @@ +@@ -18,6 +18,8 @@ #include "base/strings/string16.h" #include "content/public/common/content_client.h" #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" @@ -34,7 +34,7 @@ index 59d448c..ef15ff1 100644 #include "ui/base/page_transition_types.h" #include "v8/include/v8.h" -@@ -189,6 +191,17 @@ class CONTENT_EXPORT ContentRendererClient { +@@ -191,6 +193,17 @@ class CONTENT_EXPORT ContentRendererClient { // Returns true if a popup window should be allowed. virtual bool AllowPopup(); @@ -53,10 +53,10 @@ index 59d448c..ef15ff1 100644 // Returns true if we should fork a new process for the given navigation. // If |send_referrer| is set to false (which is the default), no referrer diff --git renderer/render_frame_impl.cc renderer/render_frame_impl.cc -index 314fe7b..c519785 100644 +index 9ea32c4..adb478d 100644 --- renderer/render_frame_impl.cc +++ renderer/render_frame_impl.cc -@@ -4440,6 +4440,14 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( +@@ -4609,6 +4609,14 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( (pending_navigation_params_ && !pending_navigation_params_->request_params.redirects.empty()); diff --git a/patch/patches/content_pepper_flash_1586.patch b/patch/patches/content_pepper_flash_1586.patch index 6fe2bee28..0f8d5ee6d 100644 --- a/patch/patches/content_pepper_flash_1586.patch +++ b/patch/patches/content_pepper_flash_1586.patch @@ -1,8 +1,8 @@ diff --git pepper_flash_file_message_filter.cc pepper_flash_file_message_filter.cc -index 48da55d..2bbb939 100644 +index 3059dd7..b327be5 100644 --- pepper_flash_file_message_filter.cc +++ pepper_flash_file_message_filter.cc -@@ -53,7 +53,7 @@ PepperFlashFileMessageFilter::PepperFlashFileMessageFilter( +@@ -55,7 +55,7 @@ PepperFlashFileMessageFilter::PepperFlashFileMessageFilter( // will construct a bad path and could provide access to the wrong files. // In this case, |plugin_data_directory_| will remain unset and // |ValidateAndConvertPepperFilePath| will fail. diff --git a/patch/patches/extensions_1257.patch b/patch/patches/extensions_1257.patch index f40beeee2..a8931f644 100644 --- a/patch/patches/extensions_1257.patch +++ b/patch/patches/extensions_1257.patch @@ -1,8 +1,8 @@ diff --git browser/guest_view/extension_options/extension_options_guest.cc browser/guest_view/extension_options/extension_options_guest.cc -index 5806540..6d1a8a7 100644 +index f594ade..f71e7ed 100644 --- browser/guest_view/extension_options/extension_options_guest.cc +++ browser/guest_view/extension_options/extension_options_guest.cc -@@ -200,7 +200,9 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents( +@@ -202,7 +202,9 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents( const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -14,10 +14,10 @@ index 5806540..6d1a8a7 100644 // view is used for displaying embedded extension options, we want any // external links to be opened in a new tab, not in a new guest view. diff --git browser/guest_view/extension_options/extension_options_guest.h browser/guest_view/extension_options/extension_options_guest.h -index 922d670..cb19e4e 100644 +index b81fe41..41e3e2a 100644 --- browser/guest_view/extension_options/extension_options_guest.h +++ browser/guest_view/extension_options/extension_options_guest.h -@@ -54,7 +54,9 @@ class ExtensionOptionsGuest +@@ -56,7 +56,9 @@ class ExtensionOptionsGuest const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/patch/patches/font_family_cache_1501.patch b/patch/patches/font_family_cache_1501.patch index dbf0daefe..fadd480ec 100644 --- a/patch/patches/font_family_cache_1501.patch +++ b/patch/patches/font_family_cache_1501.patch @@ -1,8 +1,8 @@ diff --git font_family_cache.h font_family_cache.h -index d5ff699..71fa27b 100644 +index 306cbf0..6ca443c 100644 --- font_family_cache.h +++ font_family_cache.h -@@ -19,6 +19,8 @@ class Profile; +@@ -20,6 +20,8 @@ class Profile; FORWARD_DECLARE_TEST(FontFamilyCacheTest, Caching); diff --git a/patch/patches/gritsettings.patch b/patch/patches/gritsettings.patch index 474bcdd26..f8533a179 100644 --- a/patch/patches/gritsettings.patch +++ b/patch/patches/gritsettings.patch @@ -1,5 +1,5 @@ diff --git resource_ids resource_ids -index 6f53f31..21b5454 100644 +index 93949e3..5552faf 100644 --- resource_ids +++ resource_ids @@ -14,6 +14,12 @@ diff --git a/patch/patches/gyp_331.patch b/patch/patches/gyp_331.patch index 5bfbdd450..b2b768a35 100644 --- a/patch/patches/gyp_331.patch +++ b/patch/patches/gyp_331.patch @@ -1,5 +1,5 @@ diff --git gyp/generator/ninja.py gyp/generator/ninja.py -index 907542b..4d77af4 100644 +index d8a45c7..3dd5518 100644 --- gyp/generator/ninja.py +++ gyp/generator/ninja.py @@ -745,7 +745,16 @@ class NinjaWriter(object): @@ -20,19 +20,3 @@ index 907542b..4d77af4 100644 src = self.GypPathToNinja(path, env) dst = self.GypPathToNinja(os.path.join(copy['destination'], basename), env) -diff --git gyp/msvs_emulation.py gyp/msvs_emulation.py -index ca67b12..a3fd903 100644 ---- gyp/msvs_emulation.py -+++ gyp/msvs_emulation.py -@@ -1027,8 +1027,10 @@ def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags, - args = vs.SetupScript(arch) - args.extend(('&&', 'set')) - popen = subprocess.Popen( -- args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) -+ args, shell=True, stdout=subprocess.PIPE) - variables, _ = popen.communicate() -+ if popen.returncode != 0: -+ raise Exception('Error invoking setup script: ' + repr(args)) - env = _ExtractImportantEnvironment(variables) - - # Inject system includes from gyp files into INCLUDE. diff --git a/patch/patches/hwnd_message_handler_1481.patch b/patch/patches/hwnd_message_handler_1481.patch index e01926b99..0731af095 100644 --- a/patch/patches/hwnd_message_handler_1481.patch +++ b/patch/patches/hwnd_message_handler_1481.patch @@ -1,8 +1,8 @@ diff --git hwnd_message_handler.cc hwnd_message_handler.cc -index b5bd8a8..997c4da 100644 +index 86ed8f8..8fb17b5 100644 --- hwnd_message_handler.cc +++ hwnd_message_handler.cc -@@ -2381,8 +2381,12 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, +@@ -2382,8 +2382,12 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, active_mouse_tracking_flags_ = 0; } else if (event.type() == ui::ET_MOUSEWHEEL) { // Reroute the mouse wheel to the window under the pointer if applicable. diff --git a/patch/patches/ime_1610.patch b/patch/patches/ime_1610.patch index 1ad56f033..3fea88932 100644 --- a/patch/patches/ime_1610.patch +++ b/patch/patches/ime_1610.patch @@ -1,8 +1,8 @@ diff --git input_method_win.cc input_method_win.cc -index ef500a7..5454067 100644 +index 56bbac1..3265c64 100644 --- input_method_win.cc +++ input_method_win.cc -@@ -586,8 +586,9 @@ bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const { +@@ -588,8 +588,9 @@ bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const { // receiving keyboard input as long as it is an active window. This works well // even when the |attached_window_handle| becomes active but has not received // WM_FOCUS yet. diff --git a/patch/patches/message_loop_443.patch b/patch/patches/message_loop_443.patch index 27e8da5a4..13c3b6f06 100644 --- a/patch/patches/message_loop_443.patch +++ b/patch/patches/message_loop_443.patch @@ -1,8 +1,8 @@ diff --git message_loop.cc message_loop.cc -index a0c5f61..a3033dc 100644 +index cfa86d9..6775c3d 100644 --- message_loop.cc +++ message_loop.cc -@@ -136,12 +136,6 @@ MessageLoop::~MessageLoop() { +@@ -137,12 +137,6 @@ MessageLoop::~MessageLoop() { // bound to a thread. DCHECK(current() == this || !current()); diff --git a/patch/patches/mime_handler_view_1565.patch b/patch/patches/mime_handler_view_1565.patch index e1f892c66..a951953da 100644 --- a/patch/patches/mime_handler_view_1565.patch +++ b/patch/patches/mime_handler_view_1565.patch @@ -1,8 +1,8 @@ diff --git mime_handler_view_guest.cc mime_handler_view_guest.cc -index 1f9ebfb..37c2217 100644 +index d704b9f..00d3c3f 100644 --- mime_handler_view_guest.cc +++ mime_handler_view_guest.cc -@@ -132,6 +132,8 @@ void MimeHandlerViewGuest::CreateWebContents( +@@ -134,6 +134,8 @@ void MimeHandlerViewGuest::CreateWebContents( WebContents::CreateParams params(browser_context(), guest_site_instance.get()); params.guest_delegate = this; @@ -11,7 +11,7 @@ index 1f9ebfb..37c2217 100644 callback.Run(WebContents::Create(params)); } -@@ -156,6 +158,30 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const { +@@ -158,6 +160,30 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const { return false; } @@ -43,10 +43,10 @@ index 1f9ebfb..37c2217 100644 WebContents* source, const content::OpenURLParams& params) { diff --git mime_handler_view_guest.h mime_handler_view_guest.h -index a876f6a..4808aa3 100644 +index 4618d9f..84a621b 100644 --- mime_handler_view_guest.h +++ mime_handler_view_guest.h -@@ -74,6 +74,15 @@ class MimeHandlerViewGuest : +@@ -75,6 +75,15 @@ class MimeHandlerViewGuest : bool ShouldHandleFindRequestsForEmbedder() const final; bool ZoomPropagatesFromEmbedderToGuest() const final; diff --git a/patch/patches/net_filter_515.patch b/patch/patches/net_filter_515.patch index 2019ebd0f..f2ca10620 100644 --- a/patch/patches/net_filter_515.patch +++ b/patch/patches/net_filter_515.patch @@ -1,5 +1,5 @@ diff --git base/network_delegate.h base/network_delegate.h -index 979d3ec..0ccfd16 100644 +index 0737137..60cfcd717 100644 --- base/network_delegate.h +++ base/network_delegate.h @@ -35,6 +35,7 @@ namespace net { @@ -25,10 +25,10 @@ index 979d3ec..0ccfd16 100644 // This is the interface for subclasses of NetworkDelegate to implement. These // member functions will be called by the respective public notification diff --git filter/filter.h filter/filter.h -index 1904a8c..8d5f1ec 100644 +index e9df3db..768b7fc 100644 --- filter/filter.h +++ filter/filter.h -@@ -57,6 +57,7 @@ +@@ -59,6 +59,7 @@ #include "net/base/net_export.h" #include "net/base/sdch_manager.h" @@ -36,19 +36,19 @@ index 1904a8c..8d5f1ec 100644 class GURL; namespace net { -@@ -231,6 +232,7 @@ class NET_EXPORT_PRIVATE Filter { +@@ -234,6 +235,7 @@ class NET_EXPORT_PRIVATE Filter { std::string OrderedFilterList() const; protected: + friend class ::CefNetworkDelegate; + friend class BrotliUnitTest; friend class GZipUnitTest; friend class SdchFilterChainingTest; - FRIEND_TEST_ALL_PREFIXES(FilterTest, ThreeFilterChain); diff --git url_request/url_request_job.cc url_request/url_request_job.cc -index fc9f4a9..4f6dbcc 100644 +index 55a4f51..937f163 100644 --- url_request/url_request_job.cc +++ url_request/url_request_job.cc -@@ -472,6 +472,9 @@ void URLRequestJob::NotifyHeadersComplete() { +@@ -447,6 +447,9 @@ void URLRequestJob::NotifyHeadersComplete() { if (request_->status().is_success()) filter_.reset(SetupFilter()); diff --git a/patch/patches/net_urlrequest_1327.patch b/patch/patches/net_urlrequest_1327.patch index f1c70dc2d..aefc90420 100644 --- a/patch/patches/net_urlrequest_1327.patch +++ b/patch/patches/net_urlrequest_1327.patch @@ -1,8 +1,8 @@ diff --git url_request.h url_request.h -index 33b2859..44cca91 100644 +index ea6a54d..2c98007 100644 --- url_request.h +++ url_request.h -@@ -653,10 +653,10 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), +@@ -652,10 +652,10 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), // or after the response headers are received. void GetConnectionAttempts(ConnectionAttempts* out) const; diff --git a/patch/patches/pdfium_print_549365.patch b/patch/patches/pdfium_print_549365.patch index 96cdb227a..dfe80d70a 100644 --- a/patch/patches/pdfium_print_549365.patch +++ b/patch/patches/pdfium_print_549365.patch @@ -1,16 +1,16 @@ diff --git fpdfsdk/src/fpdfview.cpp fpdfsdk/src/fpdfview.cpp -index fcb6731..0c92fe5 100644 +index 041adda..407cbba 100644 --- fpdfsdk/src/fpdfview.cpp +++ fpdfsdk/src/fpdfview.cpp -@@ -12,6 +12,7 @@ +@@ -14,6 +14,7 @@ #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/fsdk_rendercontext.h" #include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/include/jsapi/fxjs_v8.h" #include "public/fpdf_ext.h" #include "public/fpdf_progressive.h" - #include "third_party/base/nonstd_unique_ptr.h" -@@ -117,6 +118,7 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( + #include "third_party/base/numerics/safe_conversions_impl.h" +@@ -116,6 +117,7 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( DLLEXPORT void STDCALL FPDF_DestroyLibrary() { CPDF_ModuleMgr::Destroy(); CFX_GEModule::Destroy(); diff --git a/patch/patches/prefs_content_1161.patch b/patch/patches/prefs_content_1161.patch index 011f70137..cad93c210 100644 --- a/patch/patches/prefs_content_1161.patch +++ b/patch/patches/prefs_content_1161.patch @@ -1,8 +1,8 @@ diff --git public/common/common_param_traits_macros.h public/common/common_param_traits_macros.h -index f71d867..c9d82fd 100644 +index e836e1b..f261e0d 100644 --- public/common/common_param_traits_macros.h +++ public/common/common_param_traits_macros.h -@@ -191,6 +191,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) +@@ -193,6 +193,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(main_frame_resizes_are_orientation_changes) IPC_STRUCT_TRAITS_MEMBER(initialize_at_minimum_page_scale) IPC_STRUCT_TRAITS_MEMBER(smart_insert_delete_enabled) @@ -11,10 +11,10 @@ index f71d867..c9d82fd 100644 IPC_STRUCT_TRAITS_MEMBER(navigate_on_drag_drop) IPC_STRUCT_TRAITS_MEMBER(spatial_navigation_enabled) diff --git public/common/web_preferences.cc public/common/web_preferences.cc -index a86de33..6129690 100644 +index c887f9a8..873ed91 100644 --- public/common/web_preferences.cc +++ public/common/web_preferences.cc -@@ -170,6 +170,7 @@ WebPreferences::WebPreferences() +@@ -171,6 +171,7 @@ WebPreferences::WebPreferences() pinch_overlay_scrollbar_thickness(0), use_solid_color_scrollbars(false), navigate_on_drag_drop(true), @@ -23,10 +23,10 @@ index a86de33..6129690 100644 slimming_paint_v2_enabled(false), cookie_enabled(true), diff --git public/common/web_preferences.h public/common/web_preferences.h -index eb8f77e..6616a39 100644 +index fc1ee14..5094abb 100644 --- public/common/web_preferences.h +++ public/common/web_preferences.h -@@ -168,6 +168,7 @@ struct CONTENT_EXPORT WebPreferences { +@@ -172,6 +172,7 @@ struct CONTENT_EXPORT WebPreferences { int pinch_overlay_scrollbar_thickness; bool use_solid_color_scrollbars; bool navigate_on_drag_drop; @@ -35,10 +35,10 @@ index eb8f77e..6616a39 100644 bool slimming_paint_v2_enabled; diff --git renderer/render_view_impl.cc renderer/render_view_impl.cc -index a5aa817..e02557b 100644 +index 00c278e..4435b20 100644 --- renderer/render_view_impl.cc +++ renderer/render_view_impl.cc -@@ -941,6 +941,8 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs, +@@ -939,6 +939,8 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs, settings->setCookieEnabled(prefs.cookie_enabled); settings->setNavigateOnDragDrop(prefs.navigate_on_drag_drop); diff --git a/patch/patches/prefs_tab_helper_1680.patch b/patch/patches/prefs_tab_helper_1680.patch index 8c366d2e0..328bab199 100644 --- a/patch/patches/prefs_tab_helper_1680.patch +++ b/patch/patches/prefs_tab_helper_1680.patch @@ -1,17 +1,17 @@ diff --git prefs_tab_helper.cc prefs_tab_helper.cc -index 1eb1268..aa4b840 100644 +index ee406db..fc86170 100644 --- prefs_tab_helper.cc +++ prefs_tab_helper.cc -@@ -7,7 +7,7 @@ - #include - #include +@@ -12,7 +12,7 @@ + #include "base/command_line.h" + #include "base/macros.h" -#include "base/memory/singleton.h" +#include "base/lazy_instance.h" + #include "base/metrics/field_trial.h" #include "base/prefs/overlay_user_pref_store.h" #include "base/prefs/pref_change_registrar.h" - #include "base/prefs/pref_service.h" -@@ -415,12 +415,10 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { +@@ -431,12 +431,10 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { GetInstance()->GetServiceForBrowserContext(profile, true)); } @@ -26,7 +26,7 @@ index 1eb1268..aa4b840 100644 PrefWatcherFactory() : BrowserContextKeyedServiceFactory( "PrefWatcher", -@@ -441,6 +439,18 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { +@@ -457,6 +455,18 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { } }; diff --git a/patch/patches/print_header_footer_1478_1565.patch b/patch/patches/print_header_footer_1478_1565.patch index 5acf36c13..6047350ae 100644 --- a/patch/patches/print_header_footer_1478_1565.patch +++ b/patch/patches/print_header_footer_1478_1565.patch @@ -1,8 +1,8 @@ diff --git printing/renderer/print_web_view_helper.cc printing/renderer/print_web_view_helper.cc -index f2dc502..c0049d0 100644 +index c09ad6a..2a92296 100644 --- printing/renderer/print_web_view_helper.cc +++ printing/renderer/print_web_view_helper.cc -@@ -74,6 +74,9 @@ const double kMinDpi = 1.0; +@@ -79,6 +79,9 @@ const double kMinDpi = 1.0; #if defined(ENABLE_PRINT_PREVIEW) bool g_is_preview_enabled = true; @@ -12,7 +12,7 @@ index f2dc502..c0049d0 100644 const char kPageLoadScriptFormat[] = "document.open(); document.write(%s); document.close();"; -@@ -88,9 +91,6 @@ void ExecuteScript(blink::WebFrame* frame, +@@ -93,9 +96,6 @@ void ExecuteScript(blink::WebFrame* frame, std::string script = base::StringPrintf(script_format, json.c_str()); frame->executeScript(blink::WebString(base::UTF8ToUTF16(script))); } @@ -22,7 +22,7 @@ index f2dc502..c0049d0 100644 int GetDPI(const PrintMsg_Print_Params* print_params) { #if defined(OS_MACOSX) -@@ -481,7 +481,6 @@ blink::WebView* FrameReference::view() { +@@ -486,7 +486,6 @@ blink::WebView* FrameReference::view() { return view_; } @@ -30,7 +30,7 @@ index f2dc502..c0049d0 100644 // static - Not anonymous so that platform implementations can use it. void PrintWebViewHelper::PrintHeaderAndFooter( blink::WebCanvas* canvas, -@@ -537,7 +536,6 @@ void PrintWebViewHelper::PrintHeaderAndFooter( +@@ -542,7 +541,6 @@ void PrintWebViewHelper::PrintHeaderAndFooter( web_view->close(); frame->close(); } @@ -38,15 +38,15 @@ index f2dc502..c0049d0 100644 // static - Not anonymous so that platform implementations can use it. float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, -@@ -810,6 +808,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view, +@@ -815,6 +813,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view, print_for_preview_(false), - delegate_(delegate.Pass()), + delegate_(std::move(delegate)), print_node_in_progress_(false), + force_print_preview_(false), is_loading_(false), is_scripted_preview_delayed_(false), ipc_nesting_level_(0), -@@ -1249,7 +1248,9 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { +@@ -1254,7 +1253,9 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { // that instead. auto plugin = delegate_->GetPdfElement(frame); if (!plugin.isNull()) { @@ -56,7 +56,7 @@ index f2dc502..c0049d0 100644 return; } print_preview_context_.InitWithFrame(frame); -@@ -1282,7 +1283,7 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) { +@@ -1287,7 +1288,7 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) { // Make a copy of the node, in case RenderView::OnContextMenuClosed resets // its |context_menu_node_|. @@ -66,18 +66,18 @@ index f2dc502..c0049d0 100644 Print(duplicate_node.document().frame(), duplicate_node, false); } else { diff --git printing/renderer/print_web_view_helper.h printing/renderer/print_web_view_helper.h -index d9ea441..dce6b9e 100644 +index 0de51e5..da084d0 100644 --- printing/renderer/print_web_view_helper.h +++ printing/renderer/print_web_view_helper.h -@@ -309,7 +309,6 @@ class PrintWebViewHelper - double* scale_factor, - PageSizeMargins* page_layout_in_points); +@@ -317,7 +317,6 @@ class PrintWebViewHelper + const PrintMsg_PrintPages_Params& params, + int page_count); -#if defined(ENABLE_PRINT_PREVIEW) // Given the |device| and |canvas| to draw on, prints the appropriate headers // and footers using strings from |header_footer_info| on to the canvas. static void PrintHeaderAndFooter(blink::WebCanvas* canvas, -@@ -319,7 +318,6 @@ class PrintWebViewHelper +@@ -327,7 +326,6 @@ class PrintWebViewHelper float webkit_scale_factor, const PageSizeMargins& page_layout_in_points, const PrintMsg_Print_Params& params); @@ -85,7 +85,7 @@ index d9ea441..dce6b9e 100644 bool GetPrintFrame(blink::WebLocalFrame** frame); -@@ -498,6 +496,7 @@ class PrintWebViewHelper +@@ -506,6 +504,7 @@ class PrintWebViewHelper ScriptingThrottler scripting_throttler_; bool print_node_in_progress_; @@ -94,10 +94,10 @@ index d9ea441..dce6b9e 100644 bool is_loading_; bool is_scripted_preview_delayed_; diff --git printing/renderer/print_web_view_helper_linux.cc printing/renderer/print_web_view_helper_linux.cc -index 3e4033d..7a8b61f 100644 +index acc72ed..545178d 100644 --- printing/renderer/print_web_view_helper_linux.cc +++ printing/renderer/print_web_view_helper_linux.cc -@@ -152,7 +152,6 @@ void PrintWebViewHelper::PrintPageInternal( +@@ -141,7 +141,6 @@ void PrintWebViewHelper::PrintPageInternal( MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); @@ -105,7 +105,7 @@ index 3e4033d..7a8b61f 100644 if (params.params.display_header_footer) { // |page_number| is 0-based, so 1 is added. // TODO(vitalybuka) : why does it work only with 1.25? -@@ -161,7 +160,6 @@ void PrintWebViewHelper::PrintPageInternal( +@@ -150,7 +149,6 @@ void PrintWebViewHelper::PrintPageInternal( scale_factor / 1.25, page_layout_in_points, params.params); } @@ -114,10 +114,10 @@ index 3e4033d..7a8b61f 100644 RenderPageContent(frame, params.page_number, canvas_area, content_area, scale_factor, canvas); diff --git printing/renderer/print_web_view_helper_mac.mm printing/renderer/print_web_view_helper_mac.mm -index 293f567..601fee6 100644 +index e682fa3..3a3aa8e 100644 --- printing/renderer/print_web_view_helper_mac.mm +++ printing/renderer/print_web_view_helper_mac.mm -@@ -125,14 +125,12 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params, +@@ -143,14 +143,12 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params, MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); skia::SetIsPreviewMetafile(*canvas, is_preview); @@ -133,10 +133,10 @@ index 293f567..601fee6 100644 scale_factor, static_cast(canvas)); } diff --git printing/renderer/print_web_view_helper_pdf_win.cc printing/renderer/print_web_view_helper_pdf_win.cc -index 13ad735..fffce71 100644 +index 11401bf..2ed0668 100644 --- printing/renderer/print_web_view_helper_pdf_win.cc +++ printing/renderer/print_web_view_helper_pdf_win.cc -@@ -160,14 +160,12 @@ void PrintWebViewHelper::PrintPageInternal( +@@ -151,14 +151,12 @@ void PrintWebViewHelper::PrintPageInternal( MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); diff --git a/patch/patches/process_title_1639.patch b/patch/patches/process_title_1639.patch index e189cb83f..7153662df 100644 --- a/patch/patches/process_title_1639.patch +++ b/patch/patches/process_title_1639.patch @@ -1,8 +1,8 @@ diff --git set_process_title.cc set_process_title.cc -index d74af96..5c7ebd2 100644 +index 2118598..8f85c70 100644 --- set_process_title.cc +++ set_process_title.cc -@@ -42,7 +42,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { +@@ -44,7 +44,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { bool have_argv0 = false; #if defined(OS_LINUX) diff --git a/patch/patches/public_browser_1257.patch b/patch/patches/public_browser_1257.patch index 79cd7e0d9..77c7723c4 100644 --- a/patch/patches/public_browser_1257.patch +++ b/patch/patches/public_browser_1257.patch @@ -14,10 +14,10 @@ index 1b6d8a6..b606a30 100644 WebContents::CreateParams::~CreateParams() { } diff --git web_contents.h web_contents.h -index c9fa8a01..e075a76 100644 +index 6f68c96..2ba25d7 100644 --- web_contents.h +++ web_contents.h -@@ -52,9 +52,11 @@ class PageState; +@@ -54,9 +54,11 @@ class PageState; class RenderFrameHost; class RenderProcessHost; class RenderViewHost; @@ -29,7 +29,7 @@ index c9fa8a01..e075a76 100644 struct CustomContextMenuContext; struct DropData; struct Manifest; -@@ -144,6 +146,10 @@ class WebContents : public PageNavigator, +@@ -146,6 +148,10 @@ class WebContents : public PageNavigator, // RenderFrame, have already been created on the renderer side, and // WebContents construction should take this into account. bool renderer_initiated_creation; @@ -41,10 +41,10 @@ index c9fa8a01..e075a76 100644 // Creates a new WebContents. diff --git web_contents_delegate.cc web_contents_delegate.cc -index 70a1f06..b9673d2 100644 +index e247f5b..45968ce 100644 --- web_contents_delegate.cc +++ web_contents_delegate.cc -@@ -165,7 +165,9 @@ bool WebContentsDelegate::ShouldCreateWebContents( +@@ -170,7 +170,9 @@ bool WebContentsDelegate::ShouldCreateWebContents( const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -56,10 +56,10 @@ index 70a1f06..b9673d2 100644 } diff --git web_contents_delegate.h web_contents_delegate.h -index f6a04a5..f41ec5b 100644 +index 6379fe4..d8e8844 100644 --- web_contents_delegate.h +++ web_contents_delegate.h -@@ -39,9 +39,11 @@ class DownloadItem; +@@ -41,9 +41,11 @@ class DownloadItem; class JavaScriptDialogManager; class PageState; class RenderViewHost; @@ -71,7 +71,7 @@ index f6a04a5..f41ec5b 100644 struct ColorSuggestion; struct ContextMenuParams; struct DropData; -@@ -296,7 +298,9 @@ class CONTENT_EXPORT WebContentsDelegate { +@@ -303,7 +305,9 @@ class CONTENT_EXPORT WebContentsDelegate { const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/patch/patches/render_widget_host_1070383005.patch b/patch/patches/render_widget_host_1070383005.patch index df3f4529c..dc8672e4c 100644 --- a/patch/patches/render_widget_host_1070383005.patch +++ b/patch/patches/render_widget_host_1070383005.patch @@ -1,5 +1,5 @@ diff --git render_widget_host_view_mac.mm render_widget_host_view_mac.mm -index ccf0de2..c4b758e 100644 +index 8a8f916..200c7b6 100644 --- render_widget_host_view_mac.mm +++ render_widget_host_view_mac.mm @@ -530,9 +530,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, diff --git a/patch/patches/renderer_preferences_util_545103.patch b/patch/patches/renderer_preferences_util_545103.patch index 1bcbca599..dd5bfaf51 100644 --- a/patch/patches/renderer_preferences_util_545103.patch +++ b/patch/patches/renderer_preferences_util_545103.patch @@ -1,8 +1,8 @@ diff --git renderer_preferences_util.cc renderer_preferences_util.cc -index 89b7d77..9996edf 100644 +index a6498fc..4bf2cf91 100644 --- renderer_preferences_util.cc +++ renderer_preferences_util.cc -@@ -26,7 +26,8 @@ +@@ -27,7 +27,8 @@ #include "ui/views/controls/textfield/textfield.h" #endif @@ -12,7 +12,7 @@ index 89b7d77..9996edf 100644 #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "ui/views/linux_ui/linux_ui.h" -@@ -94,7 +95,8 @@ void UpdateFromSystemSettings(content::RendererPreferences* prefs, +@@ -95,7 +96,8 @@ void UpdateFromSystemSettings(content::RendererPreferences* prefs, prefs->caret_blink_interval = views::Textfield::GetCaretBlinkMs() / 1000.0; #endif diff --git a/patch/patches/spellcheck_137.patch b/patch/patches/spellcheck_137.patch index a7ffa1084..70551cd9c 100644 --- a/patch/patches/spellcheck_137.patch +++ b/patch/patches/spellcheck_137.patch @@ -26,13 +26,13 @@ index 87b5b9e..8e6dfff 100644 SpellcheckServiceFactory::SpellcheckServiceFactory() diff --git spellcheck_factory.h spellcheck_factory.h -index 7cdf471..d52b881 100644 +index e8eb9f7..48126000 100644 --- spellcheck_factory.h +++ spellcheck_factory.h @@ -7,7 +7,7 @@ - #include "base/basictypes.h" #include "base/gtest_prod_util.h" + #include "base/macros.h" -#include "base/memory/singleton.h" +#include "base/lazy_instance.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" diff --git a/patch/patches/supports_user_data_1710.patch b/patch/patches/supports_user_data_1710.patch index e336293b8..34da88402 100644 --- a/patch/patches/supports_user_data_1710.patch +++ b/patch/patches/supports_user_data_1710.patch @@ -1,8 +1,8 @@ diff --git supports_user_data.h supports_user_data.h -index 711ee7d..cf38fc0 100644 +index 5c1c7e9..77c9253 100644 --- supports_user_data.h +++ supports_user_data.h -@@ -32,9 +32,9 @@ class BASE_EXPORT SupportsUserData { +@@ -33,9 +33,9 @@ class BASE_EXPORT SupportsUserData { // Multiple user data values can be stored under different keys. // This object will TAKE OWNERSHIP of the given data pointer, and will // delete the object if it is changed or the object is destroyed. diff --git a/patch/patches/ui_webview_1257.patch b/patch/patches/ui_webview_1257.patch index 8ac2b1729..513baf147 100644 --- a/patch/patches/ui_webview_1257.patch +++ b/patch/patches/ui_webview_1257.patch @@ -14,10 +14,10 @@ index c5a2b03..0594c4a 100644 return delegate_->HandleShouldCreateWebContents(); return true; diff --git web_dialog_view.h web_dialog_view.h -index d897dbf..92bb481 100644 +index a978921c..5f3fd33 100644 --- web_dialog_view.h +++ web_dialog_view.h -@@ -120,7 +120,9 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView, +@@ -123,7 +123,9 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView, const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/patch/patches/views_widget_180_1677.patch b/patch/patches/views_widget_180_1677.patch index 8abd6b1b7..4796dd7b7 100644 --- a/patch/patches/views_widget_180_1677.patch +++ b/patch/patches/views_widget_180_1677.patch @@ -1,8 +1,8 @@ diff --git content/browser/renderer_host/render_widget_host_view_aura.cc content/browser/renderer_host/render_widget_host_view_aura.cc -index edb45db..0dfcfb2 100644 +index 6968dfc..ecb9129 100644 --- content/browser/renderer_host/render_widget_host_view_aura.cc +++ content/browser/renderer_host/render_widget_host_view_aura.cc -@@ -772,6 +772,13 @@ void RenderWidgetHostViewAura::SetKeyboardFocus() { +@@ -774,6 +774,13 @@ void RenderWidgetHostViewAura::SetKeyboardFocus() { ::SetFocus(host->GetAcceleratedWidget()); } #endif @@ -17,10 +17,10 @@ index edb45db..0dfcfb2 100644 set_focus_on_mouse_down_ = false; host_->Focus(); diff --git content/browser/renderer_host/render_widget_host_view_base.cc content/browser/renderer_host/render_widget_host_view_base.cc -index 1c07d7d..47c1911 100644 +index a2a0884..c6eef9d 100644 --- content/browser/renderer_host/render_widget_host_view_base.cc +++ content/browser/renderer_host/render_widget_host_view_base.cc -@@ -374,6 +374,7 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() +@@ -375,6 +375,7 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() current_device_scale_factor_(0), current_display_rotation_(gfx::Display::ROTATE_0), pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), @@ -28,7 +28,7 @@ index 1c07d7d..47c1911 100644 renderer_frame_number_(0), weak_factory_(this) { } -@@ -568,6 +569,10 @@ void RenderWidgetHostViewBase::EndFrameSubscription() { +@@ -569,6 +570,10 @@ void RenderWidgetHostViewBase::EndFrameSubscription() { NOTREACHED(); } @@ -36,14 +36,14 @@ index 1c07d7d..47c1911 100644 + has_external_parent_ = val; +} + - uint32 RenderWidgetHostViewBase::RendererFrameNumber() { + uint32_t RenderWidgetHostViewBase::RendererFrameNumber() { return renderer_frame_number_; } diff --git content/browser/renderer_host/render_widget_host_view_base.h content/browser/renderer_host/render_widget_host_view_base.h -index 1f1e43c..22b5593 100644 +index d714137..9d17d2f 100644 --- content/browser/renderer_host/render_widget_host_view_base.h +++ content/browser/renderer_host/render_widget_host_view_base.h -@@ -78,6 +78,7 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, +@@ -87,6 +87,7 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, void BeginFrameSubscription( scoped_ptr subscriber) override; void EndFrameSubscription() override; @@ -51,7 +51,7 @@ index 1f1e43c..22b5593 100644 // IPC::Listener implementation: bool OnMessageReceived(const IPC::Message& msg) override; -@@ -434,6 +435,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, +@@ -438,6 +439,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, // renderer. bool pinch_zoom_enabled_; @@ -63,7 +63,7 @@ index 1f1e43c..22b5593 100644 void FlushInput(); diff --git content/public/browser/render_widget_host_view.h content/public/browser/render_widget_host_view.h -index d503fa9..5a7ea6c 100644 +index 9b48ddb..0314569 100644 --- content/public/browser/render_widget_host_view.h +++ content/public/browser/render_widget_host_view.h @@ -146,6 +146,10 @@ class CONTENT_EXPORT RenderWidgetHostView { @@ -135,10 +135,10 @@ index 48368f9..6a566ba 100644 bool DesktopWindowTreeHostWin::HandleMouseEvent(const ui::MouseEvent& event) { diff --git ui/views/widget/desktop_aura/desktop_window_tree_host_win.h ui/views/widget/desktop_aura/desktop_window_tree_host_win.h -index 363c019..97ada1d 100644 +index bee915a..23f93e2 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +++ ui/views/widget/desktop_aura/desktop_window_tree_host_win.h -@@ -242,6 +242,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin +@@ -243,6 +243,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin // Init time, before the Widget has created the NonClientView. bool has_non_client_view_; @@ -150,7 +150,7 @@ index 363c019..97ada1d 100644 // a reference. corewm::TooltipWin* tooltip_; diff --git ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc -index 656769c..0e5d460 100644 +index d3aafd9..8bbfd6a 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -168,6 +168,7 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( @@ -237,12 +237,12 @@ index 656769c..0e5d460 100644 if (xev->xfocus.mode != NotifyGrab) { ReleaseCapture(); diff --git ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h -index c6d9257..0a36f28 100644 +index 1036152..7b2b426 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h +++ ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h -@@ -96,6 +96,12 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -98,6 +98,12 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 // there is no dialog on the host window. - const XID GetModalDialog(); + XID GetModalDialog(); + void set_screen_bounds(const gfx::Rect& bounds) { screen_bounds_ = bounds; } + @@ -253,7 +253,7 @@ index c6d9257..0a36f28 100644 protected: // Overridden from DesktopWindowTreeHost: void Init(aura::Window* content_window, -@@ -272,6 +278,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -274,6 +280,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 // The bounds of |xwindow_|. gfx::Rect bounds_in_pixels_; @@ -263,7 +263,7 @@ index c6d9257..0a36f28 100644 // Whenever the bounds are set, we keep the previous set of bounds around so // we can have a better chance of getting the real // |restored_bounds_in_pixels_|. Window managers tend to send a Configure -@@ -308,6 +317,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -310,6 +319,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 // Whether we used an ARGB visual for our window. bool use_argb_visual_; @@ -274,7 +274,7 @@ index c6d9257..0a36f28 100644 DesktopDragDropClientAuraX11* drag_drop_client_; scoped_ptr x11_non_client_event_filter_; -@@ -364,6 +377,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -366,6 +379,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 base::WeakPtrFactory close_widget_factory_; @@ -346,10 +346,10 @@ index 9b20295..20b1aec 100644 x_active_window_ = None; } diff --git ui/views/widget/widget.cc ui/views/widget/widget.cc -index 6873cde..770e2a9 100644 +index aaa9320..c9e17a0 100644 --- ui/views/widget/widget.cc +++ ui/views/widget/widget.cc -@@ -125,6 +125,7 @@ Widget::InitParams::InitParams() +@@ -126,6 +126,7 @@ Widget::InitParams::InitParams() use_system_default_icon(false), show_state(ui::SHOW_STATE_DEFAULT), parent(nullptr), @@ -357,7 +357,7 @@ index 6873cde..770e2a9 100644 native_widget(nullptr), native_theme(nullptr), desktop_window_tree_host(nullptr), -@@ -150,6 +151,7 @@ Widget::InitParams::InitParams(Type type) +@@ -151,6 +152,7 @@ Widget::InitParams::InitParams(Type type) use_system_default_icon(false), show_state(ui::SHOW_STATE_DEFAULT), parent(nullptr), @@ -365,7 +365,7 @@ index 6873cde..770e2a9 100644 native_widget(nullptr), native_theme(nullptr), desktop_window_tree_host(nullptr), -@@ -327,7 +329,7 @@ void Widget::Init(const InitParams& in_params) { +@@ -328,7 +330,7 @@ void Widget::Init(const InitParams& in_params) { InitParams params = in_params; params.child |= (params.type == InitParams::TYPE_CONTROL); @@ -374,7 +374,7 @@ index 6873cde..770e2a9 100644 if (params.opacity == views::Widget::InitParams::INFER_OPACITY && params.type != views::Widget::InitParams::TYPE_WINDOW && -@@ -390,7 +392,12 @@ void Widget::Init(const InitParams& in_params) { +@@ -391,7 +393,12 @@ void Widget::Init(const InitParams& in_params) { Minimize(); } else if (params.delegate) { SetContentsView(params.delegate->GetContentsView()); @@ -389,10 +389,10 @@ index 6873cde..770e2a9 100644 // This must come after SetContentsView() or it might not be able to find // the correct NativeTheme (on Linux). See http://crbug.com/384492 diff --git ui/views/widget/widget.h ui/views/widget/widget.h -index b53bb48..f79ce8f 100644 +index 4ad8c2b..abf716c 100644 --- ui/views/widget/widget.h +++ ui/views/widget/widget.h -@@ -232,6 +232,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, +@@ -234,6 +234,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Whether the widget should be maximized or minimized. ui::WindowShowState show_state; gfx::NativeView parent; diff --git a/patch/patches/webkit_popups.patch b/patch/patches/webkit_popups.patch index 20bd4072e..840313f18 100644 --- a/patch/patches/webkit_popups.patch +++ b/patch/patches/webkit_popups.patch @@ -1,8 +1,8 @@ diff --git Source/web/ChromeClientImpl.cpp Source/web/ChromeClientImpl.cpp -index 5488a95..18c184f 100644 +index 8a40549..3011ab4 100644 --- Source/web/ChromeClientImpl.cpp +++ Source/web/ChromeClientImpl.cpp -@@ -821,7 +821,7 @@ bool ChromeClientImpl::hasOpenedPopup() const +@@ -829,7 +829,7 @@ bool ChromeClientImpl::hasOpenedPopup() const PassRefPtrWillBeRawPtr ChromeClientImpl::openPopupMenu(LocalFrame& frame, HTMLSelectElement& select) { notifyPopupOpeningObservers(); @@ -12,10 +12,10 @@ index 5488a95..18c184f 100644 ASSERT(RuntimeEnabledFeatures::pagePopupEnabled()); diff --git Source/web/WebViewImpl.cpp Source/web/WebViewImpl.cpp -index 3efbcdf..18f0c9e3 100644 +index a065625..bbd9093 100644 --- Source/web/WebViewImpl.cpp +++ Source/web/WebViewImpl.cpp -@@ -414,6 +414,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) +@@ -476,6 +476,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) , m_enableFakePageScaleAnimationForTesting(false) , m_fakePageScaleAnimationPageScaleFactor(0) , m_fakePageScaleAnimationUseAnchor(false) @@ -23,7 +23,20 @@ index 3efbcdf..18f0c9e3 100644 , m_doingDragAndDrop(false) , m_ignoreInputEvents(false) , m_compositorDeviceScaleFactorOverride(0) -@@ -4050,9 +4051,14 @@ void WebViewImpl::pageScaleFactorChanged() +@@ -2272,12 +2273,6 @@ void WebViewImpl::mouseCaptureLost() + + void WebViewImpl::setFocus(bool enable) + { +- // On Windows, unnecessary setFocus(false) is called if a popup is shown and +- // the hotdog menu is clicked. +- // TODO(tkent): This should be fixed in Chromium. +- if (!enable && m_pagePopup) +- return; +- + m_page->focusController().setFocused(enable); + if (enable) { + m_page->focusController().setActive(true); +@@ -4151,9 +4146,14 @@ void WebViewImpl::pageScaleFactorChanged() m_client->pageScaleFactorChanged(); } @@ -40,10 +53,10 @@ index 3efbcdf..18f0c9e3 100644 void WebViewImpl::startDragging(LocalFrame* frame, diff --git Source/web/WebViewImpl.h Source/web/WebViewImpl.h -index c4453c1..bb6ee4e 100644 +index 9288a7f..18b0067 100644 --- Source/web/WebViewImpl.h +++ Source/web/WebViewImpl.h -@@ -395,7 +395,8 @@ public: +@@ -396,7 +396,8 @@ public: // Returns true if popup menus should be rendered by the browser, false if // they should be rendered by WebKit (which is the default). @@ -53,7 +66,7 @@ index c4453c1..bb6ee4e 100644 bool shouldAutoResize() const { -@@ -678,6 +679,8 @@ private: +@@ -691,6 +692,8 @@ private: float m_fakePageScaleAnimationPageScaleFactor; bool m_fakePageScaleAnimationUseAnchor; @@ -63,7 +76,7 @@ index c4453c1..bb6ee4e 100644 bool m_ignoreInputEvents; diff --git public/web/WebView.h public/web/WebView.h -index 843f633..f922327 100644 +index e21137b..e435d73 100644 --- public/web/WebView.h +++ public/web/WebView.h @@ -411,6 +411,7 @@ public: diff --git a/tests/unittests/frame_unittest.cc b/tests/unittests/frame_unittest.cc index e61653371..89e6a987f 100644 --- a/tests/unittests/frame_unittest.cc +++ b/tests/unittests/frame_unittest.cc @@ -245,7 +245,7 @@ class FrameNavExpectationsFactoryBrowser : public FrameNavExpectationsFactory { scoped_ptr expectations; expectations = Create(nav); expectations->set_completion_callback(completion_callback); - return expectations.Pass(); + return expectations; } protected: @@ -268,7 +268,7 @@ class FrameNavExpectationsFactoryRenderer : public FrameNavExpectationsFactory { scoped_ptr expectations; expectations = Create(nav); expectations->set_completion_callback(completion_callback); - return expectations.Pass(); + return expectations; } protected: @@ -2298,7 +2298,7 @@ scoped_ptr } EXPECT_TRUE(factory); EXPECT_EQ(id, factory->GetID()); - return factory.Pass(); + return factory; } // static @@ -2332,7 +2332,7 @@ scoped_ptr } EXPECT_TRUE(factory); EXPECT_EQ(id, factory->GetID()); - return factory.Pass(); + return factory; } } // namespace