diff --git a/BUILD.gn b/BUILD.gn index 059f542c9..05ec282a5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -99,8 +99,12 @@ import("//build/config/locales.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/ui.gni") import("//cef/cef_repack_locales.gni") +import("//chrome/common/features.gni") +import("//extensions/features/features.gni") import("//media/media_options.gni") import("//mojo/public/tools/bindings/mojom.gni") +import("//ppapi/features/features.gni") +import("//printing/features/features.gni") import("//third_party/icu/config.gni") import("//third_party/widevine/cdm/widevine.gni") import("//tools/grit/repack.gni") @@ -318,10 +322,10 @@ static_library("libcef_static") { "libcef/browser/net/network_delegate.h", "libcef/browser/net/resource_request_job.cc", "libcef/browser/net/resource_request_job.h", - "libcef/browser/net/response_filter_wrapper.cc", - "libcef/browser/net/response_filter_wrapper.h", "libcef/browser/net/scheme_handler.cc", "libcef/browser/net/scheme_handler.h", + "libcef/browser/net/source_stream.cc", + "libcef/browser/net/source_stream.h", "libcef/browser/net/url_request_context.cc", "libcef/browser/net/url_request_context.h", "libcef/browser/net/url_request_context_getter.h", @@ -608,12 +612,13 @@ static_library("libcef_static") { "//content/public/renderer", "//content/public/utility", "//crypto", - "//device/core", + "//device/base", "//device/geolocation", "//device/hid", "//extensions/browser", + "//extensions/browser/api:api_registration", "//extensions/common/api", - "//extensions/common/api:api_registration", + "//extensions/features", "//extensions/renderer", "//extensions/utility", "//gpu", @@ -624,6 +629,8 @@ static_library("libcef_static") { "//net:net_browser_services", "//net:net_with_v8", "//pdf", + "//ppapi/features", + "//printing/features", "//skia", "//storage/browser", "//third_party/brotli", @@ -632,7 +639,7 @@ static_library("libcef_static") { "//third_party/leveldatabase", "//third_party/libxml", "//third_party/WebKit/public:blink", - "//third_party/widevine/cdm:version_h", + "//third_party/widevine/cdm:headers", "//third_party/icu", "//third_party/zlib:minizip", "//ui/base", @@ -672,8 +679,10 @@ static_library("libcef_static") { "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", - "libcef/utility/printing_handler.cc", - "libcef/utility/printing_handler.h", + + # Part of //chrome/utility. + "//chrome/utility/printing_handler.cc", + "//chrome/utility/printing_handler.h", ] deps += [ diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index 03f60c966..a38e3388e 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -7,5 +7,5 @@ # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding { - 'chromium_checkout': '614d31daee2f61b0180df403a8ad43f20b9f6dd7', + 'chromium_checkout': '3a87aecc31cd1ffe751dd72c04e5a96a1fc8108a', } diff --git a/include/capi/cef_response_filter_capi.h b/include/capi/cef_response_filter_capi.h index 3817abc8f..9c96cd42b 100644 --- a/include/capi/cef_response_filter_capi.h +++ b/include/capi/cef_response_filter_capi.h @@ -62,22 +62,35 @@ typedef struct _cef_response_filter_t { int (CEF_CALLBACK *init_filter)(struct _cef_response_filter_t* self); /// - // Called to filter a chunk of data. |data_in| is the input buffer containing - // |data_in_size| bytes of pre-filter data (|data_in| will be NULL if - // |data_in_size| is zero). |data_out| is the output buffer that can accept up - // to |data_out_size| bytes of filtered output data. Set |data_in_read| to the - // number of bytes that were read from |data_in|. Set |data_out_written| to - // the number of bytes that were written into |data_out|. If some or all of - // the pre-filter data was read successfully but more data is needed in order - // to continue filtering (filtered output is pending) return - // RESPONSE_FILTER_NEED_MORE_DATA. If some or all of the pre-filter data was - // read successfully and all available filtered output has been written return - // RESPONSE_FILTER_DONE. If an error occurs during filtering return - // RESPONSE_FILTER_ERROR. This function will be called repeatedly until there - // is no more data to filter (resource response is complete), |data_in_read| - // matches |data_in_size| (all available pre-filter bytes have been read), and - // the function returns RESPONSE_FILTER_DONE or RESPONSE_FILTER_ERROR. Do not - // keep a reference to the buffers passed to this function. + // Called to filter a chunk of data. Expected usage is as follows: + // + // A. Read input data from |data_in| and set |data_in_read| to the number of + // bytes that were read up to a maximum of |data_in_size|. |data_in| will + // be NULL if |data_in_size| is zero. + // B. Write filtered output data to |data_out| and set |data_out_written| to + // the number of bytes that were written up to a maximum of + // |data_out_size|. If no output data was written then all data must be + // read from |data_in| (user must set |data_in_read| = |data_in_size|). + // C. Return RESPONSE_FILTER_DONE if all output data was written or + // RESPONSE_FILTER_NEED_MORE_DATA if output data is still pending. + // + // This function will be called repeatedly until the input buffer has been + // fully read (user sets |data_in_read| = |data_in_size|) and there is no more + // input data to filter (the resource response is complete). This function may + // then be called an additional time with an NULL input buffer if the user + // filled the output buffer (set |data_out_written| = |data_out_size|) and + // returned RESPONSE_FILTER_NEED_MORE_DATA to indicate that output data is + // still pending. + // + // Calls to this function will stop when one of the following conditions is + // met: + // + // A. There is no more input data to filter (the resource response is + // complete) and the user sets |data_out_written| = 0 or returns + // RESPONSE_FILTER_DONE to indicate that all data has been written, or; + // B. The user returns RESPONSE_FILTER_ERROR to indicate an error. + // + // Do not keep a reference to the buffers passed to this function. /// cef_response_filter_status_t (CEF_CALLBACK *filter)( struct _cef_response_filter_t* self, void* data_in, size_t data_in_size, diff --git a/include/cef_response_filter.h b/include/cef_response_filter.h index 594d4a982..55e667770 100644 --- a/include/cef_response_filter.h +++ b/include/cef_response_filter.h @@ -57,22 +57,34 @@ class CefResponseFilter : public virtual CefBase { virtual bool InitFilter() =0; /// - // Called to filter a chunk of data. |data_in| is the input buffer containing - // |data_in_size| bytes of pre-filter data (|data_in| will be NULL if - // |data_in_size| is zero). |data_out| is the output buffer that can accept up - // to |data_out_size| bytes of filtered output data. Set |data_in_read| to the - // number of bytes that were read from |data_in|. Set |data_out_written| to - // the number of bytes that were written into |data_out|. If some or all of - // the pre-filter data was read successfully but more data is needed in order - // to continue filtering (filtered output is pending) return - // RESPONSE_FILTER_NEED_MORE_DATA. If some or all of the pre-filter data was - // read successfully and all available filtered output has been written return - // RESPONSE_FILTER_DONE. If an error occurs during filtering return - // RESPONSE_FILTER_ERROR. This method will be called repeatedly until there is - // no more data to filter (resource response is complete), |data_in_read| - // matches |data_in_size| (all available pre-filter bytes have been read), and - // the method returns RESPONSE_FILTER_DONE or RESPONSE_FILTER_ERROR. Do not - // keep a reference to the buffers passed to this method. + // Called to filter a chunk of data. Expected usage is as follows: + // + // A. Read input data from |data_in| and set |data_in_read| to the number of + // bytes that were read up to a maximum of |data_in_size|. |data_in| will + // be NULL if |data_in_size| is zero. + // B. Write filtered output data to |data_out| and set |data_out_written| to + // the number of bytes that were written up to a maximum of + // |data_out_size|. If no output data was written then all data must be + // read from |data_in| (user must set |data_in_read| = |data_in_size|). + // C. Return RESPONSE_FILTER_DONE if all output data was written or + // RESPONSE_FILTER_NEED_MORE_DATA if output data is still pending. + // + // This method will be called repeatedly until the input buffer has been + // fully read (user sets |data_in_read| = |data_in_size|) and there is no + // more input data to filter (the resource response is complete). This method + // may then be called an additional time with an empty input buffer if the + // user filled the output buffer (set |data_out_written| = |data_out_size|) + // and returned RESPONSE_FILTER_NEED_MORE_DATA to indicate that output data is + // still pending. + // + // Calls to this method will stop when one of the following conditions is met: + // + // A. There is no more input data to filter (the resource response is + // complete) and the user sets |data_out_written| = 0 or returns + // RESPONSE_FILTER_DONE to indicate that all data has been written, or; + // B. The user returns RESPONSE_FILTER_ERROR to indicate an error. + // + // Do not keep a reference to the buffers passed to this method. /// /*--cef(optional_param=data_in,default_retval=RESPONSE_FILTER_ERROR)--*/ virtual FilterStatus Filter(void* data_in, diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 6201a47be..01db8e7f1 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -563,12 +563,6 @@ typedef struct _cef_browser_settings_t { /// cef_state_t javascript_dom_paste; - /// - // Controls whether the caret position will be drawn. Also configurable using - // the "enable-caret-browsing" command-line switch. - /// - cef_state_t caret_browsing; - /// // Controls whether any plugins will be loaded. Also configurable using the // "disable-plugins" command-line switch. diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index bbe348dfc..71c4c0a8e 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -705,7 +705,6 @@ struct CefBrowserSettingsTraits { target->javascript_close_windows = src->javascript_close_windows; target->javascript_access_clipboard = src->javascript_access_clipboard; target->javascript_dom_paste = src->javascript_dom_paste; - target->caret_browsing = src->caret_browsing; target->plugins = src->plugins; target->universal_access_from_file_urls = src->universal_access_from_file_urls; diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index 9999b5404..9483ef2c4 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -741,7 +741,8 @@ void CefBrowserHostImpl::Print() { if (!actionable_contents) return; printing::CefPrintViewManager::FromWebContents( - actionable_contents)->PrintNow(); + actionable_contents)->PrintNow( + actionable_contents->GetRenderViewHost()->GetMainFrame()); } else { CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::Print, this)); @@ -762,7 +763,8 @@ void CefBrowserHostImpl::PrintToPDF(const CefString& path, callback.get(), path); } printing::CefPrintViewManager::FromWebContents(actionable_contents)-> - PrintToPDF(base::FilePath(path), settings, pdf_callback); + PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path), + settings, pdf_callback); } else { CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::PrintToPDF, this, path, settings, @@ -1413,7 +1415,8 @@ void CefBrowserHostImpl::DestroyBrowser() { menu_manager_->Destroy(); // Notify any observers that may have state associated with this browser. - FOR_EACH_OBSERVER(Observer, observers_, OnBrowserDestroyed(this)); + for (auto& observer : observers_) + observer.OnBrowserDestroyed(this); // Disassociate the platform delegate from this browser. platform_delegate_->BrowserDestroyed(this); @@ -2108,11 +2111,12 @@ void CefBrowserHostImpl::UpdateTargetURL(content::WebContents* source, } } -bool CefBrowserHostImpl::AddMessageToConsole(content::WebContents* source, - int32_t level, - const base::string16& message, - int32_t line_no, - const base::string16& source_id) { +bool CefBrowserHostImpl::DidAddMessageToConsole( + content::WebContents* source, + int32_t level, + const base::string16& message, + int32_t line_no, + const base::string16& source_id) { if (client_.get()) { CefRefPtr handler = client_->GetDisplayHandler(); if (handler.get()) @@ -2355,28 +2359,21 @@ void CefBrowserHostImpl::RequestMediaAccessPermission( bool webcam_requested = (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE); if (microphone_requested || webcam_requested) { - switch (request.request_type) { - case content::MEDIA_OPEN_DEVICE_PEPPER_ONLY: - case content::MEDIA_DEVICE_ACCESS: - case content::MEDIA_GENERATE_STREAM: - case content::MEDIA_ENUMERATE_DEVICES: - // Pick the desired device or fall back to the first available of the - // given type. - if (microphone_requested) { - CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( - request.requested_audio_device_id, - true, - false, - &devices); - } - if (webcam_requested) { - CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( - request.requested_video_device_id, - false, - true, - &devices); - } - break; + // Pick the desired device or fall back to the first available of the + // given type. + if (microphone_requested) { + CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( + request.requested_audio_device_id, + true, + false, + &devices); + } + if (webcam_requested) { + CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( + request.requested_video_device_id, + false, + true, + &devices); } } @@ -3015,6 +3012,24 @@ gfx::Point CefBrowserHostImpl::GetScreenPoint(const gfx::Point& view) const { return gfx::Point(); } +void CefBrowserHostImpl::StartDragging( + const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) { + if (platform_delegate_) { + platform_delegate_->StartDragging(drop_data, allowed_ops, image, + image_offset, event_info, source_rwh); + } +} + +void CefBrowserHostImpl::UpdateDragCursor(blink::WebDragOperation operation) { + if (platform_delegate_) + platform_delegate_->UpdateDragCursor(operation); +} + void CefBrowserHostImpl::OnAddressChange(CefRefPtr frame, const GURL& url) { if (client_.get()) { diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index 71732d069..103e28a98 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -32,6 +32,11 @@ #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" +namespace content { +struct DragEventSourceInfo; +class RenderWidgetHostImpl; +} + namespace net { class URLRequest; } @@ -323,6 +328,15 @@ class CefBrowserHostImpl : public CefBrowserHost, // scaling will be applied to the result. gfx::Point GetScreenPoint(const gfx::Point& view) const; + void StartDragging( + const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh); + void UpdateDragCursor(blink::WebDragOperation operation); + // Thread safe accessors. const CefBrowserSettings& settings() const { return settings_; } CefRefPtr client() const { return client_; } @@ -365,11 +379,11 @@ class CefBrowserHostImpl : public CefBrowserHost, void CloseContents(content::WebContents* source) override; void UpdateTargetURL(content::WebContents* source, const GURL& url) override; - bool AddMessageToConsole(content::WebContents* source, - int32_t level, - const base::string16& message, - int32_t line_no, - const base::string16& source_id) override; + bool DidAddMessageToConsole(content::WebContents* source, + int32_t level, + const base::string16& message, + int32_t line_no, + const base::string16& source_id) override; void BeforeUnloadFired(content::WebContents* source, bool proceed, bool* proceed_to_fire_unload) override; diff --git a/libcef/browser/browser_main.cc b/libcef/browser/browser_main.cc index aa02f8cf8..2ec4c2194 100644 --- a/libcef/browser/browser_main.cc +++ b/libcef/browser/browser_main.cc @@ -18,6 +18,7 @@ #include "libcef/browser/extensions/extensions_browser_client.h" #include "libcef/browser/extensions/extension_system_factory.h" #include "libcef/browser/net/chrome_scheme_handler.h" +#include "libcef/browser/printing/printing_message_filter.h" #include "libcef/browser/thread_util.h" #include "libcef/common/extensions/extensions_client.h" #include "libcef/common/extensions/extensions_util.h" @@ -181,6 +182,8 @@ void CefBrowserMainParts::PreMainMessageLoopRun() { extensions::CefExtensionSystemFactory::GetInstance(); } + printing::CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt(); + CefRequestContextSettings settings; CefContext::Get()->PopulateRequestContextSettings(&settings); diff --git a/libcef/browser/browser_platform_delegate.cc b/libcef/browser/browser_platform_delegate.cc index 53b5deaf7..1890243ca 100644 --- a/libcef/browser/browser_platform_delegate.cc +++ b/libcef/browser/browser_platform_delegate.cc @@ -177,6 +177,21 @@ void CefBrowserPlatformDelegate::DragTargetDrop(const CefMouseEvent& event) { NOTREACHED(); } +void CefBrowserPlatformDelegate::StartDragging( + const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) { + NOTREACHED(); +} + +void CefBrowserPlatformDelegate::UpdateDragCursor( + blink::WebDragOperation operation) { + NOTREACHED(); +} + void CefBrowserPlatformDelegate::DragSourceEndedAt( int x, int y, cef_drag_operations_mask_t op) { diff --git a/libcef/browser/browser_platform_delegate.h b/libcef/browser/browser_platform_delegate.h index 5b710baf3..29b3719ca 100644 --- a/libcef/browser/browser_platform_delegate.h +++ b/libcef/browser/browser_platform_delegate.h @@ -244,6 +244,14 @@ class CefBrowserPlatformDelegate { cef_drag_operations_mask_t allowed_ops); virtual void DragTargetDragLeave(); virtual void DragTargetDrop(const CefMouseEvent& event); + virtual void StartDragging( + const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh); + virtual void UpdateDragCursor(blink::WebDragOperation operation); virtual void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op); virtual void DragSourceSystemDragEnded(); diff --git a/libcef/browser/browser_urlrequest_impl.cc b/libcef/browser/browser_urlrequest_impl.cc index 5d3d94ff6..b394262ff 100644 --- a/libcef/browser/browser_urlrequest_impl.cc +++ b/libcef/browser/browser_urlrequest_impl.cc @@ -82,7 +82,7 @@ class NET_EXPORT CefURLFetcherResponseWriter : return num_bytes; } - int Finish(const net::CompletionCallback& callback) override { + int Finish(int net_error, const net::CompletionCallback& callback) override { if (url_request_.get()) url_request_ = NULL; return net::OK; diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index ed09d54cd..ac2513279 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -39,7 +39,9 @@ #include "base/base_switches.h" #include "base/command_line.h" #include "base/files/file_path.h" +#include "base/json/json_reader.h" #include "base/path_service.h" +#include "cef/grit/cef_resources.h" #include "chrome/browser/spellchecker/spellcheck_message_filter.h" #include "chrome/common/chrome_switches.h" #include "components/navigation_interception/intercept_navigation_throttle.h" @@ -60,6 +62,7 @@ #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/common/content_switches.h" +#include "content/public/common/service_names.mojom.h" #include "content/public/common/storage_quota_params.h" #include "content/public/common/web_preferences.h" #include "extensions/browser/extensions_browser_client.h" @@ -72,6 +75,7 @@ #include "net/ssl/ssl_cert_request_info.h" #include "ppapi/host/ppapi_host.h" #include "third_party/WebKit/public/web/WebWindowFeatures.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_switches.h" #include "url/gurl.h" @@ -457,9 +461,10 @@ void CefContentBrowserClient::RenderProcessWillLaunch( const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); const int id = host->GetID(); + Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); host->GetChannel()->AddFilter(new CefBrowserMessageFilter(id)); - host->AddFilter(new printing::CefPrintingMessageFilter(id)); + host->AddFilter(new printing::CefPrintingMessageFilter(id, profile)); if (!command_line->HasSwitch(switches::kDisableSpellChecking)) { host->AddFilter(new SpellCheckMessageFilter(id)); @@ -468,18 +473,16 @@ void CefContentBrowserClient::RenderProcessWillLaunch( #endif } - content::BrowserContext* browser_context = host->GetBrowserContext(); - host->AddFilter(new CefPluginInfoMessageFilter(id, - static_cast(browser_context))); + static_cast(profile))); if (extensions::ExtensionsEnabled()) { host->AddFilter( - new extensions::ExtensionMessageFilter(id, browser_context)); + new extensions::ExtensionMessageFilter(id, profile)); host->AddFilter( - new extensions::IOThreadExtensionMessageFilter(id, browser_context)); + new extensions::IOThreadExtensionMessageFilter(id, profile)); host->AddFilter( - new extensions::ExtensionsGuestViewMessageFilter(id, browser_context)); + new extensions::ExtensionsGuestViewMessageFilter(id, profile)); } // If the renderer process crashes then the host may already have @@ -489,7 +492,7 @@ void CefContentBrowserClient::RenderProcessWillLaunch( host->AddObserver(CefBrowserInfoManager::GetInstance()); host->Send(new CefProcessMsg_SetIsIncognitoProcess( - browser_context->IsOffTheRecord())); + profile->IsOffTheRecord())); } bool CefContentBrowserClient::ShouldUseProcessPerSite( @@ -587,6 +590,25 @@ void CefContentBrowserClient::SiteInstanceDeleting( site_instance->GetId())); } +std::unique_ptr +CefContentBrowserClient::GetServiceManifestOverlay( + const std::string& name) { + int id = -1; + if (name == content::mojom::kBrowserServiceName) + id = IDR_CEF_BROWSER_MANIFEST_OVERLAY; + else if (name == content::mojom::kRendererServiceName) + id = IDR_CEF_RENDERER_MANIFEST_OVERLAY; + else if (name == content::mojom::kUtilityServiceName) + id = IDR_CEF_UTILITY_MANIFEST_OVERLAY; + if (id == -1) + return nullptr; + + base::StringPiece manifest_contents = + ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( + id, ui::ScaleFactor::SCALE_FACTOR_NONE); + return base::JSONReader::Read(manifest_contents); +} + void CefContentBrowserClient::AppendExtraCommandLineSwitches( base::CommandLine* command_line, int child_process_id) { const base::CommandLine* browser_cmd = @@ -660,7 +682,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches( command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames, arraysize(kSwitchNames)); -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) if (!browser_cmd->HasSwitch(switches::kNoSandbox)) { // Pass the Widevine CDM path to the Zygote process. See comments in // CefWidevineLoader::AddPepperPlugins. diff --git a/libcef/browser/content_browser_client.h b/libcef/browser/content_browser_client.h index 59b5aa856..8bef2ed75 100644 --- a/libcef/browser/content_browser_client.h +++ b/libcef/browser/content_browser_client.h @@ -46,6 +46,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient { bool IsHandledURL(const GURL& url) override; void SiteInstanceGotProcess(content::SiteInstance* site_instance) override; void SiteInstanceDeleting(content::SiteInstance* site_instance) override; + std::unique_ptr GetServiceManifestOverlay( + const std::string& name) override; void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) override; content::QuotaPermissionContext* @@ -104,7 +106,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient { #endif #if defined(OS_WIN) - const wchar_t* GetResourceDllName() override; + const wchar_t* GetResourceDllName(); bool PreSpawnRenderer(sandbox::TargetPolicy* policy) override; #endif diff --git a/libcef/browser/context.cc b/libcef/browser/context.cc index d8247aaf5..6b7d89da3 100644 --- a/libcef/browser/context.cc +++ b/libcef/browser/context.cc @@ -398,7 +398,7 @@ void CefContext::OnContextInitialized() { static_cast(g_browser_process)-> OnContextInitialized(); -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) CefWidevineLoader::GetInstance()->OnContextInitialized(); #endif diff --git a/libcef/browser/devtools_frontend.cc b/libcef/browser/devtools_frontend.cc index becc92d63..54c4bc1ca 100644 --- a/libcef/browser/devtools_frontend.cc +++ b/libcef/browser/devtools_frontend.cc @@ -48,7 +48,7 @@ class ResponseWriter : public net::URLFetcherResponseWriter { int Write(net::IOBuffer* buffer, int num_bytes, const net::CompletionCallback& callback) override; - int Finish(const net::CompletionCallback& callback) override; + int Finish(int net_error, const net::CompletionCallback& callback) override; private: base::WeakPtr shell_devtools_; @@ -89,7 +89,8 @@ int ResponseWriter::Write(net::IOBuffer* buffer, return num_bytes; } -int ResponseWriter::Finish(const net::CompletionCallback& callback) { +int ResponseWriter::Finish(int net_error, + const net::CompletionCallback& callback) { return net::OK; } diff --git a/libcef/browser/javascript_dialog_manager.cc b/libcef/browser/javascript_dialog_manager.cc index a65bc3845..9f1f5092a 100644 --- a/libcef/browser/javascript_dialog_manager.cc +++ b/libcef/browser/javascript_dialog_manager.cc @@ -195,8 +195,10 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog( weak_ptr_factory_.GetWeakPtr(), callback)); } -void CefJavaScriptDialogManager::CancelActiveAndPendingDialogs( - content::WebContents* web_contents) { +void CefJavaScriptDialogManager::CancelDialogs( + content::WebContents* web_contents, + bool suppress_callbacks, + bool reset_state) { CefRefPtr client = browser_->GetClient(); if (client.get()) { CefRefPtr handler = client->GetJSDialogHandler(); @@ -212,10 +214,6 @@ void CefJavaScriptDialogManager::CancelActiveAndPendingDialogs( } } -void CefJavaScriptDialogManager::ResetDialogState( - content::WebContents* web_contents) { -} - void CefJavaScriptDialogManager::DialogClosed( const DialogClosedCallback& callback, bool success, diff --git a/libcef/browser/javascript_dialog_manager.h b/libcef/browser/javascript_dialog_manager.h index 3d505efc9..a5aa51b19 100644 --- a/libcef/browser/javascript_dialog_manager.h +++ b/libcef/browser/javascript_dialog_manager.h @@ -41,10 +41,9 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager { content::WebContents* web_contents, bool is_reload, const DialogClosedCallback& callback) override; - void CancelActiveAndPendingDialogs( - content::WebContents* web_contents) override; - void ResetDialogState( - content::WebContents* web_contents) override; + void CancelDialogs(content::WebContents* web_contents, + bool suppress_callbacks, + bool reset_state) override; private: // Method executed by the callback passed to CefJavaScriptDialogRunner::Run. diff --git a/libcef/browser/menu_model_impl.cc b/libcef/browser/menu_model_impl.cc index 37d36ecec..842b567d2 100644 --- a/libcef/browser/menu_model_impl.cc +++ b/libcef/browser/menu_model_impl.cc @@ -654,7 +654,8 @@ void CefMenuModelImpl::MenuWillShow() { delegate_->MenuWillShow(this); if (menu_model_delegate_) menu_model_delegate_->MenuWillShow(this); - FOR_EACH_OBSERVER(Observer, observers_, MenuWillShow(this)); + for (auto& observer : observers_) + observer.MenuWillShow(this); } void CefMenuModelImpl::MenuWillClose() { @@ -776,7 +777,8 @@ void CefMenuModelImpl::OnMenuClosed() { delegate_->MenuClosed(this); if (menu_model_delegate_) menu_model_delegate_->MenuClosed(this); - FOR_EACH_OBSERVER(Observer, observers_, MenuClosed(this)); + for (auto& observer : observers_) + observer.MenuClosed(this); } bool CefMenuModelImpl::VerifyContext() { diff --git a/libcef/browser/native/browser_platform_delegate_native_mac.mm b/libcef/browser/native/browser_platform_delegate_native_mac.mm index 5418ee30b..85b4974cf 100644 --- a/libcef/browser/native/browser_platform_delegate_native_mac.mm +++ b/libcef/browser/native/browser_platform_delegate_native_mac.mm @@ -20,7 +20,7 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" +#include "third_party/WebKit/public/platform/WebInputEvent.h" #import "ui/base/cocoa/cocoa_base_utils.h" #import "ui/base/cocoa/underlay_opengl_hosting_window.h" #include "ui/events/keycodes/keyboard_codes_posix.h" diff --git a/libcef/browser/native/native_menu_win.cc b/libcef/browser/native/native_menu_win.cc index b231efa86..2abe19b43 100644 --- a/libcef/browser/native/native_menu_win.cc +++ b/libcef/browser/native/native_menu_win.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/stl_util.h" #include "base/strings/string_util.h" @@ -404,7 +405,6 @@ CefNativeMenuWin::CefNativeMenuWin(ui::MenuModel* model, HWND system_menu_for) CefNativeMenuWin::~CefNativeMenuWin() { if (destroyed_flag_) *destroyed_flag_ = true; - base::STLDeleteContainerPointers(items_.begin(), items_.end()); DestroyMenu(menu_); } @@ -485,7 +485,7 @@ void CefNativeMenuWin::Rebuild(MenuInsertionDelegateWin* delegate) { void CefNativeMenuWin::UpdateStates() { // A depth-first walk of the menu items, updating states. int model_index = 0; - std::vector::const_iterator it; + ItemDataList::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), @@ -567,7 +567,8 @@ LRESULT CALLBACK CefNativeMenuWin::MenuMessageHook( // 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()); + for (auto& observer : this_ptr->listeners_) + observer.OnMenuOpened(); this_ptr->listeners_called_ = true; } @@ -622,7 +623,7 @@ void CefNativeMenuWin::AddMenuItemAt(int menu_index, int model_index) { else mii.fType = MFT_OWNERDRAW; - ItemData* item_data = new ItemData; + std::unique_ptr item_data = base::MakeUnique(); item_data->label = base::string16(); ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); if (type == ui::MenuModel::TYPE_SUBMENU) { @@ -637,8 +638,8 @@ void CefNativeMenuWin::AddMenuItemAt(int menu_index, int 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); + mii.dwItemData = reinterpret_cast(item_data.get()); + items_.insert(items_.begin() + model_index, std::move(item_data)); UpdateMenuItemInfoForString(&mii, model_index, model_->GetLabelAt(model_index)); InsertMenuItem(menu_, menu_index, TRUE, &mii); @@ -651,7 +652,7 @@ void CefNativeMenuWin::AddSeparatorItemAt(int menu_index, int model_index) { 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); + items_.insert(items_.begin() + model_index, base::MakeUnique()); InsertMenuItem(menu_, menu_index, TRUE, &mii); } diff --git a/libcef/browser/native/native_menu_win.h b/libcef/browser/native/native_menu_win.h index 6640b3283..a50edbb6f 100644 --- a/libcef/browser/native/native_menu_win.h +++ b/libcef/browser/native/native_menu_win.h @@ -5,6 +5,7 @@ #ifndef CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_ #define CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_ +#include #include #include "libcef/browser/native/menu_wrapper.h" @@ -119,7 +120,8 @@ class CefNativeMenuWin : public MenuWrapper { // An object that collects all of the data associated with an individual menu // item. struct ItemData; - std::vector items_; + typedef std::vector> ItemDataList; + ItemDataList items_; // The window that receives notifications from the menu. class MenuHostWindow; diff --git a/libcef/browser/net/network_delegate.cc b/libcef/browser/net/network_delegate.cc index 544b32336..846d146e9 100644 --- a/libcef/browser/net/network_delegate.cc +++ b/libcef/browser/net/network_delegate.cc @@ -9,7 +9,7 @@ #include "include/cef_urlrequest.h" #include "libcef/browser/browser_host_impl.h" -#include "libcef/browser/net/response_filter_wrapper.h" +#include "libcef/browser/net/source_stream.h" #include "libcef/browser/net/url_request_user_data.h" #include "libcef/browser/thread_util.h" #include "libcef/common/request_impl.h" @@ -23,16 +23,11 @@ #include "components/prefs/pref_service.h" #include "content/public/common/content_switches.h" #include "net/base/net_errors.h" -#include "net/filter/filter.h" #include "net/http/http_util.h" #include "net/url_request/url_request.h" namespace { -// Buffer size allocated when filtering data. -// Should match the value in net/filter/filter.cc. -const int kFilterBufSize = 32 * 1024; - class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback { public: typedef net::CompletionCallback CallbackType; @@ -266,6 +261,41 @@ bool CefNetworkDelegate::AreStrictSecureCookiesEnabled() { base::CompareCase::INSENSITIVE_ASCII); } +std::unique_ptr CefNetworkDelegate::CreateSourceStream( + net::URLRequest* request, + std::unique_ptr upstream) { + CefRefPtr cef_filter; + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForRequest(request); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr frame = browser->GetFrameForRequest(request); + + CefRefPtr cefRequest = new CefRequestImpl(); + cefRequest->Set(request); + cefRequest->SetReadOnly(true); + + CefRefPtr cefResponse = new CefResponseImpl(); + cefResponse->Set(request); + cefResponse->SetReadOnly(true); + + cef_filter = handler->GetResourceResponseFilter(browser.get(), frame, + cefRequest.get(), + cefResponse.get()); + } + } + } + + if (cef_filter && cef_filter->InitFilter()) + return base::MakeUnique(cef_filter, std::move(upstream)); + + return upstream; +} + int CefNetworkDelegate::OnBeforeURLRequest( net::URLRequest* request, const net::CompletionCallback& callback, @@ -442,55 +472,3 @@ bool CefNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const { bool CefNetworkDelegate::OnAreStrictSecureCookiesEnabled() const { return AreStrictSecureCookiesEnabled(); } - -net::Filter* CefNetworkDelegate::SetupFilter(net::URLRequest* request, - net::Filter* filter_list) { - CefRefPtr cef_filter; - - CefRefPtr browser = - CefBrowserHostImpl::GetBrowserForRequest(request); - if (browser.get()) { - CefRefPtr client = browser->GetClient(); - if (client.get()) { - CefRefPtr handler = client->GetRequestHandler(); - if (handler.get()) { - CefRefPtr frame = browser->GetFrameForRequest(request); - - CefRefPtr cefRequest = new CefRequestImpl(); - cefRequest->Set(request); - cefRequest->SetReadOnly(true); - - CefRefPtr cefResponse = new CefResponseImpl(); - cefResponse->Set(request); - cefResponse->SetReadOnly(true); - - cef_filter = handler->GetResourceResponseFilter(browser.get(), frame, - cefRequest.get(), - cefResponse.get()); - } - } - } - - if (cef_filter.get() && cef_filter->InitFilter()) { - std::unique_ptr wrapper( - new CefResponseFilterWrapper(cef_filter, filter_list != nullptr)); - wrapper->InitBuffer(kFilterBufSize); - - if (filter_list) { - // Install the wrapper at the end of the filter list. - net::Filter* last_filter = filter_list; - do { - if (!last_filter->next_filter_.get()) { - last_filter->next_filter_ = std::move(wrapper); - break; - } - last_filter = last_filter->next_filter_.get(); - } while (last_filter); - } else { - // Only the wrapper exists. - filter_list = wrapper.release(); - } - } - - return filter_list; -} diff --git a/libcef/browser/net/network_delegate.h b/libcef/browser/net/network_delegate.h index e87b61f97..fcb2dac74 100644 --- a/libcef/browser/net/network_delegate.h +++ b/libcef/browser/net/network_delegate.h @@ -31,6 +31,9 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl { private: // net::NetworkDelegate methods. + std::unique_ptr CreateSourceStream( + net::URLRequest* request, + std::unique_ptr upstream) override; int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) override; @@ -44,8 +47,6 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl { const base::FilePath& path) const override; bool OnAreExperimentalCookieFeaturesEnabled() const override; bool OnAreStrictSecureCookiesEnabled() const override; - net::Filter* SetupFilter(net::URLRequest* request, - net::Filter* filter_list) override; // Weak, owned by our owner (CefURLRequestContextGetterImpl). BooleanPrefMember* force_google_safesearch_; diff --git a/libcef/browser/net/response_filter_wrapper.cc b/libcef/browser/net/response_filter_wrapper.cc deleted file mode 100644 index 9a57898d6..000000000 --- a/libcef/browser/net/response_filter_wrapper.cc +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2014 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/net/response_filter_wrapper.h" - -#include "base/logging.h" - -// FilterType is used for logging purposes only. -CefResponseFilterWrapper::CefResponseFilterWrapper( - CefRefPtr cef_filter, - bool has_other_filters) - : Filter(Filter::FILTER_TYPE_UNSUPPORTED), - cef_filter_(cef_filter), - has_other_filters_(has_other_filters) { - DCHECK(cef_filter_.get()); -} - -CefResponseFilterWrapper::~CefResponseFilterWrapper() { -} - -net::Filter::FilterStatus CefResponseFilterWrapper::ReadFilteredData( - char* dest_buffer, - int* dest_len) { - if (!dest_buffer || !dest_len || *dest_len <= 0) - return net::Filter::FILTER_ERROR; - - size_t data_in_size = static_cast(stream_data_len_); - size_t data_in_read = 0; - size_t data_out_size = static_cast(*dest_len); - size_t data_out_write = 0; - - cef_response_filter_status_t cef_status = cef_filter_->Filter( - next_stream_data_, data_in_size, data_in_read, - dest_buffer, data_out_size, data_out_write); - - // Return early if there's an error. - if (cef_status == RESPONSE_FILTER_ERROR) - return net::Filter::FILTER_ERROR; - - // Normalize the out values. - if (data_in_read > data_in_size) { - LOG(ERROR) << - "potential buffer overflow; data_in_read exceeds data_in_size"; - data_in_read = data_in_size; - } - if (data_out_write > data_out_size) { - LOG(ERROR) << - "potential buffer overflow; data_out_write exceeds data_out_size"; - data_out_write = data_out_size; - } - - // Output the number of bytes written. - *dest_len = static_cast(data_out_write); - - if (data_in_size - data_in_read > 0U) { - // There are bytes left so adjust the stream pointer and return FILTER_OK. - next_stream_data_ += data_in_read; - stream_data_len_ -= static_cast(data_in_read); - return Filter::FILTER_OK; - } - - // No bytes left. Might need more data or might be done. - // If |has_other_filters_| is true then we must return FILTER_NEED_MORE_DATA - // or additional data will not be sent. - next_stream_data_ = nullptr; - stream_data_len_ = 0; - if (cef_status == RESPONSE_FILTER_NEED_MORE_DATA || has_other_filters_) - return Filter::FILTER_NEED_MORE_DATA; - return Filter::FILTER_DONE; -} diff --git a/libcef/browser/net/response_filter_wrapper.h b/libcef/browser/net/response_filter_wrapper.h deleted file mode 100644 index a925911ad..000000000 --- a/libcef/browser/net/response_filter_wrapper.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 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_NET_RESPONSE_FILTER_WRAPPER_H_ -#define CEF_LIBCEF_BROWSER_NET_RESPONSE_FILTER_WRAPPER_H_ - -#include "include/cef_response_filter.h" - -#include "base/macros.h" -#include "net/filter/filter.h" - -class CefResponseFilterWrapper : public net::Filter { - public: - CefResponseFilterWrapper(CefRefPtr cef_filter, - bool has_other_filters); - ~CefResponseFilterWrapper() override; - - // Decodes the pre-filter data and writes the output into the dest_buffer - // passed in. - // The function returns FilterStatus. See filter.h for its description. - // - // Upon entry, *dest_len is the total size (in number of chars) of the - // destination buffer. Upon exit, *dest_len is the actual number of chars - // written into the destination buffer. - // - // This function will fail if there is no pre-filter data in the - // stream_buffer_. On the other hand, *dest_len can be 0 upon successful - // return. For example, the internal filter may process some pre-filter data - // but not produce output yet. - FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len) override; - - private: - CefRefPtr cef_filter_; - const bool has_other_filters_; - - DISALLOW_COPY_AND_ASSIGN(CefResponseFilterWrapper); -}; - -#endif // CEF_LIBCEF_BROWSER_NET_RESPONSE_FILTER_WRAPPER_H_ diff --git a/libcef/browser/net/scheme_handler.cc b/libcef/browser/net/scheme_handler.cc index 69aec2f25..8dae14f69 100644 --- a/libcef/browser/net/scheme_handler.cc +++ b/libcef/browser/net/scheme_handler.cc @@ -14,6 +14,7 @@ #include "base/threading/sequenced_worker_pool.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/url_constants.h" +#include "net/net_features.h" #include "net/url_request/data_protocol_handler.h" #include "net/url_request/file_protocol_handler.h" #include "net/url_request/ftp_protocol_handler.h" @@ -26,7 +27,7 @@ void InstallInternalProtectedHandlers( net::URLRequestJobFactoryImpl* job_factory, CefURLRequestManager* request_manager, content::ProtocolHandlerMap* protocol_handlers, - net::FtpTransactionFactory* ftp_transaction_factory) { + net::HostResolver* host_resolver) { protocol_handlers->insert( std::make_pair(url::kDataScheme, linked_ptr( @@ -38,11 +39,11 @@ void InstallInternalProtectedHandlers( content::BrowserThread::GetBlockingPool()-> GetTaskRunnerWithShutdownBehavior( base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))))); -#if !defined(DISABLE_FTP_SUPPORT) +#if !BUILDFLAG(DISABLE_FTP_SUPPORT) protocol_handlers->insert( std::make_pair(url::kFtpScheme, linked_ptr( - new net::FtpProtocolHandler(ftp_transaction_factory)))); + net::FtpProtocolHandler::Create(host_resolver).release()))); #endif for (content::ProtocolHandlerMap::iterator it = diff --git a/libcef/browser/net/scheme_handler.h b/libcef/browser/net/scheme_handler.h index 427f5c38e..776d8c557 100644 --- a/libcef/browser/net/scheme_handler.h +++ b/libcef/browser/net/scheme_handler.h @@ -12,7 +12,7 @@ #include "url/gurl.h" namespace net { -class FtpTransactionFactory; +class HostResolver; class URLRequestJobFactoryImpl; } @@ -26,7 +26,7 @@ void InstallInternalProtectedHandlers( net::URLRequestJobFactoryImpl* job_factory, CefURLRequestManager* request_manager, content::ProtocolHandlerMap* protocol_handlers, - net::FtpTransactionFactory* ftp_transaction_factory); + net::HostResolver* host_resolver); // Register the internal scheme handlers that can be overridden. void RegisterInternalHandlers(CefURLRequestManager* request_manager); diff --git a/libcef/browser/net/source_stream.cc b/libcef/browser/net/source_stream.cc new file mode 100644 index 000000000..5c6622c01 --- /dev/null +++ b/libcef/browser/net/source_stream.cc @@ -0,0 +1,77 @@ +// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/net/source_stream.h" + +#include + +#include "net/base/io_buffer.h" + +// Use TYPE_INVALID so that URLRequestJob::NotifyHeadersComplete() doesn't +// assume that the "content-length" header is accurate. +CefSourceStream::CefSourceStream( + CefRefPtr cef_filter, + std::unique_ptr upstream) + : net::FilterSourceStream(net::SourceStream::TYPE_INVALID, + std::move(upstream)), + cef_filter_(cef_filter) { +} + +int CefSourceStream::FilterData(net::IOBuffer* output_buffer, + int output_buffer_size, + net::IOBuffer* input_buffer, + int input_buffer_size, + int* consumed_bytes, + bool upstream_eof_reached) { + if (!output_buffer || output_buffer_size <= 0) + return net::ERR_CONTENT_DECODING_FAILED; + + if (input_buffer_size == 0 && last_status_ == RESPONSE_FILTER_DONE) { + // No more input data. Respect the client's desire to be done with + // outputting data. + *consumed_bytes = 0; + return 0; + } + + size_t data_in_size = static_cast(input_buffer_size); + size_t data_in_read = 0; + size_t data_out_size = static_cast(output_buffer_size); + size_t data_out_written = 0; + + last_status_ = cef_filter_->Filter( + data_in_size > 0 ? input_buffer->data() : nullptr, + data_in_size, data_in_read, + output_buffer->data(), data_out_size, data_out_written); + + // Return early if there's an error. + if (last_status_ == RESPONSE_FILTER_ERROR) + return net::ERR_CONTENT_DECODING_FAILED; + + // Validate the out values. + if (data_in_read > data_in_size) { + LOG(ERROR) << "potential buffer overflow; data_in_read > data_in_size"; + return net::ERR_CONTENT_DECODING_FAILED; + } + if (data_out_written > data_out_size) { + LOG(ERROR) << "potential buffer overflow; data_out_written > data_out_size"; + return net::ERR_CONTENT_DECODING_FAILED; + } + + // If FilterData() returns 0, *|consumed_bytes| must be equal to + // |input_buffer_size|. + if (data_out_written == 0 && data_in_read != data_in_size) { + LOG(ERROR) << "when no data is written all input must be consumed; " + "data_out_written == 0 && data_in_read != data_in_size"; + return net::ERR_CONTENT_DECODING_FAILED; + } + + *consumed_bytes = static_cast(data_in_read); + + // Output the number of bytes written. + return static_cast(data_out_written); +} + +std::string CefSourceStream::GetTypeAsString() const { + return "cef_filter"; +} diff --git a/libcef/browser/net/source_stream.h b/libcef/browser/net/source_stream.h new file mode 100644 index 000000000..da260bacb --- /dev/null +++ b/libcef/browser/net/source_stream.h @@ -0,0 +1,34 @@ +// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_NET_SOURCE_STREAM_H_ +#define CEF_LIBCEF_BROWSER_NET_SOURCE_STREAM_H_ + +#include "include/cef_response_filter.h" + +#include "base/macros.h" +#include "net/filter/filter_source_stream.h" + +class CefSourceStream : public net::FilterSourceStream { + public: + CefSourceStream(CefRefPtr cef_filter, + std::unique_ptr upstream); + + int FilterData(net::IOBuffer* output_buffer, + int output_buffer_size, + net::IOBuffer* input_buffer, + int input_buffer_size, + int* consumed_bytes, + bool upstream_eof_reached) override; + std::string GetTypeAsString() const override; + + private: + CefRefPtr cef_filter_; + + cef_response_filter_status_t last_status_ = RESPONSE_FILTER_NEED_MORE_DATA; + + DISALLOW_COPY_AND_ASSIGN(CefSourceStream); +}; + +#endif // CEF_LIBCEF_BROWSER_NET_SOURCE_STREAM_H_ \ No newline at end of file diff --git a/libcef/browser/net/url_request_context_getter_impl.cc b/libcef/browser/net/url_request_context_getter_impl.cc index 1235dd9d3..40da1d7da 100644 --- a/libcef/browser/net/url_request_context_getter_impl.cc +++ b/libcef/browser/net/url_request_context_getter_impl.cc @@ -322,20 +322,16 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() { std::move(main_backend), true /* set_up_quic_server_info */))); -#if !defined(DISABLE_FTP_SUPPORT) - ftp_transaction_factory_.reset( - new net::FtpNetworkLayer(network_session_params.host_resolver)); -#endif - std::unique_ptr job_factory( new net::URLRequestJobFactoryImpl()); url_request_manager_.reset(new CefURLRequestManager(job_factory.get())); // Install internal scheme handlers that cannot be overridden. - scheme::InstallInternalProtectedHandlers(job_factory.get(), - url_request_manager_.get(), - &protocol_handlers_, - ftp_transaction_factory_.get()); + scheme::InstallInternalProtectedHandlers( + job_factory.get(), + url_request_manager_.get(), + &protocol_handlers_, + network_session_params.host_resolver); protocol_handlers_.clear(); // Register internal scheme handlers that can be overridden. diff --git a/libcef/browser/net/url_request_context_getter_impl.h b/libcef/browser/net/url_request_context_getter_impl.h index 2cb192b9d..b5aa16207 100644 --- a/libcef/browser/net/url_request_context_getter_impl.h +++ b/libcef/browser/net/url_request_context_getter_impl.h @@ -105,7 +105,6 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter { std::unique_ptr http_auth_preferences_; std::unique_ptr url_request_context_; std::unique_ptr url_request_manager_; - std::unique_ptr ftp_transaction_factory_; content::ProtocolHandlerMap protocol_handlers_; content::URLRequestInterceptorScopedVector request_interceptors_; diff --git a/libcef/browser/osr/browser_platform_delegate_osr.cc b/libcef/browser/osr/browser_platform_delegate_osr.cc index 42a2639a0..51d78a8ab 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr.cc @@ -11,6 +11,8 @@ #include "libcef/browser/osr/web_contents_view_osr.h" #include "libcef/common/drag_data_impl.h" +#include "content/browser/renderer_host/render_widget_host_input_event_router.h" +#include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/render_view_host.h" CefBrowserPlatformDelegateOsr::CefBrowserPlatformDelegateOsr( @@ -247,52 +249,119 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter( CefRefPtr drag_data, const CefMouseEvent& event, cef_drag_operations_mask_t allowed_ops) { - content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost(); - if (!rvh) + content::WebContentsImpl* web_contents = + static_cast(browser_->web_contents()); + if (!web_contents) return; + if (current_rvh_for_drag_) + DragTargetDragLeave(); + + const gfx::Point client_pt(event.x, event.y); + gfx::Point transformed_pt; + current_rwh_for_drag_ = + web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint( + web_contents->GetRenderViewHost()->GetWidget()->GetView(), + client_pt, &transformed_pt)->GetWeakPtr(); + current_rvh_for_drag_ = web_contents->GetRenderViewHost(); + drag_data_ = drag_data; + drag_allowed_ops_ = allowed_ops; CefDragDataImpl* data_impl = static_cast(drag_data.get()); base::AutoLock lock_scope(data_impl->lock()); content::DropData* drop_data = data_impl->drop_data(); - const gfx::Point client_pt(event.x, event.y); const gfx::Point& screen_pt = GetScreenPoint(client_pt); blink::WebDragOperationsMask ops = static_cast(allowed_ops); int modifiers = TranslateModifiers(event.modifiers); - rvh->FilterDropData(drop_data); - rvh->DragTargetDragEnter(*drop_data, client_pt, screen_pt, ops, modifiers); + current_rwh_for_drag_->FilterDropData(drop_data); + + // Give the delegate an opportunity to cancel the drag. + if (web_contents->GetDelegate() && + !web_contents->GetDelegate()->CanDragEnter( + web_contents, *drop_data, ops)) { + drag_data_ = nullptr; + return; + } + + current_rwh_for_drag_->DragTargetDragEnter( + *drop_data, transformed_pt, screen_pt, ops, modifiers); } void CefBrowserPlatformDelegateOsr::DragTargetDragOver( const CefMouseEvent& event, cef_drag_operations_mask_t allowed_ops) { - content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost(); - if (!rvh) + if (!drag_data_) + return; + + content::WebContentsImpl* web_contents = + static_cast(browser_->web_contents()); + if (!web_contents) return; const gfx::Point client_pt(event.x, event.y); + gfx::Point transformed_pt; + content::RenderWidgetHostImpl* target_rwh = + web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint( + web_contents->GetRenderViewHost()->GetWidget()->GetView(), + client_pt, &transformed_pt); + + if (target_rwh != current_rwh_for_drag_.get()) { + if (current_rwh_for_drag_) + current_rwh_for_drag_->DragTargetDragLeave(); + DragTargetDragEnter(drag_data_, event, drag_allowed_ops_); + } + + if (!drag_data_) + return; + const gfx::Point& screen_pt = GetScreenPoint(client_pt); blink::WebDragOperationsMask ops = static_cast(allowed_ops); int modifiers = TranslateModifiers(event.modifiers); - rvh->DragTargetDragOver(client_pt, screen_pt, ops, modifiers); + target_rwh->DragTargetDragOver(transformed_pt, screen_pt, ops, modifiers); } void CefBrowserPlatformDelegateOsr::DragTargetDragLeave() { - content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost(); - if (!rvh) + if (current_rvh_for_drag_ != browser_->web_contents()->GetRenderViewHost() || + !drag_data_) { return; + } - rvh->DragTargetDragLeave(); + if (current_rwh_for_drag_) { + current_rwh_for_drag_->DragTargetDragLeave(); + current_rwh_for_drag_.reset(); + } + + drag_data_ = nullptr; } void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) { - content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost(); - if (!rvh) + if (!drag_data_) + return; + + content::WebContentsImpl* web_contents = + static_cast(browser_->web_contents()); + if (!web_contents) + return; + + gfx::Point client_pt(event.x, event.y); + gfx::Point transformed_pt; + content::RenderWidgetHostImpl* target_rwh = + web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint( + web_contents->GetRenderViewHost()->GetWidget()->GetView(), + client_pt, &transformed_pt); + + if (target_rwh != current_rwh_for_drag_.get()) { + if (current_rwh_for_drag_) + current_rwh_for_drag_->DragTargetDragLeave(); + DragTargetDragEnter(drag_data_, event, drag_allowed_ops_); + } + + if (!drag_data_) return; { @@ -300,35 +369,85 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) { static_cast(drag_data_.get()); base::AutoLock lock_scope(data_impl->lock()); content::DropData* drop_data = data_impl->drop_data(); - const gfx::Point client_pt(event.x, event.y); const gfx::Point& screen_pt = GetScreenPoint(client_pt); int modifiers = TranslateModifiers(event.modifiers); - rvh->DragTargetDrop(*drop_data, client_pt, screen_pt, modifiers); + target_rwh->DragTargetDrop(*drop_data, transformed_pt, screen_pt, + modifiers); } drag_data_ = nullptr; } +void CefBrowserPlatformDelegateOsr::StartDragging( + const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) { + drag_start_rwh_ = source_rwh->GetWeakPtr(); + + bool handled = false; + + CefRefPtr handler = + browser_->GetClient()->GetRenderHandler(); + if (handler.get()) { + CefRefPtr drag_data(new CefDragDataImpl(drop_data)); + drag_data->SetReadOnly(true); + base::MessageLoop::ScopedNestableTaskAllower allow( + base::MessageLoop::current()); + handled = handler->StartDragging( + browser_, + drag_data.get(), + static_cast(allowed_ops), + event_info.event_location.x(), + event_info.event_location.y()); + } + + if (!handled) + DragSourceSystemDragEnded(); +} + +void CefBrowserPlatformDelegateOsr::UpdateDragCursor( + blink::WebDragOperation operation) { + CefRefPtr handler = + browser_->GetClient()->GetRenderHandler(); + if (handler.get()) { + handler->UpdateDragCursor( + browser_, static_cast(operation)); + } +} + void CefBrowserPlatformDelegateOsr::DragSourceEndedAt( int x, int y, cef_drag_operations_mask_t op) { - content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost(); - if (!rvh) + if (!drag_start_rwh_) + return; + + content::WebContentsImpl* web_contents = + static_cast(browser_->web_contents()); + if (!web_contents) return; const gfx::Point& screen_pt = GetScreenPoint(gfx::Point(x, y)); blink::WebDragOperation drag_op = static_cast(op); - rvh->DragSourceEndedAt(x, y, screen_pt.x(), screen_pt.y(), drag_op); + web_contents->DragSourceEndedAt(x, y, screen_pt.x(), screen_pt.y(), drag_op, + drag_start_rwh_.get()); } void CefBrowserPlatformDelegateOsr::DragSourceSystemDragEnded() { - content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost(); - if (!rvh) + if (!drag_start_rwh_) return; - rvh->DragSourceSystemDragEnded(); + content::WebContents* web_contents = browser_->web_contents(); + if (!web_contents) + return; + + web_contents->SystemDragEnded(drag_start_rwh_.get()); + + drag_start_rwh_ = nullptr; } CefWindowHandle CefBrowserPlatformDelegateOsr::GetParentWindowHandle() const { diff --git a/libcef/browser/osr/browser_platform_delegate_osr.h b/libcef/browser/osr/browser_platform_delegate_osr.h index d7c8dfb4d..f14b425f6 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.h +++ b/libcef/browser/osr/browser_platform_delegate_osr.h @@ -11,6 +11,10 @@ class CefRenderWidgetHostViewOSR; class CefWebContentsViewOSR; +namespace content { +class RenderWidgetHostImpl; +} + // Base implementation of windowless browser functionality. class CefBrowserPlatformDelegateOsr : public CefBrowserPlatformDelegate, @@ -72,6 +76,14 @@ class CefBrowserPlatformDelegateOsr : cef_drag_operations_mask_t allowed_ops) override; void DragTargetDragLeave() override; void DragTargetDrop(const CefMouseEvent& event) override; + void StartDragging( + const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) override; + void UpdateDragCursor(blink::WebDragOperation operation) override; void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op) override; void DragSourceSystemDragEnded() override; @@ -95,6 +107,20 @@ class CefBrowserPlatformDelegateOsr : // Pending drag/drop data. CefRefPtr drag_data_; + cef_drag_operations_mask_t drag_allowed_ops_; + + // We keep track of the RenderWidgetHost we're dragging over. If it changes + // during a drag, we need to re-send the DragEnter message. + base::WeakPtr current_rwh_for_drag_; + + // We also keep track of the RenderViewHost we're dragging over to avoid + // sending the drag exited message after leaving the current + // view. |current_rvh_for_drag_| should not be dereferenced. + void* current_rvh_for_drag_; + + // We keep track of the RenderWidgetHost from which the current drag started, + // in order to properly route the drag end message to it. + base::WeakPtr drag_start_rwh_; }; #endif // CEF_LIBCEF_BROWSER_OSR_BROWSER_PLATFORM_DELEGATE_OSR_H_ diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index 13eb412e3..09dea77a0 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -1090,10 +1090,6 @@ CefRenderWidgetHostViewOSR::DelegatedFrameHostSendReclaimCompositorResources( resources)); } -void CefRenderWidgetHostViewOSR::DelegatedFrameHostOnLostCompositorResources() { - render_widget_host_->ScheduleComposite(); -} - void CefRenderWidgetHostViewOSR::SetBeginFrameSource( cc::BeginFrameSource* source) { // TODO(cef): Maybe we can use this method in combination with diff --git a/libcef/browser/osr/render_widget_host_view_osr.h b/libcef/browser/osr/render_widget_host_view_osr.h index 8af787710..6377e4a74 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.h +++ b/libcef/browser/osr/render_widget_host_view_osr.h @@ -190,7 +190,6 @@ class CefRenderWidgetHostViewOSR int output_surface_id, bool is_swap_ack, const cc::ReturnedResourceArray& resources) override; - void DelegatedFrameHostOnLostCompositorResources() override; void SetBeginFrameSource(cc::BeginFrameSource* source) override; bool IsAutoResizeEnabled() const override; #endif // !defined(OS_MACOSX) 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 cb2cb5994..c5dc92088 100644 --- a/libcef/browser/osr/render_widget_host_view_osr_mac.mm +++ b/libcef/browser/osr/render_widget_host_view_osr_mac.mm @@ -58,10 +58,6 @@ class MacHelper : is_swap_ack, resources)); } - void BrowserCompositorMacOnLostCompositorResources() override { - view_->render_widget_host()->ScheduleComposite(); - } - void BrowserCompositorMacSendBeginFrame( const cc::BeginFrameArgs& args) override { view_->render_widget_host()->Send( diff --git a/libcef/browser/osr/software_output_device_osr.cc b/libcef/browser/osr/software_output_device_osr.cc index 074dfa398..8b4968b56 100644 --- a/libcef/browser/osr/software_output_device_osr.cc +++ b/libcef/browser/osr/software_output_device_osr.cc @@ -32,8 +32,6 @@ void CefSoftwareOutputDeviceOSR::Resize(const gfx::Size& viewport_pixel_size, float scale_factor) { CEF_REQUIRE_UIT(); - scale_factor_ = scale_factor; - if (viewport_pixel_size_ == viewport_pixel_size) return; diff --git a/libcef/browser/osr/web_contents_view_osr.cc b/libcef/browser/osr/web_contents_view_osr.cc index c39a29c51..5f87987ac 100644 --- a/libcef/browser/osr/web_contents_view_osr.cc +++ b/libcef/browser/osr/web_contents_view_osr.cc @@ -197,7 +197,8 @@ void CefWebContentsViewOSR::StartDragging( blink::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info) { + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) { if (guest_) { // Based on WebContentsViewGuest::StartDragging. content::WebContentsImpl* embedder_web_contents = @@ -213,36 +214,24 @@ void CefWebContentsViewOSR::StartDragging( content::RecordAction( base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); view->StartDragging(drop_data, allowed_ops, image, image_offset, - event_info); + event_info, source_rwh); } else { - embedder_web_contents->SystemDragEnded(); + embedder_web_contents->SystemDragEnded(source_rwh); } return; } CefRefPtr browser; - CefRefPtr handler; - bool handled = false; CefRenderWidgetHostViewOSR* view = static_cast(view_); if (view) browser = view->browser_impl(); - if (browser.get()) - handler = browser->GetClient()->GetRenderHandler(); - if (handler.get()) { - CefRefPtr drag_data(new CefDragDataImpl(drop_data)); - drag_data->SetReadOnly(true); - base::MessageLoop::ScopedNestableTaskAllower allow( - base::MessageLoop::current()); - handled = handler->StartDragging( - browser.get(), - drag_data.get(), - static_cast(allowed_ops), - event_info.event_location.x(), - event_info.event_location.y()); + if (browser.get()) { + browser->StartDragging(drop_data, allowed_ops, image, image_offset, + event_info, source_rwh); + } else if (web_contents_) { + web_contents_->SystemDragEnded(source_rwh); } - if (!handled && web_contents_) - web_contents_->SystemDragEnded(); } void CefWebContentsViewOSR::UpdateDragCursor( @@ -261,16 +250,10 @@ void CefWebContentsViewOSR::UpdateDragCursor( } CefRefPtr browser; - CefRefPtr handler; CefRenderWidgetHostViewOSR* view = static_cast(view_); if (view) browser = view->browser_impl(); if (browser.get()) - handler = browser->GetClient()->GetRenderHandler(); - if (handler.get()) { - handler->UpdateDragCursor( - browser.get(), - static_cast(operation)); - } + browser->UpdateDragCursor(operation); } diff --git a/libcef/browser/osr/web_contents_view_osr.h b/libcef/browser/osr/web_contents_view_osr.h index 3c6d1831f..95df8d78e 100644 --- a/libcef/browser/osr/web_contents_view_osr.h +++ b/libcef/browser/osr/web_contents_view_osr.h @@ -66,7 +66,8 @@ class CefWebContentsViewOSR : public content::WebContentsView, blink::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info) override; + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) override; void UpdateDragCursor(blink::WebDragOperation operation) override; private: diff --git a/libcef/browser/plugins/plugin_info_message_filter.cc b/libcef/browser/plugins/plugin_info_message_filter.cc index b3e176fee..37cd9ff88 100644 --- a/libcef/browser/plugins/plugin_info_message_filter.cc +++ b/libcef/browser/plugins/plugin_info_message_filter.cc @@ -20,6 +20,7 @@ #include "build/build_config.h" #include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugins_field_trial.h" +#include "chrome/common/features.h" #include "chrome/common/pref_names.h" #include "components/content_settings/core/browser/content_settings_utils.h" #include "content/public/browser/browser_context.h" @@ -60,18 +61,18 @@ bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) { return true; #endif -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) // Treat CDM invocations like JavaScript. if (plugin.name == base::ASCIIToUTF16(kWidevineCdmDisplayName)) { DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); return true; } -#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) return false; } -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) enum PluginAvailabilityStatusForUMA { PLUGIN_NOT_REGISTERED, @@ -92,14 +93,14 @@ static void SendPluginAvailabilityUMA(const std::string& mime_type, #endif // defined(WIDEVINE_CDM_AVAILABLE) } -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) void ReportMetrics(const std::string& mime_type, const GURL& url, const url::Origin& main_frame_origin) { } -#if defined(ENABLE_EXTENSIONS) +#if BUILDFLAG(ENABLE_EXTENSIONS) // Returns whether a request from a plugin to load |resource| from a renderer // with process id |process_id| is a request for an internal resource by an app // listed in |accessible_resources| in its manifest. @@ -129,7 +130,7 @@ bool IsPluginLoadingAccessibleResourceInWebView( return renderer_state->GetOwnerInfo(process_id, nullptr, &owner_extension) && owner_extension == extension_id; } -#endif // defined(ENABLE_EXTENSIONS) +#endif // BUILDFLAG(ENABLE_EXTENSIONS) } // namespace @@ -139,7 +140,7 @@ CefPluginInfoMessageFilter::Context::Context( : render_process_id_(render_process_id), resource_context_(profile->GetResourceContext()), host_content_settings_map_(profile->GetHostContentSettingsMap()) { -#if defined(ENABLE_EXTENSIONS) +#if BUILDFLAG(ENABLE_EXTENSIONS) if (extensions::ExtensionsEnabled()) extension_registry_ = extensions::ExtensionRegistry::Get(profile); #endif @@ -174,7 +175,7 @@ bool CefPluginInfoMessageFilter::OnMessageReceived( IPC_BEGIN_MESSAGE_MAP(CefPluginInfoMessageFilter, message) IPC_MESSAGE_HANDLER_DELAY_REPLY(CefViewHostMsg_GetPluginInfo, OnGetPluginInfo) -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) IPC_MESSAGE_HANDLER( CefViewHostMsg_IsInternalPluginAvailableForMimeType, OnIsInternalPluginAvailableForMimeType) @@ -249,7 +250,7 @@ void CefPluginInfoMessageFilter::PluginsLoaded( } } -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) void CefPluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType( const std::string& mime_type, @@ -285,7 +286,7 @@ void CefPluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType( mime_type, is_plugin_disabled ? PLUGIN_DISABLED : PLUGIN_NOT_REGISTERED); } -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) void CefPluginInfoMessageFilter::Context::DecidePluginStatus( const GetPluginInfo_Params& params, @@ -312,12 +313,13 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus( // TODO(tommycli): Remove once we deprecate the plugin ASK policy. bool legacy_ask_user = plugin_setting == CONTENT_SETTING_ASK; plugin_setting = PluginsFieldTrial::EffectiveContentSetting( - CONTENT_SETTINGS_TYPE_PLUGINS, plugin_setting); + host_content_settings_map_, CONTENT_SETTINGS_TYPE_PLUGINS, + plugin_setting); DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); DCHECK(plugin_setting != CONTENT_SETTING_ASK); -#if defined(ENABLE_PLUGIN_INSTALLATION) +#if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) // Check if the plugin is outdated. if (plugin_status == PluginMetadata::SECURITY_STATUS_OUT_OF_DATE && !allow_outdated_plugins_.GetValue()) { @@ -339,7 +341,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus( return; } -#if defined(ENABLE_EXTENSIONS) +#if BUILDFLAG(ENABLE_EXTENSIONS) // If an app has explicitly made internal resources available by listing them // in |accessible_resources| in the manifest, then allow them to be loaded by // plugins inside a guest-view. @@ -350,7 +352,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus( extension_registry_, render_process_id_, params.url)) { plugin_setting = CONTENT_SETTING_ALLOW; } -#endif // defined(ENABLE_EXTENSIONS) +#endif // BUILDFLAG(ENABLE_EXTENSIONS) if (plugin_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) { *status = CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; @@ -362,7 +364,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus( : CefViewHostMsg_GetPluginInfo_Status::kBlocked; } -#if defined(ENABLE_EXTENSIONS) +#if BUILDFLAG(ENABLE_EXTENSIONS) // Allow an embedder of to block a plugin from being loaded inside // the guest. In order to do this, set the status to 'Unauthorized' here, // and update the status as appropriate depending on the response from the diff --git a/libcef/browser/plugins/plugin_info_message_filter.h b/libcef/browser/plugins/plugin_info_message_filter.h index ddd4c7588..254c1167b 100644 --- a/libcef/browser/plugins/plugin_info_message_filter.h +++ b/libcef/browser/plugins/plugin_info_message_filter.h @@ -18,6 +18,8 @@ #include "components/content_settings/core/common/content_settings.h" #include "components/prefs/pref_member.h" #include "content/public/browser/browser_message_filter.h" +#include "extensions/features/features.h" +#include "ppapi/features/features.h" class CefBrowserContext; class CefRequestContextHandler; @@ -74,7 +76,7 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter { private: int render_process_id_; content::ResourceContext* resource_context_; -#if defined(ENABLE_EXTENSIONS) +#if BUILDFLAG(ENABLE_EXTENSIONS) extensions::ExtensionRegistry* extension_registry_; #endif const HostContentSettingsMap* host_content_settings_map_; @@ -109,7 +111,7 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter { IPC::Message* reply_msg, const std::vector& plugins); -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) // Returns whether any internal plugin supporting |mime_type| is registered // and enabled. Does not determine whether the plugin can actually be // instantiated (e.g. whether it has all its dependencies). diff --git a/libcef/browser/prefs/browser_prefs.cc b/libcef/browser/prefs/browser_prefs.cc index 3c2e2e614..0c241fa05 100644 --- a/libcef/browser/prefs/browser_prefs.cc +++ b/libcef/browser/prefs/browser_prefs.cc @@ -14,7 +14,7 @@ #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/net/prediction_options.h" -#include "chrome/browser/prefs/command_line_pref_store.h" +#include "chrome/browser/prefs/chrome_command_line_pref_store.h" #include "chrome/browser/supervised_user/supervised_user_pref_store.h" #include "chrome/browser/supervised_user/supervised_user_settings_service.h" #include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h" @@ -33,8 +33,8 @@ #include "components/proxy_config/pref_proxy_config_tracker_impl.h" #include "components/proxy_config/proxy_config_dictionary.h" #include "components/spellcheck/browser/pref_names.h" -#include "components/syncable_prefs/pref_service_syncable.h" -#include "components/syncable_prefs/pref_service_syncable_factory.h" +#include "components/sync_preferences/pref_service_syncable.h" +#include "components/sync_preferences/pref_service_syncable_factory.h" #include "components/update_client/update_client.h" #include "content/public/browser/browser_thread.h" #include "extensions/browser/extension_prefs.h" @@ -102,13 +102,13 @@ std::unique_ptr CreatePrefService( // Use of PrefServiceSyncable is required by Chrome code such as // HostContentSettingsMapFactory that calls PrefServiceSyncableFromProfile. - syncable_prefs::PrefServiceSyncableFactory factory; + sync_preferences::PrefServiceSyncableFactory factory; // Used to store command-line preferences, most of which will be evaluated in // the CommandLinePrefStore constructor. Preferences set in this manner cannot // be overridden by the user. - scoped_refptr command_line_pref_store( - new CommandLinePrefStore(command_line)); + scoped_refptr command_line_pref_store( + new ChromeCommandLinePrefStore(command_line)); renderer_prefs::SetCommandLinePrefDefaults(command_line_pref_store.get()); factory.set_command_line_prefs(command_line_pref_store); diff --git a/libcef/browser/prefs/renderer_prefs.cc b/libcef/browser/prefs/renderer_prefs.cc index 43f34bccb..a4e9d6cf9 100644 --- a/libcef/browser/prefs/renderer_prefs.cc +++ b/libcef/browser/prefs/renderer_prefs.cc @@ -20,10 +20,10 @@ #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_webkit_preferences.h" #include "chrome/browser/font_family_cache.h" -#include "chrome/browser/prefs/command_line_pref_store.h" #include "chrome/browser/ui/prefs/prefs_tab_helper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "components/prefs/command_line_pref_store.h" #include "components/prefs/pref_service.h" #include "components/prefs/pref_store.h" #include "components/pref_registry/pref_registry_syncable.h" @@ -52,8 +52,6 @@ void SetDefaultPrefs(content::WebPreferences& web) { !command_line->HasSwitch(switches::kDisableJavascriptCloseWindows); web.javascript_can_access_clipboard = !command_line->HasSwitch(switches::kDisableJavascriptAccessClipboard); - web.caret_browsing_enabled = - command_line->HasSwitch(switches::kEnableCaretBrowsing); web.allow_universal_access_from_file_urls = command_line->HasSwitch(switches::kAllowUniversalAccessFromFileUrls); web.shrinks_standalone_images_to_fit = @@ -247,7 +245,6 @@ void SetCefPrefs(const CefBrowserSettings& cef, SET_STATE(cef.javascript_access_clipboard, web.javascript_can_access_clipboard); SET_STATE(cef.javascript_dom_paste, web.dom_paste_enabled); - SET_STATE(cef.caret_browsing, web.caret_browsing_enabled); SET_STATE(cef.plugins, web.plugins_enabled); SET_STATE(cef.universal_access_from_file_urls, web.allow_universal_access_from_file_urls); diff --git a/libcef/browser/printing/print_view_manager.cc b/libcef/browser/printing/print_view_manager.cc index d267e0c36..06994563f 100644 --- a/libcef/browser/printing/print_view_manager.cc +++ b/libcef/browser/printing/print_view_manager.cc @@ -5,20 +5,20 @@ #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" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted_memory.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/printing/print_job_manager.h" -#include "chrome/browser/printing/print_preview_dialog_controller.h" #include "chrome/browser/printing/printer_query.h" #include "components/printing/common/print_messages.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "printing/pdf_metafile_skia.h" @@ -47,6 +47,7 @@ void FillInDictionaryFromPdfPrintSettings( print_settings.SetInteger(kSettingCopies, 1); print_settings.SetBoolean(kSettingCollate, false); print_settings.SetString(kSettingDeviceName, ""); + print_settings.SetInteger(kSettingScaleFactor, 100); print_settings.SetBoolean(kSettingGenerateDraftData, false); print_settings.SetBoolean(kSettingPreviewModifiable, false); @@ -119,9 +120,9 @@ void StopWorker(int document_cookie) { } scoped_refptr -GetDataFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) { - std::unique_ptr shared_buf( - new base::SharedMemory(handle, true)); + GetDataFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) { + std::unique_ptr shared_buf = + base::MakeUnique(handle, true); if (!shared_buf->Map(data_size)) { NOTREACHED(); @@ -156,6 +157,13 @@ void SavePdfFile(scoped_refptr data, } // namespace +struct CefPrintViewManager::PdfPrintState { + content::RenderFrameHost* printing_rfh_ = nullptr; + base::FilePath output_path_; + base::DictionaryValue settings_; + PdfPrintCallback callback_; +}; + CefPrintViewManager::CefPrintViewManager(content::WebContents* web_contents) : CefPrintViewManagerBase(web_contents) { } @@ -164,15 +172,62 @@ CefPrintViewManager::~CefPrintViewManager() { TerminatePdfPrintJob(); } -#if defined(ENABLE_BASIC_PRINTING) -bool CefPrintViewManager::PrintForSystemDialogNow() { - return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); -} -#endif // ENABLE_BASIC_PRINTING +bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh, + const base::FilePath& path, + const CefPdfPrintSettings& settings, + const PdfPrintCallback& callback) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); -bool CefPrintViewManager::OnMessageReceived(const IPC::Message& message) { + // Don't start print again while printing is currently in progress. + if (pdf_print_state_) + return false; + + // Don't print interstitials or crashed tabs. + if (!web_contents() || web_contents()->ShowingInterstitialPage() || + web_contents()->IsCrashed()) { + return false; + } + + pdf_print_state_.reset(new PdfPrintState); + pdf_print_state_->printing_rfh_ = rfh; + pdf_print_state_->output_path_ = path; + pdf_print_state_->callback_ = callback; + + FillInDictionaryFromPdfPrintSettings(settings, + ++next_pdf_request_id_, + pdf_print_state_->settings_); + + rfh->Send(new PrintMsg_InitiatePrintPreview(rfh->GetRoutingID(), + !!settings.selection_only)); + + return true; +} + +void CefPrintViewManager::RenderFrameDeleted( + content::RenderFrameHost* render_frame_host) { + if (pdf_print_state_ && + render_frame_host == pdf_print_state_->printing_rfh_) { + TerminatePdfPrintJob(); + } + CefPrintViewManagerBase::RenderFrameDeleted(render_frame_host); +} + +void CefPrintViewManager::NavigationStopped() { + TerminatePdfPrintJob(); + CefPrintViewManagerBase::NavigationStopped(); +} + +void CefPrintViewManager::RenderProcessGone(base::TerminationStatus status) { + TerminatePdfPrintJob(); + CefPrintViewManagerBase::RenderProcessGone(status); +} + +bool CefPrintViewManager::OnMessageReceived( + const IPC::Message& message, + content::RenderFrameHost* render_frame_host) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(CefPrintViewManager, message) + IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(CefPrintViewManager, message, + render_frame_host) IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog) IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, OnRequestPrintPreview) @@ -181,48 +236,22 @@ bool CefPrintViewManager::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() - return handled || CefPrintViewManagerBase::OnMessageReceived(message); + return handled || + CefPrintViewManagerBase::OnMessageReceived(message, render_frame_host); } -void CefPrintViewManager::NavigationStopped() { - CefPrintViewManagerBase::NavigationStopped(); - TerminatePdfPrintJob(); -} - -void CefPrintViewManager::RenderProcessGone(base::TerminationStatus status) { - CefPrintViewManagerBase::RenderProcessGone(status); - TerminatePdfPrintJob(); -} - -void CefPrintViewManager::PrintToPDF(const base::FilePath& path, - const CefPdfPrintSettings& settings, - const PdfPrintCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (!web_contents() || pdf_print_settings_) - return; - - pdf_output_path_ = path; - pdf_print_callback_ = callback; - - pdf_print_settings_.reset(new base::DictionaryValue); - FillInDictionaryFromPdfPrintSettings(settings, - ++next_pdf_request_id_, - *pdf_print_settings_); - - Send(new PrintMsg_InitiatePrintPreview(routing_id(), - !!settings.selection_only)); -} - -void CefPrintViewManager::OnDidShowPrintDialog() { +void CefPrintViewManager::OnDidShowPrintDialog(content::RenderFrameHost* rfh) { } void CefPrintViewManager::OnRequestPrintPreview( const PrintHostMsg_RequestPrintPreview_Params&) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (!web_contents() || !pdf_print_settings_) + if (!pdf_print_state_) return; - Send(new PrintMsg_PrintPreview(routing_id(), *pdf_print_settings_)); + pdf_print_state_->printing_rfh_->Send(new PrintMsg_PrintPreview( + pdf_print_state_->printing_rfh_->GetRoutingID(), + pdf_print_state_->settings_)); } void CefPrintViewManager::OnMetafileReadyForPrinting( @@ -230,6 +259,9 @@ void CefPrintViewManager::OnMetafileReadyForPrinting( DCHECK_CURRENTLY_ON(BrowserThread::UI); StopWorker(params.document_cookie); + if (!pdf_print_state_) + return; + scoped_refptr data_bytes = GetDataFromHandle(params.metafile_data_handle, params.data_size); if (!data_bytes || !data_bytes->size()) { @@ -237,37 +269,32 @@ void CefPrintViewManager::OnMetafileReadyForPrinting( return; } - base::FilePath pdf_output_path = pdf_output_path_; - PdfPrintCallback pdf_print_callback = pdf_print_callback_; + const base::FilePath output_path = pdf_print_state_->output_path_; + const PdfPrintCallback print_callback = pdf_print_state_->callback_; // Reset state information. - pdf_output_path_.clear(); - pdf_print_callback_.Reset(); - pdf_print_settings_.reset(); + pdf_print_state_.reset(); // Save the PDF file to disk and then execute the callback. BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - base::Bind(&SavePdfFile, data_bytes, pdf_output_path, - pdf_print_callback)); + base::Bind(&SavePdfFile, data_bytes, output_path, print_callback)); } void CefPrintViewManager::TerminatePdfPrintJob() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (!pdf_print_settings_.get()) + if (!pdf_print_state_) return; - if (!pdf_print_callback_.is_null()) { + if (!pdf_print_state_->callback_.is_null()) { // Execute the callback. BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(pdf_print_callback_, false)); + base::Bind(pdf_print_state_->callback_, false)); } // Reset state information. - pdf_output_path_.clear(); - pdf_print_callback_.Reset(); - pdf_print_settings_.reset(); + pdf_print_state_.reset(); } } // namespace printing diff --git a/libcef/browser/printing/print_view_manager.h b/libcef/browser/printing/print_view_manager.h index 703bcbb52..e586f63fb 100644 --- a/libcef/browser/printing/print_view_manager.h +++ b/libcef/browser/printing/print_view_manager.h @@ -10,13 +10,14 @@ #include "base/macros.h" #include "content/public/browser/web_contents_user_data.h" -struct PrintHostMsg_DidPreviewDocument_Params; -struct PrintHostMsg_RequestPrintPreview_Params; - namespace content { +class RenderFrameHost; class RenderProcessHost; } +struct PrintHostMsg_DidPreviewDocument_Params; +struct PrintHostMsg_RequestPrintPreview_Params; + namespace printing { // Manages the print commands for a WebContents. @@ -26,35 +27,28 @@ class CefPrintViewManager : public: ~CefPrintViewManager() override; -#if defined(ENABLE_BASIC_PRINTING) - // Same as PrintNow(), but for the case where a user prints with the system - // dialog from print preview. - bool PrintForSystemDialogNow(); -#endif // ENABLE_BASIC_PRINTING - - // content::WebContentsObserver implementation. - bool OnMessageReceived(const IPC::Message& message) override; - - // content::WebContentsObserver implementation. - // Cancels the print job. - void NavigationStopped() override; - // Terminates or cancels the print job if one was pending. - void RenderProcessGone(base::TerminationStatus status) override; - // Callback executed on PDF printing completion. typedef base::Callback PdfPrintCallback; // Print the current document to a PDF file. Execute |callback| on completion. - void PrintToPDF(const base::FilePath& path, + bool PrintToPDF(content::RenderFrameHost* rfh, + const base::FilePath& path, const CefPdfPrintSettings& settings, const PdfPrintCallback& callback); + // content::WebContentsObserver implementation. + void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; + void NavigationStopped() override; + void RenderProcessGone(base::TerminationStatus status) override; + bool OnMessageReceived(const IPC::Message& message, + content::RenderFrameHost* render_frame_host) override; + private: explicit CefPrintViewManager(content::WebContents* web_contents); friend class content::WebContentsUserData; // IPC Message handlers. - void OnDidShowPrintDialog(); + void OnDidShowPrintDialog(content::RenderFrameHost* rfh); void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&); void OnMetafileReadyForPrinting( const PrintHostMsg_DidPreviewDocument_Params&); @@ -63,9 +57,8 @@ class CefPrintViewManager : // Used for printing to PDF. Only accessed on the browser process UI thread. int next_pdf_request_id_ = -1; - base::FilePath pdf_output_path_; - std::unique_ptr pdf_print_settings_; - PdfPrintCallback pdf_print_callback_; + struct PdfPrintState; + std::unique_ptr pdf_print_state_; DISALLOW_COPY_AND_ASSIGN(CefPrintViewManager); }; diff --git a/libcef/browser/printing/print_view_manager_base.cc b/libcef/browser/printing/print_view_manager_base.cc index 01a3b535c..d3962e18c 100644 --- a/libcef/browser/printing/print_view_manager_base.cc +++ b/libcef/browser/printing/print_view_manager_base.cc @@ -4,23 +4,25 @@ #include "libcef/browser/printing/print_view_manager_base.h" +#include #include -#include "libcef/browser/content_browser_client.h" - #include "base/auto_reset.h" #include "base/bind.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/timer/timer.h" +#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" #include "components/prefs/pref_service.h" @@ -29,8 +31,10 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "printing/features/features.h" #include "printing/pdf_metafile_skia.h" #include "printing/printed_document.h" #include "ui/base/l10n/l10n_util.h" @@ -48,6 +52,7 @@ namespace printing { CefPrintViewManagerBase::CefPrintViewManagerBase( content::WebContents* web_contents) : PrintManager(web_contents), + printing_rfh_(nullptr), printing_succeeded_(false), inside_inner_message_loop_(false), #if !defined(OS_MACOSX) @@ -55,13 +60,11 @@ CefPrintViewManagerBase::CefPrintViewManagerBase( #endif queue_(g_browser_process->print_job_manager()->queue()) { DCHECK(queue_.get()); - PrefService* pref_service = - static_cast(web_contents->GetBrowserContext())-> - GetPrefs(); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); printing_enabled_.Init( - prefs::kPrintingEnabled, - pref_service, - base::Bind(&CefPrintViewManagerBase::UpdateScriptedPrintingBlocked, + prefs::kPrintingEnabled, profile->GetPrefs(), + base::Bind(&CefPrintViewManagerBase::UpdatePrintingEnabled, base::Unretained(this))); } @@ -70,16 +73,20 @@ CefPrintViewManagerBase::~CefPrintViewManagerBase() { DisconnectFromCurrentPrintJob(); } -#if defined(ENABLE_BASIC_PRINTING) -bool CefPrintViewManagerBase::PrintNow() { - return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); +#if BUILDFLAG(ENABLE_BASIC_PRINTING) +bool CefPrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) { + DisconnectFromCurrentPrintJob(); + + SetPrintingRFH(rfh); + int32_t id = rfh->GetRoutingID(); + return PrintNowInternal(rfh, base::MakeUnique(id)); } #endif -void CefPrintViewManagerBase::UpdateScriptedPrintingBlocked() { - Send(new PrintMsg_SetScriptedPrintingBlocked( - routing_id(), - !printing_enabled_.GetValue())); +void CefPrintViewManagerBase::UpdatePrintingEnabled() { + web_contents()->ForEachFrame( + base::Bind(&CefPrintViewManagerBase::SendPrintingEnabled, + base::Unretained(this), printing_enabled_.GetValue())); } void CefPrintViewManagerBase::NavigationStopped() { @@ -87,23 +94,6 @@ void CefPrintViewManagerBase::NavigationStopped() { TerminatePrintJob(true); } -void CefPrintViewManagerBase::RenderProcessGone( - base::TerminationStatus status) { - PrintManager::RenderProcessGone(status); - ReleasePrinterQuery(); - - if (!print_job_.get()) - return; - - scoped_refptr document(print_job_->document()); - if (document.get()) { - // If IsComplete() returns false, the document isn't completely rendered. - // Since our renderer is gone, there's nothing to do, cancel it. Otherwise, - // the print job may finish without problem. - TerminatePrintJob(!document->IsComplete()); - } -} - base::string16 CefPrintViewManagerBase::RenderSourceName() { base::string16 name(web_contents()->GetTitle()); if (name.empty()) @@ -173,24 +163,24 @@ void CefPrintViewManagerBase::OnDidPrintPage( #if defined(OS_WIN) print_job_->AppendPrintedPage(params.page_number); if (metafile_must_be_valid) { + // TODO(thestig): Figure out why rendering text with GDI results in random + // missing characters for some users. https://crbug.com/658606 bool print_text_with_gdi = document->settings().print_text_with_gdi() && !document->settings().printer_is_xps() && - !base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableGDITextPrinting); + switches::GDITextPrintingEnabled(); scoped_refptr bytes = new base::RefCountedBytes( reinterpret_cast(shared_buf->memory()), params.data_size); document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf")); print_job_->StartPdfToEmfConversion( - bytes, params.page_size, params.content_area, print_text_with_gdi); + bytes, params.page_size, params.content_area, + print_text_with_gdi); } #else // Update the rendered document. It will send notifications to the listener. - document->SetPage(params.page_number, - std::move(metafile), - params.page_size, + document->SetPage(params.page_number, std::move(metafile), params.page_size, params.content_area); ShouldQuitFromInnerMessageLoop(); @@ -212,18 +202,43 @@ void CefPrintViewManagerBase::OnShowInvalidPrinterSettingsError() { } void CefPrintViewManagerBase::DidStartLoading() { - UpdateScriptedPrintingBlocked(); + UpdatePrintingEnabled(); } -bool CefPrintViewManagerBase::OnMessageReceived(const IPC::Message& message) { +void CefPrintViewManagerBase::RenderFrameDeleted( + content::RenderFrameHost* render_frame_host) { + // Terminates or cancels the print job if one was pending. + if (render_frame_host != printing_rfh_) + return; + + printing_rfh_ = nullptr; + + PrintManager::PrintingRenderFrameDeleted(); + ReleasePrinterQuery(); + + if (!print_job_.get()) + return; + + scoped_refptr document(print_job_->document()); + if (document.get()) { + // If IsComplete() returns false, the document isn't completely rendered. + // Since our renderer is gone, there's nothing to do, cancel it. Otherwise, + // the print job may finish without problem. + TerminatePrintJob(!document->IsComplete()); + } +} + +bool CefPrintViewManagerBase::OnMessageReceived( + const IPC::Message& message, + content::RenderFrameHost* render_frame_host) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(CefPrintViewManagerBase, message) IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError, - OnShowInvalidPrinterSettingsError); + OnShowInvalidPrinterSettingsError) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() - return handled || PrintManager::OnMessageReceived(message); + return handled || PrintManager::OnMessageReceived(message, render_frame_host); } void CefPrintViewManagerBase::Observe( @@ -335,7 +350,7 @@ void CefPrintViewManagerBase::ShouldQuitFromInnerMessageLoop() { bool CefPrintViewManagerBase::CreateNewPrintJob(PrintJobWorkerOwner* job) { DCHECK(!inside_inner_message_loop_); - // Disconnect the current print_job_. + // Disconnect the current |print_job_|. DisconnectFromCurrentPrintJob(); // We can't print if there is no renderer. @@ -380,12 +395,6 @@ void CefPrintViewManagerBase::DisconnectFromCurrentPrintJob() { #endif } -void CefPrintViewManagerBase::PrintingDone(bool success) { - if (!print_job_.get()) - return; - Send(new PrintMsg_PrintingDone(routing_id(), success)); -} - void CefPrintViewManagerBase::TerminatePrintJob(bool cancel) { if (!print_job_.get()) return; @@ -407,16 +416,23 @@ void CefPrintViewManagerBase::TerminatePrintJob(bool cancel) { } void CefPrintViewManagerBase::ReleasePrintJob() { + content::RenderFrameHost* rfh = printing_rfh_; + printing_rfh_ = nullptr; + if (!print_job_.get()) return; - PrintingDone(printing_succeeded_); + if (rfh) { + auto msg = base::MakeUnique(rfh->GetRoutingID(), + printing_succeeded_); + rfh->Send(msg.release()); + } registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source(print_job_.get())); print_job_->DisconnectSource(); // Don't close the worker thread. - print_job_ = NULL; + print_job_ = nullptr; } bool CefPrintViewManagerBase::RunInnerMessageLoop() { @@ -485,14 +501,18 @@ bool CefPrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) { return true; } -bool CefPrintViewManagerBase::PrintNowInternal(IPC::Message* message) { +bool CefPrintViewManagerBase::PrintNowInternal( + content::RenderFrameHost* rfh, + std::unique_ptr message) { // Don't print / print preview interstitials or crashed tabs. - if (web_contents()->ShowingInterstitialPage() || - web_contents()->IsCrashed()) { - delete message; + if (web_contents()->ShowingInterstitialPage() || web_contents()->IsCrashed()) return false; - } - return Send(message); + return rfh->Send(message.release()); +} + +void CefPrintViewManagerBase::SetPrintingRFH(content::RenderFrameHost* rfh) { + DCHECK(!printing_rfh_); + printing_rfh_ = rfh; } void CefPrintViewManagerBase::ReleasePrinterQuery() { @@ -502,13 +522,12 @@ void CefPrintViewManagerBase::ReleasePrinterQuery() { int cookie = cookie_; cookie_ = 0; - printing::PrintJobManager* print_job_manager = - g_browser_process->print_job_manager(); + PrintJobManager* print_job_manager = g_browser_process->print_job_manager(); // May be NULL in tests. if (!print_job_manager) return; - scoped_refptr printer_query; + scoped_refptr printer_query; printer_query = queue_->PopPrinterQuery(cookie); if (!printer_query.get()) return; @@ -517,4 +536,10 @@ void CefPrintViewManagerBase::ReleasePrinterQuery() { base::Bind(&PrinterQuery::StopWorker, printer_query)); } +void CefPrintViewManagerBase::SendPrintingEnabled( + bool enabled, + content::RenderFrameHost* rfh) { + rfh->Send(new PrintMsg_SetPrintingEnabled(rfh->GetRoutingID(), enabled)); +} + } // namespace printing diff --git a/libcef/browser/printing/print_view_manager_base.h b/libcef/browser/printing/print_view_manager_base.h index 70301c082..e14da839f 100644 --- a/libcef/browser/printing/print_view_manager_base.h +++ b/libcef/browser/printing/print_view_manager_base.h @@ -5,6 +5,8 @@ #ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ #define CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ +#include + #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/strings/string16.h" @@ -13,12 +15,13 @@ #include "components/printing/browser/print_manager.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "printing/features/features.h" #include "printing/printed_pages_source.h" struct PrintHostMsg_DidPrintPage_Params; namespace content { -class RenderViewHost; +class RenderFrameHost; } namespace printing { @@ -36,15 +39,15 @@ class CefPrintViewManagerBase : public content::NotificationObserver, public: ~CefPrintViewManagerBase() override; -#if defined(ENABLE_BASIC_PRINTING) +#if BUILDFLAG(ENABLE_BASIC_PRINTING) // Prints the current document immediately. Since the rendering is // asynchronous, the actual printing will not be completed on the return of // this function. Returns false if printing is impossible at the moment. - virtual bool PrintNow(); + virtual bool PrintNow(content::RenderFrameHost* rfh); #endif // ENABLE_BASIC_PRINTING - // Whether to block scripted printing for our tab or not. - void UpdateScriptedPrintingBlocked(); + // Whether printing is enabled or not. + void UpdatePrintingEnabled(); // PrintedPagesSource implementation. base::string16 RenderSourceName() override; @@ -53,17 +56,19 @@ class CefPrintViewManagerBase : public content::NotificationObserver, explicit CefPrintViewManagerBase(content::WebContents* web_contents); // Helper method for Print*Now(). - bool PrintNowInternal(IPC::Message* message); + bool PrintNowInternal(content::RenderFrameHost* rfh, + std::unique_ptr message); + + void SetPrintingRFH(content::RenderFrameHost* rfh); + + // content::WebContentsObserver implementation. + void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; + bool OnMessageReceived(const IPC::Message& message, + content::RenderFrameHost* render_frame_host) override; // Cancels the print job. void NavigationStopped() override; - // Terminates or cancels the print job if one was pending. - void RenderProcessGone(base::TerminationStatus status) override; - - // content::WebContentsObserver implementation. - bool OnMessageReceived(const IPC::Message& message) override; - private: // content::NotificationObserver implementation. void Observe(int type, @@ -104,9 +109,6 @@ class CefPrintViewManagerBase : public content::NotificationObserver, // disconnect from it. void DisconnectFromCurrentPrintJob(); - // Notify that the printing is done. - void PrintingDone(bool success); - // Terminates the print job. No-op if no print job has been created. If // |cancel| is true, cancel it instead of waiting for the job to finish. Will // call ReleasePrintJob(). @@ -130,8 +132,14 @@ class CefPrintViewManagerBase : public content::NotificationObserver, // Release the PrinterQuery associated with our |cookie_|. void ReleasePrinterQuery(); + // Helper method for UpdatePrintingEnabled(). + void SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh); + content::NotificationRegistrar registrar_; + // The current RFH that is printing with a system printing dialog. + content::RenderFrameHost* printing_rfh_; + // Manages the low-level talk to the printer. scoped_refptr print_job_; diff --git a/libcef/browser/printing/printing_message_filter.cc b/libcef/browser/printing/printing_message_filter.cc index 4a156c5db..65f7f9237 100644 --- a/libcef/browser/printing/printing_message_filter.cc +++ b/libcef/browser/printing/printing_message_filter.cc @@ -4,19 +4,25 @@ #include "libcef/browser/printing/printing_message_filter.h" +#include #include #include #include "base/bind.h" +#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/common/pref_names.h" +#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h" #include "components/printing/browser/print_manager_utils.h" #include "components/printing/common/print_messages.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/child_process_host.h" +#include "printing/features/features.h" #if defined(OS_LINUX) #include "libcef/browser/printing/print_dialog_linux.h" @@ -26,24 +32,90 @@ using content::BrowserThread; namespace printing { -CefPrintingMessageFilter::CefPrintingMessageFilter(int render_process_id) +namespace { + +// There's a race condition between deletion of the CefPrintingMessageFilter +// object on the UI thread and deletion of the PrefService (owned by Profile) +// on the UI thread. If the PrefService will be deleted first then +// PrefMember::Destroy() must be called from ShutdownOnUIThread() to avoid +// heap-use-after-free on CefPrintingMessageFilter destruction (due to +// ~PrefMember trying to access the already-deleted PrefService). +// ShutdownNotifierFactory makes sure that ShutdownOnUIThread() is called in +// this case. +class ShutdownNotifierFactory + : public BrowserContextKeyedServiceShutdownNotifierFactory { + public: + static ShutdownNotifierFactory* GetInstance(); + + private: + friend struct base::DefaultLazyInstanceTraits; + + ShutdownNotifierFactory() + : BrowserContextKeyedServiceShutdownNotifierFactory( + "CefPrintingMessageFilter") { + } + ~ShutdownNotifierFactory() override {} + + DISALLOW_COPY_AND_ASSIGN(ShutdownNotifierFactory); +}; + +base::LazyInstance::Leaky + g_shutdown_notifier_factory = LAZY_INSTANCE_INITIALIZER; + +// static +ShutdownNotifierFactory* ShutdownNotifierFactory::GetInstance() { + return g_shutdown_notifier_factory.Pointer(); +} + +} // namespace + +CefPrintingMessageFilter::CefPrintingMessageFilter(int render_process_id, + Profile* profile) : content::BrowserMessageFilter(PrintMsgStart), render_process_id_(render_process_id), queue_(g_browser_process->print_job_manager()->queue()) { DCHECK(queue_.get()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); + shutdown_notifier_ = + ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe( + base::Bind(&CefPrintingMessageFilter::ShutdownOnUIThread, + base::Unretained(this))); + + is_printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs()); + is_printing_enabled_.MoveToThread( + content::BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); +} + +void CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt() { + ShutdownNotifierFactory::GetInstance(); } CefPrintingMessageFilter::~CefPrintingMessageFilter() { + DCHECK_CURRENTLY_ON(BrowserThread::UI); +} + +void CefPrintingMessageFilter::ShutdownOnUIThread() { + is_printing_enabled_.Destroy(); + shutdown_notifier_.reset(); } void CefPrintingMessageFilter::OverrideThreadForMessage( const IPC::Message& message, BrowserThread::ID* thread) { +#if defined(OS_ANDROID) + if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID || + message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) { + *thread = BrowserThread::UI; + } +#endif +} + +void CefPrintingMessageFilter::OnDestruct() const { + BrowserThread::DeleteOnUIThread::Destruct(this); } bool CefPrintingMessageFilter::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(CefPrintingMessageFilter, message) - IPC_MESSAGE_HANDLER(PrintHostMsg_IsPrintingEnabled, OnIsPrintingEnabled) IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings, OnGetDefaultPrintSettings) IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint) @@ -55,11 +127,6 @@ bool CefPrintingMessageFilter::OnMessageReceived(const IPC::Message& message) { return handled; } -void CefPrintingMessageFilter::OnIsPrintingEnabled(bool* is_enabled) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - *is_enabled = true; -} - void CefPrintingMessageFilter::OnGetDefaultPrintSettings( IPC::Message* reply_msg) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -70,6 +137,11 @@ void CefPrintingMessageFilter::OnGetDefaultPrintSettings( #endif scoped_refptr printer_query; + if (!is_printing_enabled_.GetValue()) { + // Reply with NULL query. + OnGetDefaultPrintSettingsReply(printer_query, reply_msg); + return; + } printer_query = queue_->PopPrinterQuery(0); if (!printer_query.get()) { printer_query = @@ -168,6 +240,11 @@ void CefPrintingMessageFilter::OnUpdatePrintSettings( std::unique_ptr new_settings(job_settings.DeepCopy()); scoped_refptr printer_query; + if (!is_printing_enabled_.GetValue()) { + // Reply with NULL query. + OnUpdatePrintSettingsReply(printer_query, reply_msg); + return; + } printer_query = queue_->PopPrinterQuery(document_cookie); if (!printer_query.get()) { int host_id = render_process_id_; diff --git a/libcef/browser/printing/printing_message_filter.h b/libcef/browser/printing/printing_message_filter.h index e6cd2b113..1288ed613 100644 --- a/libcef/browser/printing/printing_message_filter.h +++ b/libcef/browser/printing/printing_message_filter.h @@ -7,31 +7,25 @@ #include +#include #include -#include "base/compiler_specific.h" #include "base/macros.h" #include "build/build_config.h" +#include "components/keyed_service/core/keyed_service_shutdown_notifier.h" +#include "components/prefs/pref_member.h" #include "content/public/browser/browser_message_filter.h" - -#if defined(OS_WIN) -#include "base/memory/shared_memory.h" -#endif +#include "printing/features/features.h" struct PrintHostMsg_ScriptedPrint_Params; +class Profile; namespace base { class DictionaryValue; -class FilePath; -} - -namespace content { -class WebContents; } namespace printing { -class PrintJobManager; class PrintQueriesQueue; class PrinterQuery; @@ -39,24 +33,23 @@ class PrinterQuery; // renderer process on the IPC thread. class CefPrintingMessageFilter : public content::BrowserMessageFilter { public: - explicit CefPrintingMessageFilter(int render_process_id); + CefPrintingMessageFilter(int render_process_id, Profile* profile); + + static void EnsureShutdownNotifierFactoryBuilt(); // content::BrowserMessageFilter methods. void OverrideThreadForMessage(const IPC::Message& message, content::BrowserThread::ID* thread) override; + void OnDestruct() const override; bool OnMessageReceived(const IPC::Message& message) override; private: + friend class base::DeleteHelper; + friend class content::BrowserThread; + ~CefPrintingMessageFilter() override; - // GetPrintSettingsForRenderView must be called via PostTask and - // base::Bind. Collapse the settings-specific params into a - // struct to avoid running into issues with too many params - // to base::Bind. - struct GetPrintSettingsForRenderViewParams; - - // Checks if printing is enabled. - void OnIsPrintingEnabled(bool* is_enabled); + void ShutdownOnUIThread(); // Get the default print setting. void OnGetDefaultPrintSettings(IPC::Message* reply_msg); @@ -80,14 +73,20 @@ class CefPrintingMessageFilter : public content::BrowserMessageFilter { void OnUpdatePrintSettingsReply(scoped_refptr printer_query, IPC::Message* reply_msg); + // Check to see if print preview has been cancelled. void OnCheckForCancel(int32_t preview_ui_id, int preview_request_id, bool* cancel); + BooleanPrefMember is_printing_enabled_; + const int render_process_id_; scoped_refptr queue_; + std::unique_ptr + shutdown_notifier_; + DISALLOW_COPY_AND_ASSIGN(CefPrintingMessageFilter); }; diff --git a/libcef/browser/resource_dispatcher_host_delegate.cc b/libcef/browser/resource_dispatcher_host_delegate.cc index d84e706b7..0cd7c627e 100644 --- a/libcef/browser/resource_dispatcher_host_delegate.cc +++ b/libcef/browser/resource_dispatcher_host_delegate.cc @@ -81,29 +81,12 @@ CefResourceDispatcherHostDelegate::~CefResourceDispatcherHostDelegate() { bool CefResourceDispatcherHostDelegate::HandleExternalProtocol( const GURL& url, - int child_id, - const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, - bool is_main_frame, - ui::PageTransition page_transition, - bool has_user_gesture, - content::ResourceContext* resource_context) { - if (!CEF_CURRENTLY_ON_UIT()) { - CEF_POST_TASK(CEF_UIT, - base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate:: - HandleExternalProtocol), - base::Unretained(this), url, child_id, web_contents_getter, - is_main_frame, page_transition, has_user_gesture, - resource_context)); - return false; - } - - content::WebContents* web_contents = web_contents_getter.Run(); - if (web_contents) { - CefRefPtr browser = - CefBrowserHostImpl::GetBrowserForContents(web_contents); - if (browser.get()) - browser->HandleExternalProtocol(url); - } + content::ResourceRequestInfo* info) { + CEF_POST_TASK(CEF_UIT, + base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate:: + HandleExternalProtocolOnUIThread), + base::Unretained(this), url, + info->GetWebContentsGetterForRequest())); return false; } @@ -218,3 +201,17 @@ std::unique_ptr return static_cast(resource_context)-> CreateClientCertStore(); } + +void CefResourceDispatcherHostDelegate::HandleExternalProtocolOnUIThread( + const GURL& url, + const content::ResourceRequestInfo::WebContentsGetter& + web_contents_getter) { + CEF_REQUIRE_UIT(); + content::WebContents* web_contents = web_contents_getter.Run(); + if (web_contents) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForContents(web_contents); + if (browser.get()) + browser->HandleExternalProtocol(url); + } +} diff --git a/libcef/browser/resource_dispatcher_host_delegate.h b/libcef/browser/resource_dispatcher_host_delegate.h index 74b7f48f6..fbbca4b54 100644 --- a/libcef/browser/resource_dispatcher_host_delegate.h +++ b/libcef/browser/resource_dispatcher_host_delegate.h @@ -23,13 +23,7 @@ class CefResourceDispatcherHostDelegate // ResourceDispatcherHostDelegate methods. bool HandleExternalProtocol( const GURL& url, - int child_id, - const content::ResourceRequestInfo::WebContentsGetter& - web_contents_getter, - bool is_main_frame, - ui::PageTransition page_transition, - bool has_user_gesture, - content::ResourceContext* resource_context) override; + content::ResourceRequestInfo* info) override; bool ShouldInterceptResourceAsStream(net::URLRequest* request, const base::FilePath& plugin_path, const std::string& mime_type, @@ -46,6 +40,11 @@ class CefResourceDispatcherHostDelegate content::ResourceContext* resource_context) override; private: + void HandleExternalProtocolOnUIThread( + const GURL& url, + const content::ResourceRequestInfo::WebContentsGetter& + web_contents_getter); + struct StreamTargetInfo { std::string extension_id; std::string view_id; diff --git a/libcef/browser/storage_partition_proxy.cc b/libcef/browser/storage_partition_proxy.cc index 8405719ff..12dcd1f80 100644 --- a/libcef/browser/storage_partition_proxy.cc +++ b/libcef/browser/storage_partition_proxy.cc @@ -81,6 +81,10 @@ CefStoragePartitionProxy::GetBackgroundSyncContext() { return parent_->GetBackgroundSyncContext(); } +content::PaymentAppContext* CefStoragePartitionProxy::GetPaymentAppContext() { + return parent_->GetPaymentAppContext(); +} + content::BroadcastChannelProvider* CefStoragePartitionProxy::GetBroadcastChannelProvider() { return parent_->GetBroadcastChannelProvider(); diff --git a/libcef/browser/storage_partition_proxy.h b/libcef/browser/storage_partition_proxy.h index 17752391f..6f785fe45 100644 --- a/libcef/browser/storage_partition_proxy.h +++ b/libcef/browser/storage_partition_proxy.h @@ -37,6 +37,7 @@ class CefStoragePartitionProxy : public content::StoragePartition { content::PlatformNotificationContext* GetPlatformNotificationContext() override; content::BackgroundSyncContext* GetBackgroundSyncContext() override; + content::PaymentAppContext* GetPaymentAppContext() override; content::BroadcastChannelProvider* GetBroadcastChannelProvider() override; void ClearDataForOrigin(uint32_t remove_mask, uint32_t quota_storage_remove_mask, diff --git a/libcef/browser/web_plugin_impl.cc b/libcef/browser/web_plugin_impl.cc index fcd782bb2..9788a3592 100644 --- a/libcef/browser/web_plugin_impl.cc +++ b/libcef/browser/web_plugin_impl.cc @@ -30,7 +30,7 @@ void PluginsCallbackImpl( } } -#if !(defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)) || \ +#if !(defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)) || \ defined(OS_LINUX) void DeliverWidevineCdmError(const std::string& error_message, @@ -171,7 +171,7 @@ void CefIsWebPluginUnstable( void CefRegisterWidevineCdm(const CefString& path, CefRefPtr callback) { -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) #if defined(OS_LINUX) // Enforce the requirement that CefRegisterWidevineCdm() is called before // CefInitialize() on Linux. See comments in @@ -187,5 +187,5 @@ void CefRegisterWidevineCdm(const CefString& path, CefWidevineLoader::GetInstance()->LoadWidevineCdm(path, callback); #else DeliverWidevineCdmError("Widevine registration is not supported", callback); -#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) } diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index 492175d74..e1d75d069 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -50,9 +50,6 @@ const char kDisableJavascriptAccessClipboard[] = // Disable DOM paste via JavaScript execCommand("paste"). const char kDisableJavascriptDomPaste[] = "disable-javascript-dom-paste"; -// Enable caret browsing. -const char kEnableCaretBrowsing[] = "enable-caret-browsing"; - // Allow universal access from file URLs. const char kAllowUniversalAccessFromFileUrls[] = "allow-universal-access-from-files"; diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index b8cf1094b..d6db72393 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -27,7 +27,6 @@ extern const char kDisableJavascriptOpenWindows[]; extern const char kDisableJavascriptCloseWindows[]; extern const char kDisableJavascriptAccessClipboard[]; extern const char kDisableJavascriptDomPaste[]; -extern const char kEnableCaretBrowsing[]; extern const char kAllowUniversalAccessFromFileUrls[]; extern const char kDisableImageLoading[]; extern const char kImageShrinkStandaloneToFit[]; diff --git a/libcef/common/content_client.cc b/libcef/common/content_client.cc index 528ad26da..c2c513361 100644 --- a/libcef/common/content_client.cc +++ b/libcef/common/content_client.cc @@ -206,7 +206,7 @@ void CefContentClient::AddPepperPlugins( AddPepperFlashFromCommandLine(plugins); #if defined(OS_LINUX) -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) CefWidevineLoader::AddPepperPlugins(plugins); #endif #endif diff --git a/libcef/common/extensions/api/BUILD.gn b/libcef/common/extensions/api/BUILD.gn index c48bb813c..92adbeac6 100644 --- a/libcef/common/extensions/api/BUILD.gn +++ b/libcef/common/extensions/api/BUILD.gn @@ -2,8 +2,8 @@ # 2014 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. -import("//build/json_schema_api.gni") import("//tools/json_schema_compiler/json_features.gni") +#import("//tools/json_schema_compiler/json_schema_api.gni") # TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See README.txt for # details. diff --git a/libcef/common/extensions/api/README.txt b/libcef/common/extensions/api/README.txt index c77005f1f..04773e532 100644 --- a/libcef/common/extensions/api/README.txt +++ b/libcef/common/extensions/api/README.txt @@ -10,20 +10,22 @@ To add a new extension API implemented only in CEF ***: API. 2. Add .idl or .json to the 'schema_sources' list in libcef/common/extensions/api/BUILD.gn. Serialization code will be - generated based on this list in step 5. -3. Add an entry in the libcef/common/extensions/api/_*_features.json files if - necessary [1]. -4. Add libcef/browser/extensions/api//_api.[h|cc] class implementation + generated based on this list in step 4. +3. Add libcef/browser/extensions/api//_api.[h|cc] class implementation files and associated entries to the 'libcef_static' target in BUILD.gn. -5. Run the cef_create_projects script and build to generate the +4. Run the cef_create_projects script and build to generate the cef/libcef/common/extensions/api/.h file and other serialization code required by the extensions system. -6. Call `::GetInstance();` or `Factory::GetFactoryInstance();` [2] +5. Add an entry in the libcef/common/extensions/api/_*_features.json files if + necessary [1]. +6. Add an entry in the libcef/common/extensions/api/*_manifest_overlay.json + files if necessary [2]. +7. Call `::GetInstance();` or `Factory::GetFactoryInstance();` [3] from EnsureBrowserContextKeyedServiceFactoriesBuilt in libcef/browser/extensions/browser_context_keyed_service_factories.cc. -7. Call `DependsOn(Factory::GetInstance());` from +8. Call `DependsOn(Factory::GetInstance());` from CefExtensionSystemFactory::CefExtensionSystemFactory in - libcef/browser/extensions/extension_system_factory.cc if necessary [2]. + libcef/browser/extensions/extension_system_factory.cc if necessary [3]. *** Note that CEF does not currently expose its own Mojo APIs. Related code is commented out in: @@ -36,7 +38,7 @@ commented out in: To add a new extension API implemented in Chrome: 1. Register the API in libcef/browser/extensions/chrome_api_registration.cc -2. Perform steps 3, 6 and 7 above. +2. Perform steps 5 through 8 above. See https://www.chromium.org/developers/design-documents/mojo for more information. @@ -46,7 +48,17 @@ information. additional details. For Chrome extensions this should match the definitions in the chrome/common/extensions/api/_*_features.json files. -[2] Some Mojo APIs use singleton Factory objects that create a one-to-one +[2] Service Manifest InterfaceProviderSpecs control interfaces exposed between + processes. Mojo interfaces exposed at the frame level are controlled by the + "navigation:frame" dictionary. Those exposed at the process level are + controlled by the "service_manager:connector" dictionary. Failure to specify + this correctly may result in a console error like the following: + + InterfaceProviderSpec "navigation:frame" prevented service: + service:content_renderer from binding interface: + mojom::Foo exposed by: service:content_browser + +[3] Some Mojo APIs use singleton Factory objects that create a one-to-one relationship between a service and a BrowserContext. This is used primarily to control shutdown/destruction order and implementors must explicitly state which services are depended on. See comments in diff --git a/libcef/common/extensions/api/browser_manifest_overlay.json b/libcef/common/extensions/api/browser_manifest_overlay.json new file mode 100644 index 000000000..6af52384e --- /dev/null +++ b/libcef/common/extensions/api/browser_manifest_overlay.json @@ -0,0 +1,14 @@ +{ + "name": "content_browser", + "display_name": "CEF", + "interface_provider_specs": { + "navigation:frame": { + "provides": { + "renderer": [ + "extensions::KeepAlive", + "extensions::mime_handler::MimeHandlerService" + ] + } + } + } +} diff --git a/libcef/common/extensions/api/renderer_manifest_overlay.json b/libcef/common/extensions/api/renderer_manifest_overlay.json new file mode 100644 index 000000000..e77a9f954 --- /dev/null +++ b/libcef/common/extensions/api/renderer_manifest_overlay.json @@ -0,0 +1,5 @@ +{ + "display_name": "Chrome Render Process", + "interface_provider_specs": { + } +} diff --git a/libcef/common/extensions/api/utility_manifest_overlay.json b/libcef/common/extensions/api/utility_manifest_overlay.json new file mode 100644 index 000000000..c4f9b0d5e --- /dev/null +++ b/libcef/common/extensions/api/utility_manifest_overlay.json @@ -0,0 +1,12 @@ +{ + "name": "content_utility", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "browser": [ + "net::interfaces::ProxyResolverFactory" + ] + } + } + } +} diff --git a/libcef/common/extensions/extensions_client.cc b/libcef/common/extensions/extensions_client.cc index 8f12d2e92..8c666164b 100644 --- a/libcef/common/extensions/extensions_client.cc +++ b/libcef/common/extensions/extensions_client.cc @@ -17,10 +17,12 @@ #include "cef/libcef/common/extensions/api/cef_behavior_features.h" #include "cef/libcef/common/extensions/api/cef_manifest_features.h" #include "cef/libcef/common/extensions/api/cef_permission_features.h" +#include "chrome/common/extensions/chrome_aliases.h" #include "chrome/common/extensions/chrome_manifest_handlers.h" #include "chrome/grit/common_resources.h" #include "extensions/common/api/generated_schemas.h" #include "extensions/common/common_manifest_handlers.h" +#include "extensions/common/extensions_aliases.h" #include "extensions/common/extension_urls.h" #include "extensions/common/features/api_feature.h" #include "extensions/common/features/behavior_feature.h" @@ -59,8 +61,10 @@ void CefExtensionsClient::Initialize() { // TODO(jamescook): Do we need to whitelist any extensions? // Set up permissions. - PermissionsInfo::GetInstance()->AddProvider(chrome_api_permissions_); - PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_); + PermissionsInfo::GetInstance()->AddProvider(chrome_api_permissions_, + GetChromePermissionAliases()); + PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_, + GetExtensionsPermissionAliases()); } const PermissionMessageProvider& @@ -177,8 +181,10 @@ std::string CefExtensionsClient::GetWebstoreBaseURL() const { return extension_urls::kChromeWebstoreBaseURL; } -std::string CefExtensionsClient::GetWebstoreUpdateURL() const { - return extension_urls::kChromeWebstoreUpdateURL; +const GURL& CefExtensionsClient::GetWebstoreUpdateURL() const { + if (webstore_update_url_.is_empty()) + webstore_update_url_ = GURL(extension_urls::GetWebstoreUpdateUrl()); + return webstore_update_url_; } bool CefExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { diff --git a/libcef/common/extensions/extensions_client.h b/libcef/common/extensions/extensions_client.h index 4849e6da0..abb141ed9 100644 --- a/libcef/common/extensions/extensions_client.h +++ b/libcef/common/extensions/extensions_client.h @@ -12,6 +12,7 @@ #include "chrome/common/extensions/permissions/chrome_permission_message_provider.h" #include "extensions/common/extensions_client.h" #include "extensions/common/permissions/extensions_api_permissions.h" +#include "url/gurl.h" namespace extensions { @@ -44,7 +45,7 @@ class CefExtensionsClient : public ExtensionsClient { bool ShouldSuppressFatalErrors() const override; void RecordDidSuppressFatalError() override; std::string GetWebstoreBaseURL() const override; - std::string GetWebstoreUpdateURL() const override; + const GURL& GetWebstoreUpdateURL() const override; bool IsBlacklistUpdateURL(const GURL& url) const override; private: @@ -54,6 +55,9 @@ class CefExtensionsClient : public ExtensionsClient { ScriptingWhitelist scripting_whitelist_; + // Mutable to allow caching in a const method. + mutable GURL webstore_update_url_; + DISALLOW_COPY_AND_ASSIGN(CefExtensionsClient); }; diff --git a/libcef/common/net/scheme_registration.cc b/libcef/common/net/scheme_registration.cc index 57730a210..493ad1aca 100644 --- a/libcef/common/net/scheme_registration.cc +++ b/libcef/common/net/scheme_registration.cc @@ -7,6 +7,7 @@ #include "libcef/common/content_client.h" #include "content/public/common/url_constants.h" +#include "net/net_features.h" #include "extensions/common/constants.h" #include "url/url_constants.h" @@ -65,7 +66,7 @@ bool IsInternalProtectedScheme(const std::string& scheme) { url::kDataScheme, url::kFileScheme, url::kFileSystemScheme, -#if !defined(DISABLE_FTP_SUPPORT) +#if !BUILDFLAG(DISABLE_FTP_SUPPORT) url::kFtpScheme, #endif }; diff --git a/libcef/common/request_impl.cc b/libcef/common/request_impl.cc index e68dc876b..2d140f80b 100644 --- a/libcef/common/request_impl.cc +++ b/libcef/common/request_impl.cc @@ -786,7 +786,7 @@ void CefRequestImpl::Get(net::URLFetcher& fetcher, } if (!first_party_for_cookies_.is_empty()) - fetcher.SetInitiatorURL(first_party_for_cookies_); + fetcher.SetInitiator(url::Origin(first_party_for_cookies_)); if (flags_ & UR_FLAG_NO_RETRY_ON_5XX) fetcher.SetAutomaticallyRetryOn5xx(false); diff --git a/libcef/common/task_runner_impl.cc b/libcef/common/task_runner_impl.cc index 22c1c1cfa..14300d801 100644 --- a/libcef/common/task_runner_impl.cc +++ b/libcef/common/task_runner_impl.cc @@ -88,14 +88,8 @@ scoped_refptr if (id >= 0 && CefContentClient::Get() && CefContentClient::Get()->browser() && BrowserThread::IsMessageLoopValid(static_cast(id))) { - // Don't use BrowserThread::GetTaskRunnerForThread because it returns - // a new MessageLoopProxy object for each call and makes pointer equality - // testing impossible. - base::MessageLoop* message_loop = - BrowserThread::UnsafeGetMessageLoopForThread( - static_cast(id)); - if (message_loop) - return message_loop->task_runner(); + return BrowserThread::GetTaskRunnerForThread( + static_cast(id)); } return NULL; @@ -106,9 +100,19 @@ scoped_refptr CefTaskRunnerImpl::GetCurrentTaskRunner() { scoped_refptr task_runner; - // Check for a MessageLoopProxy. This covers all of the named browser and - // render process threads, plus a few extra. - task_runner = base::ThreadTaskRunnerHandle::Get(); + // For named browser process threads return the same TaskRunner as + // GetTaskRunner(). Otherwise BelongsToThread() will return incorrect results. + BrowserThread::ID current_id; + if (BrowserThread::GetCurrentThreadIdentifier(¤t_id) && + BrowserThread::IsMessageLoopValid(current_id)) { + task_runner = BrowserThread::GetTaskRunnerForThread(current_id); + } + + if (!task_runner.get()) { + // Check for a MessageLoopProxy. This covers all of the named browser and + // render process threads, plus a few extra. + task_runner = base::ThreadTaskRunnerHandle::Get(); + } if (!task_runner.get()) { // Check for a WebWorker thread. diff --git a/libcef/common/widevine_loader.cc b/libcef/common/widevine_loader.cc index a17657eb0..02561ae49 100644 --- a/libcef/common/widevine_loader.cc +++ b/libcef/common/widevine_loader.cc @@ -4,7 +4,7 @@ #include "libcef/common/widevine_loader.h" -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) #include "libcef/browser/context.h" #include "libcef/browser/thread_util.h" @@ -403,4 +403,4 @@ CefWidevineLoader::CefWidevineLoader() { CefWidevineLoader::~CefWidevineLoader() { } -#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) diff --git a/libcef/common/widevine_loader.h b/libcef/common/widevine_loader.h index 7c7784528..01a55370e 100644 --- a/libcef/common/widevine_loader.h +++ b/libcef/common/widevine_loader.h @@ -10,7 +10,7 @@ #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) #include @@ -59,6 +59,6 @@ class CefWidevineLoader { ~CefWidevineLoader(); }; -#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) #endif // CEF_LIBCEF_COMMON_WIDEVINE_LOADER_H_ diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 380385209..1fab4fbce 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -68,7 +68,7 @@ CefRefPtr CefBrowserImpl::GetBrowserForMainFrame( CefRefPtr CefBrowserImpl::GetHost() { NOTREACHED() << "GetHost cannot be called from the render process"; - return NULL; + return nullptr; } bool CefBrowserImpl::CanGoBack() { @@ -157,31 +157,31 @@ bool CefBrowserImpl::HasDocument() { } CefRefPtr CefBrowserImpl::GetMainFrame() { - CEF_REQUIRE_RT_RETURN(NULL); + CEF_REQUIRE_RT_RETURN(nullptr); if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()).get(); - return NULL; + return nullptr; } CefRefPtr CefBrowserImpl::GetFocusedFrame() { - CEF_REQUIRE_RT_RETURN(NULL); + CEF_REQUIRE_RT_RETURN(nullptr); if (render_view()->GetWebView() && render_view()->GetWebView()->focusedFrame()) { return GetWebFrameImpl(render_view()->GetWebView()->focusedFrame()).get(); } - return NULL; + return nullptr; } CefRefPtr CefBrowserImpl::GetFrame(int64 identifier) { - CEF_REQUIRE_RT_RETURN(NULL); + CEF_REQUIRE_RT_RETURN(nullptr); return GetWebFrameImpl(identifier).get(); } CefRefPtr CefBrowserImpl::GetFrame(const CefString& name) { - CEF_REQUIRE_RT_RETURN(NULL); + CEF_REQUIRE_RT_RETURN(nullptr); blink::WebView* web_view = render_view()->GetWebView(); if (web_view) { @@ -198,7 +198,7 @@ CefRefPtr CefBrowserImpl::GetFrame(const CefString& name) { return GetWebFrameImpl(frame).get(); } - return NULL; + return nullptr; } size_t CefBrowserImpl::GetFrameCount() { @@ -207,13 +207,9 @@ size_t CefBrowserImpl::GetFrameCount() { int count = 0; if (render_view()->GetWebView()) { - WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); - if (main_frame) { - WebFrame* cur = main_frame; - do { - count++; - cur = cur->traverseNext(true); - } while (cur != main_frame); + for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; + frame = frame->traverseNext()) { + count++; } } @@ -227,13 +223,9 @@ void CefBrowserImpl::GetFrameIdentifiers(std::vector& identifiers) { identifiers.clear(); if (render_view()->GetWebView()) { - WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); - if (main_frame) { - WebFrame* cur = main_frame; - do { - identifiers.push_back(webkit_glue::GetIdentifier(cur)); - cur = cur->traverseNext(true); - } while (cur != main_frame); + for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; + frame = frame->traverseNext()) { + identifiers.push_back(webkit_glue::GetIdentifier(frame)); } } } @@ -245,13 +237,9 @@ void CefBrowserImpl::GetFrameNames(std::vector& names) { names.clear(); if (render_view()->GetWebView()) { - WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); - if (main_frame) { - WebFrame* cur = main_frame; - do { - names.push_back(CefString(cur->uniqueName().utf8())); - cur = cur->traverseNext(true); - } while (cur != main_frame); + for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; + frame = frame->traverseNext()) { + names.push_back(CefString(frame->uniqueName().utf8())); } } } @@ -347,7 +335,7 @@ 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()); - return NULL; + return nullptr; } // Check if we already know about the frame. @@ -357,18 +345,14 @@ CefRefPtr CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) { if (render_view()->GetWebView()) { // Check if the frame exists but we don't know about it yet. - WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); - if (main_frame) { - WebFrame* cur = main_frame; - do { - if (webkit_glue::GetIdentifier(cur) == frame_id) - return GetWebFrameImpl(cur); - cur = cur->traverseNext(true); - } while (cur != main_frame); + for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; + frame = frame->traverseNext()) { + if (webkit_glue::GetIdentifier(frame) == frame_id) + return GetWebFrameImpl(frame); } } - return NULL; + return nullptr; } void CefBrowserImpl::AddFrameObject(int64_t frame_id, @@ -409,7 +393,7 @@ void CefBrowserImpl::OnDestruct() { handler->OnBrowserDestroyed(this); } - response_manager_.reset(NULL); + response_manager_.reset(); CefContentRendererClient::Get()->OnBrowserDestroyed(this); } @@ -552,7 +536,7 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) { false, true)); success = handler->OnProcessMessageReceived(this, PID_BROWSER, message.get()); - message->Detach(NULL); + message->Detach(nullptr); } } } else if (params.name == "execute-code") { diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index 42c7e9ad5..96b90f7e2 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -106,6 +106,7 @@ class CefPrerenderingSupport : public blink::WebPrerenderingSupport { void add(const blink::WebPrerender& prerender) override {} void cancel(const blink::WebPrerender& prerender) override {} void abandon(const blink::WebPrerender& prerender) override {} + void prefetchFinished() override {} }; // Stub implementation of blink::WebPrerendererClient. @@ -186,9 +187,8 @@ CefContentRendererClient::CefContentRendererClient() extensions::ExtensionsRendererClient::Set( extensions_renderer_client_.get()); } -#if defined(ENABLE_PRINTING) + printing::SetAgent(CefContentClient::Get()->GetUserAgent()); -#endif } CefContentRendererClient::~CefContentRendererClient() { @@ -467,6 +467,9 @@ void CefContentRendererClient::RenderFrameCreated( content::RenderFrame* render_frame) { new CefRenderFrameObserver(render_frame); new CefPepperHelper(render_frame); + new printing::PrintWebViewHelper( + render_frame, + base::WrapUnique(new extensions::CefPrintWebViewHelperDelegate())); if (extensions::ExtensionsEnabled()) extensions_renderer_client_->RenderFrameCreated(render_frame); @@ -477,9 +480,6 @@ void CefContentRendererClient::RenderFrameCreated( void CefContentRendererClient::RenderViewCreated( content::RenderView* render_view) { new CefPrerendererClient(render_view); - new printing::PrintWebViewHelper( - render_view, - base::WrapUnique(new extensions::CefPrintWebViewHelperDelegate())); if (extensions::ExtensionsEnabled()) extensions_renderer_client_->RenderViewCreated(render_view); @@ -598,8 +598,7 @@ bool CefContentRendererClient::ShouldFork(blink::WebLocalFrame* frame, bool CefContentRendererClient::WillSendRequest( blink::WebFrame* frame, ui::PageTransition transition_type, - const GURL& url, - const GURL& first_party_for_cookies, + const blink::WebURL& url, GURL* new_url) { if (extensions::ExtensionsEnabled()) { return extensions_renderer_client_->WillSendRequest(frame, transition_type, diff --git a/libcef/renderer/content_renderer_client.h b/libcef/renderer/content_renderer_client.h index 0e2ddacb5..c1476197e 100644 --- a/libcef/renderer/content_renderer_client.h +++ b/libcef/renderer/content_renderer_client.h @@ -113,8 +113,7 @@ class CefContentRendererClient : public content::ContentRendererClient, bool* send_referrer) override; bool WillSendRequest(blink::WebFrame* frame, ui::PageTransition transition_type, - const GURL& url, - const GURL& first_party_for_cookies, + const blink::WebURL& url, GURL* new_url) override; unsigned long long VisitedLinkHash(const char* canonical_url, size_t length) override; @@ -176,6 +175,8 @@ class CefContentRendererClient : public content::ContentRendererClient, // Access must be protected by |single_process_cleanup_lock_|. bool single_process_cleanup_complete_; base::Lock single_process_cleanup_lock_; + + DISALLOW_COPY_AND_ASSIGN(CefContentRendererClient); }; #endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_ diff --git a/libcef/renderer/dom_node_impl.cc b/libcef/renderer/dom_node_impl.cc index 9b644d37a..e1af86d2b 100644 --- a/libcef/renderer/dom_node_impl.cc +++ b/libcef/renderer/dom_node_impl.cc @@ -78,7 +78,7 @@ bool CefDOMNodeImpl::IsEditable() { if (node_.isElementNode()) { const WebElement& element = node_.toConst(); - if (element.isTextFormControlElement()) + if (webkit_glue::IsTextControlElement(element)) return true; // Also return true if it has an ARIA role of 'textbox'. diff --git a/libcef/renderer/extensions/extensions_renderer_client.cc b/libcef/renderer/extensions/extensions_renderer_client.cc index f51190498..3307c2a7e 100644 --- a/libcef/renderer/extensions/extensions_renderer_client.cc +++ b/libcef/renderer/extensions/extensions_renderer_client.cc @@ -170,18 +170,18 @@ bool CefExtensionsRendererClient::OverrideCreatePlugin( bool CefExtensionsRendererClient::WillSendRequest( blink::WebFrame* frame, ui::PageTransition transition_type, - const GURL& url, + const blink::WebURL& url, GURL* new_url) { // Check whether the request should be allowed. If not allowed, we reset the // URL to something invalid to prevent the request and cause an error. - if (url.SchemeIs(extensions::kExtensionScheme) && - !resource_request_policy_->CanRequestResource(url, frame, + if (url.protocolIs(extensions::kExtensionScheme) && + !resource_request_policy_->CanRequestResource(GURL(url), frame, transition_type)) { *new_url = GURL(chrome::kExtensionInvalidRequestURL); return true; } - if (url.SchemeIs(extensions::kExtensionResourceScheme) && + if (url.protocolIs(extensions::kExtensionResourceScheme) && !resource_request_policy_->CanRequestExtensionResourceScheme(url, frame)) { *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); @@ -239,7 +239,7 @@ bool CefExtensionsRendererClient::ShouldFork(blink::WebLocalFrame* frame, // for subframes, so this check only makes sense for top-level frames. // TODO(alexmos,nasko): Figure out how this check should work when reloading // subframes in --site-per-process mode. - if (!frame->parent() && frame->document().url() == url) { + if (!frame->parent() && GURL(frame->document().url()) == url) { if (is_extension_url != IsStandaloneExtensionProcess()) return true; } diff --git a/libcef/renderer/extensions/extensions_renderer_client.h b/libcef/renderer/extensions/extensions_renderer_client.h index b7cd290e4..012742762 100644 --- a/libcef/renderer/extensions/extensions_renderer_client.h +++ b/libcef/renderer/extensions/extensions_renderer_client.h @@ -18,6 +18,7 @@ namespace blink { class WebFrame; class WebLocalFrame; struct WebPluginParams; +class WebURL; } namespace content { @@ -50,7 +51,7 @@ class CefExtensionsRendererClient : public ExtensionsRendererClient { const blink::WebPluginParams& params); bool WillSendRequest(blink::WebFrame* frame, ui::PageTransition transition_type, - const GURL& url, + const blink::WebURL& url, GURL* new_url); void RunScriptsAtDocumentStart(content::RenderFrame* render_frame); void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame); diff --git a/libcef/renderer/extensions/print_web_view_helper_delegate.cc b/libcef/renderer/extensions/print_web_view_helper_delegate.cc index 2f3439ec7..f14338702 100644 --- a/libcef/renderer/extensions/print_web_view_helper_delegate.cc +++ b/libcef/renderer/extensions/print_web_view_helper_delegate.cc @@ -22,7 +22,7 @@ CefPrintWebViewHelperDelegate::~CefPrintWebViewHelperDelegate(){ } bool CefPrintWebViewHelperDelegate::CancelPrerender( - content::RenderView* render_view, int routing_id) { + content::RenderFrame* render_frame) { return false; } diff --git a/libcef/renderer/extensions/print_web_view_helper_delegate.h b/libcef/renderer/extensions/print_web_view_helper_delegate.h index 31d606695..75e6f105e 100644 --- a/libcef/renderer/extensions/print_web_view_helper_delegate.h +++ b/libcef/renderer/extensions/print_web_view_helper_delegate.h @@ -14,8 +14,7 @@ class CefPrintWebViewHelperDelegate public: ~CefPrintWebViewHelperDelegate() override; - bool CancelPrerender(content::RenderView* render_view, - int routing_id) override; + bool CancelPrerender(content::RenderFrame* render_frame) override; blink::WebElement GetPdfElement(blink::WebLocalFrame* frame) override; bool IsPrintPreviewEnabled() override; bool OverridePrint(blink::WebLocalFrame* frame) override; diff --git a/libcef/renderer/media/cef_key_systems.cc b/libcef/renderer/media/cef_key_systems.cc index 53bc4f86d..9c420fa20 100644 --- a/libcef/renderer/media/cef_key_systems.cc +++ b/libcef/renderer/media/cef_key_systems.cc @@ -16,6 +16,7 @@ #include "libcef/common/cef_messages.h" #include "media/base/eme_constants.h" #include "media/base/key_system_properties.h" +#include "ppapi/features/features.h" #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. @@ -31,7 +32,7 @@ using media::SupportedCodecs; namespace { -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) bool IsPepperCdmAvailable( const std::string& pepper_type, std::vector* additional_param_names, @@ -135,15 +136,15 @@ void AddPepperBasedWidevine( media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier. } #endif // defined(WIDEVINE_CDM_AVAILABLE) -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) } // namespace void AddCefKeySystems( std::vector>* key_systems_properties) { -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) #if defined(WIDEVINE_CDM_AVAILABLE) AddPepperBasedWidevine(key_systems_properties); #endif // defined(WIDEVINE_CDM_AVAILABLE) -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) } diff --git a/libcef/renderer/plugins/cef_plugin_placeholder.cc b/libcef/renderer/plugins/cef_plugin_placeholder.cc index ba2fd3a7c..2da1cdf29 100644 --- a/libcef/renderer/plugins/cef_plugin_placeholder.cc +++ b/libcef/renderer/plugins/cef_plugin_placeholder.cc @@ -24,8 +24,8 @@ #include "content/public/renderer/render_thread.h" #include "gin/object_template_builder.h" #include "third_party/WebKit/public/platform/URLConversion.h" +#include "third_party/WebKit/public/platform/WebInputEvent.h" #include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebScriptSource.h" #include "third_party/WebKit/public/web/WebView.h" diff --git a/libcef/renderer/render_thread_observer.cc b/libcef/renderer/render_thread_observer.cc index 7941e3545..74a44fc9e 100644 --- a/libcef/renderer/render_thread_observer.cc +++ b/libcef/renderer/render_thread_observer.cc @@ -11,7 +11,7 @@ #include "components/visitedlink/renderer/visitedlink_slave.h" #include "content/public/renderer/render_thread.h" #include "net/base/net_module.h" -#include "services/shell/public/cpp/interface_registry.h" +#include "services/service_manager/public/cpp/interface_registry.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebURL.h" #include "third_party/WebKit/public/web/WebSecurityPolicy.h" diff --git a/libcef/renderer/webkit_glue.cc b/libcef/renderer/webkit_glue.cc index 02f8ff2ac..5e32ad8c1 100644 --- a/libcef/renderer/webkit_glue.cc +++ b/libcef/renderer/webkit_glue.cc @@ -186,6 +186,11 @@ v8::MaybeLocal CallV8Function(v8::Local context, return func_rv; } +bool IsTextControlElement(const blink::WebElement& element) { + const blink::Element* web_element = element.constUnwrap(); + return web_element->isTextControl(); +} + v8::MaybeLocal ExecuteV8ScriptAndReturnValue( const blink::WebString& source, const blink::WebString& source_url, diff --git a/libcef/renderer/webkit_glue.h b/libcef/renderer/webkit_glue.h index e3a79792b..5704874e1 100644 --- a/libcef/renderer/webkit_glue.h +++ b/libcef/renderer/webkit_glue.h @@ -15,6 +15,7 @@ #include "v8/include/v8.h" namespace blink { +class WebElement; class WebFrame; class WebNode; class WebString; @@ -46,6 +47,8 @@ int64_t GetIdentifier(blink::WebFrame* frame); blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name, blink::WebFrame* relative_to_frame); +bool IsTextControlElement(const blink::WebElement& element); + v8::MaybeLocal CallV8Function(v8::Local context, v8::Local function, v8::Local receiver, diff --git a/libcef/resources/cef_resources.grd b/libcef/resources/cef_resources.grd index 39b102eb2..166a145d5 100644 --- a/libcef/resources/cef_resources.grd +++ b/libcef/resources/cef_resources.grd @@ -15,6 +15,9 @@ + + + diff --git a/libcef/utility/content_utility_client.cc b/libcef/utility/content_utility_client.cc index ee813776d..77e1fc265 100644 --- a/libcef/utility/content_utility_client.cc +++ b/libcef/utility/content_utility_client.cc @@ -12,10 +12,10 @@ #include "chrome/utility/utility_message_handler.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "net/proxy/mojo_proxy_resolver_factory_impl.h" -#include "services/shell/public/cpp/interface_registry.h" +#include "services/service_manager/public/cpp/interface_registry.h" #if defined(OS_WIN) -#include "libcef/utility/printing_handler.h" +#include "chrome/utility/printing_handler.h" #endif namespace { @@ -30,7 +30,7 @@ void CreateProxyResolverFactory( CefContentUtilityClient::CefContentUtilityClient() { #if defined(OS_WIN) - handlers_.push_back(new PrintingHandler()); + handlers_.push_back(new printing::PrintingHandler()); #endif } @@ -50,7 +50,7 @@ bool CefContentUtilityClient::OnMessageReceived( } void CefContentUtilityClient::ExposeInterfacesToBrowser( - shell::InterfaceRegistry* registry) { + service_manager::InterfaceRegistry* registry) { registry->AddInterface( base::Bind(CreateProxyResolverFactory)); } diff --git a/libcef/utility/content_utility_client.h b/libcef/utility/content_utility_client.h index 45ec78179..965f723d8 100644 --- a/libcef/utility/content_utility_client.h +++ b/libcef/utility/content_utility_client.h @@ -17,7 +17,8 @@ class CefContentUtilityClient : public content::ContentUtilityClient { ~CefContentUtilityClient() override; bool OnMessageReceived(const IPC::Message& message) override; - void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) override; + void ExposeInterfacesToBrowser( + service_manager::InterfaceRegistry* registry) override; private: typedef ScopedVector Handlers; diff --git a/libcef/utility/printing_handler.cc b/libcef/utility/printing_handler.cc deleted file mode 100644 index 8d0ac3ddd..000000000 --- a/libcef/utility/printing_handler.cc +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2014 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/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" -#include "printing/page_range.h" -#include "printing/pdf_render_settings.h" - -#if defined(OS_WIN) -#include "base/win/iat_patch_function.h" -#include "printing/emf_win.h" -#include "ui/gfx/gdi_util.h" -#endif - -namespace { - -bool Send(IPC::Message* message) { - return content::UtilityThread::Get()->Send(message); -} - -void ReleaseProcessIfNeeded() { - content::UtilityThread::Get()->ReleaseProcessIfNeeded(); -} - -#if defined(OS_WIN) -void PreCacheFontCharacters(const LOGFONT* logfont, - const wchar_t* text, - size_t text_length) { - Send(new ChromeUtilityHostMsg_PreCacheFontCharacters( - *logfont, base::string16(text, text_length))); -} -#endif - -} // namespace - -PrintingHandler::PrintingHandler() { -#if defined(OS_WIN) - chrome_pdf::SetPDFEnsureTypefaceCharactersAccessible(PreCacheFontCharacters); -#endif -} - -PrintingHandler::~PrintingHandler() {} - -bool PrintingHandler::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PrintingHandler, message) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles, - OnRenderPDFPagesToMetafile) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage, - OnRenderPDFPagesToMetafileGetPage) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop, - OnRenderPDFPagesToMetafileStop) -#endif // OS_WIN - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -#if defined(OS_WIN) -void PrintingHandler::OnRenderPDFPagesToMetafile( - IPC::PlatformFileForTransit pdf_transit, - const printing::PdfRenderSettings& settings, - bool print_text_with_gdi) { - pdf_rendering_settings_ = settings; - chrome_pdf::SetPDFUseGDIPrinting(print_text_with_gdi); - base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit); - int page_count = LoadPDF(std::move(pdf_file)); - Send( - new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount(page_count)); -} - -void PrintingHandler::OnRenderPDFPagesToMetafileGetPage( - int page_number, - IPC::PlatformFileForTransit output_file) { - base::File emf_file = IPC::PlatformFileForTransitToFile(output_file); - double scale_factor = 1.0; - bool success = - RenderPdfPageToMetafile(page_number, std::move(emf_file), &scale_factor); - Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone( - success, scale_factor)); -} - -void PrintingHandler::OnRenderPDFPagesToMetafileStop() { - ReleaseProcessIfNeeded(); -} - -int PrintingHandler::LoadPDF(base::File pdf_file) { - int64_t length = pdf_file.GetLength(); - if (length < 0) - return 0; - - pdf_data_.resize(length); - if (length != pdf_file.Read(0, pdf_data_.data(), pdf_data_.size())) - return 0; - - int total_page_count = 0; - if (!chrome_pdf::GetPDFDocInfo( - &pdf_data_.front(), pdf_data_.size(), &total_page_count, NULL)) { - return 0; - } - return total_page_count; -} - -bool PrintingHandler::RenderPdfPageToMetafile(int page_number, - base::File output_file, - double* scale_factor) { - printing::Emf metafile; - metafile.Init(); - - // We need to scale down DC to fit an entire page into DC available area. - // Current metafile is based on screen DC and have current screen size. - // Writing outside of those boundaries will result in the cut-off output. - // On metafiles (this is the case here), scaling down will still record - // original coordinates and we'll be able to print in full resolution. - // Before playback we'll need to counter the scaling up that will happen - // in the service (print_system_win.cc). - *scale_factor = - gfx::CalculatePageScale(metafile.context(), - pdf_rendering_settings_.area().right(), - pdf_rendering_settings_.area().bottom()); - gfx::ScaleDC(metafile.context(), *scale_factor); - - // The underlying metafile is of type Emf and ignores the arguments passed - // to StartPage. - metafile.StartPage(gfx::Size(), gfx::Rect(), 1); - if (!chrome_pdf::RenderPDFPageToDC( - &pdf_data_.front(), - pdf_data_.size(), - page_number, - metafile.context(), - pdf_rendering_settings_.dpi(), - pdf_rendering_settings_.area().x(), - pdf_rendering_settings_.area().y(), - pdf_rendering_settings_.area().width(), - pdf_rendering_settings_.area().height(), - true, - false, - true, - true, - pdf_rendering_settings_.autorotate())) { - return false; - } - metafile.FinishPage(); - metafile.FinishDocument(); - return metafile.SaveTo(&output_file); -} - -#endif // OS_WIN - diff --git a/libcef/utility/printing_handler.h b/libcef/utility/printing_handler.h deleted file mode 100644 index c13c84d5c..000000000 --- a/libcef/utility/printing_handler.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 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 LIBCEF_UTILITY_PRINTING_HANDLER_H_ -#define LIBCEF_UTILITY_PRINTING_HANDLER_H_ - -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "chrome/utility/utility_message_handler.h" -#include "ipc/ipc_platform_file.h" -#include "pdf/pdf.h" -#include "printing/pdf_render_settings.h" - -#if !defined(OS_WIN) -#error "Must be building on Windows." -#endif - -namespace printing { -class PdfRenderSettings; -struct PwgRasterSettings; -struct PageRange; -} - -// Dispatches IPCs for printing. -class PrintingHandler : public UtilityMessageHandler { - public: - PrintingHandler(); - ~PrintingHandler() override; - - // IPC::Listener: - bool OnMessageReceived(const IPC::Message& message) override; - - private: - // IPC message handlers. -#if defined(OS_WIN) - void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, - const printing::PdfRenderSettings& settings, - bool print_text_with_gdi); - void OnRenderPDFPagesToMetafileGetPage( - int page_number, - IPC::PlatformFileForTransit output_file); - void OnRenderPDFPagesToMetafileStop(); - - int LoadPDF(base::File pdf_file); - bool RenderPdfPageToMetafile(int page_number, - base::File output_file, - double* scale_factor); - - std::vector pdf_data_; - printing::PdfRenderSettings pdf_rendering_settings_; -#endif // defined(OS_WIN) - - DISALLOW_COPY_AND_ASSIGN(PrintingHandler); -}; - -#endif // LIBCEF_UTILITY_PRINTING_HANDLER_H_ diff --git a/patch/patch.cfg b/patch/patch.cfg index aa893a703..c959ab68a 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -209,7 +209,7 @@ patches = [ # Enable support for filtering resource responses. # https://bitbucket.org/chromiumembedded/cef/issues/515 'name': 'net_filter_515', - 'path': '../net/', + 'path': '../', }, { # Modify views::View to extend SupportsUserData. @@ -288,4 +288,10 @@ patches = [ 'name': 'net_security_expiration_1994', 'path': '../', }, + { + # Remove DCHECK hit during latency reporting when using OSR. + # https://bitbucket.org/chromiumembedded/cef/issues/2060 + 'name': 'render_widget_latency_2060', + 'path': '../', + }, ] diff --git a/patch/patches/browser_compositor_mac.patch b/patch/patches/browser_compositor_mac.patch index 4dc79ddf4..1c556ca52 100644 --- a/patch/patches/browser_compositor_mac.patch +++ b/patch/patches/browser_compositor_mac.patch @@ -1,8 +1,8 @@ diff --git content/browser/renderer_host/browser_compositor_view_mac.h content/browser/renderer_host/browser_compositor_view_mac.h -index 4b8d5bc..6a1b374 100644 +index 865b29f..ef44e27 100644 --- content/browser/renderer_host/browser_compositor_view_mac.h +++ content/browser/renderer_host/browser_compositor_view_mac.h -@@ -56,9 +56,11 @@ class BrowserCompositorMac : public cc::BeginFrameObserver, +@@ -55,9 +55,11 @@ class BrowserCompositorMac : public cc::BeginFrameObserver, // These will not return nullptr until Destroy is called. DelegatedFrameHost* GetDelegatedFrameHost(); @@ -15,10 +15,10 @@ index 4b8d5bc..6a1b374 100644 void SwapCompositorFrame(uint32_t compositor_frame_sink_id, diff --git content/browser/renderer_host/browser_compositor_view_mac.mm content/browser/renderer_host/browser_compositor_view_mac.mm -index 3ec7423..14d5add 100644 +index 4ff716d..aaf17b2 100644 --- content/browser/renderer_host/browser_compositor_view_mac.mm +++ content/browser/renderer_host/browser_compositor_view_mac.mm -@@ -200,6 +200,12 @@ BrowserCompositorMac::~BrowserCompositorMac() { +@@ -199,6 +199,12 @@ BrowserCompositorMac::~BrowserCompositorMac() { g_spare_recyclable_compositors.Get().clear(); } @@ -31,7 +31,7 @@ index 3ec7423..14d5add 100644 ui::AcceleratedWidgetMac* BrowserCompositorMac::GetAcceleratedWidgetMac() { if (recyclable_compositor_) return recyclable_compositor_->accelerated_widget_mac(); -@@ -417,8 +423,13 @@ SkColor BrowserCompositorMac::DelegatedFrameHostGetGutterColor( +@@ -416,8 +422,13 @@ SkColor BrowserCompositorMac::DelegatedFrameHostGetGutterColor( } gfx::Size BrowserCompositorMac::DelegatedFrameHostDesiredSizeInDIP() const { diff --git a/patch/patches/browser_frame_host_guest_1687.patch b/patch/patches/browser_frame_host_guest_1687.patch index 2db7712c6..6a4305c9f 100644 --- a/patch/patches/browser_frame_host_guest_1687.patch +++ b/patch/patches/browser_frame_host_guest_1687.patch @@ -1,14 +1,22 @@ diff --git render_widget_host_view_guest.cc render_widget_host_view_guest.cc -index 7122187..19dec1a 100644 +index c628e20..3c4e008d 100644 --- render_widget_host_view_guest.cc +++ render_widget_host_view_guest.cc -@@ -253,6 +253,9 @@ void RenderWidgetHostViewGuest::Destroy() { +@@ -253,13 +253,14 @@ void RenderWidgetHostViewGuest::Destroy() { } gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { + RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); + if (rwhv) + return rwhv->GetPhysicalBackingSize(); - return RenderWidgetHostViewBase::GetPhysicalBackingSize(); + // We obtain the reference to native view from the owner RenderWidgetHostView. + // If the guest is embedded inside a cross-process frame, it is possible to + // reach here after the frame is detached in which case there will be no owner + // view. +- if (!GetOwnerRenderWidgetHostView()) +- return gfx::Size(); +- return RenderWidgetHostViewBase::GetPhysicalBackingSize(); ++ return gfx::Size(); } + base::string16 RenderWidgetHostViewGuest::GetSelectedText() { diff --git a/patch/patches/browser_plugin_guest_1565.patch b/patch/patches/browser_plugin_guest_1565.patch index 3ca87b04d..0b31a1934 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 2dc039f..66e45e2 100644 +index d4d4f14..977e24e 100644 --- browser/browser_plugin/browser_plugin_guest.cc +++ browser/browser_plugin/browser_plugin_guest.cc -@@ -28,7 +28,7 @@ +@@ -29,7 +29,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 2dc039f..66e45e2 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" -@@ -293,20 +293,19 @@ void BrowserPluginGuest::InitInternal( +@@ -310,20 +310,19 @@ void BrowserPluginGuest::InitInternal( guest_window_rect_ = params.view_rect; if (owner_web_contents_ != owner_web_contents) { @@ -36,7 +36,7 @@ index 2dc039f..66e45e2 100644 } RendererPreferences* renderer_prefs = -@@ -758,11 +757,10 @@ void BrowserPluginGuest::OnWillAttachComplete( +@@ -796,11 +795,10 @@ void BrowserPluginGuest::OnWillAttachComplete( ->GetWidget() ->Init(); GetWebContents()->GetMainFrame()->Init(); @@ -52,7 +52,7 @@ index 2dc039f..66e45e2 100644 } diff --git public/browser/browser_plugin_guest_delegate.cc public/browser/browser_plugin_guest_delegate.cc -index 732df23..25dbc62 100644 +index 8d691ef..eb13b5d 100644 --- public/browser/browser_plugin_guest_delegate.cc +++ public/browser/browser_plugin_guest_delegate.cc @@ -4,6 +4,8 @@ @@ -64,8 +64,8 @@ index 732df23..25dbc62 100644 namespace content { bool BrowserPluginGuestDelegate::CanRunInDetachedState() const { -@@ -36,4 +38,23 @@ bool BrowserPluginGuestDelegate::CanUseCrossProcessFrames() { - return true; +@@ -48,4 +50,23 @@ SiteInstance* BrowserPluginGuestDelegate::GetOwnerSiteInstance() { + return nullptr; } +void BrowserPluginGuestDelegate::OnGuestAttached( @@ -89,19 +89,18 @@ index 732df23..25dbc62 100644 + } // namespace content diff --git public/browser/browser_plugin_guest_delegate.h public/browser/browser_plugin_guest_delegate.h -index 0f805651..fe0385d 100644 +index a32205c..1d93d7b 100644 --- public/browser/browser_plugin_guest_delegate.h +++ public/browser/browser_plugin_guest_delegate.h -@@ -21,6 +21,8 @@ class Size; - namespace content { - +@@ -19,6 +19,7 @@ namespace content { class GuestHost; -+class RenderWidgetHost; + class RenderWidgetHost; + class SiteInstance; +class WebContentsView; // Objects implement this interface to get notified about changes in the guest // WebContents and to provide necessary functionality. -@@ -87,6 +89,17 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate { +@@ -85,6 +86,17 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate { // content module. virtual void SetGuestHost(GuestHost* guest_host) {} @@ -118,4 +117,4 @@ index 0f805651..fe0385d 100644 + // Sets the position of the context menu for the guest contents. The value // reported from the guest renderer should be ignored. The reported value - // fromt he guest renderer is incorrect in situations where BrowserPlugin is + // from the guest renderer is incorrect in situations where BrowserPlugin is diff --git a/patch/patches/chrome_profile.patch b/patch/patches/chrome_profile.patch index e594a33fb..717887161 100644 --- a/patch/patches/chrome_profile.patch +++ b/patch/patches/chrome_profile.patch @@ -63,10 +63,10 @@ index 4b43013..169ca47 100644 content::BrowserContext* GetBrowserContextRedirectedInIncognito( content::BrowserContext* context); diff --git chrome/browser/profiles/profile_manager.h chrome/browser/profiles/profile_manager.h -index ba156c5..0ed578b 100644 +index f715370..fb38098 100644 --- chrome/browser/profiles/profile_manager.h +++ chrome/browser/profiles/profile_manager.h -@@ -89,7 +89,7 @@ class ProfileManager : public base::NonThreadSafe, +@@ -90,7 +90,7 @@ class ProfileManager : public base::NonThreadSafe, // acceptable. Returns null if creation of the new profile fails. // TODO(bauerb): Migrate calls from other code to GetProfileByPath(), then // make this method private. @@ -75,7 +75,7 @@ index ba156c5..0ed578b 100644 // Returns total number of profiles available on this machine. size_t GetNumberOfProfiles(); -@@ -117,7 +117,7 @@ class ProfileManager : public base::NonThreadSafe, +@@ -118,7 +118,7 @@ class ProfileManager : public base::NonThreadSafe, // Returns true if the profile pointer is known to point to an existing // profile. @@ -84,7 +84,7 @@ index ba156c5..0ed578b 100644 // Returns the directory where the first created profile is stored, // relative to the user data directory currently in use. -@@ -126,7 +126,7 @@ class ProfileManager : public base::NonThreadSafe, +@@ -127,7 +127,7 @@ class ProfileManager : public base::NonThreadSafe, // Get the Profile last used (the Profile to which owns the most recently // focused window) with this Chrome build. If no signed profile has been // stored in Local State, hand back the Default profile. diff --git a/patch/patches/chrome_widevine.patch b/patch/patches/chrome_widevine.patch index f53d9bac0..375ebbc2d 100644 --- a/patch/patches/chrome_widevine.patch +++ b/patch/patches/chrome_widevine.patch @@ -1,11 +1,11 @@ diff --git chrome/common/chrome_content_client.cc chrome/common/chrome_content_client.cc -index 616c9b1..cf1c881 100644 +index bb7757b..532f036 100644 --- chrome/common/chrome_content_client.cc +++ chrome/common/chrome_content_client.cc -@@ -77,7 +77,7 @@ +@@ -78,7 +78,7 @@ #endif - #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ + #if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) && \ - !defined(WIDEVINE_CDM_IS_COMPONENT) + !defined(WIDEVINE_CDM_IS_COMPONENT) && defined(WIDEVINE_CDM_VERSION_STRING) #define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT diff --git a/patch/patches/compositor_1368.patch b/patch/patches/compositor_1368.patch index b15141e00..73eae93a2 100644 --- a/patch/patches/compositor_1368.patch +++ b/patch/patches/compositor_1368.patch @@ -1,5 +1,5 @@ diff --git content/browser/compositor/gpu_process_transport_factory.cc content/browser/compositor/gpu_process_transport_factory.cc -index 73ee42f..b30dc83 100644 +index 7d1cf0c..a806826 100644 --- content/browser/compositor/gpu_process_transport_factory.cc +++ content/browser/compositor/gpu_process_transport_factory.cc @@ -196,6 +196,13 @@ GpuProcessTransportFactory::~GpuProcessTransportFactory() { @@ -14,10 +14,10 @@ index 73ee42f..b30dc83 100644 + } + #if defined(USE_AURA) - if (shell::ShellIsRemote()) { + if (service_manager::ServiceManagerIsRemote()) { NOTREACHED(); diff --git ui/compositor/compositor.h ui/compositor/compositor.h -index 6a6b423..4a0d9e4 100644 +index 76f8f38..0fdc07b 100644 --- ui/compositor/compositor.h +++ ui/compositor/compositor.h @@ -18,6 +18,7 @@ @@ -28,7 +28,7 @@ index 6a6b423..4a0d9e4 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" -@@ -195,6 +196,17 @@ class COMPOSITOR_EXPORT CompositorLock +@@ -188,6 +189,17 @@ class COMPOSITOR_EXPORT CompositorLock DISALLOW_COPY_AND_ASSIGN(CompositorLock); }; @@ -46,7 +46,7 @@ index 6a6b423..4a0d9e4 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 -@@ -218,6 +230,9 @@ class COMPOSITOR_EXPORT Compositor +@@ -211,6 +223,9 @@ class COMPOSITOR_EXPORT Compositor // Schedules a redraw of the layer tree associated with this compositor. void ScheduleDraw(); @@ -56,7 +56,7 @@ index 6a6b423..4a0d9e4 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 -@@ -400,6 +415,8 @@ class COMPOSITOR_EXPORT Compositor +@@ -393,6 +408,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 f39ee6ea5..0ab513fac 100644 --- a/patch/patches/content_nav_1129.patch +++ b/patch/patches/content_nav_1129.patch @@ -1,5 +1,5 @@ diff --git public/renderer/content_renderer_client.cc public/renderer/content_renderer_client.cc -index bb040a6..c801841 100644 +index 642521f..8fb647f 100644 --- public/renderer/content_renderer_client.cc +++ public/renderer/content_renderer_client.cc @@ -100,7 +100,6 @@ bool ContentRendererClient::AllowPopup() { @@ -19,10 +19,10 @@ index bb040a6..c801841 100644 return false; } diff --git public/renderer/content_renderer_client.h public/renderer/content_renderer_client.h -index 14d8550..92e5b21 100644 +index f2a854f..913e30c 100644 --- public/renderer/content_renderer_client.h +++ public/renderer/content_renderer_client.h -@@ -208,7 +208,6 @@ class CONTENT_EXPORT ContentRendererClient { +@@ -204,7 +204,6 @@ class CONTENT_EXPORT ContentRendererClient { // Returns true if a popup window should be allowed. virtual bool AllowPopup(); @@ -30,7 +30,7 @@ index 14d8550..92e5b21 100644 // TODO(sgurun) This callback is deprecated and will be removed as soon // as android webview completes implementation of a resource throttle based // shouldoverrideurl implementation. See crbug.com/325351 -@@ -224,6 +223,7 @@ class CONTENT_EXPORT ContentRendererClient { +@@ -220,6 +219,7 @@ class CONTENT_EXPORT ContentRendererClient { blink::WebNavigationPolicy default_policy, bool is_redirect); @@ -39,10 +39,10 @@ index 14d8550..92e5b21 100644 // built in media player for the given |url|. Defaults to false. virtual bool ShouldUseMediaPlayerForURL(const GURL& url); diff --git renderer/render_frame_impl.cc renderer/render_frame_impl.cc -index 8880b8d..cab954b 100644 +index 2f79ac0..7e0c73b 100644 --- renderer/render_frame_impl.cc +++ renderer/render_frame_impl.cc -@@ -5008,7 +5008,6 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( +@@ -5112,7 +5112,6 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( (pending_navigation_params_ && !pending_navigation_params_->request_params.redirects.empty()); @@ -50,7 +50,7 @@ index 8880b8d..cab954b 100644 // The handlenavigation API is deprecated and will be removed once // crbug.com/325351 is resolved. if (GetContentClient()->renderer()->HandleNavigation( -@@ -5017,7 +5016,6 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( +@@ -5121,7 +5120,6 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( is_redirect)) { return blink::WebNavigationPolicyIgnore; } diff --git a/patch/patches/gn_config.patch b/patch/patches/gn_config.patch index 41aeccd00..47e61b40a 100644 --- a/patch/patches/gn_config.patch +++ b/patch/patches/gn_config.patch @@ -1,8 +1,8 @@ diff --git .gn .gn -index 585f0d8..9f60467 100644 +index e4b474a..38a41be 100644 --- .gn +++ .gn -@@ -237,6 +237,7 @@ exec_script_whitelist = [ +@@ -241,6 +241,7 @@ exec_script_whitelist = [ "//build/toolchain/win/BUILD.gn", "//build/util/branding.gni", "//build/util/version.gni", @@ -11,10 +11,10 @@ index 585f0d8..9f60467 100644 # TODO(dgn): Layer violation but breaks the build otherwise, see diff --git BUILD.gn BUILD.gn -index 93699f0..3346d3e 100644 +index 43c7b3d..df225a1 100644 --- BUILD.gn +++ BUILD.gn -@@ -280,6 +280,7 @@ group("both_gn_and_gyp") { +@@ -282,6 +282,7 @@ group("both_gn_and_gyp") { # and whether there should be other targets that are iOS-only and missing. deps += [ "//cc:cc_unittests", @@ -23,11 +23,11 @@ index 93699f0..3346d3e 100644 "//chrome/test:unit_tests", "//components:components_browsertests", diff --git build/config/win/visual_studio_version.gni build/config/win/visual_studio_version.gni -index 5bfa9a7..5e6e05d 100644 +index 982fbe8..e757be46 100644 --- build/config/win/visual_studio_version.gni +++ build/config/win/visual_studio_version.gni @@ -12,9 +12,8 @@ declare_args() { - # Use "2013" for Visual Studio 2013, or "2013e" for the Express version. + # Currently always "2015". visual_studio_version = "" - # Directory of the Windows driver kit. If visual_studio_path is empty, this @@ -80,7 +80,7 @@ index fbc201e..299156d 100644 diff --git build/vs_toolchain.py build/vs_toolchain.py -index 9c55984..d44d116 100755 +index c768a8a..bb91777 100755 --- build/vs_toolchain.py +++ build/vs_toolchain.py @@ -74,11 +74,18 @@ def SetEnvironmentAndGetRuntimeDllDirs(): @@ -103,10 +103,10 @@ index 9c55984..d44d116 100755 # directory in order to run binaries locally, but they are needed in order # to create isolates or the mini_installer. Copying them to the output diff --git chrome/chrome_paks.gni chrome/chrome_paks.gni -index 3e93269..9821a4b 100644 +index c3ac484..13ae760 100644 --- chrome/chrome_paks.gni +++ chrome/chrome_paks.gni -@@ -233,7 +233,7 @@ template("chrome_paks") { +@@ -235,7 +235,7 @@ template("chrome_paks") { additional_source_patterns = invoker.additional_locale_source_patterns } input_locales = locales @@ -116,10 +116,10 @@ index 3e93269..9821a4b 100644 if (is_mac) { output_locales = locales_as_mac_outputs diff --git chrome/installer/mini_installer/BUILD.gn chrome/installer/mini_installer/BUILD.gn -index 6994618..4ed3f85 100644 +index 0f37e54..7b81cde 100644 --- chrome/installer/mini_installer/BUILD.gn +++ chrome/installer/mini_installer/BUILD.gn -@@ -125,7 +125,7 @@ template("generate_mini_installer") { +@@ -124,7 +124,7 @@ template("generate_mini_installer") { inputs = [ "$chrome_dll_file", "$root_out_dir/chrome.exe", diff --git a/patch/patches/gritsettings.patch b/patch/patches/gritsettings.patch index aef48e7d7..13b131106 100644 --- a/patch/patches/gritsettings.patch +++ b/patch/patches/gritsettings.patch @@ -1,10 +1,10 @@ diff --git resource_ids resource_ids -index 82347ce..8e09968 100644 +index c500512..0ac0e98 100644 --- resource_ids +++ resource_ids -@@ -14,6 +14,12 @@ - { - "SRCDIR": "../..", +@@ -358,5 +358,12 @@ + # Thinking about appending to the end? + # Please read the header and find the right section above instead. + "cef/libcef/resources/cef_resources.grd": { + "includes": [31500], @@ -12,6 +12,6 @@ index 82347ce..8e09968 100644 + "cef/libcef/resources/cef_strings.grd": { + "messages": [32000], + }, - "chrome/browser/browser_resources.grd": { - "includes": [400], - "structures": [850], ++ + # Resource ids starting at 31000 are reserved for projects built on Chromium. + } diff --git a/patch/patches/ime_1610.patch b/patch/patches/ime_1610.patch index e860c907a..e44906e4f 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 8975069..858bc9b 100644 +index 49efa46..c9eb806 100644 --- input_method_win.cc +++ input_method_win.cc -@@ -642,8 +642,9 @@ bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const { +@@ -664,8 +664,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_1992243003.patch b/patch/patches/message_loop_443_1992243003.patch index 7ef5e3bc7..40167c1f6 100644 --- a/patch/patches/message_loop_443_1992243003.patch +++ b/patch/patches/message_loop_443_1992243003.patch @@ -1,5 +1,5 @@ diff --git message_loop.cc message_loop.cc -index 74287b1..7309e88 100644 +index 1581f6c..ecb3149 100644 --- message_loop.cc +++ message_loop.cc @@ -96,12 +96,6 @@ MessageLoop::~MessageLoop() { @@ -15,7 +15,7 @@ index 74287b1..7309e88 100644 #if defined(OS_WIN) if (in_high_res_mode_) Time::ActivateHighResolutionTimer(false); -@@ -313,6 +307,9 @@ MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory) +@@ -319,6 +313,9 @@ MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory) in_high_res_mode_(false), #endif nestable_tasks_allowed_(true), @@ -26,7 +26,7 @@ index 74287b1..7309e88 100644 run_loop_(NULL), incoming_task_queue_(new internal::IncomingTaskQueue(this)), diff --git message_loop.h message_loop.h -index 5b1728e..79c4c58 100644 +index ac7a303..b39018b 100644 --- message_loop.h +++ message_loop.h @@ -299,6 +299,16 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { @@ -46,7 +46,7 @@ index 5b1728e..79c4c58 100644 // Can only be called from the thread that owns the MessageLoop. bool is_running() const; -@@ -437,6 +447,12 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { +@@ -436,6 +446,12 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { // insider a (accidentally induced?) nested message pump. bool nestable_tasks_allowed_; @@ -60,10 +60,10 @@ index 5b1728e..79c4c58 100644 // if type_ is TYPE_CUSTOM and pump_ is null. MessagePumpFactoryCallback pump_factory_; diff --git message_pump_win.cc message_pump_win.cc -index b9b2c84..9abef7e 100644 +index f1ec727..4b859c0 100644 --- message_pump_win.cc +++ message_pump_win.cc -@@ -478,20 +478,28 @@ bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) { +@@ -366,20 +366,28 @@ bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) { } bool MessagePumpForUI::ProcessPumpReplacementMessage() { @@ -88,7 +88,7 @@ index b9b2c84..9abef7e 100644 + bool have_message = false; MSG msg; - const bool have_message = -- g_peek_message(&msg, nullptr, 0, 0, PM_REMOVE) != FALSE; +- PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) != FALSE; + // We should not process all window messages if we are in the context of an + // OS modal loop, i.e. in the context of a windows API call like MessageBox. + // This is to ensure that these messages are peeked out by the OS modal loop. @@ -102,5 +102,5 @@ index b9b2c84..9abef7e 100644 - // Expect no message or a message different than kMsgHaveWork. DCHECK(!have_message || kMsgHaveWork != msg.message || - msg.hwnd != message_hwnd_); + msg.hwnd != message_window_.hwnd()); diff --git a/patch/patches/mime_handler_view_1565.patch b/patch/patches/mime_handler_view_1565.patch index 6bad81e69..ce8e46958 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 dcf7527..46fe51e 100644 +index 049af16..c5130acd 100644 --- mime_handler_view_guest.cc +++ mime_handler_view_guest.cc -@@ -138,6 +138,8 @@ void MimeHandlerViewGuest::CreateWebContents( +@@ -179,6 +179,8 @@ void MimeHandlerViewGuest::CreateWebContents( WebContents::CreateParams params(browser_context(), guest_site_instance.get()); params.guest_delegate = this; @@ -11,7 +11,7 @@ index dcf7527..46fe51e 100644 callback.Run(WebContents::Create(params)); } -@@ -162,6 +164,30 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const { +@@ -203,6 +205,30 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const { return false; } @@ -43,10 +43,10 @@ index dcf7527..46fe51e 100644 WebContents* source, const content::OpenURLParams& params) { diff --git mime_handler_view_guest.h mime_handler_view_guest.h -index 87d249e..c6a8ad3 100644 +index d237318..b9cd2ab 100644 --- mime_handler_view_guest.h +++ mime_handler_view_guest.h -@@ -77,6 +77,15 @@ class MimeHandlerViewGuest : +@@ -83,6 +83,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 516c0e278..ca547eda4 100644 --- a/patch/patches/net_filter_515.patch +++ b/patch/patches/net_filter_515.patch @@ -1,60 +1,40 @@ -diff --git base/network_delegate.h base/network_delegate.h -index 6fc19f9..583c8a9 100644 ---- base/network_delegate.h -+++ base/network_delegate.h -@@ -37,6 +37,7 @@ namespace net { - // of net/base here, because we have a net_base library. Forward declarations - // are ok. - class CookieOptions; -+class Filter; - class HttpRequestHeaders; - class HttpResponseHeaders; - class ProxyInfo; -@@ -116,6 +117,13 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { +diff --git net/base/network_delegate.h net/base/network_delegate.h +index 0fccae1..73e33ad 100644 +--- net/base/network_delegate.h ++++ net/base/network_delegate.h +@@ -16,6 +16,7 @@ + #include "net/base/completion_callback.h" + #include "net/base/net_export.h" + #include "net/cookies/canonical_cookie.h" ++#include "net/filter/source_stream.h" + #include "net/proxy/proxy_retry_info.h" + + class GURL; +@@ -116,6 +117,10 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { const GURL& target_url, const GURL& referrer_url) const; -+ // Optionally add a new filter to the filter list. Returns the first filter in -+ // the list. -+ virtual Filter* SetupFilter(URLRequest* request, -+ Filter* filter_list) { -+ return filter_list; -+ } ++ virtual std::unique_ptr CreateSourceStream( ++ net::URLRequest* request, ++ std::unique_ptr upstream) { return upstream; } + private: // 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 91875a2..b6c665f 100644 ---- filter/filter.h -+++ filter/filter.h -@@ -59,6 +59,7 @@ - #include "net/base/net_export.h" - #include "net/base/sdch_manager.h" +diff --git net/url_request/url_request_job.cc net/url_request/url_request_job.cc +index b315664..55701edf 100644 +--- net/url_request/url_request_job.cc ++++ net/url_request/url_request_job.cc +@@ -494,6 +494,12 @@ void URLRequestJob::NotifyHeadersComplete() { + DCHECK(!source_stream_); + source_stream_ = SetUpSourceStream(); -+class CefNetworkDelegate; - class GURL; - - namespace net { -@@ -240,6 +241,7 @@ class NET_EXPORT Filter { - FilterType type() const { return type_id_; } - - protected: -+ friend class ::CefNetworkDelegate; - friend class BrotliUnitTest; - friend class GZipUnitTest; - friend class SdchFilterChainingTest; -diff --git url_request/url_request_job.cc url_request/url_request_job.cc -index f9df570..72b48ec 100644 ---- url_request/url_request_job.cc -+++ url_request/url_request_job.cc -@@ -489,6 +489,9 @@ void URLRequestJob::NotifyHeadersComplete() { - if (request_->status().is_success()) - filter_ = SetupFilter(); - -+ if (network_delegate_) -+ filter_.reset(network_delegate_->SetupFilter(request_, filter_.release())); ++ // Allow the delegate to add a downstream SourceStream for filtering. ++ if (network_delegate_ && source_stream_) { ++ source_stream_ = network_delegate_->CreateSourceStream( ++ request_, std::move(source_stream_)); ++ } + - if (!filter_.get()) { - std::string content_length; - request_->GetResponseHeaderByName("content-length", &content_length); + if (!source_stream_) { + NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, + ERR_CONTENT_DECODING_INIT_FAILED)); diff --git a/patch/patches/net_security_expiration_1994.patch b/patch/patches/net_security_expiration_1994.patch index 2b9637f3e..03047f21b 100644 --- a/patch/patches/net_security_expiration_1994.patch +++ b/patch/patches/net_security_expiration_1994.patch @@ -55,10 +55,10 @@ index c732cee..1c80e81 100644 } // namespace net diff --git net/http/transport_security_state.cc net/http/transport_security_state.cc -index a3f468d..8d1928f 100644 +index 9b42feb..f7860be 100644 --- net/http/transport_security_state.cc +++ net/http/transport_security_state.cc -@@ -1374,8 +1374,10 @@ void TransportSecurityState::SetShouldRequireCTForTesting(bool* required) { +@@ -1362,8 +1362,10 @@ void TransportSecurityState::SetShouldRequireCTForTesting(bool* required) { g_ct_required_for_testing = *required ? 1 : -1; } @@ -72,10 +72,10 @@ index a3f468d..8d1928f 100644 // We consider built-in information to be timely for 10 weeks. return (base::Time::Now() - build_time).InDays() < 70 /* 10 weeks */; diff --git net/http/transport_security_state.h net/http/transport_security_state.h -index 3326ca2..a2de308 100644 +index fc40b7d..c0b14a4 100644 --- net/http/transport_security_state.h +++ net/http/transport_security_state.h -@@ -472,6 +472,10 @@ class NET_EXPORT TransportSecurityState +@@ -475,6 +475,10 @@ class NET_EXPORT TransportSecurityState // nullptr to reset. static void SetShouldRequireCTForTesting(bool* required); @@ -86,7 +86,7 @@ index 3326ca2..a2de308 100644 private: friend class TransportSecurityStateTest; FRIEND_TEST_ALL_PREFIXES(HttpSecurityHeadersTest, UpdateDynamicPKPOnly); -@@ -495,7 +499,7 @@ class NET_EXPORT TransportSecurityState +@@ -498,7 +502,7 @@ class NET_EXPORT TransportSecurityState // IsBuildTimely returns true if the current build is new enough ensure that // built in security information (i.e. HSTS preloading and pinning // information) is timely. @@ -95,7 +95,7 @@ index 3326ca2..a2de308 100644 // Helper method for actually checking pins. PKPStatus CheckPublicKeyPinsImpl( -@@ -586,6 +590,8 @@ class NET_EXPORT TransportSecurityState +@@ -589,6 +593,8 @@ class NET_EXPORT TransportSecurityState // True if public key pinning bypass is enabled for local trust anchors. bool enable_pkp_bypass_for_local_trust_anchors_; diff --git a/patch/patches/net_urlrequest_1327.patch b/patch/patches/net_urlrequest_1327.patch index 22a111790..113fb0be1 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 993afc9..a207f44 100644 +index 9ef191c..2100168 100644 --- url_request.h +++ url_request.h -@@ -646,10 +646,11 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), +@@ -655,10 +655,11 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), // Returns the error status of the request. // Do not use! Going to be protected! const URLRequestStatus& status() const { return status_; } diff --git a/patch/patches/pdfium_print_549365.patch b/patch/patches/pdfium_print_549365.patch index feac93b71..e3a8b8fd4 100644 --- a/patch/patches/pdfium_print_549365.patch +++ b/patch/patches/pdfium_print_549365.patch @@ -1,8 +1,8 @@ diff --git BUILD.gn BUILD.gn -index b6b33f1..d80ead9 100644 +index f91ea0e..b57c692 100644 --- BUILD.gn +++ BUILD.gn -@@ -181,6 +181,10 @@ static_library("pdfium") { +@@ -183,6 +183,10 @@ static_library("pdfium") { } else { libs += [ "freetype" ] } @@ -14,10 +14,10 @@ index b6b33f1..d80ead9 100644 static_library("test_support") { diff --git fpdfsdk/fpdfview.cpp fpdfsdk/fpdfview.cpp -index 001ebb0..8b2b6cc 100644 +index 334c14c..fd918f3 100644 --- fpdfsdk/fpdfview.cpp +++ fpdfsdk/fpdfview.cpp -@@ -30,6 +30,7 @@ +@@ -31,6 +31,7 @@ #include "fpdfsdk/fsdk_define.h" #include "fpdfsdk/fsdk_pauseadapter.h" #include "fpdfsdk/javascript/ijs_runtime.h" @@ -25,8 +25,8 @@ index 001ebb0..8b2b6cc 100644 #include "public/fpdf_ext.h" #include "public/fpdf_progressive.h" #include "third_party/base/numerics/safe_conversions_impl.h" -@@ -299,6 +300,7 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary() { - #endif // PDF_ENABLE_XFA +@@ -263,6 +264,7 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary() { + CPDF_ModuleMgr::Destroy(); CFX_GEModule::Destroy(); + FXJS_Release(); diff --git a/patch/patches/prefs_content_1161.patch b/patch/patches/prefs_content_1161.patch index 6344b2106..e08acb471 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 f2eb0d2..4909609 100644 +index 86fcd13..c695975 100644 --- public/common/common_param_traits_macros.h +++ public/common/common_param_traits_macros.h -@@ -203,6 +203,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) +@@ -201,6 +201,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,11 +11,11 @@ index f2eb0d2..4909609 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 18a484d..338f2f8 100644 +index da49d44..e42e715 100644 --- public/common/web_preferences.cc +++ public/common/web_preferences.cc -@@ -175,6 +175,7 @@ WebPreferences::WebPreferences() - pinch_overlay_scrollbar_thickness(0), +@@ -173,6 +173,7 @@ WebPreferences::WebPreferences() + spatial_navigation_enabled(false), use_solid_color_scrollbars(false), navigate_on_drag_drop(true), + base_background_color(0xFFFFFFFF), // Color::white @@ -23,11 +23,11 @@ index 18a484d..338f2f8 100644 inert_visual_viewport(false), record_whole_document(false), diff --git public/common/web_preferences.h public/common/web_preferences.h -index 5509a57..d32b4cc 100644 +index b853dd3..d2324bd 100644 --- public/common/web_preferences.h +++ public/common/web_preferences.h -@@ -188,6 +188,7 @@ struct CONTENT_EXPORT WebPreferences { - int pinch_overlay_scrollbar_thickness; +@@ -186,6 +186,7 @@ struct CONTENT_EXPORT WebPreferences { + bool spatial_navigation_enabled; bool use_solid_color_scrollbars; bool navigate_on_drag_drop; + uint32_t base_background_color; @@ -35,10 +35,10 @@ index 5509a57..d32b4cc 100644 bool inert_visual_viewport; bool record_whole_document; diff --git renderer/render_view_impl.cc renderer/render_view_impl.cc -index 6a461f6..4eba51c 100644 +index 0c11c30..c0ae0af 100644 --- renderer/render_view_impl.cc +++ renderer/render_view_impl.cc -@@ -1492,6 +1492,8 @@ void RenderViewImpl::ApplyWebPreferencesInternal( +@@ -1351,6 +1351,8 @@ void RenderViewImpl::ApplyWebPreferencesInternal( blink::WebView* web_view, CompositorDependencies* compositor_deps) { ApplyWebPreferences(prefs, web_view); diff --git a/patch/patches/prefs_tab_helper_1680.patch b/patch/patches/prefs_tab_helper_1680.patch index 9969991f0..e389515d0 100644 --- a/patch/patches/prefs_tab_helper_1680.patch +++ b/patch/patches/prefs_tab_helper_1680.patch @@ -1,5 +1,5 @@ diff --git prefs_tab_helper.cc prefs_tab_helper.cc -index 448bb72..aa98dda 100644 +index e20d4e5c..d350a14 100644 --- prefs_tab_helper.cc +++ prefs_tab_helper.cc @@ -11,8 +11,8 @@ @@ -12,7 +12,7 @@ index 448bb72..aa98dda 100644 #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -@@ -422,12 +422,10 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { +@@ -429,12 +429,10 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { GetInstance()->GetServiceForBrowserContext(profile, true)); } @@ -27,7 +27,7 @@ index 448bb72..aa98dda 100644 PrefWatcherFactory() : BrowserContextKeyedServiceFactory( "PrefWatcher", -@@ -448,6 +446,18 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { +@@ -455,6 +453,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 102b71646..90130703b 100644 --- a/patch/patches/print_header_footer_1478_1565.patch +++ b/patch/patches/print_header_footer_1478_1565.patch @@ -1,24 +1,36 @@ diff --git chrome/browser/ui/cocoa/applescript/tab_applescript.mm chrome/browser/ui/cocoa/applescript/tab_applescript.mm -index 4552193..dbf30ae 100644 +index cb9d140..528091d 100644 --- chrome/browser/ui/cocoa/applescript/tab_applescript.mm +++ chrome/browser/ui/cocoa/applescript/tab_applescript.mm -@@ -9,7 +9,9 @@ +@@ -9,7 +9,6 @@ #include "base/logging.h" #import "base/mac/scoped_nsobject.h" #include "base/strings/sys_string_conversions.h" -+#if defined(ENABLE_PRINT_PREVIEW) - #include "chrome/browser/printing/print_view_manager.h" -+#endif +-#include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/cocoa/applescript/apple_event_util.h" #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" -@@ -224,11 +226,15 @@ void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id, +@@ -25,8 +24,13 @@ + #include "content/public/browser/save_page_type.h" + #include "content/public/browser/web_contents.h" + #include "content/public/browser/web_contents_delegate.h" ++#include "printing/features/features.h" + #include "url/gurl.h" + ++#if BUILDFLAG(ENABLE_PRINT_PREVIEW) ++#include "chrome/browser/printing/print_view_manager.h" ++#endif ++ + using content::NavigationController; + using content::NavigationEntry; + using content::OpenURLParams; +@@ -231,11 +235,15 @@ - (void)handlesStopScriptCommand:(NSScriptCommand*)command { - (void)handlesPrintScriptCommand:(NSScriptCommand*)command { AppleScript::LogAppleScriptUMA(AppleScript::AppleScriptCommand::TAB_PRINT); -+#if defined(ENABLE_PRINT_PREVIEW) - bool initiated = - printing::PrintViewManager::FromWebContents(webContents_)->PrintNow(); ++#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + bool initiated = printing::PrintViewManager::FromWebContents(webContents_) + ->PrintNow(webContents_->GetMainFrame()); if (!initiated) { AppleScript::SetError(AppleScript::errInitiatePrinting); } @@ -29,215 +41,215 @@ index 4552193..dbf30ae 100644 - (void)handlesSaveScriptCommand:(NSScriptCommand*)command { diff --git components/printing/common/print_messages.cc components/printing/common/print_messages.cc -index 6798e35..215777f 100644 +index 5820bb1..a1a8f08 100644 --- components/printing/common/print_messages.cc +++ components/printing/common/print_messages.cc -@@ -103,7 +103,6 @@ void PrintMsg_PrintPages_Params::Reset() { +@@ -105,7 +105,6 @@ void PrintMsg_PrintPages_Params::Reset() { pages = std::vector(); } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) PrintHostMsg_RequestPrintPreview_Params:: PrintHostMsg_RequestPrintPreview_Params() : is_modifiable(false), -@@ -125,4 +124,3 @@ PrintHostMsg_SetOptionsFromDocument_Params:: +@@ -127,4 +126,3 @@ PrintHostMsg_SetOptionsFromDocument_Params:: PrintHostMsg_SetOptionsFromDocument_Params:: ~PrintHostMsg_SetOptionsFromDocument_Params() { } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) diff --git components/printing/common/print_messages.h components/printing/common/print_messages.h -index a019144..af8839d 100644 +index 3d1e71a..a876c2a 100644 --- components/printing/common/print_messages.h +++ components/printing/common/print_messages.h -@@ -71,7 +71,6 @@ struct PrintMsg_PrintPages_Params { +@@ -73,7 +73,6 @@ struct PrintMsg_PrintPages_Params { std::vector pages; }; --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) struct PrintHostMsg_RequestPrintPreview_Params { PrintHostMsg_RequestPrintPreview_Params(); ~PrintHostMsg_RequestPrintPreview_Params(); -@@ -90,7 +89,6 @@ struct PrintHostMsg_SetOptionsFromDocument_Params { +@@ -92,7 +91,6 @@ struct PrintHostMsg_SetOptionsFromDocument_Params { printing::DuplexMode duplex; printing::PageRanges page_ranges; }; --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_ -@@ -177,7 +175,6 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PageRange) +@@ -182,7 +180,6 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PageRange) IPC_STRUCT_TRAITS_MEMBER(to) IPC_STRUCT_TRAITS_END() --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params) IPC_STRUCT_TRAITS_MEMBER(is_modifiable) IPC_STRUCT_TRAITS_MEMBER(webnode_only) -@@ -198,7 +195,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_SetOptionsFromDocument_Params) +@@ -203,7 +200,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_SetOptionsFromDocument_Params) // Specifies page range to be printed. IPC_STRUCT_TRAITS_MEMBER(page_ranges) IPC_STRUCT_TRAITS_END() --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins) IPC_STRUCT_TRAITS_MEMBER(content_width) -@@ -218,7 +214,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params) +@@ -223,7 +219,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params) IPC_STRUCT_TRAITS_MEMBER(pages) IPC_STRUCT_TRAITS_END() --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Parameters to describe a rendered document. IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params) // A shared memory handle to metafile data. -@@ -272,7 +267,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params) +@@ -280,7 +275,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params) // Indicates whether the existing preview data needs to be cleared or not. IPC_STRUCT_MEMBER(bool, clear_preview_data) IPC_STRUCT_END() --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) // Parameters to describe a rendered page. IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params) -@@ -311,22 +305,20 @@ IPC_STRUCT_END() +@@ -319,22 +313,20 @@ IPC_STRUCT_END() // Messages sent from the browser to the renderer. --#if defined(ENABLE_PRINT_PREVIEW) - // Tells the render view to initiate print preview for the entire document. - IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */) --#endif // defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + // Tells the RenderFrame to initiate print preview for the entire document. + IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* has_selection */) +-#endif - // Tells the render frame to initiate printing or print preview for a particular - // node, depending on which mode the render frame is in. + // Tells the RenderFrame to initiate printing or print preview for a particular + // node, depending on which mode the RenderFrame is in. IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu) --#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW) -+#if defined(ENABLE_BASIC_PRINTING) +-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) ++#if BUILDFLAG(ENABLE_BASIC_PRINTING) // Tells the renderer to print the print preview tab's PDF plugin without // showing the print dialog. (This is the final step in the print preview // workflow.) IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview, base::DictionaryValue /* settings */) --#endif // defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW) -+#endif // defined(ENABLE_BASIC_PRINTING) +-#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) ++#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) - #if defined(ENABLE_BASIC_PRINTING) - // Tells the render view to switch the CSS to print media type, renders every -@@ -345,13 +337,11 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone, - IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked, - bool /* blocked */) + #if BUILDFLAG(ENABLE_BASIC_PRINTING) + // Tells the RenderFrame to switch the CSS to print media type, renders every +@@ -352,13 +344,11 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone, + // Tells the RenderFrame whether printing is enabled or not. + IPC_MESSAGE_ROUTED1(PrintMsg_SetPrintingEnabled, bool /* enabled */) --#if defined(ENABLE_PRINT_PREVIEW) - // Tells the render view to switch the CSS to print media type, renders every +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + // Tells the RenderFrame to switch the CSS to print media type, renders every // requested pages for print preview using the given |settings|. This gets // called multiple times as the user updates settings. IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview, base::DictionaryValue /* settings */) --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // Messages sent from the renderer to the browser. -@@ -411,7 +401,6 @@ IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten, +@@ -414,7 +404,6 @@ IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten, int /* fd in browser */) // Used only by Chrome OS. #endif // defined(OS_ANDROID) --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Asks the browser to do print preview. IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview, PrintHostMsg_RequestPrintPreview_Params /* params */) -@@ -445,7 +434,6 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel, +@@ -448,7 +437,6 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel, // The memory handle in this message is already valid in the browser process. IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting, PrintHostMsg_DidPreviewDocument_Params /* params */) --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) // This is sent when there are invalid printer settings. IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError) -@@ -454,7 +442,6 @@ IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError) +@@ -457,7 +445,6 @@ IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError) IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed, int /* document cookie */) --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Tell the browser print preview failed. IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed, int /* document cookie */) -@@ -481,4 +468,3 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview, +@@ -484,4 +471,3 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview, // Notify the browser to set print presets based on source PDF document. IPC_MESSAGE_ROUTED1(PrintHostMsg_SetOptionsFromDocument, PrintHostMsg_SetOptionsFromDocument_Params /* params */) --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) diff --git components/printing/renderer/print_web_view_helper.cc components/printing/renderer/print_web_view_helper.cc -index 7e9df81..33489d0 100644 +index e343eef..025671c 100644 --- components/printing/renderer/print_web_view_helper.cc +++ components/printing/renderer/print_web_view_helper.cc -@@ -86,6 +86,9 @@ const float kPrintingMinimumShrinkFactor = 1.333f; +@@ -88,6 +88,9 @@ const float kPrintingMinimumShrinkFactor = 1.333f; - #if defined(ENABLE_PRINT_PREVIEW) + #if BUILDFLAG(ENABLE_PRINT_PREVIEW) bool g_is_preview_enabled = true; +#else +bool g_is_preview_enabled = false; -+#endif // defined(ENABLE_PRINT_PREVIEW) ++#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) const char kPageLoadScriptFormat[] = "document.open(); document.write(%s); document.close();"; -@@ -100,9 +103,6 @@ void ExecuteScript(blink::WebFrame* frame, +@@ -102,9 +105,6 @@ void ExecuteScript(blink::WebFrame* frame, std::string script = base::StringPrintf(script_format, json.c_str()); frame->executeScript(blink::WebString(base::UTF8ToUTF16(script))); } -#else -bool g_is_preview_enabled = false; --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) int GetDPI(const PrintMsg_Print_Params* print_params) { #if defined(OS_MACOSX) -@@ -302,7 +302,6 @@ bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame, +@@ -321,7 +321,6 @@ bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame, return plugin && plugin->supportsPaginatedPrint(); } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Returns true if the current destination printer is PRINT_TO_PDF. bool IsPrintToPdfRequested(const base::DictionaryValue& job_settings) { bool print_to_pdf = false; -@@ -324,7 +323,6 @@ bool PrintingFrameHasPageSizeStyle(blink::WebLocalFrame* frame, +@@ -343,7 +342,6 @@ bool PrintingFrameHasPageSizeStyle(blink::WebLocalFrame* frame, } return frame_has_custom_page_size_style; } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) // Disable scaling when either: // - The PDF specifies disabling scaling. -@@ -378,7 +376,6 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame, +@@ -397,7 +395,6 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame, } #endif --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) bool FitToPageEnabled(const base::DictionaryValue& job_settings) { bool fit_to_paper_size = false; if (!job_settings.GetBoolean(kSettingFitToPageEnabled, &fit_to_paper_size)) { -@@ -421,7 +418,6 @@ blink::WebPrintScalingOption GetPrintScalingOption( +@@ -440,7 +437,6 @@ blink::WebPrintScalingOption GetPrintScalingOption( } return blink::WebPrintScalingOptionFitToPrintableArea; } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) - PrintMsg_Print_Params CalculatePrintParamsForCss( - blink::WebLocalFrame* frame, -@@ -505,7 +501,6 @@ blink::WebView* FrameReference::view() { + // Helper function to scale and round an integer value with a double valued + // scaling. +@@ -559,7 +555,6 @@ blink::WebView* FrameReference::view() { return view_; } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // static - Not anonymous so that platform implementations can use it. void PrintWebViewHelper::PrintHeaderAndFooter( blink::WebCanvas* canvas, -@@ -563,7 +558,6 @@ void PrintWebViewHelper::PrintHeaderAndFooter( +@@ -617,7 +612,6 @@ void PrintWebViewHelper::PrintHeaderAndFooter( web_view->close(); } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) // static - Not anonymous so that platform implementations can use it. float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, -@@ -840,6 +834,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view, +@@ -902,6 +896,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderFrame* render_frame, print_for_preview_(false), delegate_(std::move(delegate)), print_node_in_progress_(false), @@ -245,91 +257,91 @@ index 7e9df81..33489d0 100644 is_loading_(false), is_scripted_preview_delayed_(false), ipc_nesting_level_(0), -@@ -898,10 +893,8 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame, +@@ -961,10 +956,8 @@ void PrintWebViewHelper::ScriptedPrint(bool user_initiated) { return; if (g_is_preview_enabled) { --#if defined(ENABLE_PRINT_PREVIEW) - print_preview_context_.InitWithFrame(frame); +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + print_preview_context_.InitWithFrame(web_frame); RequestPrintPreview(PRINT_PREVIEW_SCRIPTED); -#endif } else { - #if defined(ENABLE_BASIC_PRINTING) - Print(frame, blink::WebNode(), true); -@@ -925,14 +918,10 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { + #if BUILDFLAG(ENABLE_BASIC_PRINTING) + Print(web_frame, blink::WebNode(), true /* is_scripted? */); +@@ -988,14 +981,10 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog) - #endif // defined(ENABLE_BASIC_PRINTING) --#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW) + #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) -#endif --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) --#endif // defined(ENABLE_PRINT_PREVIEW) - IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked, - SetScriptedPrintBlocked) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) + IPC_MESSAGE_HANDLER(PrintMsg_SetPrintingEnabled, OnSetPrintingEnabled) IPC_MESSAGE_UNHANDLED(handled = false) -@@ -987,7 +976,6 @@ void PrintWebViewHelper::OnPrintForSystemDialog() { + IPC_END_MESSAGE_MAP() +@@ -1033,7 +1022,6 @@ void PrintWebViewHelper::OnPrintForSystemDialog() { } - #endif // defined(ENABLE_BASIC_PRINTING) + #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) --#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintWebViewHelper::OnPrintForPrintPreview( const base::DictionaryValue& job_settings) { CHECK_LE(ipc_nesting_level_, 1); -@@ -1052,7 +1040,6 @@ void PrintWebViewHelper::OnPrintForPrintPreview( +@@ -1092,7 +1080,6 @@ void PrintWebViewHelper::OnPrintForPrintPreview( DidFinishPrinting(FAIL_PRINT); } } --#endif // defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout( const PageSizeMargins& page_layout_in_points, -@@ -1077,7 +1064,6 @@ void PrintWebViewHelper::UpdateFrameMarginsCssInfo( +@@ -1117,7 +1104,6 @@ void PrintWebViewHelper::UpdateFrameMarginsCssInfo( ignore_css_margins_ = (margins_type != DEFAULT_MARGINS); } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) { if (ipc_nesting_level_ > 1) return; -@@ -1238,7 +1224,7 @@ bool PrintWebViewHelper::CreatePreviewDocument() { +@@ -1302,7 +1288,7 @@ bool PrintWebViewHelper::CreatePreviewDocument() { return true; } --#if !defined(OS_MACOSX) && defined(ENABLE_PRINT_PREVIEW) +-#if !defined(OS_MACOSX) && BUILDFLAG(ENABLE_PRINT_PREVIEW) +#if !defined(OS_MACOSX) bool PrintWebViewHelper::RenderPreviewPage( int page_number, const PrintMsg_Print_Params& print_params) { -@@ -1268,7 +1254,7 @@ bool PrintWebViewHelper::RenderPreviewPage( +@@ -1332,7 +1318,7 @@ bool PrintWebViewHelper::RenderPreviewPage( } return PreviewPageRendered(page_number, draft_metafile.get()); } --#endif // !defined(OS_MACOSX) && defined(ENABLE_PRINT_PREVIEW) +-#endif // !defined(OS_MACOSX) && BUILDFLAG(ENABLE_PRINT_PREVIEW) +#endif // !defined(OS_MACOSX) bool PrintWebViewHelper::FinalizePrintReadyDocument() { DCHECK(!is_print_ready_metafile_sent_); -@@ -1298,7 +1284,6 @@ bool PrintWebViewHelper::FinalizePrintReadyDocument() { +@@ -1362,7 +1348,6 @@ bool PrintWebViewHelper::FinalizePrintReadyDocument() { Send(new PrintHostMsg_MetafileReadyForPrinting(routing_id(), preview_params)); return true; } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintWebViewHelper::OnPrintingDone(bool success) { if (ipc_nesting_level_ > 1) -@@ -1313,7 +1298,6 @@ void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) { - is_scripted_printing_blocked_ = blocked; +@@ -1377,7 +1362,6 @@ void PrintWebViewHelper::OnSetPrintingEnabled(bool enabled) { + is_printing_enabled_ = enabled; } --#if defined(ENABLE_PRINT_PREVIEW) - void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + void PrintWebViewHelper::OnInitiatePrintPreview(bool has_selection) { if (ipc_nesting_level_ > 1) return; -@@ -1324,7 +1308,9 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { +@@ -1388,7 +1372,9 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool has_selection) { // that instead. auto plugin = delegate_->GetPdfElement(frame); if (!plugin.isNull()) { @@ -339,181 +351,181 @@ index 7e9df81..33489d0 100644 return; } print_preview_context_.InitWithFrame(frame); -@@ -1332,7 +1318,6 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { +@@ -1396,7 +1382,6 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool has_selection) { ? PRINT_PREVIEW_USER_INITIATED_SELECTION : PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME); } -#endif - bool PrintWebViewHelper::IsPrintingEnabled() { - bool result = false; -@@ -1358,11 +1343,9 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) { + bool PrintWebViewHelper::IsPrintingEnabled() const { + return is_printing_enabled_; +@@ -1420,11 +1405,9 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) { // Make a copy of the node, in case RenderView::OnContextMenuClosed resets // its |context_menu_node_|. - if (g_is_preview_enabled) { --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + if (g_is_preview_enabled || force_print_preview_) { print_preview_context_.InitWithNode(node); RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE); -#endif } else { - #if defined(ENABLE_BASIC_PRINTING) + #if BUILDFLAG(ENABLE_BASIC_PRINTING) blink::WebNode duplicate_node(node); -@@ -1428,7 +1411,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { +@@ -1490,7 +1473,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { } break; --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) case FAIL_PREVIEW: int cookie = print_pages_params_ ? print_pages_params_->params.document_cookie : 0; -@@ -1440,7 +1422,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { +@@ -1502,7 +1484,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { } print_preview_context_.Failed(notify_browser_of_print_failure_); break; --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) } prep_frame_view_.reset(); print_pages_params_.reset(); -@@ -1572,7 +1553,6 @@ bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame, +@@ -1634,7 +1615,6 @@ bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame, return true; } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) bool PrintWebViewHelper::SetOptionsFromPdfDocument( PrintHostMsg_SetOptionsFromDocument_Params* options) { blink::WebLocalFrame* source_frame = print_preview_context_.source_frame(); -@@ -1681,7 +1661,6 @@ bool PrintWebViewHelper::UpdatePrintSettings( +@@ -1743,7 +1723,6 @@ bool PrintWebViewHelper::UpdatePrintSettings( return true; } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) - #if defined(ENABLE_BASIC_PRINTING) + #if BUILDFLAG(ENABLE_BASIC_PRINTING) bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebLocalFrame* frame, -@@ -1790,7 +1769,6 @@ void PrintWebViewHelper::PrintPageInternal( +@@ -1857,7 +1836,6 @@ void PrintWebViewHelper::PrintPageInternal( MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) if (params.params.display_header_footer) { // TODO(thestig): Figure out why Linux needs this. It is almost certainly // |printingMinimumShrinkFactor| from Blink. -@@ -1805,7 +1783,6 @@ void PrintWebViewHelper::PrintPageInternal( +@@ -1872,7 +1850,6 @@ void PrintWebViewHelper::PrintPageInternal( scale_factor / fudge_factor, page_layout_in_points, params.params); } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) float webkit_scale_factor = RenderPageContent(frame, params.page_number, canvas_area, content_area, -@@ -1841,7 +1818,6 @@ bool PrintWebViewHelper::CopyMetafileDataToSharedMem( +@@ -1908,7 +1885,6 @@ bool PrintWebViewHelper::CopyMetafileDataToSharedMem( return true; } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintWebViewHelper::ShowScriptedPrintPreview() { if (is_scripted_preview_delayed_) { is_scripted_preview_delayed_ = false; -@@ -1969,7 +1945,6 @@ bool PrintWebViewHelper::PreviewPageRendered(int page_number, +@@ -2036,7 +2012,6 @@ bool PrintWebViewHelper::PreviewPageRendered(int page_number, Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params)); return true; } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) PrintWebViewHelper::PrintPreviewContext::PrintPreviewContext() : total_page_count_(0), diff --git components/printing/renderer/print_web_view_helper.h components/printing/renderer/print_web_view_helper.h -index dd8d24d..7c73d38 100644 +index 2dad908..fea05fd 100644 --- components/printing/renderer/print_web_view_helper.h +++ components/printing/renderer/print_web_view_helper.h -@@ -138,9 +138,7 @@ class PrintWebViewHelper +@@ -143,9 +143,7 @@ class PrintWebViewHelper OK, FAIL_PRINT_INIT, FAIL_PRINT, --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) FAIL_PREVIEW, -#endif }; enum PrintPreviewErrorBuckets { -@@ -175,10 +173,8 @@ class PrintWebViewHelper +@@ -181,10 +179,8 @@ class PrintWebViewHelper void OnPrintForSystemDialog(); void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); - #endif // defined(ENABLE_BASIC_PRINTING) --#if defined(ENABLE_PRINT_PREVIEW) - void OnInitiatePrintPreview(bool selection_only); + #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + void OnInitiatePrintPreview(bool has_selection); void OnPrintPreview(const base::DictionaryValue& settings); --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) void OnPrintingDone(bool success); // Get |page_size| and |content_area| information from -@@ -191,7 +187,6 @@ class PrintWebViewHelper +@@ -197,7 +193,6 @@ class PrintWebViewHelper // Update |ignore_css_margins_| based on settings. void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings); --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Prepare frame for creating preview document. void PrepareFrameForPreviewDocument(); -@@ -208,7 +203,6 @@ class PrintWebViewHelper +@@ -214,7 +209,6 @@ class PrintWebViewHelper // Finalize the print ready preview document. bool FinalizePrintReadyDocument(); --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) - // Enable/Disable window.print calls. If |blocked| is true window.print - // calls will silently fail. Call with |blocked| set to false to reenable. -@@ -237,7 +231,6 @@ class PrintWebViewHelper + // Enable/Disable printing. + void OnSetPrintingEnabled(bool enabled); +@@ -242,7 +236,6 @@ class PrintWebViewHelper const blink::WebNode& node, int* number_of_pages); --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Set options for print preset from source PDF document. bool SetOptionsFromPdfDocument( PrintHostMsg_SetOptionsFromDocument_Params* options); -@@ -248,7 +241,6 @@ class PrintWebViewHelper +@@ -253,7 +246,6 @@ class PrintWebViewHelper bool UpdatePrintSettings(blink::WebLocalFrame* frame, const blink::WebNode& node, const base::DictionaryValue& passed_job_settings); --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) // Get final print settings from the user. // Return false if the user cancels or on error. -@@ -323,7 +315,6 @@ class PrintWebViewHelper +@@ -328,7 +320,6 @@ class PrintWebViewHelper const PrintMsg_PrintPages_Params& params, int page_count); --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(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, -@@ -333,7 +324,6 @@ class PrintWebViewHelper +@@ -338,7 +329,6 @@ class PrintWebViewHelper float webkit_scale_factor, const PageSizeMargins& page_layout_in_points, const PrintMsg_Print_Params& params); --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) - bool GetPrintFrame(blink::WebLocalFrame** frame); + // Script Initiated Printing ------------------------------------------------ -@@ -345,7 +335,6 @@ class PrintWebViewHelper +@@ -348,7 +338,6 @@ class PrintWebViewHelper bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, bool user_initiated); --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Shows scripted print preview when options from plugin are available. void ShowScriptedPrintPreview(); -@@ -361,7 +350,6 @@ class PrintWebViewHelper +@@ -364,7 +353,6 @@ class PrintWebViewHelper // |metafile| is the rendered page. Otherwise |metafile| is NULL. // Returns true if print preview should continue, false on failure. bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile); --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings); -@@ -514,6 +502,7 @@ class PrintWebViewHelper +@@ -516,6 +504,7 @@ class PrintWebViewHelper ScriptingThrottler scripting_throttler_; bool print_node_in_progress_; @@ -522,37 +534,37 @@ index dd8d24d..7c73d38 100644 bool is_loading_; bool is_scripted_preview_delayed_; diff --git components/printing/renderer/print_web_view_helper_mac.mm components/printing/renderer/print_web_view_helper_mac.mm -index 0b13474..4bf7c6b 100644 +index ff49472..b107439 100644 --- components/printing/renderer/print_web_view_helper_mac.mm +++ components/printing/renderer/print_web_view_helper_mac.mm -@@ -68,7 +68,6 @@ void PrintWebViewHelper::PrintPageInternal( +@@ -69,7 +69,6 @@ Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params)); } --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) bool PrintWebViewHelper::RenderPreviewPage( int page_number, const PrintMsg_Print_Params& print_params) { -@@ -105,7 +104,6 @@ bool PrintWebViewHelper::RenderPreviewPage( +@@ -106,7 +105,6 @@ } return PreviewPageRendered(page_number, draft_metafile.get()); } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params, int page_number, -@@ -140,14 +138,12 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params, +@@ -142,14 +140,12 @@ MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); skia::SetIsPreviewMetafile(*canvas, is_preview); --#if defined(ENABLE_PRINT_PREVIEW) +-#if BUILDFLAG(ENABLE_PRINT_PREVIEW) if (params.display_header_footer) { PrintHeaderAndFooter(static_cast(canvas), page_number + 1, print_preview_context_.total_page_count(), *frame, scale_factor, page_layout_in_points, params); } --#endif // defined(ENABLE_PRINT_PREVIEW) +-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) RenderPageContent(frame, page_number, canvas_area, content_area, scale_factor, static_cast(canvas)); } diff --git a/patch/patches/render_frame_message_filter_626728.patch b/patch/patches/render_frame_message_filter_626728.patch index f3697a20c..661b1fe19 100644 --- a/patch/patches/render_frame_message_filter_626728.patch +++ b/patch/patches/render_frame_message_filter_626728.patch @@ -1,8 +1,8 @@ diff --git content/browser/frame_host/render_frame_message_filter.cc content/browser/frame_host/render_frame_message_filter.cc -index fbe7feb..d05b2cf 100644 +index 573b5d9..e61cfa0 100644 --- content/browser/frame_host/render_frame_message_filter.cc +++ content/browser/frame_host/render_frame_message_filter.cc -@@ -490,7 +490,7 @@ void RenderFrameMessageFilter::GetPluginsCallback( +@@ -491,7 +491,7 @@ void RenderFrameMessageFilter::GetPluginsCallback( PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter(); std::vector plugins; diff --git a/patch/patches/render_view_host_impl_1392.patch b/patch/patches/render_view_host_impl_1392.patch index 5de1155cb..a3ad01f16 100644 --- a/patch/patches/render_view_host_impl_1392.patch +++ b/patch/patches/render_view_host_impl_1392.patch @@ -1,8 +1,8 @@ diff --git render_view_host_impl.h render_view_host_impl.h -index f8cce52..cb56120 100644 +index e8890aa..910a25b 100644 --- render_view_host_impl.h +++ render_view_host_impl.h -@@ -203,6 +203,7 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, +@@ -167,6 +167,7 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, void set_is_swapped_out(bool is_swapped_out) { is_swapped_out_ = is_swapped_out; } diff --git a/patch/patches/render_widget_host_1070383005.patch b/patch/patches/render_widget_host_1070383005.patch index 3f55d69e6..df46f245d 100644 --- a/patch/patches/render_widget_host_1070383005.patch +++ b/patch/patches/render_widget_host_1070383005.patch @@ -1,8 +1,8 @@ diff --git render_widget_host_view_mac.mm render_widget_host_view_mac.mm -index be346a8..16683e7 100644 +index 689ae2c..52e405d 100644 --- render_widget_host_view_mac.mm +++ render_widget_host_view_mac.mm -@@ -461,9 +461,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, +@@ -462,9 +462,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, // Paint this view host with |background_color_| when there is no content // ready to draw. background_layer_.reset([[CALayer alloc] init]); diff --git a/patch/patches/render_widget_latency_2060.patch b/patch/patches/render_widget_latency_2060.patch new file mode 100644 index 000000000..ad9229c80 --- /dev/null +++ b/patch/patches/render_widget_latency_2060.patch @@ -0,0 +1,12 @@ +diff --git content/browser/renderer_host/input/render_widget_host_latency_tracker.cc content/browser/renderer_host/input/render_widget_host_latency_tracker.cc +index a8d3ac2..908d0e5d 100644 +--- content/browser/renderer_host/input/render_widget_host_latency_tracker.cc ++++ content/browser/renderer_host/input/render_widget_host_latency_tracker.cc +@@ -96,7 +96,6 @@ void UpdateLatencyCoordinates(const WebInputEvent& event, + #define CONFIRM_VALID_TIMING(start, end) \ + DCHECK(!start.first_event_time.is_null()); \ + DCHECK(!end.last_event_time.is_null()); \ +- DCHECK_GE(end.last_event_time, start.first_event_time); + + // Touch/wheel to scroll latency that is mostly under 1 second. + #define UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(name, start, end) \ diff --git a/patch/patches/renderer_preferences_util_545103.patch b/patch/patches/renderer_preferences_util_545103.patch index 92a14858a..630d78f68 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 aa4f1c2..cdf2fd9 100644 +index c20a01d..ceeb3eb 100644 --- renderer_preferences_util.cc +++ renderer_preferences_util.cc -@@ -30,7 +30,8 @@ +@@ -31,7 +31,8 @@ #include "ui/base/cocoa/defaults_utils.h" #endif @@ -12,7 +12,7 @@ index aa4f1c2..cdf2fd9 100644 #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "ui/views/linux_ui/linux_ui.h" -@@ -132,7 +133,8 @@ void UpdateFromSystemSettings(content::RendererPreferences* prefs, +@@ -133,7 +134,8 @@ void UpdateFromSystemSettings(content::RendererPreferences* prefs, prefs->caret_blink_interval = interval.InSecondsF(); #endif diff --git a/patch/patches/storage_partition_1973.patch b/patch/patches/storage_partition_1973.patch index e9da9050a..e662b5dca 100644 --- a/patch/patches/storage_partition_1973.patch +++ b/patch/patches/storage_partition_1973.patch @@ -54,10 +54,10 @@ index bd02cb1..074e77f 100644 BrowserContext* browser_context); diff --git content/browser/browser_context.cc content/browser/browser_context.cc -index 5b7ba41..82d8fb1 100644 +index 063b0ef..b05fd26 100644 --- content/browser/browser_context.cc +++ content/browser/browser_context.cc -@@ -115,7 +115,14 @@ StoragePartition* GetStoragePartitionFromConfig( +@@ -117,7 +117,14 @@ StoragePartition* GetStoragePartitionFromConfig( if (browser_context->IsOffTheRecord()) in_memory = true; @@ -73,7 +73,7 @@ index 5b7ba41..82d8fb1 100644 } void SaveSessionStateOnIOThread( -@@ -506,6 +513,11 @@ ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( +@@ -516,6 +523,11 @@ ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( : nullptr; } @@ -103,10 +103,10 @@ index c34d15a1..429c0e8 100644 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, diff --git content/browser/renderer_host/render_process_host_impl.cc content/browser/renderer_host/render_process_host_impl.cc -index f952adc..e9998f3 100644 +index 43b5cf5..c387825 100644 --- content/browser/renderer_host/render_process_host_impl.cc +++ content/browser/renderer_host/render_process_host_impl.cc -@@ -675,7 +675,7 @@ void RenderProcessHostImpl::EarlyZygoteLaunch() { +@@ -649,7 +649,7 @@ void RenderProcessHostImpl::EarlyZygoteLaunch() { RenderProcessHostImpl::RenderProcessHostImpl( BrowserContext* browser_context, @@ -115,7 +115,7 @@ index f952adc..e9998f3 100644 bool is_for_guests_only) : fast_shutdown_started_(false), deleting_soon_(false), -@@ -1024,6 +1024,22 @@ std::unique_ptr RenderProcessHostImpl::CreateChannelProxy() { +@@ -1001,6 +1001,22 @@ void RenderProcessHostImpl::ResetChannelProxy() { void RenderProcessHostImpl::CreateMessageFilters() { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -138,7 +138,7 @@ index f952adc..e9998f3 100644 AddFilter(new ResourceSchedulerFilter(GetID())); MediaInternals* media_internals = MediaInternals::GetInstance(); // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages -@@ -1038,8 +1054,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { +@@ -1015,8 +1031,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { new RenderMessageFilter( GetID(), GetBrowserContext(), request_context.get(), widget_helper_.get(), media_internals, @@ -149,7 +149,7 @@ index f952adc..e9998f3 100644 AddFilter(render_message_filter.get()); render_frame_message_filter_ = new RenderFrameMessageFilter( -@@ -1070,9 +1086,9 @@ void RenderProcessHostImpl::CreateMessageFilters() { +@@ -1047,9 +1063,9 @@ void RenderProcessHostImpl::CreateMessageFilters() { resource_message_filter_ = new ResourceMessageFilter( GetID(), PROCESS_TYPE_RENDERER, @@ -158,13 +158,13 @@ index f952adc..e9998f3 100644 storage_partition_impl_->GetFileSystemContext(), - storage_partition_impl_->GetServiceWorkerContext(), + service_worker_context, - storage_partition_impl_->GetHostZoomLevelContext(), get_contexts_callback); -@@ -1097,14 +1113,12 @@ void RenderProcessHostImpl::CreateMessageFilters() { + AddFilter(resource_message_filter_.get()); +@@ -1072,14 +1088,12 @@ void RenderProcessHostImpl::CreateMessageFilters() { + AddFilter(audio_renderer_host_.get()); AddFilter( new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); - AddFilter(new VideoCaptureHost(media_stream_manager)); - AddFilter(new AppCacheDispatcherHost( - storage_partition_impl_->GetAppCacheService(), GetID())); + AddFilter(new AppCacheDispatcherHost(app_cache_service, GetID())); @@ -179,7 +179,7 @@ index f952adc..e9998f3 100644 blob_storage_context.get())); #if defined(ENABLE_WEBRTC) -@@ -1150,14 +1164,13 @@ void RenderProcessHostImpl::CreateMessageFilters() { +@@ -1125,14 +1139,13 @@ void RenderProcessHostImpl::CreateMessageFilters() { scoped_refptr cache_storage_filter = new CacheStorageDispatcherHost(); @@ -196,7 +196,7 @@ index f952adc..e9998f3 100644 AddFilter(service_worker_filter.get()); AddFilter(new SharedWorkerMessageFilter( -@@ -1165,12 +1178,12 @@ void RenderProcessHostImpl::CreateMessageFilters() { +@@ -1140,12 +1153,12 @@ void RenderProcessHostImpl::CreateMessageFilters() { WorkerStoragePartition( storage_partition_impl_->GetURLRequestContext(), storage_partition_impl_->GetMediaURLRequestContext(), @@ -212,7 +212,7 @@ index f952adc..e9998f3 100644 message_port_message_filter_.get())); #if defined(ENABLE_WEBRTC) -@@ -1185,11 +1198,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { +@@ -1160,11 +1173,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { GetID(), storage_partition_impl_->GetQuotaManager(), GetContentClient()->browser()->CreateQuotaPermissionContext())); @@ -225,7 +225,7 @@ index f952adc..e9998f3 100644 resource_context, service_worker_context, browser_context); AddFilter(notification_message_filter_.get()); -@@ -1198,7 +1208,7 @@ void RenderProcessHostImpl::CreateMessageFilters() { +@@ -1173,7 +1183,7 @@ void RenderProcessHostImpl::CreateMessageFilters() { AddFilter(new HistogramMessageFilter()); AddFilter(new MemoryMessageFilter(this)); AddFilter(new PushMessagingMessageFilter( @@ -233,10 +233,10 @@ index f952adc..e9998f3 100644 + GetID(), service_worker_context)); #if defined(OS_ANDROID) AddFilter(new ScreenOrientationMessageFilterAndroid()); - #endif -@@ -1208,6 +1218,11 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { - std::unique_ptr registry( - new shell::InterfaceRegistry); + synchronous_compositor_filter_ = +@@ -1186,6 +1196,11 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { + auto registry = base::MakeUnique( + service_manager::mojom::kServiceManager_ConnectorSpec); + // Cast to the derived type from StoragePartitionImpl. + auto platform_notification_context = @@ -246,7 +246,7 @@ index f952adc..e9998f3 100644 channel_->AddAssociatedInterface( base::Bind(&RenderProcessHostImpl::OnRouteProviderRequest, base::Unretained(this))); -@@ -1239,8 +1254,7 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { +@@ -1224,8 +1239,7 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { AddUIThreadInterface( registry.get(), base::Bind(&PlatformNotificationContextImpl::CreateService, @@ -256,7 +256,7 @@ index f952adc..e9998f3 100644 GetID())); AddUIThreadInterface( registry.get(), -@@ -1395,6 +1409,7 @@ void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() { +@@ -1399,6 +1413,7 @@ void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!is_worker_ref_count_disabled_); is_worker_ref_count_disabled_ = true; @@ -265,18 +265,18 @@ index f952adc..e9998f3 100644 return; service_worker_ref_count_ = 0; diff --git content/browser/renderer_host/render_process_host_impl.h content/browser/renderer_host/render_process_host_impl.h -index f07c487e..aae8a3e 100644 +index 93c9fd0..968b230 100644 --- content/browser/renderer_host/render_process_host_impl.h +++ content/browser/renderer_host/render_process_host_impl.h -@@ -73,7 +73,6 @@ class RenderWidgetHostImpl; - class RenderWidgetHostViewFrameSubscriber; +@@ -66,7 +66,6 @@ class RenderWidgetHelper; + class RenderWidgetHost; class ResourceMessageFilter; class StoragePartition; -class StoragePartitionImpl; namespace mojom { class StoragePartitionService; -@@ -109,7 +108,7 @@ class CONTENT_EXPORT RenderProcessHostImpl +@@ -102,7 +101,7 @@ class CONTENT_EXPORT RenderProcessHostImpl public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider) { public: RenderProcessHostImpl(BrowserContext* browser_context, @@ -285,7 +285,7 @@ index f07c487e..aae8a3e 100644 bool is_for_guests_only); ~RenderProcessHostImpl() override; -@@ -484,7 +483,7 @@ class CONTENT_EXPORT RenderProcessHostImpl +@@ -493,7 +492,7 @@ class CONTENT_EXPORT RenderProcessHostImpl BrowserContext* browser_context_; // Owned by |browser_context_|. @@ -295,7 +295,7 @@ index f07c487e..aae8a3e 100644 // The observers watching our lifetime. base::ObserverList observers_; diff --git content/browser/site_instance_impl.cc content/browser/site_instance_impl.cc -index a55d786..9e0de6a 100644 +index 7980783..e6d5a49 100644 --- content/browser/site_instance_impl.cc +++ content/browser/site_instance_impl.cc @@ -116,9 +116,8 @@ RenderProcessHost* SiteInstanceImpl::GetProcess() { @@ -311,11 +311,11 @@ index a55d786..9e0de6a 100644 partition, site_.SchemeIs(kGuestScheme)); diff --git content/browser/storage_partition_impl.h content/browser/storage_partition_impl.h -index 584f2db..551e350 100644 +index 34dcfa6..5459ec4 100644 --- content/browser/storage_partition_impl.h +++ content/browser/storage_partition_impl.h -@@ -24,9 +24,7 @@ - #include "content/browser/notifications/platform_notification_context_impl.h" +@@ -25,9 +25,7 @@ + #include "content/browser/payments/payment_app_context.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/common/content_export.h" -#include "content/common/storage_partition_service.mojom.h" @@ -324,19 +324,21 @@ index 584f2db..551e350 100644 #include "net/cookies/cookie_store.h" #include "storage/browser/quota/special_storage_policy.h" -@@ -72,9 +70,8 @@ class CONTENT_EXPORT StoragePartitionImpl +@@ -73,10 +71,9 @@ class CONTENT_EXPORT StoragePartitionImpl HostZoomLevelContext* GetHostZoomLevelContext() override; ZoomLevelDelegate* GetZoomLevelDelegate() override; PlatformNotificationContextImpl* GetPlatformNotificationContext() override; - - BackgroundSyncContext* GetBackgroundSyncContext(); +- PaymentAppContext* GetPaymentAppContext(); - BroadcastChannelProvider* GetBroadcastChannelProvider(); + BackgroundSyncContext* GetBackgroundSyncContext() override; ++ PaymentAppContext* GetPaymentAppContext() override; + BroadcastChannelProvider* GetBroadcastChannelProvider() override; // mojom::StoragePartitionService interface. void OpenLocalStorage( -@@ -109,7 +106,8 @@ class CONTENT_EXPORT StoragePartitionImpl +@@ -111,7 +108,8 @@ class CONTENT_EXPORT StoragePartitionImpl BrowserContext* browser_context() const; // Called by each renderer process once. @@ -375,7 +377,7 @@ index 075ae3e..57fb5fd 100644 void InitializeOnIOThread(); diff --git content/public/browser/browser_context.h content/public/browser/browser_context.h -index aaa5e23..2309a2a 100644 +index d69bd71..e5da59f 100644 --- content/public/browser/browser_context.h +++ content/public/browser/browser_context.h @@ -170,6 +170,8 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { @@ -403,7 +405,7 @@ index aaa5e23..2309a2a 100644 } // namespace content diff --git content/public/browser/storage_partition.h content/public/browser/storage_partition.h -index 909b370..8c6f09d 100644 +index 909b370..29587b9 100644 --- content/public/browser/storage_partition.h +++ content/public/browser/storage_partition.h @@ -13,6 +13,8 @@ @@ -415,7 +417,7 @@ index 909b370..8c6f09d 100644 #include "net/cookies/cookie_store.h" class GURL; -@@ -41,6 +43,8 @@ class DatabaseTracker; +@@ -41,12 +43,15 @@ class DatabaseTracker; namespace content { class AppCacheService; @@ -424,16 +426,24 @@ index 909b370..8c6f09d 100644 class BrowserContext; class CacheStorageContext; class DOMStorageContext; -@@ -74,6 +78,8 @@ class CONTENT_EXPORT StoragePartition { + class HostZoomLevelContext; + class HostZoomMap; + class IndexedDBContext; ++class PaymentAppContext; + class PlatformNotificationContext; + class ServiceWorkerContext; + class ZoomLevelDelegate; +@@ -74,6 +79,9 @@ class CONTENT_EXPORT StoragePartition { virtual HostZoomLevelContext* GetHostZoomLevelContext() = 0; virtual ZoomLevelDelegate* GetZoomLevelDelegate() = 0; virtual PlatformNotificationContext* GetPlatformNotificationContext() = 0; + virtual BackgroundSyncContext* GetBackgroundSyncContext() = 0; ++ virtual PaymentAppContext* GetPaymentAppContext() = 0; + virtual BroadcastChannelProvider* GetBroadcastChannelProvider() = 0; enum : uint32_t { REMOVE_DATA_MASK_APPCACHE = 1 << 0, -@@ -166,6 +172,10 @@ class CONTENT_EXPORT StoragePartition { +@@ -166,6 +174,10 @@ class CONTENT_EXPORT StoragePartition { // unwritten data has been written out to the filesystem. virtual void Flush() = 0; @@ -460,14 +470,14 @@ index 9b26c41..e9f4a0c 100644 "web_ui_url_fetcher.cc", "web_ui_url_fetcher.h", diff --git extensions/common/api/BUILD.gn extensions/common/api/BUILD.gn -index 010da6d..a13ba7a 100644 +index a04e789..bf15551 100644 --- extensions/common/api/BUILD.gn +++ extensions/common/api/BUILD.gn -@@ -99,6 +99,7 @@ group("api") { +@@ -35,6 +35,7 @@ group("api") { public_deps = [ ":generated_api", ":mojom", + "//content/public/common", + "//extensions/features", ] } - diff --git a/patch/patches/views_1749.patch b/patch/patches/views_1749.patch index 62cba8a82..a5bb943f4 100644 --- a/patch/patches/views_1749.patch +++ b/patch/patches/views_1749.patch @@ -1,5 +1,5 @@ diff --git controls/button/menu_button.cc controls/button/menu_button.cc -index 38fc310..fdd8a13 100644 +index e98dda7..14825f6 100644 --- controls/button/menu_button.cc +++ controls/button/menu_button.cc @@ -195,7 +195,7 @@ void MenuButton::OnPaint(gfx::Canvas* canvas) { @@ -11,7 +11,7 @@ index 38fc310..fdd8a13 100644 kMenuMarkerPaddingRight, 0); } -@@ -322,7 +322,7 @@ gfx::Rect MenuButton::GetChildAreaBounds() { +@@ -323,7 +323,7 @@ gfx::Rect MenuButton::GetChildAreaBounds() { gfx::Size s = size(); if (show_menu_marker_) { @@ -20,7 +20,7 @@ index 38fc310..fdd8a13 100644 kMenuMarkerPaddingRight); } -@@ -411,4 +411,10 @@ int MenuButton::GetMaximumScreenXCoordinate() { +@@ -412,4 +412,10 @@ int MenuButton::GetMaximumScreenXCoordinate() { return monitor_bounds.right() - 1; } @@ -32,7 +32,7 @@ index 38fc310..fdd8a13 100644 + } // namespace views diff --git controls/button/menu_button.h controls/button/menu_button.h -index 696a941..ce5abcd 100644 +index c232cc1..cc207f9 100644 --- controls/button/menu_button.h +++ controls/button/menu_button.h @@ -54,6 +54,9 @@ class VIEWS_EXPORT MenuButton : public LabelButton { @@ -56,7 +56,7 @@ index 696a941..ce5abcd 100644 // The time is used for simulating menu behavior for the menu button; that // is, if the menu is shown and the button is pressed, we need to close the diff --git view.h view.h -index 28171db..747930c 100644 +index bb5ebdf..959645a 100644 --- view.h +++ view.h @@ -18,6 +18,7 @@ @@ -67,7 +67,7 @@ index 28171db..747930c 100644 #include "build/build_config.h" #include "ui/accessibility/ax_enums.h" #include "ui/base/accelerators/accelerator.h" -@@ -113,7 +114,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, +@@ -112,7 +113,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, public ui::LayerOwner, public ui::AcceleratorTarget, public ui::EventTarget, diff --git a/patch/patches/views_widget_180_1481_1677_1749.patch b/patch/patches/views_widget_180_1481_1677_1749.patch index 98e6f7113..0ddb4a2c9 100644 --- a/patch/patches/views_widget_180_1481_1677_1749.patch +++ b/patch/patches/views_widget_180_1481_1677_1749.patch @@ -1,57 +1,44 @@ -diff --git content/browser/renderer_host/render_widget_host_view_aura.cc content/browser/renderer_host/render_widget_host_view_aura.cc -index 852e71f..b765a5b 100644 ---- content/browser/renderer_host/render_widget_host_view_aura.cc -+++ content/browser/renderer_host/render_widget_host_view_aura.cc -@@ -769,6 +769,13 @@ void RenderWidgetHostViewAura::SetKeyboardFocus() { - } - } - #endif -+#if defined(OS_LINUX) -+ if (has_external_parent_ && CanFocus()) { -+ aura::WindowTreeHost* host = window_->GetHost(); -+ if (host) -+ host->Show(); -+ } -+#endif - // TODO(wjmaclean): can host_ ever be null? - if (host_ && set_focus_on_mouse_down_or_key_event_) { - set_focus_on_mouse_down_or_key_event_ = false; diff --git content/browser/renderer_host/render_widget_host_view_base.cc content/browser/renderer_host/render_widget_host_view_base.cc -index 292087d..8d6da47 100644 +index 6408c68..735a253 100644 --- content/browser/renderer_host/render_widget_host_view_base.cc +++ content/browser/renderer_host/render_widget_host_view_base.cc @@ -44,6 +44,7 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() + current_device_scale_factor_(0), current_display_rotation_(display::Display::ROTATE_0), - pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), text_input_manager_(nullptr), + has_external_parent_(false), renderer_frame_number_(0), weak_factory_(this) { } -@@ -324,6 +325,10 @@ void RenderWidgetHostViewBase::FocusedNodeTouched( +@@ -327,6 +328,14 @@ void RenderWidgetHostViewBase::FocusedNodeTouched( DVLOG(1) << "FocusedNodeTouched: " << editable; } +void RenderWidgetHostViewBase::SetHasExternalParent(bool val) { + has_external_parent_ = val; +} ++ ++bool RenderWidgetHostViewBase::HasExternalParent() const { ++ return has_external_parent_; ++} + 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 5e25a02..b81350b 100644 +index 88e7a04..0e6a740 100644 --- content/browser/renderer_host/render_widget_host_view_base.h +++ content/browser/renderer_host/render_widget_host_view_base.h -@@ -107,6 +107,7 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, +@@ -107,6 +107,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, void EndFrameSubscription() override; void FocusedNodeTouched(const gfx::Point& location_dips_screen, bool editable) override; + void SetHasExternalParent(bool val) override; ++ bool HasExternalParent() const override; // This only needs to be overridden by RenderWidgetHostViewBase subclasses // that handle content embedded within other RenderWidgetHostViews. -@@ -477,6 +478,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, +@@ -488,6 +490,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, // destroyed before the RWHV is destroyed. TextInputManager* text_input_manager_; @@ -62,17 +49,51 @@ index 5e25a02..b81350b 100644 private: void FlushInput(); +diff --git content/browser/renderer_host/render_widget_host_view_event_handler.cc content/browser/renderer_host/render_widget_host_view_event_handler.cc +index 2adb005..222ca88 100644 +--- content/browser/renderer_host/render_widget_host_view_event_handler.cc ++++ content/browser/renderer_host/render_widget_host_view_event_handler.cc +@@ -28,6 +28,10 @@ + #include "ui/events/blink/web_input_event.h" + #include "ui/touch_selection/touch_selection_controller.h" + ++#if defined(OS_LINUX) ++#include "ui/aura/window_tree_host.h" ++#endif ++ + #if defined(OS_WIN) + #include "content/browser/frame_host/render_frame_host_impl.h" + #include "content/public/common/context_menu_params.h" +@@ -812,6 +816,14 @@ void RenderWidgetHostViewEventHandler::SetKeyboardFocus() { + } + } + #endif ++#if defined(OS_LINUX) ++ if (host_view_->HasExternalParent() && ++ window_ && window_->delegate()->CanFocus()) { ++ aura::WindowTreeHost* host = window_->GetHost(); ++ if (host) ++ host->Show(); ++ } ++#endif + // TODO(wjmaclean): can host_ ever be null? + if (host_ && set_focus_on_mouse_down_or_key_event_) { + set_focus_on_mouse_down_or_key_event_ = false; diff --git content/public/browser/render_widget_host_view.h content/public/browser/render_widget_host_view.h -index ff3127b..e666db1 100644 +index f721d17..5b6dfa9 100644 --- content/public/browser/render_widget_host_view.h +++ content/public/browser/render_widget_host_view.h -@@ -172,6 +172,10 @@ class CONTENT_EXPORT RenderWidgetHostView { +@@ -171,6 +171,14 @@ class CONTENT_EXPORT RenderWidgetHostView { // when the value has changed. Views must initially default to false. virtual void SetNeedsBeginFrames(bool needs_begin_frames) = 0; + // Set whether the widget has a external parent view/window outside of the + // Chromium-controlled view/window hierarchy. + virtual void SetHasExternalParent(bool val) = 0; ++ ++ // Returns true if the widget has a external parent view/window outside of the ++ // Chromium-controlled view/window hierarchy. ++ virtual bool HasExternalParent() const = 0; + #if defined(OS_MACOSX) // Return the accelerated widget which hosts the CALayers that draw the @@ -91,7 +112,7 @@ index f772f64..7d13f9f 100644 return host ? host->GetAcceleratedWidget() : NULL; } diff --git ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc -index 964fe4a..b878661 100644 +index 0dea5ca..415836b 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -86,6 +86,7 @@ DesktopWindowTreeHostWin::DesktopWindowTreeHostWin( @@ -116,7 +137,7 @@ index 964fe4a..b878661 100644 remove_standard_frame_ = params.remove_standard_frame; has_non_client_view_ = Widget::RequiresNonClientView(params.type); -@@ -645,6 +650,10 @@ bool DesktopWindowTreeHostWin::CanActivate() const { +@@ -638,6 +643,10 @@ bool DesktopWindowTreeHostWin::CanActivate() const { return native_widget_delegate_->CanActivate(); } @@ -127,7 +148,7 @@ index 964fe4a..b878661 100644 bool DesktopWindowTreeHostWin::WantsMouseEventsWhenInactive() const { return wants_mouse_events_when_inactive_; } -@@ -825,11 +834,15 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() { +@@ -818,11 +827,15 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() { } void DesktopWindowTreeHostWin::HandleNativeFocus(HWND last_focused_window) { @@ -146,10 +167,10 @@ index 964fe4a..b878661 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 884df90..518a69c 100644 +index c1ee992..4e5fae7 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +++ ui/views/widget/desktop_aura/desktop_window_tree_host_win.h -@@ -138,6 +138,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin +@@ -135,6 +135,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin bool CanMaximize() const override; bool CanMinimize() const override; bool CanActivate() const override; @@ -157,7 +178,7 @@ index 884df90..518a69c 100644 bool WantsMouseEventsWhenInactive() const override; bool WidgetSizeIsClientSize() const override; bool IsModal() const override; -@@ -252,6 +253,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin +@@ -249,6 +250,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin // True if the window should have the frame removed. bool remove_standard_frame_; @@ -169,7 +190,7 @@ index 884df90..518a69c 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 816faa3..4c2d702 100644 +index 8550a32..9cdd035 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -195,6 +195,7 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( @@ -207,7 +228,7 @@ index 816faa3..4c2d702 100644 return ToDIPRect(bounds_in_pixels_); } -@@ -1208,6 +1213,8 @@ void DesktopWindowTreeHostX11::HideImpl() { +@@ -1202,6 +1207,8 @@ void DesktopWindowTreeHostX11::HideImpl() { } gfx::Rect DesktopWindowTreeHostX11::GetBounds() const { @@ -216,7 +237,7 @@ index 816faa3..4c2d702 100644 return bounds_in_pixels_; } -@@ -1267,6 +1274,8 @@ void DesktopWindowTreeHostX11::SetBounds( +@@ -1261,6 +1268,8 @@ void DesktopWindowTreeHostX11::SetBounds( } gfx::Point DesktopWindowTreeHostX11::GetLocationOnNativeScreen() const { @@ -225,7 +246,7 @@ index 816faa3..4c2d702 100644 return bounds_in_pixels_.origin(); } -@@ -1390,9 +1399,15 @@ void DesktopWindowTreeHostX11::InitX11Window( +@@ -1386,9 +1395,15 @@ void DesktopWindowTreeHostX11::InitX11Window( attribute_mask |= CWBorderPixel; swa.border_pixel = 0; @@ -242,7 +263,7 @@ index 816faa3..4c2d702 100644 bounds_in_pixels_.y(), bounds_in_pixels_.width(), bounds_in_pixels_.height(), 0, // border width -@@ -2022,6 +2037,10 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent( +@@ -2019,6 +2034,10 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent( } break; } @@ -254,10 +275,10 @@ index 816faa3..4c2d702 100644 case FocusOut: OnFocusEvent(xev->type == FocusIn, event->xfocus.mode, 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 a4b68b3..bb82659 100644 +index cc2339f..949ea23 100644 --- ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h +++ ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h -@@ -91,6 +91,12 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -90,6 +90,12 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 // there is no dialog on the host window. XID GetModalDialog(); @@ -270,7 +291,7 @@ index a4b68b3..bb82659 100644 protected: // Overridden from DesktopWindowTreeHost: void Init(aura::Window* content_window, -@@ -301,6 +307,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -298,6 +304,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 // The bounds of |xwindow_|. gfx::Rect bounds_in_pixels_; @@ -280,7 +301,7 @@ index a4b68b3..bb82659 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 -@@ -340,6 +349,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -337,6 +346,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 // Whether we used an ARGB visual for our window. bool use_argb_visual_; @@ -291,7 +312,7 @@ index a4b68b3..bb82659 100644 DesktopDragDropClientAuraX11* drag_drop_client_; std::unique_ptr x11_non_client_event_filter_; -@@ -427,6 +440,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 +@@ -424,6 +437,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 XID modal_dialog_xid_; @@ -302,7 +323,7 @@ index a4b68b3..bb82659 100644 base::WeakPtrFactory weak_factory_; diff --git ui/views/widget/widget.cc ui/views/widget/widget.cc -index 68e6acd..07eb1fc 100644 +index 4c21064..2ff6833 100644 --- ui/views/widget/widget.cc +++ ui/views/widget/widget.cc @@ -126,9 +126,11 @@ Widget::InitParams::InitParams(Type type) @@ -350,10 +371,10 @@ index 68e6acd..07eb1fc 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 1e62c09..551518e 100644 +index 0c7ab33..a958c3a 100644 --- ui/views/widget/widget.h +++ ui/views/widget/widget.h -@@ -234,12 +234,17 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, +@@ -233,12 +233,17 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // rendered, and that the client area should be equivalent to the window // area. Only used on some platforms (Windows and Linux). bool remove_standard_frame; @@ -371,7 +392,7 @@ index 1e62c09..551518e 100644 // Used only by mus and is necessitated by mus not being a NativeView. ui::Window* parent_mus = nullptr; // Specifies the initial bounds of the Widget. Default is empty, which means -@@ -753,6 +758,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, +@@ -752,6 +757,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, bool movement_disabled() const { return movement_disabled_; } void set_movement_disabled(bool disabled) { movement_disabled_ = disabled; } @@ -382,7 +403,7 @@ index 1e62c09..551518e 100644 // Returns the work area bounds of the screen the Widget belongs to. gfx::Rect GetWorkAreaBoundsInScreen() const; -@@ -971,6 +980,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, +@@ -970,6 +979,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // disabled. bool movement_disabled_; @@ -410,7 +431,7 @@ index b843416..8b81a51 100644 } case Widget::InitParams::TYPE_CONTROL: diff --git ui/views/win/hwnd_message_handler.cc ui/views/win/hwnd_message_handler.cc -index 020d0a1..4a613f7 100644 +index 6f80d3e..158a43a 100644 --- ui/views/win/hwnd_message_handler.cc +++ ui/views/win/hwnd_message_handler.cc @@ -850,6 +850,8 @@ void HWNDMessageHandler::SizeConstraintsChanged() { @@ -422,7 +443,7 @@ index 020d0a1..4a613f7 100644 SetWindowLong(hwnd(), GWL_STYLE, style); } -@@ -2472,8 +2474,12 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, +@@ -2508,8 +2510,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. @@ -438,10 +459,10 @@ index 020d0a1..4a613f7 100644 // There are cases where the code handling the message destroys the window, diff --git ui/views/win/hwnd_message_handler_delegate.h ui/views/win/hwnd_message_handler_delegate.h -index 14021805..c4843c8 100644 +index f5328c4..0ee7915 100644 --- ui/views/win/hwnd_message_handler_delegate.h +++ ui/views/win/hwnd_message_handler_delegate.h -@@ -59,6 +59,10 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { +@@ -56,6 +56,10 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { virtual bool CanMinimize() const = 0; virtual bool CanActivate() const = 0; diff --git a/patch/patches/web_contents_1257.patch b/patch/patches/web_contents_1257.patch index 8db634868..c40673a28 100644 --- a/patch/patches/web_contents_1257.patch +++ b/patch/patches/web_contents_1257.patch @@ -29,10 +29,10 @@ index e639319..5f75a9a 100644 void EnterFullscreenModeForTab(content::WebContents* contents, const GURL& origin) final; diff --git chrome/browser/prerender/prerender_contents.cc chrome/browser/prerender/prerender_contents.cc -index 4ded1cb..ce3306b 100644 +index c3e60e0..93365f5c 100644 --- chrome/browser/prerender/prerender_contents.cc +++ chrome/browser/prerender/prerender_contents.cc -@@ -141,7 +141,9 @@ class PrerenderContents::WebContentsDelegateImpl +@@ -139,7 +139,9 @@ class PrerenderContents::WebContentsDelegateImpl const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -44,10 +44,10 @@ index 4ded1cb..ce3306b 100644 // window.opener property, terminate prerendering. prerender_contents_->Destroy(FINAL_STATUS_CREATE_NEW_WINDOW); diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc -index 869fbec..7ca4f52 100644 +index bbb37ff..484eda3 100644 --- chrome/browser/ui/browser.cc +++ chrome/browser/ui/browser.cc -@@ -1588,7 +1588,9 @@ bool Browser::ShouldCreateWebContents( +@@ -1589,7 +1589,9 @@ bool Browser::ShouldCreateWebContents( const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -59,7 +59,7 @@ index 869fbec..7ca4f52 100644 // If a BackgroundContents is created, suppress the normal WebContents. return !MaybeCreateBackgroundContents( diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h -index 5410f5a..a6aaef1 100644 +index 6cdff54..0efcaa2 100644 --- chrome/browser/ui/browser.h +++ chrome/browser/ui/browser.h @@ -619,7 +619,9 @@ class Browser : public TabStripModelObserver, @@ -74,10 +74,10 @@ index 5410f5a..a6aaef1 100644 int opener_render_process_id, int opener_render_frame_id, diff --git content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc -index d7a0cbb..7883136 100644 +index 8850f6a..1a3719e 100644 --- content/browser/web_contents/web_contents_impl.cc +++ content/browser/web_contents/web_contents_impl.cc -@@ -1577,6 +1577,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -1572,6 +1572,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { std::string unique_name; frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name); @@ -90,7 +90,7 @@ index d7a0cbb..7883136 100644 WebContentsViewDelegate* delegate = GetContentClient()->browser()->GetWebContentsViewDelegate(this); -@@ -1607,6 +1613,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -1602,6 +1608,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { std::move(view_), &render_view_host_delegate_view_)); } @@ -98,7 +98,7 @@ index d7a0cbb..7883136 100644 CHECK(render_view_host_delegate_view_); CHECK(view_.get()); -@@ -2060,11 +2067,14 @@ void WebContentsImpl::CreateNewWindow( +@@ -2063,11 +2070,14 @@ void WebContentsImpl::CreateNewWindow( static_cast(session_storage_namespace); CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); @@ -114,7 +114,7 @@ index d7a0cbb..7883136 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 -@@ -2088,6 +2098,8 @@ void WebContentsImpl::CreateNewWindow( +@@ -2096,6 +2106,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; @@ -139,21 +139,22 @@ index fa0afb5..d677b31 100644 WebContents::CreateParams::CreateParams(const CreateParams& other) = default; diff --git content/public/browser/web_contents.h content/public/browser/web_contents.h -index 8c66b2a..ed523c7 100644 +index af944f7..cde1d7b 100644 --- content/public/browser/web_contents.h +++ content/public/browser/web_contents.h -@@ -59,8 +59,10 @@ class PageState; +@@ -59,9 +59,11 @@ class PageState; class RenderFrameHost; class RenderProcessHost; class RenderViewHost; +class RenderViewHostDelegateView; + class RenderWidgetHost; class RenderWidgetHostView; class WebContentsDelegate; +class WebContentsView; struct CustomContextMenuContext; struct DropData; struct Manifest; -@@ -161,6 +163,10 @@ class WebContents : public PageNavigator, +@@ -162,6 +164,10 @@ class WebContents : public PageNavigator, // Note that the pre-created renderer process may not be used if the first // navigation requires a dedicated or privileged process, such as a WebUI. bool initialize_renderer; @@ -165,10 +166,10 @@ index 8c66b2a..ed523c7 100644 // Creates a new WebContents. diff --git content/public/browser/web_contents_delegate.cc content/public/browser/web_contents_delegate.cc -index d107135..2d290e1 100644 +index b86ec61..2d1ddb2 100644 --- content/public/browser/web_contents_delegate.cc +++ content/public/browser/web_contents_delegate.cc -@@ -148,7 +148,9 @@ bool WebContentsDelegate::ShouldCreateWebContents( +@@ -144,7 +144,9 @@ bool WebContentsDelegate::ShouldCreateWebContents( const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -180,13 +181,13 @@ index d107135..2d290e1 100644 } diff --git content/public/browser/web_contents_delegate.h content/public/browser/web_contents_delegate.h -index 62ef1de..824b0e1 100644 +index 2beb83c..b02f4f1 100644 --- content/public/browser/web_contents_delegate.h +++ content/public/browser/web_contents_delegate.h -@@ -45,9 +45,11 @@ class JavaScriptDialogManager; +@@ -42,9 +42,11 @@ class ColorChooser; + class JavaScriptDialogManager; class PageState; class RenderFrameHost; - class RenderViewHost; +class RenderViewHostDelegateView; class SessionStorageNamespace; class WebContents; @@ -195,7 +196,7 @@ index 62ef1de..824b0e1 100644 struct ColorSuggestion; struct ContextMenuParams; struct DropData; -@@ -314,7 +316,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/webkit_popups.patch b/patch/patches/webkit_popups.patch index ac66720a7..29bc6b52c 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 f1a79c4..021a083 100644 +index 1c0863b..a0f06f4 100644 --- Source/web/ChromeClientImpl.cpp +++ Source/web/ChromeClientImpl.cpp -@@ -892,7 +892,7 @@ bool ChromeClientImpl::hasOpenedPopup() const { +@@ -893,7 +893,7 @@ bool ChromeClientImpl::hasOpenedPopup() const { PopupMenu* ChromeClientImpl::openPopupMenu(LocalFrame& frame, HTMLSelectElement& select) { notifyPopupOpeningObservers(); @@ -12,10 +12,10 @@ index f1a79c4..021a083 100644 DCHECK(RuntimeEnabledFeatures::pagePopupEnabled()); diff --git Source/web/WebViewImpl.cpp Source/web/WebViewImpl.cpp -index 966246f..a528578 100644 +index 8e1ca8b..83589b6 100644 --- Source/web/WebViewImpl.cpp +++ Source/web/WebViewImpl.cpp -@@ -405,6 +405,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, +@@ -379,6 +379,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, m_enableFakePageScaleAnimationForTesting(false), m_fakePageScaleAnimationPageScaleFactor(0), m_fakePageScaleAnimationUseAnchor(false), @@ -23,7 +23,7 @@ index 966246f..a528578 100644 m_doingDragAndDrop(false), m_ignoreInputEvents(false), m_compositorDeviceScaleFactorOverride(0), -@@ -4249,8 +4250,13 @@ void WebViewImpl::mainFrameScrollOffsetChanged() { +@@ -3727,8 +3728,13 @@ void WebViewImpl::mainFrameScrollOffsetChanged() { m_devToolsEmulator->mainFrameScrollOrScaleChanged(); } @@ -37,12 +37,12 @@ index 966246f..a528578 100644 + return m_shouldUseExternalPopupMenus; } - void WebViewImpl::startDragging(LocalFrame* frame, + void WebViewImpl::setIgnoreInputEvents(bool newValue) { diff --git Source/web/WebViewImpl.h Source/web/WebViewImpl.h -index 8e74ed5..6a37808 100644 +index d002c0d..74cbb22 100644 --- Source/web/WebViewImpl.h +++ Source/web/WebViewImpl.h -@@ -380,7 +380,8 @@ class WEB_EXPORT WebViewImpl final +@@ -375,7 +375,8 @@ class WEB_EXPORT WebViewImpl final // Returns true if popup menus should be rendered by the browser, false if // they should be rendered by WebKit (which is the default). @@ -52,20 +52,20 @@ index 8e74ed5..6a37808 100644 bool shouldAutoResize() const { return m_shouldAutoResize; } -@@ -685,6 +686,8 @@ class WEB_EXPORT WebViewImpl final +@@ -654,6 +655,8 @@ class WEB_EXPORT WebViewImpl final float m_fakePageScaleAnimationPageScaleFactor; bool m_fakePageScaleAnimationUseAnchor; + bool m_shouldUseExternalPopupMenus; + + // TODO(paulmeyer): Move this to WebWidget once all drag-and-drop functions + // are there. bool m_doingDragAndDrop; - - bool m_ignoreInputEvents; diff --git public/web/WebView.h public/web/WebView.h -index fde211e..fea968a 100644 +index 3127234..e79f0d2 100644 --- public/web/WebView.h +++ public/web/WebView.h -@@ -443,6 +443,7 @@ class WebView : protected WebWidget { +@@ -408,6 +408,7 @@ class WebView : protected WebWidget { // Sets whether select popup menus should be rendered by the browser. BLINK_EXPORT static void setUseExternalPopupMenus(bool); diff --git a/patch/patches/webui_2037.patch b/patch/patches/webui_2037.patch index 553369e39..684480628 100644 --- a/patch/patches/webui_2037.patch +++ b/patch/patches/webui_2037.patch @@ -1,5 +1,5 @@ diff --git chrome/browser/ui/webui/net_internals/net_internals_ui.cc chrome/browser/ui/webui/net_internals/net_internals_ui.cc -index 92fa2f1..cc3f54a 100644 +index 1e821dc..76bc9e7 100644 --- chrome/browser/ui/webui/net_internals/net_internals_ui.cc +++ chrome/browser/ui/webui/net_internals/net_internals_ui.cc @@ -689,9 +689,17 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( diff --git a/patch/patches/webview_plugin_2020.patch b/patch/patches/webview_plugin_2020.patch index a26c1a65e..bd2785021 100644 --- a/patch/patches/webview_plugin_2020.patch +++ b/patch/patches/webview_plugin_2020.patch @@ -1,8 +1,8 @@ diff --git chrome/app/generated_resources.grd chrome/app/generated_resources.grd -index dbd83a1..acf844e 100644 +index 351ceb7..304c765 100644 --- chrome/app/generated_resources.grd +++ chrome/app/generated_resources.grd -@@ -7082,7 +7082,7 @@ Keep your key file in a safe place. You will need it to create new versions of y +@@ -7199,7 +7199,7 @@ Keep your key file in a safe place. You will need it to create new versions of y @@ -12,7 +12,7 @@ index dbd83a1..acf844e 100644 diff --git components/plugins/renderer/loadable_plugin_placeholder.cc components/plugins/renderer/loadable_plugin_placeholder.cc -index 9bc0478..d0263d3 100644 +index 1f38fdb..03e0f60 100644 --- components/plugins/renderer/loadable_plugin_placeholder.cc +++ components/plugins/renderer/loadable_plugin_placeholder.cc @@ -127,11 +127,10 @@ void LoadablePluginPlaceholder::ReplacePlugin(blink::WebPlugin* new_plugin) { @@ -30,13 +30,13 @@ index 9bc0478..d0263d3 100644 } diff --git components/plugins/renderer/webview_plugin.cc components/plugins/renderer/webview_plugin.cc -index af1d919..0429d59 100644 +index 8d45c42..2a2ec9a 100644 --- components/plugins/renderer/webview_plugin.cc +++ components/plugins/renderer/webview_plugin.cc -@@ -17,7 +17,9 @@ - #include "content/public/renderer/render_view.h" +@@ -18,7 +18,9 @@ #include "gin/converter.h" #include "skia/ext/platform_canvas.h" + #include "third_party/WebKit/public/platform/WebInputEvent.h" +#include "third_party/WebKit/public/platform/WebSize.h" #include "third_party/WebKit/public/platform/WebURL.h" +#include "third_party/WebKit/public/platform/WebURLRequest.h" @@ -87,15 +87,15 @@ index af1d919..0429d59 100644 + for (std::list::iterator it = data_.begin(); it != data_.end(); + ++it) { + plugin->didReceiveData( -+ it->c_str(), base::checked_cast(it->length())); ++ it->c_str(), base::checked_cast(it->length())); + total_bytes += it->length(); + } + UMA_HISTOGRAM_MEMORY_KB( + "PluginDocument.Memory", -+ (base::checked_cast(total_bytes / 1024))); ++ (base::checked_cast(total_bytes / 1024))); + UMA_HISTOGRAM_COUNTS( + "PluginDocument.NumChunks", -+ (base::checked_cast(data_.size()))); ++ (base::checked_cast(data_.size()))); + } + // We need to transfer the |focused_| to new plugin after it loaded. + if (focused_) { @@ -143,7 +143,7 @@ index af1d919..0429d59 100644 } bool WebViewPlugin::acceptsLoadDrops() { return false; } -@@ -277,9 +315,8 @@ void WebViewPlugin::scheduleAnimation() { +@@ -279,9 +317,8 @@ void WebViewPlugin::scheduleAnimation() { } } @@ -155,7 +155,7 @@ index af1d919..0429d59 100644 return; v8::Isolate* isolate = blink::mainThreadIsolate(); -@@ -291,7 +328,7 @@ void WebViewPlugin::PluginWebFrameClient::didClearWindowObject( +@@ -293,7 +330,7 @@ void WebViewPlugin::PluginWebFrameClient::didClearWindowObject( v8::Local global = context->Global(); global->Set(gin::StringToV8(isolate, "plugin"), @@ -165,7 +165,7 @@ index af1d919..0429d59 100644 void WebViewPlugin::OnDestruct() {} diff --git components/plugins/renderer/webview_plugin.h components/plugins/renderer/webview_plugin.h -index 086fa6d..6f69dec 100644 +index fdb1cf9..97e3995 100644 --- components/plugins/renderer/webview_plugin.h +++ components/plugins/renderer/webview_plugin.h @@ -42,6 +42,7 @@ class Size; diff --git a/tests/cefclient/browser/browser_window_osr_mac.mm b/tests/cefclient/browser/browser_window_osr_mac.mm index 302fb5020..92ae48435 100644 --- a/tests/cefclient/browser/browser_window_osr_mac.mm +++ b/tests/cefclient/browser/browser_window_osr_mac.mm @@ -143,7 +143,6 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) { NSOpenGLPixelFormat * pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute[]) { - NSOpenGLPFAWindow, NSOpenGLPFADoubleBuffer, NSOpenGLPFADepthSize, 32, diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index ab73ecefa..a7a5d70e9 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -119,7 +119,9 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) { // Create the application on the UI thread. - (void)createApplication:(id)object { NSApplication* application = [NSApplication sharedApplication]; - [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; + [[NSBundle mainBundle] loadNibNamed:@"MainMenu" + owner:NSApp + topLevelObjects:nil]; // Set the delegate for application events. [application setDelegate:self]; diff --git a/tests/cefsimple/cefsimple_mac.mm b/tests/cefsimple/cefsimple_mac.mm index 8b4874524..e9c10cc1c 100644 --- a/tests/cefsimple/cefsimple_mac.mm +++ b/tests/cefsimple/cefsimple_mac.mm @@ -87,7 +87,9 @@ // Create the application on the UI thread. - (void)createApplication:(id)object { [NSApplication sharedApplication]; - [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; + [[NSBundle mainBundle] loadNibNamed:@"MainMenu" + owner:NSApp + topLevelObjects:nil]; // Set the delegate for application events. [[NSApplication sharedApplication] setDelegate:self]; diff --git a/tests/ceftests/os_rendering_unittest.cc b/tests/ceftests/os_rendering_unittest.cc index 3485172d3..08e75fe63 100644 --- a/tests/ceftests/os_rendering_unittest.cc +++ b/tests/ceftests/os_rendering_unittest.cc @@ -711,7 +711,11 @@ class OSRTestHandler : public RoutingTestHandler, #if defined(OS_MACOSX) EXPECT_EQ(0xff5d99d6, *(reinterpret_cast(buffer))); #elif defined(OS_LINUX) || defined(OS_WIN) - EXPECT_EQ(0xff6497ea, *(reinterpret_cast(buffer))); + if (scale_factor_ == 1.0) { + EXPECT_EQ(0xff6497ea, *(reinterpret_cast(buffer))); + } else { + EXPECT_EQ(0xff4d90fe, *(reinterpret_cast(buffer))); + } #else #error "Unsupported platform" #endif diff --git a/tests/ceftests/request_handler_unittest.cc b/tests/ceftests/request_handler_unittest.cc index 8e67a5952..a1e1fcb59 100644 --- a/tests/ceftests/request_handler_unittest.cc +++ b/tests/ceftests/request_handler_unittest.cc @@ -1335,11 +1335,11 @@ class ResponseFilterPassThru : public ResponseFilterTestBase { if (limit_read_) // Expected to read 2 full buffers of kResponseBufferSize at 1kb // increments (2 * 32) and one partial buffer. - EXPECT_EQ(filter_count_, 2U * 32U + 1U); + EXPECT_EQ(2U * 32U + 1U, filter_count_); else { // Expected to read 2 full buffers of kResponseBufferSize and one partial // buffer. - EXPECT_EQ(filter_count_, 3U); + EXPECT_EQ(3U, filter_count_); } EXPECT_STREQ(input_.c_str(), received_content.c_str()); @@ -1436,9 +1436,9 @@ class ResponseFilterNeedMore : public ResponseFilterTestBase { Write(&data_in_ptr[i], 1, WRITE_PARAMS); } - // If a match is currently in-progress we need more data. Otherwise, we're - // done. - return find_match_offset_ > 0 ? + // If a match is currently in-progress and input was provided then we need + // more data. Otherwise, we're done. + return find_match_offset_ > 0 && data_in_size > 0 ? RESPONSE_FILTER_NEED_MORE_DATA : RESPONSE_FILTER_DONE; } @@ -1476,7 +1476,7 @@ class ResponseFilterNeedMore : public ResponseFilterTestBase { // Expected to read 2 full buffers of kResponseBufferSize and one partial // buffer, and then one additional call to drain the overflow. - EXPECT_EQ(filter_count_, 4U); + EXPECT_EQ(4U, filter_count_); } private: diff --git a/tests/shared/browser/resource_util_mac.mm b/tests/shared/browser/resource_util_mac.mm index 3134548e2..f7587643a 100644 --- a/tests/shared/browser/resource_util_mac.mm +++ b/tests/shared/browser/resource_util_mac.mm @@ -15,26 +15,14 @@ namespace client { namespace { +// Implementation adapted from Chromium's base/mac/foundation_util.mm +bool UncachedAmIBundled() { + return [[[NSBundle mainBundle] bundlePath] hasSuffix:@".app"]; +} + bool AmIBundled() { - // Implementation adapted from Chromium's base/mac/foundation_util.mm - ProcessSerialNumber psn = {0, kCurrentProcess}; - - FSRef fsref; - OSStatus pbErr; - if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { - NOTREACHED(); - return false; - } - - FSCatalogInfo info; - OSErr fsErr; - if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, - NULL, NULL, NULL)) != noErr) { - NOTREACHED(); - return false; - } - - return (info.nodeFlags & kFSNodeIsDirectoryMask); + static bool am_i_bundled = UncachedAmIBundled(); + return am_i_bundled; } } // namespace