Update to Chromium version 92.0.4515.0 (#885287)

This commit is contained in:
Marshall Greenblatt 2021-06-03 21:34:56 -04:00
parent f2f52c1e2c
commit 00dca9601e
190 changed files with 1234 additions and 1309 deletions

View File

@ -363,6 +363,9 @@ if (is_win) {
# Required by content_switches.cc # Required by content_switches.cc
"//media:media_buildflags", "//media:media_buildflags",
# Required by crash_keys.cc (from base/stl_util.h)
"//third_party/abseil-cpp:absl",
] ]
} }
} }
@ -796,6 +799,10 @@ static_library("libcef_static") {
# For Chrome runtime support. # For Chrome runtime support.
"//chrome/app/chrome_main_delegate.cc", "//chrome/app/chrome_main_delegate.cc",
"//chrome/app/chrome_main_delegate.h", "//chrome/app/chrome_main_delegate.h",
# Part of //content//test::test_support which is testingonly.
"//content/public/test/scoped_web_ui_controller_factory_registration.cc",
"//content/public/test/scoped_web_ui_controller_factory_registration.h",
] ]
configs += [ configs += [

View File

@ -7,5 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{ {
'chromium_checkout': 'refs/tags/91.0.4472.0' 'chromium_checkout': 'refs/tags/92.0.4515.0'
} }

View File

@ -311,13 +311,12 @@ AlloyBrowserContext::GetClientHintsControllerDelegate() {
ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() { ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>( return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate()); GetStoragePartition(nullptr)->GetZoomLevelDelegate());
} }
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
AlloyBrowserContext::GetURLLoaderFactory() { AlloyBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition(this) return GetDefaultStoragePartition()->GetURLLoaderFactoryForBrowserProcess();
->GetURLLoaderFactoryForBrowserProcess();
} }
base::FilePath AlloyBrowserContext::GetPath() { base::FilePath AlloyBrowserContext::GetPath() {
@ -339,18 +338,11 @@ AlloyBrowserContext::CreateZoomLevelDelegate(
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr())); zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
} }
bool AlloyBrowserContext::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate* content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() { AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) { if (!download_manager_delegate_) {
content::DownloadManager* manager = download_manager_delegate_.reset(
BrowserContext::GetDownloadManager(this); new CefDownloadManagerDelegate(GetDownloadManager()));
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
} }
return download_manager_delegate_.get(); return download_manager_delegate_.get();
} }

View File

@ -64,7 +64,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
base::FilePath GetPath() const override; base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override; const base::FilePath& partition_path) override;
bool IsOffTheRecord() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override; content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;

View File

@ -639,7 +639,7 @@ void AlloyBrowserHostImpl::SendExternalBeginFrame() {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&AlloyBrowserHostImpl::SendExternalBeginFrame, this)); base::BindOnce(&AlloyBrowserHostImpl::SendExternalBeginFrame, this));
return; return;
} }
@ -654,7 +654,7 @@ void AlloyBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&AlloyBrowserHostImpl::SendTouchEvent, CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SendTouchEvent,
this, event)); this, event));
return; return;
} }
@ -800,9 +800,9 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
// The PDF viewer will load the PDF extension in the guest view, and print // The PDF viewer will load the PDF extension in the guest view, and print
// preview will load chrome://print in the guest view. All other navigations // preview will load chrome://print in the guest view. All other navigations
// are passed to the owner browser. // are passed to the owner browser.
CEF_POST_TASK( CEF_POST_TASK(CEF_UIT,
CEF_UIT, base::BindOnce(
base::Bind(base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab), base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params)); this, nullptr, params));
return false; return false;
@ -1077,8 +1077,8 @@ void AlloyBrowserHostImpl::DragSourceEndedAt(
void AlloyBrowserHostImpl::SetAudioMuted(bool mute) { void AlloyBrowserHostImpl::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SetAudioMuted,
base::Bind(&AlloyBrowserHostImpl::SetAudioMuted, this, mute)); this, mute));
return; return;
} }
if (!web_contents()) if (!web_contents())

View File

@ -109,7 +109,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
} }
void AlloyBrowserMainParts::PreMainMessageLoopStart() { void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
#if defined(USE_AURA) && defined(USE_X11) #if defined(USE_AURA) && defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine(); ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif #endif
@ -129,7 +129,7 @@ void AlloyBrowserMainParts::PreMainMessageLoopStart() {
media_router::ChromeMediaRouterFactory::DoPlatformInit(); media_router::ChromeMediaRouterFactory::DoPlatformInit();
} }
void AlloyBrowserMainParts::PostMainMessageLoopStart() { void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
#if defined(OS_LINUX) #if defined(OS_LINUX)
printing::PrintingContextLinux::SetCreatePrintDialogFunction( printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&CefPrintDialogLinux::CreatePrintDialog); &CefPrintDialogLinux::CreatePrintDialog);
@ -155,7 +155,8 @@ int AlloyBrowserMainParts::PreCreateThreads() {
int AlloyBrowserMainParts::PreMainMessageLoopRun() { int AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA) #if defined(USE_AURA)
display::Screen::SetScreenInstance(views::CreateDesktopScreen()); screen_ = views::CreateDesktopScreen();
display::Screen::SetScreenInstance(screen_.get());
#endif #endif
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {

View File

@ -24,6 +24,9 @@ class ExtensionsClient;
} // namespace extensions } // namespace extensions
#if defined(USE_AURA) #if defined(USE_AURA)
namespace display {
class Screen;
}
namespace wm { namespace wm {
class WMState; class WMState;
} }
@ -47,8 +50,8 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
int PreEarlyInitialization() override; int PreEarlyInitialization() override;
void ToolkitInitialized() override; void ToolkitInitialized() override;
void PreMainMessageLoopStart() override; void PreCreateMainMessageLoop() override;
void PostMainMessageLoopStart() override; void PostCreateMainMessageLoop() override;
int PreCreateThreads() override; int PreCreateThreads() override;
int PreMainMessageLoopRun() override; int PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override; void PostMainMessageLoopRun() override;
@ -91,6 +94,7 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
#if defined(USE_AURA) #if defined(USE_AURA)
std::unique_ptr<display::Screen> screen_;
std::unique_ptr<wm::WMState> wm_state_; std::unique_ptr<wm::WMState> wm_state_;
#endif #endif

View File

@ -98,6 +98,7 @@
#include "content/public/common/storage_quota_params.h" #include "content/public/common/storage_quota_params.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_message_filter.h" #include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h" #include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
@ -238,9 +239,10 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
RunNow(std::move(callback_), allow); RunNow(std::move(callback_), allow);
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue, CEF_UIT,
this, allow)); base::BindOnce(&CefAllowCertificateErrorCallbackImpl::Continue, this,
allow));
} }
} }
@ -1043,6 +1045,11 @@ void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
associated_registry->AddInterface( associated_registry->AddInterface(
base::BindRepeating(&BindPluginInfoHost, host->GetID())); base::BindRepeating(&BindPluginInfoHost, host->GetID()));
if (extensions::ExtensionsEnabled()) {
associated_registry->AddInterface(base::BindRepeating(
&extensions::EventRouter::BindForRenderer, host->GetID()));
}
CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry, CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry,
host); host);
} }
@ -1152,7 +1159,7 @@ bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
int render_process_id, int render_process_id,
URLLoaderFactoryType type, URLLoaderFactoryType type,
const url::Origin& request_initiator, const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id, absl::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id, ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@ -1250,7 +1257,7 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
bool is_main_frame, bool is_main_frame,
ui::PageTransition page_transition, ui::PageTransition page_transition,
bool has_user_gesture, bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin, const absl::optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// Call the other HandleExternalProtocol variant. // Call the other HandleExternalProtocol variant.
return false; return false;
@ -1269,7 +1276,7 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
// nothing handles the request. // nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler( auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request, web_contents_getter, frame_tree_node_id, resource_request,
base::Bind(CefBrowserPlatformDelegate::HandleExternalProtocol, base::BindRepeating(CefBrowserPlatformDelegate::HandleExternalProtocol,
resource_request.url)); resource_request.url));
net_service::ProxyURLLoaderFactory::CreateProxy( net_service::ProxyURLLoaderFactory::CreateProxy(
@ -1366,7 +1373,7 @@ bool AlloyContentBrowserClient::ArePersistentMediaDeviceIDsAllowed(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const GURL& url, const GURL& url,
const GURL& site_for_cookies, const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin) { const absl::optional<url::Origin>& top_frame_origin) {
// Persistent MediaDevice IDs are allowed if cookies are allowed. // Persistent MediaDevice IDs are allowed if cookies are allowed.
return CookieSettingsFactory::GetForProfile( return CookieSettingsFactory::GetForProfile(
Profile::FromBrowserContext(browser_context)) Profile::FromBrowserContext(browser_context))

View File

@ -158,7 +158,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
int render_process_id, int render_process_id,
URLLoaderFactoryType type, URLLoaderFactoryType type,
const url::Origin& request_initiator, const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id, absl::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id, ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@ -185,7 +185,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
bool is_main_frame, bool is_main_frame,
ui::PageTransition page_transition, ui::PageTransition page_transition,
bool has_user_gesture, bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin, const absl::optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override; override;
bool HandleExternalProtocol( bool HandleExternalProtocol(
@ -211,7 +211,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const GURL& scope, const GURL& scope,
const GURL& site_for_cookies, const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin) override; const absl::optional<url::Origin>& top_frame_origin) override;
bool ShouldAllowPluginCreation( bool ShouldAllowPluginCreation(
const url::Origin& embedder_origin, const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) override; const content::PepperPluginInfo& plugin_info) override;

View File

@ -379,12 +379,12 @@ void CefBrowserPlatformDelegateAlloy::PrintToPDF(
return; return;
printing::CefPrintViewManager::PdfPrintCallback pdf_callback; printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
if (callback.get()) { if (callback.get()) {
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished, pdf_callback = base::BindOnce(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path); callback.get(), path);
} }
GetPrintViewManager(actionable_contents) GetPrintViewManager(actionable_contents)
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path), ->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, pdf_callback); settings, std::move(pdf_callback));
} }
void CefBrowserPlatformDelegateAlloy::Find(int identifier, void CefBrowserPlatformDelegateAlloy::Find(int identifier,

View File

@ -6,6 +6,7 @@
#include "libcef/browser/alloy/chrome_profile_alloy.h" #include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/variations/variations_client.h" #include "components/variations/variations_client.h"
#include "components/variations/variations_ids_provider.h" #include "components/variations/variations_ids_provider.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
@ -35,7 +36,10 @@ class CefVariationsClient : public variations::VariationsClient {
} // namespace } // namespace
ChromeProfileAlloy::ChromeProfileAlloy() {} ChromeProfileAlloy::ChromeProfileAlloy() {
profile_metrics::SetBrowserProfileType(
this, profile_metrics::BrowserProfileType::kRegular);
}
ChromeProfileAlloy::~ChromeProfileAlloy() {} ChromeProfileAlloy::~ChromeProfileAlloy() {}
@ -44,13 +48,15 @@ bool ChromeProfileAlloy::IsOffTheRecord() {
} }
bool ChromeProfileAlloy::IsOffTheRecord() const { bool ChromeProfileAlloy::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false; return false;
} }
const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const { const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
NOTREACHED(); NOTREACHED();
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id( static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
"ProfileImp::NoOTRProfileID"); Profile::OTRProfileID::PrimaryID());
return *otr_profile_id; return *otr_profile_id;
} }
@ -116,11 +122,6 @@ ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
return nullptr; return nullptr;
} }
PrefService* ChromeProfileAlloy::GetOffTheRecordPrefs() {
NOTREACHED();
return nullptr;
}
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) { bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
NOTREACHED(); NOTREACHED();
return false; return false;

View File

@ -38,7 +38,6 @@ class ChromeProfileAlloy : public Profile {
bool IsSupervised() const override; bool IsSupervised() const override;
bool IsChild() const override; bool IsChild() const override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override; ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
PrefService* GetOffTheRecordPrefs() override;
bool IsSameOrParent(Profile* profile) override; bool IsSameOrParent(Profile* profile) override;
base::Time GetStartTime() const override; base::Time GetStartTime() const override;
base::FilePath last_selected_directory() override; base::FilePath last_selected_directory() override;

View File

@ -56,10 +56,3 @@ bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
return !!CefBrowserContext::FromBrowserContext( return !!CefBrowserContext::FromBrowserContext(
static_cast<const content::BrowserContext*>(profile)); static_cast<const content::BrowserContext*>(profile));
} }
Profile* ChromeProfileManagerAlloy::GetLastUsedProfile(
const base::FilePath& user_data_dir) {
// Override this method to avoid having to register prefs::kProfileLastUsed,
// usage of which doesn't make sense for CEF.
return GetActiveBrowserContext()->AsProfile();
}

View File

@ -18,7 +18,6 @@ class ChromeProfileManagerAlloy : public ProfileManager {
Profile* GetProfile(const base::FilePath& profile_dir) override; Profile* GetProfile(const base::FilePath& profile_dir) override;
bool IsValidProfile(const void* profile) override; bool IsValidProfile(const void* profile) override;
Profile* GetLastUsedProfile(const base::FilePath& user_data_dir) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerAlloy); DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerAlloy);

View File

@ -44,7 +44,7 @@ class StreamCreatedCallbackAdapter final
client_receiver, client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe, media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted, bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override { const absl::optional<base::UnguessableToken>& stream_id) override {
DCHECK(!initially_muted); // Loopback streams shouldn't be started muted. DCHECK(!initially_muted); // Loopback streams shouldn't be started muted.
callback_.Run(std::move(stream), std::move(client_receiver), callback_.Run(std::move(stream), std::move(client_receiver),
std::move(data_pipe)); std::move(data_pipe));

View File

@ -8,6 +8,7 @@
#include "libcef/browser/browser_platform_delegate.h" #include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_util.h" #include "libcef/browser/browser_util.h"
#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/keyboard_event_processing_result.h" #include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
@ -17,6 +18,7 @@
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h" #include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
using content::KeyboardEventProcessingResult; using content::KeyboardEventProcessingResult;
@ -232,18 +234,6 @@ bool CefBrowserContentsDelegate::HandleKeyboardEvent(
void CefBrowserContentsDelegate::RenderFrameCreated( void CefBrowserContentsDelegate::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */); browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
if (render_frame_host->GetParent() == nullptr) {
// May be already registered if the renderer crashed previously.
auto render_view_host = render_frame_host->GetRenderViewHost();
if (!registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host))) {
registrar_->Add(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host));
}
}
} }
void CefBrowserContentsDelegate::RenderFrameHostChanged( void CefBrowserContentsDelegate::RenderFrameHostChanged(
@ -264,17 +254,6 @@ void CefBrowserContentsDelegate::RenderFrameDeleted(
} }
} }
void CefBrowserContentsDelegate::RenderViewDeleted(
content::RenderViewHost* render_view_host) {
if (registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host))) {
registrar_->Remove(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host));
}
}
void CefBrowserContentsDelegate::RenderViewReady() { void CefBrowserContentsDelegate::RenderViewReady() {
if (auto c = client()) { if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) { if (auto handler = c->GetRequestHandler()) {
@ -472,6 +451,13 @@ void CefBrowserContentsDelegate::OnWebContentsFocused(
} }
} }
void CefBrowserContentsDelegate::OnFocusChangedInPage(
content::FocusedNodeDetails* details) {
focus_on_editable_field_ =
details->focus_type != blink::mojom::blink::FocusType::kNone &&
details->is_editable_node;
}
void CefBrowserContentsDelegate::WebContentsDestroyed() { void CefBrowserContentsDelegate::WebContentsDestroyed() {
auto wc = web_contents(); auto wc = web_contents();
ObserveWebContents(nullptr); ObserveWebContents(nullptr);
@ -484,15 +470,12 @@ void CefBrowserContentsDelegate::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
DCHECK(type == content::NOTIFICATION_LOAD_STOP || DCHECK_EQ(type, content::NOTIFICATION_LOAD_STOP);
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
if (type == content::NOTIFICATION_LOAD_STOP) { if (type == content::NOTIFICATION_LOAD_STOP) {
content::NavigationController* controller = content::NavigationController* controller =
content::Source<content::NavigationController>(source).ptr(); content::Source<content::NavigationController>(source).ptr();
OnTitleChange(controller->GetWebContents()->GetTitle()); OnTitleChange(controller->GetWebContents()->GetTitle());
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
} }
} }

View File

@ -10,6 +10,7 @@
#include "libcef/browser/frame_host_impl.h" #include "libcef/browser/frame_host_impl.h"
#include "base/callback_list.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
@ -108,7 +109,6 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void RenderFrameHostChanged(content::RenderFrameHost* old_host, void RenderFrameHostChanged(content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) override; content::RenderFrameHost* new_host) override;
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override; void RenderViewReady() override;
void RenderProcessGone(base::TerminationStatus status) override; void RenderProcessGone(base::TerminationStatus status) override;
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override; void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
@ -129,6 +129,7 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override; const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnWebContentsFocused( void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override; content::RenderWidgetHost* render_widget_host) override;
void OnFocusChangedInPage(content::FocusedNodeDetails* details) override;
void WebContentsDestroyed() override; void WebContentsDestroyed() override;
// NotificationObserver methods. // NotificationObserver methods.

View File

@ -300,7 +300,7 @@ void CefBrowserContext::OnRenderFrameCreated(
frame_tree_node_id, handler); frame_tree_node_id, handler);
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT,
base::Bind(&CefIOThreadState::AddHandler, iothread_state_, base::BindOnce(&CefIOThreadState::AddHandler, iothread_state_,
render_process_id, render_frame_id, render_process_id, render_frame_id,
frame_tree_node_id, handler)); frame_tree_node_id, handler));
} }
@ -332,7 +332,7 @@ void CefBrowserContext::OnRenderFrameDeleted(
handler_map_.RemoveHandler(render_process_id, render_frame_id, handler_map_.RemoveHandler(render_process_id, render_frame_id,
frame_tree_node_id); frame_tree_node_id);
CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::RemoveHandler, CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefIOThreadState::RemoveHandler,
iothread_state_, render_process_id, iothread_state_, render_process_id,
render_frame_id, frame_tree_node_id)); render_frame_id, frame_tree_node_id));
} }
@ -438,14 +438,15 @@ void CefBrowserContext::RegisterSchemeHandlerFactory(
const CefString& scheme_name, const CefString& scheme_name,
const CefString& domain_name, const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) { CefRefPtr<CefSchemeHandlerFactory> factory) {
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(
base::Bind(&CefIOThreadState::RegisterSchemeHandlerFactory, CEF_IOT,
base::BindOnce(&CefIOThreadState::RegisterSchemeHandlerFactory,
iothread_state_, scheme_name, domain_name, factory)); iothread_state_, scheme_name, domain_name, factory));
} }
void CefBrowserContext::ClearSchemeHandlerFactories() { void CefBrowserContext::ClearSchemeHandlerFactories() {
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT,
base::Bind(&CefIOThreadState::ClearSchemeHandlerFactories, base::BindOnce(&CefIOThreadState::ClearSchemeHandlerFactories,
iothread_state_)); iothread_state_));
} }
@ -482,8 +483,7 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() { network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
auto browser_context = AsBrowserContext(); auto browser_context = AsBrowserContext();
return browser_context->GetDefaultStoragePartition(browser_context) return browser_context->GetDefaultStoragePartition()->GetNetworkContext();
->GetNetworkContext();
} }
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() { CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
@ -517,7 +517,7 @@ CefBrowserContext::GetGlobalCookieableSchemes() {
CefString(&settings.cookieable_schemes_list), CefString(&settings.cookieable_schemes_list),
!settings.cookieable_schemes_exclude_defaults); !settings.cookieable_schemes_exclude_defaults);
} }
return base::nullopt; return absl::nullopt;
}()); }());
return *schemes; return *schemes;
} }

View File

@ -16,9 +16,9 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "chrome/common/plugin.mojom.h" #include "chrome/common/plugin.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/origin.h" #include "url/origin.h"
/* /*
@ -200,7 +200,7 @@ class CefBrowserContext {
CefMediaRouterManager* GetMediaRouterManager(); CefMediaRouterManager* GetMediaRouterManager();
using CookieableSchemes = base::Optional<std::vector<std::string>>; using CookieableSchemes = absl::optional<std::vector<std::string>>;
// Returns the schemes associated with this context specifically, or the // Returns the schemes associated with this context specifically, or the
// global configuration if unset. // global configuration if unset.

View File

@ -58,7 +58,7 @@ void CefBrowserFrame::DidFinishFrameLoad(const GURL& validated_url,
} }
void CefBrowserFrame::UpdateDraggableRegions( void CefBrowserFrame::UpdateDraggableRegions(
base::Optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) { absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
if (auto host = GetFrameHost()) { if (auto host = GetFrameHost()) {
host->UpdateDraggableRegions(std::move(regions)); host->UpdateDraggableRegions(std::move(regions));
} }

View File

@ -36,7 +36,7 @@ class CefBrowserFrame
void DidFinishFrameLoad(const GURL& validated_url, void DidFinishFrameLoad(const GURL& validated_url,
int32_t http_status_code) override; int32_t http_status_code) override;
void UpdateDraggableRegions( void UpdateDraggableRegions(
base::Optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
override; override;
// FrameServiceBase methods: // FrameServiceBase methods:

View File

@ -232,8 +232,7 @@ void CefBrowserHostBase::StartDownload(const CefString& url) {
if (!browser_context) if (!browser_context)
return; return;
content::DownloadManager* manager = content::DownloadManager* manager = browser_context->GetDownloadManager();
content::BrowserContext::GetDownloadManager(browser_context);
if (!manager) if (!manager)
return; return;

View File

@ -56,7 +56,8 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
// Create or load a specific disk-based profile. May continue // Create or load a specific disk-based profile. May continue
// synchronously or asynchronously. // synchronously or asynchronously.
profile_manager->CreateProfileAsync( profile_manager->CreateProfileAsync(
cache_path_, base::Bind(&ChromeBrowserContext::ProfileCreated, cache_path_,
base::BindRepeating(&ChromeBrowserContext::ProfileCreated,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
return; return;
} else { } else {
@ -96,7 +97,8 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF(); const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF();
parent_profile = parent_profile =
g_browser_process->profile_manager()->GetPrimaryUserProfile(); g_browser_process->profile_manager()->GetPrimaryUserProfile();
profile_ = parent_profile->GetOffTheRecordProfile(profile_id); profile_ = parent_profile->GetOffTheRecordProfile(
profile_id, /*create_if_needed=*/true);
otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_); otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_);
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED; status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;
should_destroy_ = true; should_destroy_ = true;

View File

@ -12,7 +12,7 @@
#include "libcef/browser/browser_info.h" #include "libcef/browser/browser_info.h"
#include "libcef/browser/chrome/browser_delegate.h" #include "libcef/browser/chrome/browser_delegate.h"
#include "base/optional.h" #include "third_party/abseil-cpp/absl/types/optional.h"
class CefBrowserContentsDelegate; class CefBrowserContentsDelegate;
class CefRequestContextImpl; class CefRequestContextImpl;

View File

@ -199,7 +199,7 @@ bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
int render_process_id, int render_process_id,
URLLoaderFactoryType type, URLLoaderFactoryType type,
const url::Origin& request_initiator, const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id, absl::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id, ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@ -243,7 +243,7 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
bool is_main_frame, bool is_main_frame,
ui::PageTransition page_transition, ui::PageTransition page_transition,
bool has_user_gesture, bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin, const absl::optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// |out_factory| will be non-nullptr when this method is initially called // |out_factory| will be non-nullptr when this method is initially called
// from NavigationURLLoaderImpl::PrepareForNonInterceptedRequest. // from NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
@ -273,9 +273,9 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
// HandleExternalProtocolHelper may be called if nothing handles the request. // HandleExternalProtocolHelper may be called if nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler( auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request, web_contents_getter, frame_tree_node_id, resource_request,
base::Bind(HandleExternalProtocolHelper, base::Unretained(this), base::BindRepeating(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, frame_tree_node_id, navigation_data, web_contents_getter, frame_tree_node_id,
resource_request)); navigation_data, resource_request));
net_service::ProxyURLLoaderFactory::CreateProxy( net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler)); web_contents_getter, std::move(receiver), std::move(request_handler));

View File

@ -48,7 +48,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
int render_process_id, int render_process_id,
URLLoaderFactoryType type, URLLoaderFactoryType type,
const url::Origin& request_initiator, const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id, absl::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id, ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@ -65,7 +65,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
bool is_main_frame, bool is_main_frame,
ui::PageTransition page_transition, ui::PageTransition page_transition,
bool has_user_gesture, bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin, const absl::optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override; override;
bool HandleExternalProtocol( bool HandleExternalProtocol(

View File

@ -111,7 +111,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
} }
void SetAccelerator(int command_id, void SetAccelerator(int command_id,
base::Optional<ui::Accelerator> accel) override { absl::optional<ui::Accelerator> accel) override {
// No-op if already at the default state. // No-op if already at the default state.
if (!accel && !GetItemInfo(command_id)) if (!accel && !GetItemInfo(command_id))
return; return;
@ -127,7 +127,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
ItemInfo() {} ItemInfo() {}
bool checked = false; bool checked = false;
base::Optional<ui::Accelerator> accel; absl::optional<ui::Accelerator> accel;
}; };
ItemInfo* GetItemInfo(int command_id) { ItemInfo* GetItemInfo(int command_id) {

View File

@ -74,7 +74,7 @@ ToolbarView* ChromeBrowserView::OverrideCreateToolbar(
BrowserView* browser_view) { BrowserView* browser_view) {
if (cef_delegate()) { if (cef_delegate()) {
auto toolbar_type = cef_delegate()->GetChromeToolbarType(); auto toolbar_type = cef_delegate()->GetChromeToolbarType();
base::Optional<ToolbarView::DisplayMode> display_mode; absl::optional<ToolbarView::DisplayMode> display_mode;
switch (toolbar_type) { switch (toolbar_type) {
case CEF_CTT_NORMAL: case CEF_CTT_NORMAL:
display_mode = ToolbarView::DisplayMode::NORMAL; display_mode = ToolbarView::DisplayMode::NORMAL;

View File

@ -9,7 +9,7 @@ CefRefPtr<CefToolbarViewImpl> CefToolbarViewImpl::Create(
CefRefPtr<CefViewDelegate> delegate, CefRefPtr<CefViewDelegate> delegate,
Browser* browser, Browser* browser,
BrowserView* browser_view, BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode) { absl::optional<ToolbarView::DisplayMode> display_mode) {
CEF_REQUIRE_UIT_RETURN(nullptr); CEF_REQUIRE_UIT_RETURN(nullptr);
CefRefPtr<CefToolbarViewImpl> view = CefRefPtr<CefToolbarViewImpl> view =
new CefToolbarViewImpl(delegate, browser, browser_view, display_mode); new CefToolbarViewImpl(delegate, browser, browser_view, display_mode);
@ -24,7 +24,7 @@ CefToolbarViewImpl::CefToolbarViewImpl(
CefRefPtr<CefViewDelegate> delegate, CefRefPtr<CefViewDelegate> delegate,
Browser* browser, Browser* browser,
BrowserView* browser_view, BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode) absl::optional<ToolbarView::DisplayMode> display_mode)
: ParentClass(delegate), : ParentClass(delegate),
browser_(browser), browser_(browser),
browser_view_(browser_view), browser_view_(browser_view),

View File

@ -24,7 +24,7 @@ class CefToolbarViewImpl
CefRefPtr<CefViewDelegate> delegate, CefRefPtr<CefViewDelegate> delegate,
Browser* browser, Browser* browser,
BrowserView* browser_view, BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode); absl::optional<ToolbarView::DisplayMode> display_mode);
static const char* const kTypeString; static const char* const kTypeString;
@ -38,7 +38,7 @@ class CefToolbarViewImpl
CefToolbarViewImpl(CefRefPtr<CefViewDelegate> delegate, CefToolbarViewImpl(CefRefPtr<CefViewDelegate> delegate,
Browser* browser, Browser* browser,
BrowserView* browser_view, BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode); absl::optional<ToolbarView::DisplayMode> display_mode);
// CefViewImpl methods: // CefViewImpl methods:
CefToolbarViewView* CreateRootView() override; CefToolbarViewView* CreateRootView() override;
@ -46,7 +46,7 @@ class CefToolbarViewImpl
Browser* const browser_; Browser* const browser_;
BrowserView* const browser_view_; BrowserView* const browser_view_;
base::Optional<ToolbarView::DisplayMode> const display_mode_; absl::optional<ToolbarView::DisplayMode> const display_mode_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefToolbarViewImpl); IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefToolbarViewImpl);
DISALLOW_COPY_AND_ASSIGN(CefToolbarViewImpl); DISALLOW_COPY_AND_ASSIGN(CefToolbarViewImpl);

View File

@ -7,5 +7,5 @@
CefToolbarViewView::CefToolbarViewView(CefViewDelegate* cef_delegate, CefToolbarViewView::CefToolbarViewView(CefViewDelegate* cef_delegate,
Browser* browser, Browser* browser,
BrowserView* browser_view, BrowserView* browser_view,
base::Optional<DisplayMode> display_mode) absl::optional<DisplayMode> display_mode)
: ParentClass(cef_delegate, browser, browser_view, display_mode) {} : ParentClass(cef_delegate, browser, browser_view, display_mode) {}

View File

@ -18,7 +18,7 @@ class CefToolbarViewView : public CefViewView<ToolbarView, CefViewDelegate> {
explicit CefToolbarViewView(CefViewDelegate* cef_delegate, explicit CefToolbarViewView(CefViewDelegate* cef_delegate,
Browser* browser, Browser* browser,
BrowserView* browser_view, BrowserView* browser_view,
base::Optional<DisplayMode> display_mode); absl::optional<DisplayMode> display_mode);
private: private:
DISALLOW_COPY_AND_ASSIGN(CefToolbarViewView); DISALLOW_COPY_AND_ASSIGN(CefToolbarViewView);

View File

@ -294,10 +294,12 @@ void CefSetOSModalLoop(bool osModalLoop) {
return; return;
} }
if (CEF_CURRENTLY_ON_UIT()) if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(CefSetOSModalLoop, osModalLoop));
return;
}
base::CurrentThread::Get()->set_os_modal_loop(osModalLoop); base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
else
CEF_POST_TASK(CEF_UIT, base::Bind(CefSetOSModalLoop, osModalLoop));
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
} }

View File

@ -35,7 +35,7 @@ void WriteToFile(const base::FilePath& path, const std::string& content) {
void AppendToFile(const base::FilePath& path, const std::string& content) { void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty()); DCHECK(!path.empty());
base::AppendToFile(path, content.c_str(), content.size()); base::AppendToFile(path, base::StringPiece(content));
} }
} // namespace } // namespace
@ -53,27 +53,27 @@ void CefDevToolsFileManager::SaveToFile(const std::string& url,
const std::string& content, const std::string& content,
bool save_as) { bool save_as) {
Save(url, content, save_as, Save(url, content, save_as,
base::Bind(&CefDevToolsFileManager::FileSavedAs, base::BindOnce(&CefDevToolsFileManager::FileSavedAs,
weak_factory_.GetWeakPtr(), url), weak_factory_.GetWeakPtr(), url),
base::Bind(&CefDevToolsFileManager::CanceledFileSaveAs, base::BindOnce(&CefDevToolsFileManager::CanceledFileSaveAs,
weak_factory_.GetWeakPtr(), url)); weak_factory_.GetWeakPtr(), url));
} }
void CefDevToolsFileManager::AppendToFile(const std::string& url, void CefDevToolsFileManager::AppendToFile(const std::string& url,
const std::string& content) { const std::string& content) {
Append(url, content, Append(url, content,
base::Bind(&CefDevToolsFileManager::AppendedTo, base::BindOnce(&CefDevToolsFileManager::AppendedTo,
weak_factory_.GetWeakPtr(), url)); weak_factory_.GetWeakPtr(), url));
} }
void CefDevToolsFileManager::Save(const std::string& url, void CefDevToolsFileManager::Save(const std::string& url,
const std::string& content, const std::string& content,
bool save_as, bool save_as,
const SaveCallback& saveCallback, SaveCallback saveCallback,
const CancelCallback& cancelCallback) { CancelCallback cancelCallback) {
auto it = saved_files_.find(url); auto it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) { if (it != saved_files_.end() && !save_as) {
SaveAsFileSelected(url, content, saveCallback, it->second); SaveAsFileSelected(url, content, std::move(saveCallback), it->second);
return; return;
} }
@ -83,7 +83,7 @@ void CefDevToolsFileManager::Save(const std::string& url,
const base::Value* path_value; const base::Value* path_value;
if (file_map->Get(base::MD5String(url), &path_value)) { if (file_map->Get(base::MD5String(url), &path_value)) {
base::Optional<base::FilePath> path = util::ValueToFilePath(*path_value); absl::optional<base::FilePath> path = util::ValueToFilePath(*path_value);
if (path) if (path)
initial_path = std::move(*path); initial_path = std::move(*path);
} }
@ -116,28 +116,29 @@ void CefDevToolsFileManager::Save(const std::string& url,
} }
browser_impl_->RunFileChooser( browser_impl_->RunFileChooser(
params, base::Bind(&CefDevToolsFileManager::SaveAsDialogDismissed, params,
weak_factory_.GetWeakPtr(), url, content, saveCallback, base::BindOnce(&CefDevToolsFileManager::SaveAsDialogDismissed,
cancelCallback)); weak_factory_.GetWeakPtr(), url, content,
std::move(saveCallback), std::move(cancelCallback)));
} }
void CefDevToolsFileManager::SaveAsDialogDismissed( void CefDevToolsFileManager::SaveAsDialogDismissed(
const std::string& url, const std::string& url,
const std::string& content, const std::string& content,
const SaveCallback& saveCallback, SaveCallback saveCallback,
const CancelCallback& cancelCallback, CancelCallback cancelCallback,
int selected_accept_filter, int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) { const std::vector<base::FilePath>& file_paths) {
if (file_paths.size() == 1) { if (file_paths.size() == 1) {
SaveAsFileSelected(url, content, saveCallback, file_paths[0]); SaveAsFileSelected(url, content, std::move(saveCallback), file_paths[0]);
} else { } else {
cancelCallback.Run(); std::move(cancelCallback).Run();
} }
} }
void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url, void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
const std::string& content, const std::string& content,
const SaveCallback& callback, SaveCallback callback,
const base::FilePath& path) { const base::FilePath& path) {
*g_last_save_path.Pointer() = path; *g_last_save_path.Pointer() = path;
saved_files_[url] = path; saved_files_[url] = path;
@ -146,7 +147,7 @@ void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
base::DictionaryValue* files_map = update.Get(); base::DictionaryValue* files_map = update.Get();
files_map->SetKey(base::MD5String(url), util::FilePathToValue(path)); files_map->SetKey(base::MD5String(url), util::FilePathToValue(path));
std::string file_system_path = path.AsUTF8Unsafe(); std::string file_system_path = path.AsUTF8Unsafe();
callback.Run(file_system_path); std::move(callback).Run(file_system_path);
file_task_runner_->PostTask(FROM_HERE, file_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&::WriteToFile, path, content)); base::BindOnce(&::WriteToFile, path, content));
} }
@ -167,11 +168,11 @@ void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) {
void CefDevToolsFileManager::Append(const std::string& url, void CefDevToolsFileManager::Append(const std::string& url,
const std::string& content, const std::string& content,
const AppendCallback& callback) { AppendCallback callback) {
auto it = saved_files_.find(url); auto it = saved_files_.find(url);
if (it == saved_files_.end()) if (it == saved_files_.end())
return; return;
callback.Run(); std::move(callback).Run();
file_task_runner_->PostTask( file_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&::AppendToFile, it->second, content)); FROM_HERE, base::BindOnce(&::AppendToFile, it->second, content));
} }

View File

@ -36,31 +36,31 @@ class CefDevToolsFileManager {
private: private:
// SaveToFile implementation: // SaveToFile implementation:
typedef base::Callback<void(const std::string&)> SaveCallback; typedef base::OnceCallback<void(const std::string&)> SaveCallback;
typedef base::Callback<void()> CancelCallback; typedef base::OnceCallback<void()> CancelCallback;
void Save(const std::string& url, void Save(const std::string& url,
const std::string& content, const std::string& content,
bool save_as, bool save_as,
const SaveCallback& saveCallback, SaveCallback saveCallback,
const CancelCallback& cancelCallback); CancelCallback cancelCallback);
void SaveAsDialogDismissed(const std::string& url, void SaveAsDialogDismissed(const std::string& url,
const std::string& content, const std::string& content,
const SaveCallback& saveCallback, SaveCallback saveCallback,
const CancelCallback& cancelCallback, CancelCallback cancelCallback,
int selected_accept_filter, int selected_accept_filter,
const std::vector<base::FilePath>& file_paths); const std::vector<base::FilePath>& file_paths);
void SaveAsFileSelected(const std::string& url, void SaveAsFileSelected(const std::string& url,
const std::string& content, const std::string& content,
const SaveCallback& callback, SaveCallback callback,
const base::FilePath& path); const base::FilePath& path);
void FileSavedAs(const std::string& url, const std::string& file_system_path); void FileSavedAs(const std::string& url, const std::string& file_system_path);
void CanceledFileSaveAs(const std::string& url); void CanceledFileSaveAs(const std::string& url);
// AppendToFile implementation: // AppendToFile implementation:
typedef base::Callback<void(void)> AppendCallback; typedef base::OnceCallback<void(void)> AppendCallback;
void Append(const std::string& url, void Append(const std::string& url,
const std::string& content, const std::string& content,
const AppendCallback& callback); AppendCallback callback);
void AppendedTo(const std::string& url); void AppendedTo(const std::string& url);
void CallClientFunction(const std::string& function_name, void CallClientFunction(const std::string& function_name,

View File

@ -160,7 +160,7 @@ void LogProtocolMessage(const base::FilePath& log_file,
WriteTimestamp(stream); WriteTimestamp(stream);
stream << ": " << type_label << ": " << to_log << "\n"; stream << ": " << type_label << ": " << to_log << "\n";
const std::string& str = stream.str(); const std::string& str = stream.str();
if (!base::AppendToFile(log_file, str.c_str(), str.size())) { if (!base::AppendToFile(log_file, base::StringPiece(str))) {
LOG(ERROR) << "Failed to write file " << log_file.value(); LOG(ERROR) << "Failed to write file " << log_file.value();
log_error = true; log_error = true;
} }
@ -294,7 +294,7 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
void CefDevToolsFrontend::Close() { void CefDevToolsFrontend::Close() {
base::PostTask(FROM_HERE, {content::BrowserThread::UI}, base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::Bind(&AlloyBrowserHostImpl::CloseBrowser, base::BindOnce(&AlloyBrowserHostImpl::CloseBrowser,
frontend_browser_.get(), true)); frontend_browser_.get(), true));
} }
@ -323,8 +323,8 @@ void CefDevToolsFrontend::ReadyToCommitNavigation(
content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost(); content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost();
if (navigation_handle->IsInMainFrame()) { if (navigation_handle->IsInMainFrame()) {
frontend_host_ = content::DevToolsFrontendHost::Create( frontend_host_ = content::DevToolsFrontendHost::Create(
frame, frame, base::BindRepeating(
base::Bind(&CefDevToolsFrontend::HandleMessageFromDevToolsFrontend, &CefDevToolsFrontend::HandleMessageFromDevToolsFrontend,
base::Unretained(this))); base::Unretained(this)));
return; return;
} }
@ -367,13 +367,11 @@ void CefDevToolsFrontend::WebContentsDestroyed() {
} }
void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend( void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
const std::string& message) { base::Value message) {
std::string method; std::string method;
base::ListValue* params = nullptr; base::ListValue* params = nullptr;
base::DictionaryValue* dict = nullptr; base::DictionaryValue* dict = nullptr;
base::Optional<base::Value> parsed_message = base::JSONReader::Read(message); if (!message.GetAsDictionary(&dict) || !dict->GetString("method", &method)) {
if (!parsed_message || !parsed_message->GetAsDictionary(&dict) ||
!dict->GetString("method", &method)) {
return; return;
} }
int request_id = 0; int request_id = 0;
@ -461,8 +459,8 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
SendMessageAck(request_id, &response); SendMessageAck(request_id, &response);
return; return;
} else { } else {
auto* partition = content::BrowserContext::GetStoragePartitionForUrl( auto* partition =
web_contents()->GetBrowserContext(), gurl); web_contents()->GetBrowserContext()->GetStoragePartitionForUrl(gurl);
url_loader_factory = partition->GetURLLoaderFactoryForBrowserProcess(); url_loader_factory = partition->GetURLLoaderFactoryForBrowserProcess();
} }
@ -608,7 +606,7 @@ void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
const base::StringPiece& message) { const base::StringPiece& message) {
DCHECK(ProtocolLoggingEnabled()); DCHECK(ProtocolLoggingEnabled());
std::string to_log = message.substr(0, kMaxLogLineLength).as_string(); std::string to_log(message.substr(0, kMaxLogLineLength));
// Execute in an ordered context that allows blocking. // Execute in an ordered context that allows blocking.
auto task_runner = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner(); auto task_runner = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner();

View File

@ -70,7 +70,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override; void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host, void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) override; base::span<const uint8_t> message) override;
void HandleMessageFromDevToolsFrontend(const std::string& message); void HandleMessageFromDevToolsFrontend(base::Value message);
private: private:
// WebContentsObserver overrides // WebContentsObserver overrides

View File

@ -62,7 +62,7 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
void OnDevToolsEvent(const base::StringPiece& method, void OnDevToolsEvent(const base::StringPiece& method,
const base::StringPiece& params) override { const base::StringPiece& params) override {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
observer_->OnDevToolsEvent(browser_, method.as_string(), params.data(), observer_->OnDevToolsEvent(browser_, std::string(method), params.data(),
params.size()); params.size());
} }

View File

@ -83,7 +83,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
EXPECT_TRUE(parser.Initialize(message)); EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized()); EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent()); EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod", parser.method_.as_string().data()); EXPECT_STREQ("Test.myMethod", parser.method_.data());
EXPECT_TRUE(parser.params_.empty()); EXPECT_TRUE(parser.params_.empty());
parser.Reset(); parser.Reset();
@ -94,8 +94,8 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
EXPECT_TRUE(parser.Initialize(message)); EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized()); EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent()); EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod2", parser.method_.as_string().data()); EXPECT_STREQ("Test.myMethod2", parser.method_.data());
EXPECT_STREQ("{}", parser.params_.as_string().data()); EXPECT_STREQ("{}", parser.params_.data());
parser.Reset(); parser.Reset();
EXPECT_FALSE(parser.IsInitialized()); EXPECT_FALSE(parser.IsInitialized());
@ -105,8 +105,8 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
EXPECT_TRUE(parser.Initialize(message)); EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized()); EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent()); EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod3", parser.method_.as_string().data()); EXPECT_STREQ("Test.myMethod3", parser.method_.data());
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data()); EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.data());
} }
TEST(DevToolsUtil, ProtocolParser_Initialize_IsFailure_ResultMalformed) { TEST(DevToolsUtil, ProtocolParser_Initialize_IsFailure_ResultMalformed) {
@ -162,7 +162,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Result) {
EXPECT_TRUE(parser.IsResult()); EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(1, parser.message_id_); EXPECT_EQ(1, parser.message_id_);
EXPECT_TRUE(parser.success_); EXPECT_TRUE(parser.success_);
EXPECT_STREQ("{}", parser.params_.as_string().data()); EXPECT_STREQ("{}", parser.params_.data());
parser.Reset(); parser.Reset();
EXPECT_FALSE(parser.IsInitialized()); EXPECT_FALSE(parser.IsInitialized());
@ -174,7 +174,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Result) {
EXPECT_TRUE(parser.IsResult()); EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(2, parser.message_id_); EXPECT_EQ(2, parser.message_id_);
EXPECT_TRUE(parser.success_); EXPECT_TRUE(parser.success_);
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data()); EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.data());
} }
TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) { TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
@ -188,7 +188,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
EXPECT_TRUE(parser.IsResult()); EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(1, parser.message_id_); EXPECT_EQ(1, parser.message_id_);
EXPECT_FALSE(parser.success_); EXPECT_FALSE(parser.success_);
EXPECT_STREQ("{}", parser.params_.as_string().data()); EXPECT_STREQ("{}", parser.params_.data());
parser.Reset(); parser.Reset();
EXPECT_FALSE(parser.IsInitialized()); EXPECT_FALSE(parser.IsInitialized());
@ -200,5 +200,5 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
EXPECT_TRUE(parser.IsResult()); EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(2, parser.message_id_); EXPECT_EQ(2, parser.message_id_);
EXPECT_FALSE(parser.success_); EXPECT_FALSE(parser.success_);
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data()); EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.data());
} }

View File

@ -153,7 +153,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN, suggested_path, download::DownloadItem::MixedContentStatus::UNKNOWN, suggested_path,
base::nullopt /*download_schedule*/, absl::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE); download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
} }
@ -172,7 +172,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
std::move(callback).Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, std::move(callback).Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN, download::DownloadItem::MixedContentStatus::UNKNOWN,
path, base::nullopt /*download_schedule*/, path, absl::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE); download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
@ -195,17 +195,17 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
void Cancel() override { void Cancel() override {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefDownloadItemCallbackImpl::DoCancel, this)); base::BindOnce(&CefDownloadItemCallbackImpl::DoCancel, this));
} }
void Pause() override { void Pause() override {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefDownloadItemCallbackImpl::DoPause, this)); base::BindOnce(&CefDownloadItemCallbackImpl::DoPause, this));
} }
void Resume() override { void Resume() override {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefDownloadItemCallbackImpl::DoResume, this)); base::BindOnce(&CefDownloadItemCallbackImpl::DoResume, this));
} }
private: private:
@ -358,7 +358,7 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE, item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN, download::DownloadItem::MixedContentStatus::UNKNOWN,
item->GetForcedFilePath(), base::nullopt /*download_schedule*/, item->GetForcedFilePath(), absl::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE); download::DOWNLOAD_INTERRUPT_REASON_NONE);
return true; return true;
} }

View File

@ -17,6 +17,8 @@
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
#include "third_party/blink/public/common/page/page_zoom.h" #include "third_party/blink/public/common/page/page_zoom.h"
using zoom::ZoomController;
namespace extensions { namespace extensions {
namespace cef { namespace cef {
@ -256,153 +258,124 @@ content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
return browser->web_contents(); return browser->web_contents();
} }
void ZoomAPIFunction::SendResponse(bool success) { ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
ResponseValue response;
if (success) {
response = ArgumentList(std::move(results_));
} else {
response = results_ ? ErrorWithArguments(std::move(results_), error_)
: Error(error_);
}
Respond(std::move(response));
}
ExtensionFunction::ResponseAction ZoomAPIFunction::Run() {
if (RunAsync())
return RespondLater();
// TODO(devlin): Track these down and eliminate them if possible. We
// shouldn't return results and an error.
if (results_)
return RespondNow(ErrorWithArguments(std::move(results_), error_));
return RespondNow(Error(error_));
}
bool TabsSetZoomFunction::RunAsync() {
std::unique_ptr<tabs::SetZoom::Params> params( std::unique_ptr<tabs::SetZoom::Params> params(
tabs::SetZoom::Params::Create(*args_)); tabs::SetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_PRERUN_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents) if (!web_contents)
return false; return RespondNow(Error(std::move(error_)));
GURL url(web_contents->GetVisibleURL()); GURL url(web_contents->GetVisibleURL());
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_)) if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return false; return RespondNow(Error(std::move(error_)));
zoom::ZoomController* zoom_controller = ZoomController* zoom_controller =
zoom::ZoomController::FromWebContents(web_contents); ZoomController::FromWebContents(web_contents);
double zoom_level = double zoom_level =
params->zoom_factor > 0 params->zoom_factor > 0
? blink::PageZoomFactorToZoomLevel(params->zoom_factor) ? blink::PageZoomFactorToZoomLevel(params->zoom_factor)
: zoom_controller->GetDefaultZoomLevel(); : zoom_controller->GetDefaultZoomLevel();
scoped_refptr<extensions::ExtensionZoomRequestClient> client( auto client = base::MakeRefCounted<ExtensionZoomRequestClient>(extension());
new extensions::ExtensionZoomRequestClient(extension()));
if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) { if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) {
// Tried to zoom a tab in disabled mode. // Tried to zoom a tab in disabled mode.
error_ = keys::kCannotZoomDisabledTabError; return RespondNow(Error(tabs_constants::kCannotZoomDisabledTabError));
return false;
} }
SendResponse(true); return RespondNow(NoArguments());
return true;
} }
bool TabsGetZoomFunction::RunAsync() { ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
std::unique_ptr<tabs::GetZoom::Params> params( std::unique_ptr<tabs::GetZoom::Params> params(
tabs::GetZoom::Params::Create(*args_)); tabs::GetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_PRERUN_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents) if (!web_contents)
return false; return RespondNow(Error(std::move(error_)));
double zoom_level = double zoom_level =
zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel(); zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel();
double zoom_factor = blink::PageZoomLevelToZoomFactor(zoom_level); double zoom_factor = blink::PageZoomLevelToZoomFactor(zoom_level);
results_ = tabs::GetZoom::Results::Create(zoom_factor);
SendResponse(true); return RespondNow(ArgumentList(tabs::GetZoom::Results::Create(zoom_factor)));
return true;
} }
bool TabsSetZoomSettingsFunction::RunAsync() { ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
using api::tabs::ZoomSettings; using api::tabs::ZoomSettings;
std::unique_ptr<tabs::SetZoomSettings::Params> params( std::unique_ptr<tabs::SetZoomSettings::Params> params(
tabs::SetZoomSettings::Params::Create(*args_)); tabs::SetZoomSettings::Params::Create(*args_));
EXTENSION_FUNCTION_PRERUN_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents) if (!web_contents)
return false; return RespondNow(Error(std::move(error_)));
GURL url(web_contents->GetVisibleURL()); GURL url(web_contents->GetVisibleURL());
std::string error;
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_)) if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return false; return RespondNow(Error(std::move(error_)));
// "per-origin" scope is only available in "automatic" mode. // "per-origin" scope is only available in "automatic" mode.
if (params->zoom_settings.scope == tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN && if (params->zoom_settings.scope == tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN &&
params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_AUTOMATIC && params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_AUTOMATIC &&
params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_NONE) { params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_NONE) {
error_ = keys::kPerOriginOnlyInAutomaticError; return RespondNow(Error(tabs_constants::kPerOriginOnlyInAutomaticError));
return false;
} }
// Determine the correct internal zoom mode to set |web_contents| to from the // Determine the correct internal zoom mode to set |web_contents| to from the
// user-specified |zoom_settings|. // user-specified |zoom_settings|.
zoom::ZoomController::ZoomMode zoom_mode = ZoomController::ZoomMode zoom_mode = ZoomController::ZOOM_MODE_DEFAULT;
zoom::ZoomController::ZOOM_MODE_DEFAULT;
switch (params->zoom_settings.mode) { switch (params->zoom_settings.mode) {
case tabs::ZOOM_SETTINGS_MODE_NONE: case tabs::ZOOM_SETTINGS_MODE_NONE:
case tabs::ZOOM_SETTINGS_MODE_AUTOMATIC: case tabs::ZOOM_SETTINGS_MODE_AUTOMATIC:
switch (params->zoom_settings.scope) { switch (params->zoom_settings.scope) {
case tabs::ZOOM_SETTINGS_SCOPE_NONE: case tabs::ZOOM_SETTINGS_SCOPE_NONE:
case tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN: case tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN:
zoom_mode = zoom::ZoomController::ZOOM_MODE_DEFAULT; zoom_mode = ZoomController::ZOOM_MODE_DEFAULT;
break; break;
case tabs::ZOOM_SETTINGS_SCOPE_PER_TAB: case tabs::ZOOM_SETTINGS_SCOPE_PER_TAB:
zoom_mode = zoom::ZoomController::ZOOM_MODE_ISOLATED; zoom_mode = ZoomController::ZOOM_MODE_ISOLATED;
} }
break; break;
case tabs::ZOOM_SETTINGS_MODE_MANUAL: case tabs::ZOOM_SETTINGS_MODE_MANUAL:
zoom_mode = zoom::ZoomController::ZOOM_MODE_MANUAL; zoom_mode = ZoomController::ZOOM_MODE_MANUAL;
break; break;
case tabs::ZOOM_SETTINGS_MODE_DISABLED: case tabs::ZOOM_SETTINGS_MODE_DISABLED:
zoom_mode = zoom::ZoomController::ZOOM_MODE_DISABLED; zoom_mode = ZoomController::ZOOM_MODE_DISABLED;
} }
zoom::ZoomController::FromWebContents(web_contents)->SetZoomMode(zoom_mode); ZoomController::FromWebContents(web_contents)->SetZoomMode(zoom_mode);
SendResponse(true); return RespondNow(NoArguments());
return true;
} }
bool TabsGetZoomSettingsFunction::RunAsync() { ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
std::unique_ptr<tabs::GetZoomSettings::Params> params( std::unique_ptr<tabs::GetZoomSettings::Params> params(
tabs::GetZoomSettings::Params::Create(*args_)); tabs::GetZoomSettings::Params::Create(*args_));
EXTENSION_FUNCTION_PRERUN_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents) if (!web_contents)
return false; return RespondNow(Error(std::move(error_)));
zoom::ZoomController* zoom_controller = ZoomController* zoom_controller =
zoom::ZoomController::FromWebContents(web_contents); ZoomController::FromWebContents(web_contents);
zoom::ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
api::tabs::ZoomSettings zoom_settings; api::tabs::ZoomSettings zoom_settings;
ZoomModeToZoomSettings(zoom_mode, &zoom_settings); ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
zoom_settings.default_zoom_factor.reset( zoom_settings.default_zoom_factor = std::make_unique<double>(
new double(blink::PageZoomLevelToZoomFactor( blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()));
zoom_controller->GetDefaultZoomLevel())));
results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); return RespondNow(
SendResponse(true); ArgumentList(api::tabs::GetZoomSettings::Results::Create(zoom_settings)));
return true;
} }
} // namespace cef } // namespace cef

View File

@ -108,23 +108,9 @@ class ZoomAPIFunction : public ExtensionFunction {
// may set |error_|. // may set |error_|.
content::WebContents* GetWebContents(int tab_id); content::WebContents* GetWebContents(int tab_id);
virtual bool RunAsync() = 0;
// Responds with success/failure. |results_| or |error_| should be set
// accordingly.
void SendResponse(bool success);
// Exposed versions of ExtensionFunction::results_ and
// ExtensionFunction::error_ that are curried into the response.
// These need to keep the same name to avoid breaking existing
// implementations, but this should be temporary with crbug.com/648275
// and crbug.com/634140.
std::unique_ptr<base::ListValue> results_;
std::string error_; std::string error_;
private: private:
ResponseAction Run() final;
const CefExtensionFunctionDetails cef_details_; const CefExtensionFunctionDetails cef_details_;
}; };
@ -132,7 +118,7 @@ class TabsSetZoomFunction : public ZoomAPIFunction {
private: private:
~TabsSetZoomFunction() override {} ~TabsSetZoomFunction() override {}
bool RunAsync() override; ResponseAction Run() override;
DECLARE_EXTENSION_FUNCTION("tabs.setZoom", TABS_SETZOOM) DECLARE_EXTENSION_FUNCTION("tabs.setZoom", TABS_SETZOOM)
}; };
@ -141,7 +127,7 @@ class TabsGetZoomFunction : public ZoomAPIFunction {
private: private:
~TabsGetZoomFunction() override {} ~TabsGetZoomFunction() override {}
bool RunAsync() override; ResponseAction Run() override;
DECLARE_EXTENSION_FUNCTION("tabs.getZoom", TABS_GETZOOM) DECLARE_EXTENSION_FUNCTION("tabs.getZoom", TABS_GETZOOM)
}; };
@ -150,7 +136,7 @@ class TabsSetZoomSettingsFunction : public ZoomAPIFunction {
private: private:
~TabsSetZoomSettingsFunction() override {} ~TabsSetZoomSettingsFunction() override {}
bool RunAsync() override; ResponseAction Run() override;
DECLARE_EXTENSION_FUNCTION("tabs.setZoomSettings", TABS_SETZOOMSETTINGS) DECLARE_EXTENSION_FUNCTION("tabs.setZoomSettings", TABS_SETZOOMSETTINGS)
}; };
@ -159,7 +145,7 @@ class TabsGetZoomSettingsFunction : public ZoomAPIFunction {
private: private:
~TabsGetZoomSettingsFunction() override {} ~TabsGetZoomSettingsFunction() override {}
bool RunAsync() override; ResponseAction Run() override;
DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS) DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS)
}; };

View File

@ -54,8 +54,8 @@ void GetAllGuestsForOwnerContents(content::WebContents* owner,
std::vector<content::WebContents*>* guests) { std::vector<content::WebContents*>* guests) {
content::BrowserPluginGuestManager* plugin_guest_manager = content::BrowserPluginGuestManager* plugin_guest_manager =
owner->GetBrowserContext()->GetGuestManager(); owner->GetBrowserContext()->GetGuestManager();
plugin_guest_manager->ForEachGuest(owner, plugin_guest_manager->ForEachGuest(
base::Bind(InsertWebContents, guests)); owner, base::BindRepeating(InsertWebContents, guests));
} }
content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) { content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {

View File

@ -29,7 +29,7 @@ void CefBrowserPlatformDelegateBackground::CloseHostWindow() {
// No host window, so continue browser destruction now. Do it asynchronously // No host window, so continue browser destruction now. Do it asynchronously
// so the call stack has a chance to unwind. // so the call stack has a chance to unwind.
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&AlloyBrowserHostImpl::WindowDestroyed, base::BindOnce(&AlloyBrowserHostImpl::WindowDestroyed,
static_cast<AlloyBrowserHostImpl*>(browser_))); static_cast<AlloyBrowserHostImpl*>(browser_)));
} }

View File

@ -13,6 +13,7 @@
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h" #include "libcef/common/extensions/extensions_util.h"
#include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
@ -446,7 +447,7 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
// manifest settings. // manifest settings.
content::GetIOThreadTaskRunner({})->PostTaskAndReply( content::GetIOThreadTaskRunner({})->PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(&InfoMap::AddExtension, info_map(), base::BindOnce(&InfoMap::AddExtension, info_map(),
base::RetainedRef(extension), base::Time::Now(), base::RetainedRef(extension), base::Time::Now(),
true, // incognito_enabled true, // incognito_enabled
false), // notifications_disabled false), // notifications_disabled
@ -459,8 +460,8 @@ void CefExtensionSystem::UnregisterExtensionWithRequestContexts(
const std::string& extension_id, const std::string& extension_id,
const UnloadedExtensionReason reason) { const UnloadedExtensionReason reason) {
content::GetIOThreadTaskRunner({})->PostTask( content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(&InfoMap::RemoveExtension, info_map(),
base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); extension_id, reason));
} }
const base::OneShotEvent& CefExtensionSystem::ready() const { const base::OneShotEvent& CefExtensionSystem::ready() const {
@ -634,9 +635,9 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
// extension. // extension.
RegisterExtensionWithRequestContexts( RegisterExtensionWithRequestContexts(
extension, extension,
base::Bind(&CefExtensionSystem::OnExtensionRegisteredWithRequestContexts, base::BindOnce(
weak_ptr_factory_.GetWeakPtr(), &CefExtensionSystem::OnExtensionRegisteredWithRequestContexts,
base::WrapRefCounted(extension))); weak_ptr_factory_.GetWeakPtr(), base::WrapRefCounted(extension)));
// Tell renderers about the loaded extension. // Tell renderers about the loaded extension.
renderer_helper_->OnExtensionLoaded(*extension); renderer_helper_->OnExtensionLoaded(*extension);

View File

@ -9,6 +9,7 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
namespace extensions { namespace extensions {
@ -45,7 +46,7 @@ void CefExtensionWebContentsObserver::RenderFrameCreated(
if ((extension->is_extension() || extension->is_platform_app()) && if ((extension->is_extension() || extension->is_platform_app()) &&
Manifest::IsComponentLocation(extension->location())) { Manifest::IsComponentLocation(extension->location())) {
policy->GrantRequestOrigin( policy->GrantRequestOrigin(
process_id, url::Origin::Create(GURL(content::kChromeUIResourcesURL))); process_id, url::Origin::Create(GURL(blink::kChromeUIResourcesURL)));
policy->GrantRequestOrigin( policy->GrantRequestOrigin(
process_id, url::Origin::Create(GURL(chrome::kChromeUIThemeURL))); process_id, url::Origin::Create(GURL(chrome::kChromeUIThemeURL)));
} }

View File

@ -100,8 +100,8 @@ ValueStore::WriteResult CefValueStore::Set(
!old_value->Equals(&it.value())) { !old_value->Equals(&it.value())) {
changes.emplace_back(it.key(), changes.emplace_back(it.key(),
old_value old_value
? base::Optional<base::Value>(old_value->Clone()) ? absl::optional<base::Value>(old_value->Clone())
: base::nullopt, : absl::nullopt,
it.value().Clone()); it.value().Clone());
storage_.SetWithoutPathExpansion(it.key(), it.value().CreateDeepCopy()); storage_.SetWithoutPathExpansion(it.key(), it.value().CreateDeepCopy());
} }
@ -123,7 +123,7 @@ ValueStore::WriteResult CefValueStore::Remove(
for (auto it = keys.cbegin(); it != keys.cend(); ++it) { for (auto it = keys.cbegin(); it != keys.cend(); ++it) {
std::unique_ptr<base::Value> old_value; std::unique_ptr<base::Value> old_value;
if (storage_.RemoveWithoutPathExpansion(*it, &old_value)) { if (storage_.RemoveWithoutPathExpansion(*it, &old_value)) {
changes.emplace_back(*it, std::move(*old_value), base::nullopt); changes.emplace_back(*it, std::move(*old_value), absl::nullopt);
} }
} }
return WriteResult(std::move(changes), CreateStatusCopy(status_)); return WriteResult(std::move(changes), CreateStatusCopy(status_));

View File

@ -197,7 +197,7 @@ void CefFileDialogManager::RunFileDialog(
params.accept_types.push_back(*it); params.accept_types.push_back(*it);
} }
RunFileChooser(params, base::Bind(RunFileDialogDismissed, callback)); RunFileChooser(params, base::BindOnce(RunFileDialogDismissed, callback));
} }
void CefFileDialogManager::RunFileChooser( void CefFileDialogManager::RunFileChooser(

View File

@ -590,7 +590,7 @@ void CefFrameHostImpl::DidFinishFrameLoad(const GURL& validated_url,
} }
void CefFrameHostImpl::UpdateDraggableRegions( void CefFrameHostImpl::UpdateDraggableRegions(
base::Optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) { absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
auto browser = GetBrowserHostBase(); auto browser = GetBrowserHostBase();
if (!browser) if (!browser)
return; return;

View File

@ -124,7 +124,7 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
void DidFinishFrameLoad(const GURL& validated_url, void DidFinishFrameLoad(const GURL& validated_url,
int32_t http_status_code) override; int32_t http_status_code) override;
void UpdateDraggableRegions( void UpdateDraggableRegions(
base::Optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
override; override;
static int64_t MakeFrameId(const content::RenderFrameHost* host); static int64_t MakeFrameId(const content::RenderFrameHost* host);

View File

@ -366,7 +366,7 @@ bool CefImageImpl::ConvertBitmap(const SkBitmap& src_bitmap,
// static // static
bool CefImageImpl::WriteCompressedFormat(const SkBitmap& bitmap, bool CefImageImpl::WriteCompressedFormat(const SkBitmap& bitmap,
std::vector<unsigned char>* compressed, std::vector<unsigned char>* compressed,
const CompressionMethod& method) { CompressionMethod method) {
const SkBitmap* bitmap_ptr = nullptr; const SkBitmap* bitmap_ptr = nullptr;
SkBitmap bitmap_postalpha; SkBitmap bitmap_postalpha;
if (bitmap.alphaType() == kPremul_SkAlphaType) { if (bitmap.alphaType() == kPremul_SkAlphaType) {
@ -386,7 +386,7 @@ bool CefImageImpl::WriteCompressedFormat(const SkBitmap& bitmap,
DCHECK(bitmap_ptr->alphaType() == kOpaque_SkAlphaType || DCHECK(bitmap_ptr->alphaType() == kOpaque_SkAlphaType ||
bitmap_ptr->alphaType() == kUnpremul_SkAlphaType); bitmap_ptr->alphaType() == kUnpremul_SkAlphaType);
return method.Run(*bitmap_ptr, compressed); return std::move(method).Run(*bitmap_ptr, compressed);
} }
// static // static
@ -394,7 +394,7 @@ bool CefImageImpl::WritePNG(const SkBitmap& bitmap,
std::vector<unsigned char>* compressed, std::vector<unsigned char>* compressed,
bool with_transparency) { bool with_transparency) {
return WriteCompressedFormat(bitmap, compressed, return WriteCompressedFormat(bitmap, compressed,
base::Bind(PNGMethod, with_transparency)); base::BindOnce(PNGMethod, with_transparency));
} }
// static // static
@ -402,5 +402,5 @@ bool CefImageImpl::WriteJPEG(const SkBitmap& bitmap,
std::vector<unsigned char>* compressed, std::vector<unsigned char>* compressed,
int quality) { int quality) {
return WriteCompressedFormat(bitmap, compressed, return WriteCompressedFormat(bitmap, compressed,
base::Bind(JPEGMethod, quality)); base::BindOnce(JPEGMethod, quality));
} }

View File

@ -95,14 +95,14 @@ class CefImageImpl : public CefImage {
// The |bitmap| argument will be RGBA or BGRA and either opaque or transparent // The |bitmap| argument will be RGBA or BGRA and either opaque or transparent
// with post-multiplied alpha. Writes the compressed output into |compressed|. // with post-multiplied alpha. Writes the compressed output into |compressed|.
typedef base::Callback<bool(const SkBitmap& /*bitmap*/, typedef base::OnceCallback<bool(const SkBitmap& /*bitmap*/,
std::vector<unsigned char>* /*compressed*/)> std::vector<unsigned char>* /*compressed*/)>
CompressionMethod; CompressionMethod;
// Write |bitmap| into |compressed| using |method|. // Write |bitmap| into |compressed| using |method|.
static bool WriteCompressedFormat(const SkBitmap& bitmap, static bool WriteCompressedFormat(const SkBitmap& bitmap,
std::vector<unsigned char>* compressed, std::vector<unsigned char>* compressed,
const CompressionMethod& method); CompressionMethod method);
// Write |bitmap| into |compressed| using PNG encoding. // Write |bitmap| into |compressed| using PNG encoding.
static bool WritePNG(const SkBitmap& bitmap, static bool WritePNG(const SkBitmap& bitmap,

View File

@ -19,7 +19,7 @@ CefIOThreadState::CefIOThreadState() {
// Using base::Unretained() is safe because both this callback and possible // Using base::Unretained() is safe because both this callback and possible
// deletion of |this| will execute on the IO thread, and this callback will // deletion of |this| will execute on the IO thread, and this callback will
// be executed first. // be executed first.
CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::InitOnIOThread, CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefIOThreadState::InitOnIOThread,
base::Unretained(this))); base::Unretained(this)));
} }

View File

@ -426,7 +426,7 @@ bool CefMainRunner::ContentMainRun(bool* initialized,
return true; return true;
} }
void CefMainRunner::PreCreateMainMessageLoop() { void CefMainRunner::PreBrowserMain() {
if (external_message_pump_) { if (external_message_pump_) {
InitExternalMessagePumpFactoryForUI(); InitExternalMessagePumpFactoryForUI();
} }
@ -439,7 +439,7 @@ int CefMainRunner::RunMainProcess(
browser_runner_ = content::BrowserMainRunner::Create(); browser_runner_ = content::BrowserMainRunner::Create();
// Initialize browser process state. Results in a call to // Initialize browser process state. Results in a call to
// AlloyBrowserMain::PreMainMessageLoopStart() which creates the UI message // AlloyBrowserMain::PreBrowserMain() which creates the UI message
// loop. // loop.
int exit_code = browser_runner_->Initialize(main_function_params); int exit_code = browser_runner_->Initialize(main_function_params);
if (exit_code >= 0) if (exit_code >= 0)

View File

@ -60,7 +60,7 @@ class CefMainRunner : public CefMainRunnerHandler {
bool ContentMainRun(bool* initialized, base::OnceClosure context_initialized); bool ContentMainRun(bool* initialized, base::OnceClosure context_initialized);
// CefMainRunnerHandler methods: // CefMainRunnerHandler methods:
void PreCreateMainMessageLoop() override; void PreBrowserMain() override;
int RunMainProcess( int RunMainProcess(
const content::MainFunctionParams& main_function_params) override; const content::MainFunctionParams& main_function_params) override;

View File

@ -162,7 +162,7 @@ void CefMediaRouterImpl::Initialize(
if (callback) { if (callback) {
// Execute client callback asynchronously for consistency. // Execute client callback asynchronously for consistency.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefCompletionCallback::OnComplete, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefCompletionCallback::OnComplete,
callback.get())); callback.get()));
} }
} }

View File

@ -35,21 +35,21 @@ const cef_event_flags_t kEmptyEventFlags = static_cast<cef_event_flags_t>(0);
class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback { class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
public: public:
typedef base::Callback<void(int, cef_event_flags_t)> Callback; typedef base::OnceCallback<void(int, cef_event_flags_t)> Callback;
explicit CefRunContextMenuCallbackImpl(const Callback& callback) explicit CefRunContextMenuCallbackImpl(Callback callback)
: callback_(callback) {} : callback_(std::move(callback)) {}
~CefRunContextMenuCallbackImpl() { ~CefRunContextMenuCallbackImpl() {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The callback is still pending. Cancel it now. // The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
RunNow(callback_, kInvalidCommandId, kEmptyEventFlags); RunNow(std::move(callback_), kInvalidCommandId, kEmptyEventFlags);
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(CEF_UIT,
CEF_UIT, base::BindOnce(&CefRunContextMenuCallbackImpl::RunNow,
base::Bind(&CefRunContextMenuCallbackImpl::RunNow, callback_, std::move(callback_), kInvalidCommandId,
kInvalidCommandId, kEmptyEventFlags)); kEmptyEventFlags));
} }
} }
} }
@ -57,13 +57,13 @@ class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
void Continue(int command_id, cef_event_flags_t event_flags) override { void Continue(int command_id, cef_event_flags_t event_flags) override {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
RunNow(callback_, command_id, event_flags); RunNow(std::move(callback_), command_id, event_flags);
callback_.Reset(); callback_.Reset();
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefRunContextMenuCallbackImpl::Continue, this, base::BindOnce(&CefRunContextMenuCallbackImpl::Continue,
command_id, event_flags)); this, command_id, event_flags));
} }
} }
@ -72,11 +72,11 @@ class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
void Disconnect() { callback_.Reset(); } void Disconnect() { callback_.Reset(); }
private: private:
static void RunNow(const Callback& callback, static void RunNow(Callback callback,
int command_id, int command_id,
cef_event_flags_t event_flags) { cef_event_flags_t event_flags) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
callback.Run(command_id, event_flags); std::move(callback).Run(command_id, event_flags);
} }
Callback callback_; Callback callback_;
@ -154,7 +154,7 @@ bool CefMenuManager::CreateContextMenu(
if (model_->GetCount() > 0) { if (model_->GetCount() > 0) {
CefRefPtr<CefRunContextMenuCallbackImpl> callbackImpl( CefRefPtr<CefRunContextMenuCallbackImpl> callbackImpl(
new CefRunContextMenuCallbackImpl( new CefRunContextMenuCallbackImpl(
base::Bind(&CefMenuManager::ExecuteCommandCallback, base::BindOnce(&CefMenuManager::ExecuteCommandCallback,
weak_ptr_factory_.GetWeakPtr()))); weak_ptr_factory_.GetWeakPtr())));
// This reference will be cleared when the callback is executed or // This reference will be cleared when the callback is executed or

View File

@ -785,8 +785,8 @@ void CefMenuModelImpl::MouseOutsideMenu(const gfx::Point& screen_point) {
// Allow the callstack to unwind before notifying the delegate since it may // Allow the callstack to unwind before notifying the delegate since it may
// result in the menu being destroyed. // result in the menu being destroyed.
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(&CefMenuModelImpl::OnMouseOutsideMenu, this,
base::Bind(&CefMenuModelImpl::OnMouseOutsideMenu, this, screen_point)); screen_point));
} }
void CefMenuModelImpl::UnhandledOpenSubmenu(bool is_rtl) { void CefMenuModelImpl::UnhandledOpenSubmenu(bool is_rtl) {
@ -797,7 +797,7 @@ void CefMenuModelImpl::UnhandledOpenSubmenu(bool is_rtl) {
// result in the menu being destroyed. // result in the menu being destroyed.
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&CefMenuModelImpl::OnUnhandledOpenSubmenu, this, is_rtl)); base::BindOnce(&CefMenuModelImpl::OnUnhandledOpenSubmenu, this, is_rtl));
} }
void CefMenuModelImpl::UnhandledCloseSubmenu(bool is_rtl) { void CefMenuModelImpl::UnhandledCloseSubmenu(bool is_rtl) {
@ -808,7 +808,7 @@ void CefMenuModelImpl::UnhandledCloseSubmenu(bool is_rtl) {
// result in the menu being destroyed. // result in the menu being destroyed.
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&CefMenuModelImpl::OnUnhandledCloseSubmenu, this, is_rtl)); base::BindOnce(&CefMenuModelImpl::OnUnhandledCloseSubmenu, this, is_rtl));
} }
bool CefMenuModelImpl::GetTextColor(int index, bool CefMenuModelImpl::GetTextColor(int index,
@ -883,7 +883,7 @@ void CefMenuModelImpl::MenuWillClose() {
// called after this. It's more convenient for the delegate to be called // called after this. It's more convenient for the delegate to be called
// afterwards, though, so post a task. // afterwards, though, so post a task.
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
FROM_HERE, base::Bind(&CefMenuModelImpl::OnMenuClosed, this)); FROM_HERE, base::BindOnce(&CefMenuModelImpl::OnMenuClosed, this));
} }
std::u16string CefMenuModelImpl::GetFormattedLabelAt(int index) { std::u16string CefMenuModelImpl::GetFormattedLabelAt(int index) {

View File

@ -349,7 +349,7 @@ void CefBrowserPlatformDelegateNativeWin::ViewText(const std::string& text) {
std::string str = text; std::string str = text;
scoped_refptr<base::RefCountedString> str_ref = scoped_refptr<base::RefCountedString> str_ref =
base::RefCountedString::TakeString(&str); base::RefCountedString::TakeString(&str);
CEF_POST_USER_VISIBLE_TASK(base::Bind(WriteTempFileAndView, str_ref)); CEF_POST_USER_VISIBLE_TASK(base::BindOnce(WriteTempFileAndView, str_ref));
} }
bool CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent( bool CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
@ -395,7 +395,7 @@ bool CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
// static // static
void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) { void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {
CEF_POST_USER_VISIBLE_TASK(base::Bind(ExecuteExternalProtocol, url)); CEF_POST_USER_VISIBLE_TASK(base::BindOnce(ExecuteExternalProtocol, url));
} }
CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle( CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(

View File

@ -36,7 +36,7 @@ bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor) {
#if defined(USE_AURA) #if defined(USE_AURA)
CefCursorHandle platform_cursor; CefCursorHandle platform_cursor;
ui::PlatformCursor image_cursor = nullptr; scoped_refptr<ui::PlatformCursor> image_cursor;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) { if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
image_cursor = ui::CursorFactory::GetInstance()->CreateImageCursor( image_cursor = ui::CursorFactory::GetInstance()->CreateImageCursor(
@ -49,10 +49,6 @@ bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor) {
handled = handler->OnCursorChange(browser, platform_cursor, cursor_type, handled = handler->OnCursorChange(browser, platform_cursor, cursor_type,
custom_cursor_info); custom_cursor_info);
if (image_cursor) {
ui::CursorFactory::GetInstance()->UnrefImageCursor(image_cursor);
}
#elif defined(OS_MAC) #elif defined(OS_MAC)
// |web_cursor| owns the resulting |native_cursor|. // |web_cursor| owns the resulting |native_cursor|.
content::WebCursor web_cursor(ui_cursor); content::WebCursor web_cursor(ui_cursor);

View File

@ -10,13 +10,17 @@
#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h" #include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#if defined(USE_AURA)
#include "ui/base/cursor/platform_cursor.h"
#endif
class CefBrowserHostBase; class CefBrowserHostBase;
namespace cursor_util { namespace cursor_util {
#if defined(USE_AURA) #if defined(USE_AURA)
cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type); cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type);
cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor); cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor);
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
// Returns true if the client handled the cursor change. // Returns true if the client handled the cursor change.

View File

@ -8,6 +8,8 @@
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/base/x/x11_cursor.h" #include "ui/base/x/x11_cursor.h"
#elif defined(USE_OZONE)
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#endif #endif
namespace cursor_util { namespace cursor_util {
@ -20,13 +22,16 @@ cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) {
return 0; return 0;
} }
cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor) { cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor) {
#if defined(USE_X11) #if defined(USE_X11)
// See https://crbug.com/1029142 for background. // See https://crbug.com/1029142 for background.
return static_cast<cef_cursor_handle_t>( return static_cast<cef_cursor_handle_t>(
static_cast<ui::X11Cursor*>(cursor)->xcursor()); ui::X11Cursor::FromPlatformCursor(cursor)->xcursor());
#elif defined(USE_OZONE)
return static_cast<cef_cursor_handle_t>(
ui::BitmapCursorOzone::FromPlatformCursor(cursor)->platform_data());
#else #else
return cursor; return 0;
#endif #endif
} }

View File

@ -156,8 +156,8 @@ cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) {
return LoadCursor(module_handle, cursor_id); return LoadCursor(module_handle, cursor_id);
} }
cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor) { cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor) {
return static_cast<ui::WinCursor*>(cursor)->hcursor(); return ui::WinCursor::FromPlatformCursor(cursor)->hcursor();
} }
} // namespace cursor_util } // namespace cursor_util

View File

@ -487,7 +487,7 @@ void CefNativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) {
// does. // does.
menu_to_select_factory_.InvalidateWeakPtrs(); menu_to_select_factory_.InvalidateWeakPtrs();
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&CefNativeMenuWin::DelayedSelect, FROM_HERE, base::BindOnce(&CefNativeMenuWin::DelayedSelect,
menu_to_select_factory_.GetWeakPtr())); menu_to_select_factory_.GetWeakPtr()));
menu_action_ = MENU_ACTION_SELECTED; menu_action_ = MENU_ACTION_SELECTED;
} }

View File

@ -48,7 +48,7 @@ void CefWindowDelegateView::Init(gfx::AcceleratedWidget parent_widget,
params.remove_standard_frame = true; params.remove_standard_frame = true;
// Cause WidgetDelegate::CanActivate to return true. See comments in // Cause WidgetDelegate::CanActivate to return true. See comments in
// AlloyBrowserHostImpl::PlatformSetFocus. // AlloyBrowserHostImpl::PlatformSetFocus.
params.activatable = views::Widget::InitParams::ACTIVATABLE_YES; params.activatable = views::Widget::InitParams::Activatable::kYes;
params.z_order = always_on_top_ ? ui::ZOrderLevel::kFloatingWindow params.z_order = always_on_top_ ? ui::ZOrderLevel::kFloatingWindow
: ui::ZOrderLevel::kNormal; : ui::ZOrderLevel::kNormal;

View File

@ -9,6 +9,7 @@
#include "libcef/browser/browser_host_base.h" #include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "net/base/network_interfaces.h"
#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_util.h"
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/x11/x11_event_source.h" #include "ui/events/platform/x11/x11_event_source.h"
@ -391,7 +392,7 @@ void CefWindowX11::ProcessXEvent(const x11::Event& event) {
if (!focus_pending_) { if (!focus_pending_) {
focus_pending_ = true; focus_pending_ = true;
CEF_POST_DELAYED_TASK(CEF_UIT, CEF_POST_DELAYED_TASK(CEF_UIT,
base::Bind(&CefWindowX11::ContinueFocus, base::BindOnce(&CefWindowX11::ContinueFocus,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
100); 100);
} }

View File

@ -44,7 +44,9 @@
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h" #include "content/public/common/url_utils.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "content/public/test/scoped_web_ui_controller_factory_registration.h"
#include "ipc/ipc_channel.h" #include "ipc/ipc_channel.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
@ -182,7 +184,7 @@ bool IsAllowedWebUIHost(const std::string& host) {
// Additional debug URLs that are not included in chrome::kChromeDebugURLs. // Additional debug URLs that are not included in chrome::kChromeDebugURLs.
const char* kAllowedDebugURLs[] = { const char* kAllowedDebugURLs[] = {
content::kChromeUIBrowserCrashURL, blink::kChromeUIBrowserCrashURL,
}; };
void GetDebugURLs(std::vector<std::string>* urls) { void GetDebugURLs(std::vector<std::string>* urls) {
@ -639,7 +641,9 @@ class CefWebUIControllerFactory : public content::WebUIControllerFactory {
static CefWebUIControllerFactory* GetInstance(); static CefWebUIControllerFactory* GetInstance();
protected: protected:
CefWebUIControllerFactory() {} CefWebUIControllerFactory()
: remove_content_registration_(
content::ContentWebUIControllerFactory::GetInstance()) {}
~CefWebUIControllerFactory() override {} ~CefWebUIControllerFactory() override {}
private: private:
@ -662,6 +666,9 @@ class CefWebUIControllerFactory : public content::WebUIControllerFactory {
return false; return false;
} }
content::ScopedWebUIControllerFactoryRegistration
remove_content_registration_;
DISALLOW_COPY_AND_ASSIGN(CefWebUIControllerFactory); DISALLOW_COPY_AND_ASSIGN(CefWebUIControllerFactory);
}; };
@ -677,9 +684,6 @@ CefWebUIControllerFactory* CefWebUIControllerFactory::GetInstance() {
void RegisterWebUIControllerFactory() { void RegisterWebUIControllerFactory() {
// Channel all WebUI handling through CefWebUIControllerFactory. // Channel all WebUI handling through CefWebUIControllerFactory.
content::WebUIControllerFactory::UnregisterFactoryForTesting(
content::ContentWebUIControllerFactory::GetInstance());
content::WebUIControllerFactory::RegisterFactory( content::WebUIControllerFactory::RegisterFactory(
CefWebUIControllerFactory::GetInstance()); CefWebUIControllerFactory::GetInstance());
} }

View File

@ -107,8 +107,9 @@ void CreateThrottlesForNavigation(content::NavigationHandle* navigation_handle,
std::unique_ptr<content::NavigationThrottle> throttle = std::unique_ptr<content::NavigationThrottle> throttle =
std::make_unique<navigation_interception::InterceptNavigationThrottle>( std::make_unique<navigation_interception::InterceptNavigationThrottle>(
navigation_handle, navigation_handle,
base::Bind(&NavigationOnUIThread, is_main_frame, frame_id, base::BindRepeating(&NavigationOnUIThread, is_main_frame, frame_id,
parent_frame_id, navigation_handle->GetFrameTreeNodeId()), parent_frame_id,
navigation_handle->GetFrameTreeNodeId()),
navigation_interception::SynchronyMode::kSync); navigation_interception::SynchronyMode::kSync);
throttles.push_back(std::move(throttle)); throttles.push_back(std::move(throttle));
} }

View File

@ -82,16 +82,16 @@ class RequestManager {
map_.erase(it); map_.erase(it);
} }
base::Optional<CefBrowserURLRequest::RequestInfo> Get(int32_t request_id) { absl::optional<CefBrowserURLRequest::RequestInfo> Get(int32_t request_id) {
if (request_id > kInitialRequestID) if (request_id > kInitialRequestID)
return base::nullopt; return absl::nullopt;
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
RequestMap::const_iterator it = map_.find(request_id); RequestMap::const_iterator it = map_.find(request_id);
if (it != map_.end()) { if (it != map_.end()) {
return it->second; return it->second;
} }
return base::nullopt; return absl::nullopt;
} }
private: private:
@ -230,8 +230,7 @@ class CefBrowserURLRequest::Context
net_service::URLLoaderFactoryGetter::Create(nullptr, browser_context); net_service::URLLoaderFactoryGetter::Create(nullptr, browser_context);
url_loader_network_observer = url_loader_network_observer =
static_cast<content::StoragePartitionImpl*>( static_cast<content::StoragePartitionImpl*>(
content::BrowserContext::GetDefaultStoragePartition( browser_context->GetDefaultStoragePartition())
browser_context))
->CreateAuthCertObserverForServiceWorker(); ->CreateAuthCertObserverForServiceWorker();
} }
@ -346,7 +345,7 @@ class CefBrowserURLRequest::Context
content_type = net_service::kContentTypeApplicationFormURLEncoded; content_type = net_service::kContentTypeApplicationFormURLEncoded;
} }
loader_->AttachStringForUpload( loader_->AttachStringForUpload(
bytes_element.AsStringPiece().as_string(), content_type); std::string(bytes_element.AsStringPiece()), content_type);
if (request_flags & UR_FLAG_REPORT_UPLOAD_PROGRESS) { if (request_flags & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
// Report the expected upload data size. // Report the expected upload data size.
@ -376,13 +375,13 @@ class CefBrowserURLRequest::Context
if (request_flags & UR_FLAG_STOP_ON_REDIRECT) { if (request_flags & UR_FLAG_STOP_ON_REDIRECT) {
// The request will be canceled in OnRedirect. // The request will be canceled in OnRedirect.
loader_->SetOnRedirectCallback( loader_->SetOnRedirectCallback(
base::Bind(&CefBrowserURLRequest::Context::OnRedirect, base::BindRepeating(&CefBrowserURLRequest::Context::OnRedirect,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
if (request_flags & UR_FLAG_REPORT_UPLOAD_PROGRESS) { if (request_flags & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
loader_->SetOnUploadProgressCallback( loader_->SetOnUploadProgressCallback(
base::Bind(&CefBrowserURLRequest::Context::OnUploadProgress, base::BindRepeating(&CefBrowserURLRequest::Context::OnUploadProgress,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
@ -395,8 +394,8 @@ class CefBrowserURLRequest::Context
loader_->SetOnResponseStartedCallback( loader_->SetOnResponseStartedCallback(
base::BindOnce(&CefBrowserURLRequest::Context::OnResponseStarted, base::BindOnce(&CefBrowserURLRequest::Context::OnResponseStarted,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
loader_->SetOnDownloadProgressCallback( loader_->SetOnDownloadProgressCallback(base::BindRepeating(
base::Bind(&CefBrowserURLRequest::Context::OnDownloadProgress, &CefBrowserURLRequest::Context::OnDownloadProgress,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
loader_->DownloadAsStream(loader_factory.get(), this); loader_->DownloadAsStream(loader_factory.get(), this);
@ -597,16 +596,16 @@ class CefBrowserURLRequest::Context
// CefBrowserURLRequest ------------------------------------------------------- // CefBrowserURLRequest -------------------------------------------------------
// static // static
base::Optional<CefBrowserURLRequest::RequestInfo> absl::optional<CefBrowserURLRequest::RequestInfo>
CefBrowserURLRequest::FromRequestID(int32_t request_id) { CefBrowserURLRequest::FromRequestID(int32_t request_id) {
if (IsValidRequestID(request_id)) { if (IsValidRequestID(request_id)) {
return g_manager.Get().Get(request_id); return g_manager.Get().Get(request_id);
} }
return base::nullopt; return absl::nullopt;
} }
// static // static
base::Optional<CefBrowserURLRequest::RequestInfo> absl::optional<CefBrowserURLRequest::RequestInfo>
CefBrowserURLRequest::FromRequestID( CefBrowserURLRequest::FromRequestID(
const content::GlobalRequestID& request_id) { const content::GlobalRequestID& request_id) {
return FromRequestID(request_id.request_id); return FromRequestID(request_id.request_id);

View File

@ -9,7 +9,7 @@
#include "include/cef_urlrequest.h" #include "include/cef_urlrequest.h"
#include "base/optional.h" #include "third_party/abseil-cpp/absl/types/optional.h"
namespace content { namespace content {
struct GlobalRequestID; struct GlobalRequestID;
@ -27,8 +27,8 @@ class CefBrowserURLRequest : public CefURLRequest {
CefRefPtr<CefURLRequestClient>>; CefRefPtr<CefURLRequestClient>>;
// Retrieve the request objects, if any, associated with |request_id|. // Retrieve the request objects, if any, associated with |request_id|.
static base::Optional<RequestInfo> FromRequestID(int32_t request_id); static absl::optional<RequestInfo> FromRequestID(int32_t request_id);
static base::Optional<RequestInfo> FromRequestID( static absl::optional<RequestInfo> FromRequestID(
const content::GlobalRequestID& request_id); const content::GlobalRequestID& request_id);
// If |frame| is nullptr requests can still be intercepted but no // If |frame| is nullptr requests can still be intercepted but no

View File

@ -26,7 +26,7 @@ namespace {
network::mojom::CookieManager* GetCookieManager( network::mojom::CookieManager* GetCookieManager(
content::BrowserContext* browser_context) { content::BrowserContext* browser_context) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
return content::BrowserContext::GetDefaultStoragePartition(browser_context) return browser_context->GetDefaultStoragePartition()
->GetCookieManagerForBrowserProcess(); ->GetCookieManagerForBrowserProcess();
} }
@ -164,7 +164,7 @@ void SaveCookiesOnUIThread(content::BrowserContext* browser_context,
bool IsCookieableScheme( bool IsCookieableScheme(
const GURL& url, const GURL& url,
const base::Optional<std::vector<std::string>>& cookieable_schemes) { const absl::optional<std::vector<std::string>>& cookieable_schemes) {
if (!url.has_scheme()) if (!url.has_scheme())
return false; return false;

View File

@ -28,10 +28,11 @@ namespace cookie_helper {
// cookieable, which may intentionally exclude standard schemes. // cookieable, which may intentionally exclude standard schemes.
bool IsCookieableScheme( bool IsCookieableScheme(
const GURL& url, const GURL& url,
const base::Optional<std::vector<std::string>>& cookieable_schemes); const absl::optional<std::vector<std::string>>& cookieable_schemes);
using AllowCookieCallback = using AllowCookieCallback =
base::Callback<void(const net::CanonicalCookie&, bool* /* allow */)>; base::RepeatingCallback<void(const net::CanonicalCookie&,
bool* /* allow */)>;
using DoneCookieCallback = using DoneCookieCallback =
base::OnceCallback<void(int /* total_count */, base::OnceCallback<void(int /* total_count */,
net::CookieList /* allowed_cookies */)>; net::CookieList /* allowed_cookies */)>;

View File

@ -30,8 +30,8 @@ CefBrowserContext* GetBrowserContext(const CefBrowserContext::Getter& getter) {
// Do not keep a reference to the object returned by this method. // Do not keep a reference to the object returned by this method.
CookieManager* GetCookieManager(CefBrowserContext* browser_context) { CookieManager* GetCookieManager(CefBrowserContext* browser_context) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
return content::BrowserContext::GetDefaultStoragePartition( return browser_context->AsBrowserContext()
browser_context->AsBrowserContext()) ->GetDefaultStoragePartition()
->GetCookieManagerForBrowserProcess(); ->GetCookieManagerForBrowserProcess();
} }
@ -39,8 +39,8 @@ CookieManager* GetCookieManager(CefBrowserContext* browser_context) {
void RunAsyncCompletionOnUIThread(CefRefPtr<CefCompletionCallback> callback) { void RunAsyncCompletionOnUIThread(CefRefPtr<CefCompletionCallback> callback) {
if (!callback.get()) if (!callback.get())
return; return;
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefCompletionCallback::OnComplete,
base::Bind(&CefCompletionCallback::OnComplete, callback.get())); callback.get()));
} }
// Always execute the callback asynchronously. // Always execute the callback asynchronously.
@ -53,7 +53,7 @@ void SetCookieCallbackImpl(CefRefPtr<CefSetCookieCallback> callback,
LOG(WARNING) << "SetCookie failed with reason: " LOG(WARNING) << "SetCookie failed with reason: "
<< access_result.status.GetDebugString(); << access_result.status.GetDebugString();
} }
CEF_POST_TASK(CEF_UIT, base::Bind(&CefSetCookieCallback::OnComplete, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefSetCookieCallback::OnComplete,
callback.get(), is_include)); callback.get(), is_include));
} }
@ -62,7 +62,7 @@ void DeleteCookiesCallbackImpl(CefRefPtr<CefDeleteCookiesCallback> callback,
uint32_t num_deleted) { uint32_t num_deleted) {
if (!callback.get()) if (!callback.get())
return; return;
CEF_POST_TASK(CEF_UIT, base::Bind(&CefDeleteCookiesCallback::OnComplete, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefDeleteCookiesCallback::OnComplete,
callback.get(), num_deleted)); callback.get(), num_deleted));
} }
@ -99,7 +99,7 @@ void GetAllCookiesCallbackImpl(
CefRefPtr<CefCookieVisitor> visitor, CefRefPtr<CefCookieVisitor> visitor,
const CefBrowserContext::Getter& browser_context_getter, const CefBrowserContext::Getter& browser_context_getter,
const net::CookieList& cookies) { const net::CookieList& cookies) {
CEF_POST_TASK(CEF_UIT, base::Bind(&ExecuteVisitor, visitor, CEF_POST_TASK(CEF_UIT, base::BindOnce(&ExecuteVisitor, visitor,
browser_context_getter, cookies)); browser_context_getter, cookies));
} }
@ -233,7 +233,7 @@ bool CefCookieManagerImpl::VisitAllCookiesInternal(
return false; return false;
GetCookieManager(browser_context) GetCookieManager(browser_context)
->GetAllCookies(base::Bind(&GetAllCookiesCallbackImpl, visitor, ->GetAllCookies(base::BindOnce(&GetAllCookiesCallbackImpl, visitor,
browser_context_getter_)); browser_context_getter_));
return true; return true;
} }
@ -258,7 +258,7 @@ bool CefCookieManagerImpl::VisitUrlCookiesInternal(
GetCookieManager(browser_context) GetCookieManager(browser_context)
->GetCookieList(url, options, ->GetCookieList(url, options,
base::Bind(&GetCookiesCallbackImpl, visitor, base::BindOnce(&GetCookiesCallbackImpl, visitor,
browser_context_getter_)); browser_context_getter_));
return true; return true;
} }
@ -311,7 +311,7 @@ bool CefCookieManagerImpl::SetCookieInternal(
GetCookieManager(browser_context) GetCookieManager(browser_context)
->SetCanonicalCookie(*canonical_cookie, url, options, ->SetCanonicalCookie(*canonical_cookie, url, options,
base::Bind(SetCookieCallbackImpl, callback)); base::BindOnce(SetCookieCallbackImpl, callback));
return true; return true;
} }
@ -342,7 +342,7 @@ bool CefCookieManagerImpl::DeleteCookiesInternal(
GetCookieManager(browser_context) GetCookieManager(browser_context)
->DeleteCookies(std::move(deletion_filter), ->DeleteCookies(std::move(deletion_filter),
base::Bind(DeleteCookiesCallbackImpl, callback)); base::BindOnce(DeleteCookiesCallbackImpl, callback));
return true; return true;
} }
@ -355,7 +355,8 @@ bool CefCookieManagerImpl::FlushStoreInternal(
return false; return false;
GetCookieManager(browser_context) GetCookieManager(browser_context)
->FlushCookieStore(base::Bind(RunAsyncCompletionOnUIThread, callback)); ->FlushCookieStore(
base::BindOnce(RunAsyncCompletionOnUIThread, callback));
return true; return true;
} }

View File

@ -68,7 +68,7 @@ class AuthCallbackImpl : public CefAuthCallback {
void RunCallbackOnIOThread( void RunCallbackOnIOThread(
CefRefPtr<CefBrowserHostBase> browser, CefRefPtr<CefBrowserHostBase> browser,
base::Optional<CefBrowserURLRequest::RequestInfo> url_request_info, absl::optional<CefBrowserURLRequest::RequestInfo> url_request_info,
const net::AuthChallengeInfo& auth_info, const net::AuthChallengeInfo& auth_info,
const GURL& origin_url, const GURL& origin_url,
CefRefPtr<AuthCallbackImpl> callback_impl) { CefRefPtr<AuthCallbackImpl> callback_impl) {
@ -142,7 +142,7 @@ void LoginDelegate::Continue(const CefString& username,
void LoginDelegate::Cancel() { void LoginDelegate::Cancel() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!callback_.is_null()) { if (!callback_.is_null()) {
std::move(callback_).Run(base::nullopt); std::move(callback_).Run(absl::nullopt);
} }
} }

View File

@ -33,12 +33,12 @@ namespace {
// User data key for ResourceContextData. // User data key for ResourceContextData.
const void* const kResourceContextUserDataKey = &kResourceContextUserDataKey; const void* const kResourceContextUserDataKey = &kResourceContextUserDataKey;
base::Optional<std::string> GetHeaderString( absl::optional<std::string> GetHeaderString(
const net::HttpResponseHeaders* headers, const net::HttpResponseHeaders* headers,
const std::string& header_name) { const std::string& header_name) {
std::string header_value; std::string header_value;
if (!headers || !headers->GetNormalizedHeader(header_name, &header_value)) { if (!headers || !headers->GetNormalizedHeader(header_name, &header_value)) {
return base::nullopt; return absl::nullopt;
} }
return header_value; return header_value;
} }
@ -147,13 +147,13 @@ class CorsPreflightRequest : public network::mojom::TrustedHeaderClient {
// mojom::TrustedHeaderClient methods: // mojom::TrustedHeaderClient methods:
void OnBeforeSendHeaders(const net::HttpRequestHeaders& headers, void OnBeforeSendHeaders(const net::HttpRequestHeaders& headers,
OnBeforeSendHeadersCallback callback) override { OnBeforeSendHeadersCallback callback) override {
std::move(callback).Run(net::OK, base::nullopt); std::move(callback).Run(net::OK, absl::nullopt);
} }
void OnHeadersReceived(const std::string& headers, void OnHeadersReceived(const std::string& headers,
const net::IPEndPoint& remote_endpoint, const net::IPEndPoint& remote_endpoint,
OnHeadersReceivedCallback callback) override { OnHeadersReceivedCallback callback) override {
std::move(callback).Run(net::OK, base::nullopt, GURL()); std::move(callback).Run(net::OK, absl::nullopt, GURL());
OnDestroy(); OnDestroy();
} }
@ -225,7 +225,7 @@ class InterceptedRequest : public network::mojom::URLLoader,
const std::vector<std::string>& removed_headers, const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_headers,
const net::HttpRequestHeaders& modified_cors_exempt_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers,
const base::Optional<GURL>& new_url) override; const absl::optional<GURL>& new_url) override;
void SetPriority(net::RequestPriority priority, void SetPriority(net::RequestPriority priority,
int32_t intra_priority_value) override; int32_t intra_priority_value) override;
void PauseReadingBodyFromNet() override; void PauseReadingBodyFromNet() override;
@ -246,7 +246,7 @@ class InterceptedRequest : public network::mojom::URLLoader,
// Helpers for optionally overriding headers. // Helpers for optionally overriding headers.
void HandleResponseOrRedirectHeaders( void HandleResponseOrRedirectHeaders(
base::Optional<net::RedirectInfo> redirect_info, absl::optional<net::RedirectInfo> redirect_info,
net::CompletionOnceCallback continuation); net::CompletionOnceCallback continuation);
void ContinueResponseOrRedirect( void ContinueResponseOrRedirect(
net::CompletionOnceCallback continuation, net::CompletionOnceCallback continuation,
@ -412,7 +412,7 @@ InterceptedRequest::~InterceptedRequest() {
SendErrorCallback(status_.error_code, false); SendErrorCallback(status_.error_code, false);
if (on_headers_received_callback_) { if (on_headers_received_callback_) {
std::move(on_headers_received_callback_) std::move(on_headers_received_callback_)
.Run(net::ERR_ABORTED, base::nullopt, GURL()); .Run(net::ERR_ABORTED, absl::nullopt, GURL());
} }
} }
@ -493,12 +493,12 @@ void InterceptedRequest::OnBeforeSendHeaders(
const net::HttpRequestHeaders& headers, const net::HttpRequestHeaders& headers,
OnBeforeSendHeadersCallback callback) { OnBeforeSendHeadersCallback callback) {
if (!current_request_uses_header_client_) { if (!current_request_uses_header_client_) {
std::move(callback).Run(net::OK, base::nullopt); std::move(callback).Run(net::OK, absl::nullopt);
return; return;
} }
request_.headers = headers; request_.headers = headers;
std::move(callback).Run(net::OK, base::nullopt); std::move(callback).Run(net::OK, absl::nullopt);
// Resume handling of client messages after continuing from an async callback. // Resume handling of client messages after continuing from an async callback.
if (proxied_client_receiver_.is_bound()) if (proxied_client_receiver_.is_bound())
@ -510,14 +510,14 @@ void InterceptedRequest::OnHeadersReceived(
const net::IPEndPoint& remote_endpoint, const net::IPEndPoint& remote_endpoint,
OnHeadersReceivedCallback callback) { OnHeadersReceivedCallback callback) {
if (!current_request_uses_header_client_) { if (!current_request_uses_header_client_) {
std::move(callback).Run(net::OK, base::nullopt, GURL()); std::move(callback).Run(net::OK, absl::nullopt, GURL());
return; return;
} }
current_headers_ = base::MakeRefCounted<net::HttpResponseHeaders>(headers); current_headers_ = base::MakeRefCounted<net::HttpResponseHeaders>(headers);
on_headers_received_callback_ = std::move(callback); on_headers_received_callback_ = std::move(callback);
base::Optional<net::RedirectInfo> redirect_info; absl::optional<net::RedirectInfo> redirect_info;
std::string location; std::string location;
if (current_headers_->IsRedirect(&location)) { if (current_headers_->IsRedirect(&location)) {
const GURL new_url = request_.url.Resolve(location); const GURL new_url = request_.url.Resolve(location);
@ -551,7 +551,7 @@ void InterceptedRequest::OnReceiveResponse(
ContinueToResponseStarted(net::OK); ContinueToResponseStarted(net::OK);
} else { } else {
HandleResponseOrRedirectHeaders( HandleResponseOrRedirectHeaders(
base::nullopt, absl::nullopt,
base::BindOnce(&InterceptedRequest::ContinueToResponseStarted, base::BindOnce(&InterceptedRequest::ContinueToResponseStarted,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
@ -659,7 +659,7 @@ void InterceptedRequest::FollowRedirect(
const std::vector<std::string>& removed_headers_ext, const std::vector<std::string>& removed_headers_ext,
const net::HttpRequestHeaders& modified_headers_ext, const net::HttpRequestHeaders& modified_headers_ext,
const net::HttpRequestHeaders& modified_cors_exempt_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers,
const base::Optional<GURL>& new_url) { const absl::optional<GURL>& new_url) {
std::vector<std::string> removed_headers = removed_headers_ext; std::vector<std::string> removed_headers = removed_headers_ext;
net::HttpRequestHeaders modified_headers = modified_headers_ext; net::HttpRequestHeaders modified_headers = modified_headers_ext;
OnProcessRequestHeaders(new_url.value_or(GURL()), &modified_headers, OnProcessRequestHeaders(new_url.value_or(GURL()), &modified_headers,
@ -802,7 +802,7 @@ void InterceptedRequest::ContinueAfterInterceptWithOverride(
} }
void InterceptedRequest::HandleResponseOrRedirectHeaders( void InterceptedRequest::HandleResponseOrRedirectHeaders(
base::Optional<net::RedirectInfo> redirect_info, absl::optional<net::RedirectInfo> redirect_info,
net::CompletionOnceCallback continuation) { net::CompletionOnceCallback continuation) {
override_headers_ = nullptr; override_headers_ = nullptr;
redirect_url_ = redirect_info.has_value() ? redirect_info->new_url : GURL(); redirect_url_ = redirect_info.has_value() ? redirect_info->new_url : GURL();
@ -860,7 +860,7 @@ void InterceptedRequest::ContinueToHandleOverrideHeaders(int error_code) {
} }
DCHECK(on_headers_received_callback_); DCHECK(on_headers_received_callback_);
base::Optional<std::string> headers; absl::optional<std::string> headers;
if (override_headers_) if (override_headers_)
headers = override_headers_->raw_headers(); headers = override_headers_->raw_headers();
header_client_redirect_url_ = redirect_url_; header_client_redirect_url_ = redirect_url_;
@ -954,7 +954,7 @@ void InterceptedRequest::ContinueToBeforeRedirect(
net::RedirectUtil::UpdateHttpRequest(original_url, original_method, net::RedirectUtil::UpdateHttpRequest(original_url, original_method,
new_redirect_info, new_redirect_info,
base::make_optional(remove_headers), base::make_optional(remove_headers),
/*modified_headers=*/base::nullopt, /*modified_headers=*/absl::nullopt,
&request_.headers, &should_clear_upload); &request_.headers, &should_clear_upload);
if (should_clear_upload) { if (should_clear_upload) {
@ -1164,7 +1164,7 @@ void InterceptedRequestHandler::OnRequestResponse(
int32_t request_id, int32_t request_id,
network::ResourceRequest* request, network::ResourceRequest* request,
net::HttpResponseHeaders* headers, net::HttpResponseHeaders* headers,
base::Optional<net::RedirectInfo> redirect_info, absl::optional<net::RedirectInfo> redirect_info,
OnRequestResponseResultCallback callback) { OnRequestResponseResultCallback callback) {
std::move(callback).Run( std::move(callback).Run(
ResponseMode::CONTINUE, nullptr, ResponseMode::CONTINUE, nullptr,

View File

@ -12,7 +12,6 @@
#include "base/containers/unique_ptr_adapters.h" #include "base/containers/unique_ptr_adapters.h"
#include "base/hash/hash.h" #include "base/hash/hash.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
@ -20,6 +19,7 @@
#include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content { namespace content {
class ResourceContext; class ResourceContext;
@ -104,7 +104,7 @@ class InterceptedRequestHandler {
int32_t request_id, int32_t request_id,
network::ResourceRequest* request, network::ResourceRequest* request,
net::HttpResponseHeaders* headers, net::HttpResponseHeaders* headers,
base::Optional<net::RedirectInfo> redirect_info, absl::optional<net::RedirectInfo> redirect_info,
OnRequestResponseResultCallback callback); OnRequestResponseResultCallback callback);
// Called to optionally filter the response body. // Called to optionally filter the response body.

View File

@ -233,7 +233,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
bool is_navigation, bool is_navigation,
bool is_download, bool is_download,
const url::Origin& request_initiator, const url::Origin& request_initiator,
const base::Closure& unhandled_request_callback) { const base::RepeatingClosure& unhandled_request_callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
browser_context_ = browser_context; browser_context_ = browser_context;
@ -297,7 +297,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
bool is_navigation_ = true; bool is_navigation_ = true;
bool is_download_ = false; bool is_download_ = false;
CefString request_initiator_; CefString request_initiator_;
base::Closure unhandled_request_callback_; base::RepeatingClosure unhandled_request_callback_;
// Default values for standard headers. // Default values for standard headers.
std::string accept_language_; std::string accept_language_;
@ -705,7 +705,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
void OnRequestResponse(int32_t request_id, void OnRequestResponse(int32_t request_id,
network::ResourceRequest* request, network::ResourceRequest* request,
net::HttpResponseHeaders* headers, net::HttpResponseHeaders* headers,
base::Optional<net::RedirectInfo> redirect_info, absl::optional<net::RedirectInfo> redirect_info,
OnRequestResponseResultCallback callback) override { OnRequestResponseResultCallback callback) override {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
@ -1179,7 +1179,7 @@ void InitOnUIThread(
content::WebContents::Getter web_contents_getter, content::WebContents::Getter web_contents_getter,
int frame_tree_node_id, int frame_tree_node_id,
const network::ResourceRequest& request, const network::ResourceRequest& request,
const base::Closure& unhandled_request_callback) { const base::RepeatingClosure& unhandled_request_callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
// May return nullptr if the WebContents was destroyed while this callback was // May return nullptr if the WebContents was destroyed while this callback was
@ -1278,7 +1278,8 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
std::make_unique<InterceptedRequestHandlerWrapper::InitState>(); std::make_unique<InterceptedRequestHandlerWrapper::InitState>();
init_state->Initialize(browser_context, browserPtr, framePtr, init_state->Initialize(browser_context, browserPtr, framePtr,
render_process_id, frame_tree_node_id, is_navigation, render_process_id, frame_tree_node_id, is_navigation,
is_download, request_initiator, base::Closure()); is_download, request_initiator,
base::RepeatingClosure());
auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>(); auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>();
wrapper->init_helper()->MaybeSetInitialized(std::move(init_state)); wrapper->init_helper()->MaybeSetInitialized(std::move(init_state));
@ -1290,7 +1291,7 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
content::WebContents::Getter web_contents_getter, content::WebContents::Getter web_contents_getter,
int frame_tree_node_id, int frame_tree_node_id,
const network::ResourceRequest& request, const network::ResourceRequest& request,
const base::Closure& unhandled_request_callback) { const base::RepeatingClosure& unhandled_request_callback) {
auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>(); auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>();
CEF_POST_TASK(CEF_UIT, base::BindOnce(InitOnUIThread, wrapper->init_helper(), CEF_POST_TASK(CEF_UIT, base::BindOnce(InitOnUIThread, wrapper->init_helper(),
web_contents_getter, frame_tree_node_id, web_contents_getter, frame_tree_node_id,

View File

@ -43,7 +43,7 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
content::WebContents::Getter web_contents_getter, content::WebContents::Getter web_contents_getter,
int frame_tree_node_id, int frame_tree_node_id,
const network::ResourceRequest& request, const network::ResourceRequest& request,
const base::Closure& unhandled_request_callback); const base::RepeatingClosure& unhandled_request_callback);
} // namespace net_service } // namespace net_service

View File

@ -508,13 +508,13 @@ void StreamReaderURLLoader::Start() {
base::BindOnce(&StreamReaderURLLoader::ContinueWithRequestHeaders, base::BindOnce(&StreamReaderURLLoader::ContinueWithRequestHeaders,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} else { } else {
ContinueWithRequestHeaders(net::OK, base::nullopt); ContinueWithRequestHeaders(net::OK, absl::nullopt);
} }
} }
void StreamReaderURLLoader::ContinueWithRequestHeaders( void StreamReaderURLLoader::ContinueWithRequestHeaders(
int32_t result, int32_t result,
const base::Optional<net::HttpRequestHeaders>& headers) { const absl::optional<net::HttpRequestHeaders>& headers) {
if (result != net::OK) { if (result != net::OK) {
RequestComplete(result); RequestComplete(result);
return; return;
@ -540,7 +540,7 @@ void StreamReaderURLLoader::FollowRedirect(
const std::vector<std::string>& removed_headers, const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_headers,
const net::HttpRequestHeaders& modified_cors_exempt_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers,
const base::Optional<GURL>& new_url) { const absl::optional<GURL>& new_url) {
NOTREACHED(); NOTREACHED();
} }
@ -651,15 +651,15 @@ void StreamReaderURLLoader::HeadersComplete(int orig_status_code,
std::move(pending_response))); std::move(pending_response)));
} else { } else {
ContinueWithResponseHeaders(std::move(pending_response), net::OK, ContinueWithResponseHeaders(std::move(pending_response), net::OK,
base::nullopt, base::nullopt); absl::nullopt, absl::nullopt);
} }
} }
void StreamReaderURLLoader::ContinueWithResponseHeaders( void StreamReaderURLLoader::ContinueWithResponseHeaders(
network::mojom::URLResponseHeadPtr pending_response, network::mojom::URLResponseHeadPtr pending_response,
int32_t result, int32_t result,
const base::Optional<std::string>& headers, const absl::optional<std::string>& headers,
const base::Optional<GURL>& redirect_url) { const absl::optional<GURL>& redirect_url) {
if (result != net::OK) { if (result != net::OK) {
RequestComplete(result); RequestComplete(result);
return; return;

View File

@ -127,7 +127,7 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
const std::vector<std::string>& removed_headers, const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_headers,
const net::HttpRequestHeaders& modified_cors_exempt_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers,
const base::Optional<GURL>& new_url) override; const absl::optional<GURL>& new_url) override;
void SetPriority(net::RequestPriority priority, void SetPriority(net::RequestPriority priority,
int intra_priority_value) override; int intra_priority_value) override;
void PauseReadingBodyFromNet() override; void PauseReadingBodyFromNet() override;
@ -136,7 +136,7 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
private: private:
void ContinueWithRequestHeaders( void ContinueWithRequestHeaders(
int32_t result, int32_t result,
const base::Optional<net::HttpRequestHeaders>& headers); const absl::optional<net::HttpRequestHeaders>& headers);
void OnInputStreamOpened(std::unique_ptr<Delegate> returned_delegate, void OnInputStreamOpened(std::unique_ptr<Delegate> returned_delegate,
std::unique_ptr<InputStream> input_stream); std::unique_ptr<InputStream> input_stream);
@ -145,8 +145,8 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
void ContinueWithResponseHeaders( void ContinueWithResponseHeaders(
network::mojom::URLResponseHeadPtr pending_response, network::mojom::URLResponseHeadPtr pending_response,
int32_t result, int32_t result,
const base::Optional<std::string>& headers, const absl::optional<std::string>& headers,
const base::Optional<GURL>& redirect_url); const absl::optional<GURL>& redirect_url);
void SendBody(); void SendBody();
void ReadMore(); void ReadMore();

View File

@ -32,8 +32,7 @@ scoped_refptr<URLLoaderFactoryGetter> URLLoaderFactoryGetter::Create(
// initialize additional state, and that should be done on the UI thread // initialize additional state, and that should be done on the UI thread
// instead of potentially racing with the WillCreateURLLoaderFactory // instead of potentially racing with the WillCreateURLLoaderFactory
// implementation. // implementation.
auto loader_factory = auto loader_factory = browser_context->GetDefaultStoragePartition()
content::BrowserContext::GetDefaultStoragePartition(browser_context)
->GetURLLoaderFactoryForBrowserProcess(); ->GetURLLoaderFactoryForBrowserProcess();
network::mojom::URLLoaderFactoryPtrInfo proxy_factory_ptr_info; network::mojom::URLLoaderFactoryPtrInfo proxy_factory_ptr_info;
@ -65,7 +64,7 @@ scoped_refptr<URLLoaderFactoryGetter> URLLoaderFactoryGetter::Create(
should_proxy |= browser_client->WillCreateURLLoaderFactory( should_proxy |= browser_client->WillCreateURLLoaderFactory(
browser_context, render_frame_host, render_process_id, browser_context, render_frame_host, render_process_id,
content::ContentBrowserClient::URLLoaderFactoryType::kDocumentSubResource, content::ContentBrowserClient::URLLoaderFactoryType::kDocumentSubResource,
url::Origin(), base::nullopt /* navigation_id */, ukm::SourceIdObj(), url::Origin(), absl::nullopt /* navigation_id */, ukm::SourceIdObj(),
&maybe_proxy_factory_request, nullptr /* header_client */, &maybe_proxy_factory_request, nullptr /* header_client */,
nullptr /* bypass_redirect_checks */, nullptr /* disable_secure_dns */, nullptr /* bypass_redirect_checks */, nullptr /* disable_secure_dns */,
nullptr /* factory_override */); nullptr /* factory_override */);

View File

@ -101,7 +101,7 @@ class CefOriginWhitelistManager {
} }
void GetCrossOriginWhitelistEntries( void GetCrossOriginWhitelistEntries(
base::Optional<CrossOriginWhiteList>* entries) const { absl::optional<CrossOriginWhiteList>* entries) const {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
if (!origin_list_.empty()) { if (!origin_list_.empty()) {
@ -226,7 +226,7 @@ bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin,
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(base::IgnoreResult(&CefAddCrossOriginWhitelistEntry), base::BindOnce(base::IgnoreResult(&CefAddCrossOriginWhitelistEntry),
source_origin, target_protocol, target_domain, source_origin, target_protocol, target_domain,
allow_target_subdomains)); allow_target_subdomains));
} }
@ -257,7 +257,7 @@ bool CefRemoveCrossOriginWhitelistEntry(const CefString& source_origin,
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(base::IgnoreResult(&CefRemoveCrossOriginWhitelistEntry), base::BindOnce(base::IgnoreResult(&CefRemoveCrossOriginWhitelistEntry),
source_origin, target_protocol, target_domain, source_origin, target_protocol, target_domain,
allow_target_subdomains)); allow_target_subdomains));
} }
@ -276,14 +276,15 @@ bool CefClearCrossOriginWhitelist() {
CefOriginWhitelistManager::GetInstance()->ClearOrigins(); CefOriginWhitelistManager::GetInstance()->ClearOrigins();
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, base::Bind(base::IgnoreResult(&CefClearCrossOriginWhitelist))); CEF_UIT,
base::BindOnce(base::IgnoreResult(&CefClearCrossOriginWhitelist)));
} }
return true; return true;
} }
void GetCrossOriginWhitelistEntries( void GetCrossOriginWhitelistEntries(
base::Optional<CrossOriginWhiteList>* entries) { absl::optional<CrossOriginWhiteList>* entries) {
CefOriginWhitelistManager::GetInstance()->GetCrossOriginWhitelistEntries( CefOriginWhitelistManager::GetInstance()->GetCrossOriginWhitelistEntries(
entries); entries);
} }

View File

@ -7,7 +7,7 @@
#include <vector> #include <vector>
#include "base/optional.h" #include "third_party/abseil-cpp/absl/types/optional.h"
#include "cef/libcef/common/mojom/cef.mojom-forward.h" #include "cef/libcef/common/mojom/cef.mojom-forward.h"
@ -25,7 +25,7 @@ using CrossOriginWhiteList =
// Called to retrieve the current list of cross-origin white list entries. This // Called to retrieve the current list of cross-origin white list entries. This
// method is thread safe. // method is thread safe.
void GetCrossOriginWhitelistEntries( void GetCrossOriginWhitelistEntries(
base::Optional<CrossOriginWhiteList>* entries); absl::optional<CrossOriginWhiteList>* entries);
// Returns true if |source| can access |target| based on the cross-origin white // Returns true if |source| can access |target| based on the cross-origin white
// list settings. // list settings.

View File

@ -207,7 +207,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
DCHECK(render_widget_host_); DCHECK(render_widget_host_);
DCHECK(!render_widget_host_->GetView()); DCHECK(!render_widget_host_->GetView());
set_current_device_scale_factor(kDefaultScaleFactor); SetCurrentDeviceScaleFactor(kDefaultScaleFactor);
if (parent_host_view_) { if (parent_host_view_) {
browser_impl_ = parent_host_view_->browser_impl(); browser_impl_ = parent_host_view_->browser_impl();
@ -432,7 +432,7 @@ bool CefRenderWidgetHostViewOSR::IsShowing() {
void CefRenderWidgetHostViewOSR::EnsureSurfaceSynchronizedForWebTest() { void CefRenderWidgetHostViewOSR::EnsureSurfaceSynchronizedForWebTest() {
++latest_capture_sequence_number_; ++latest_capture_sequence_number_;
SynchronizeVisualProperties(cc::DeadlinePolicy::UseInfiniteDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseInfiniteDeadline(),
base::nullopt); absl::nullopt);
} }
gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() { gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() {
@ -452,15 +452,15 @@ void CefRenderWidgetHostViewOSR::SetBackgroundColor(SkColor color) {
content::RenderWidgetHostViewBase::SetBackgroundColor(color); content::RenderWidgetHostViewBase::SetBackgroundColor(color);
} }
base::Optional<SkColor> CefRenderWidgetHostViewOSR::GetBackgroundColor() { absl::optional<SkColor> CefRenderWidgetHostViewOSR::GetBackgroundColor() {
return background_color_; return background_color_;
} }
void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() {} void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() {}
base::Optional<content::DisplayFeature> absl::optional<content::DisplayFeature>
CefRenderWidgetHostViewOSR::GetDisplayFeature() { CefRenderWidgetHostViewOSR::GetDisplayFeature() {
return base::nullopt; return absl::nullopt;
} }
void CefRenderWidgetHostViewOSR::SetDisplayFeatureForTesting( void CefRenderWidgetHostViewOSR::SetDisplayFeatureForTesting(
@ -524,7 +524,7 @@ CefRenderWidgetHostViewOSR::GetCurrentLocalSurfaceId() const {
} }
void CefRenderWidgetHostViewOSR::UpdateLocalSurfaceIdFromEmbeddedClient( void CefRenderWidgetHostViewOSR::UpdateLocalSurfaceIdFromEmbeddedClient(
const base::Optional<viz::LocalSurfaceId>& const absl::optional<viz::LocalSurfaceId>&
embedded_client_local_surface_id) { embedded_client_local_surface_id) {
if (embedded_client_local_surface_id) { if (embedded_client_local_surface_id) {
parent_local_surface_id_allocator_->UpdateFromChild( parent_local_surface_id_allocator_->UpdateFromChild(
@ -652,7 +652,7 @@ void CefRenderWidgetHostViewOSR::Destroy() {
delete this; delete this;
} }
void CefRenderWidgetHostViewOSR::SetTooltipText( void CefRenderWidgetHostViewOSR::UpdateTooltipUnderCursor(
const std::u16string& tooltip_text) { const std::u16string& tooltip_text) {
if (!browser_impl_.get()) if (!browser_impl_.get())
return; return;
@ -667,7 +667,7 @@ void CefRenderWidgetHostViewOSR::SetTooltipText(
gfx::Size CefRenderWidgetHostViewOSR::GetCompositorViewportPixelSize() { gfx::Size CefRenderWidgetHostViewOSR::GetCompositorViewportPixelSize() {
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
current_device_scale_factor()); GetCurrentDeviceScaleFactor());
} }
uint32_t CefRenderWidgetHostViewOSR::GetCaptureSequenceNumber() const { uint32_t CefRenderWidgetHostViewOSR::GetCaptureSequenceNumber() const {
@ -890,7 +890,7 @@ void CefRenderWidgetHostViewOSR::DidNavigate() {
GetLocalSurfaceId()); GetLocalSurfaceId());
} else { } else {
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
base::nullopt); absl::nullopt);
} }
} }
if (delegated_frame_host_) if (delegated_frame_host_)
@ -927,7 +927,7 @@ void CefRenderWidgetHostViewOSR::OnRenderFrameMetadataChangedAfterActivation(
// Send the notification asynchronously. // Send the notification asynchronously.
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefRenderWidgetHostViewOSR::OnScrollOffsetChanged, base::BindOnce(&CefRenderWidgetHostViewOSR::OnScrollOffsetChanged,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
} }
@ -961,12 +961,12 @@ void CefRenderWidgetHostViewOSR::WasResized() {
} }
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
base::nullopt); absl::nullopt);
} }
void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties( void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties(
const cc::DeadlinePolicy& deadline_policy, const cc::DeadlinePolicy& deadline_policy,
const base::Optional<viz::LocalSurfaceId>& child_local_surface_id) { const absl::optional<viz::LocalSurfaceId>& child_local_surface_id) {
SetFrameRate(); SetFrameRate();
const bool resized = ResizeRootLayer(); const bool resized = ResizeRootLayer();
@ -1005,7 +1005,7 @@ void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
return; return;
SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(),
base::nullopt); absl::nullopt);
if (render_widget_host_->delegate()) if (render_widget_host_->delegate())
render_widget_host_->delegate()->SendScreenRects(); render_widget_host_->delegate()->SendScreenRects();
@ -1180,7 +1180,7 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
// some other callback. // some other callback.
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefRenderWidgetHostViewOSR::CancelWidget, base::BindOnce(&CefRenderWidgetHostViewOSR::CancelWidget,
popup_host_view_->weak_ptr_factory_.GetWeakPtr())); popup_host_view_->weak_ptr_factory_.GetWeakPtr()));
} }
} else if (!guest_host_views_.empty()) { } else if (!guest_host_views_.empty()) {
@ -1394,7 +1394,7 @@ void CefRenderWidgetHostViewOSR::UpdateFrameRate() {
gfx::Size CefRenderWidgetHostViewOSR::SizeInPixels() { gfx::Size CefRenderWidgetHostViewOSR::SizeInPixels() {
return gfx::ScaleToCeiledSize(GetViewBounds().size(), return gfx::ScaleToCeiledSize(GetViewBounds().size(),
current_device_scale_factor()); GetCurrentDeviceScaleFactor());
} }
#if defined(OS_MAC) #if defined(OS_MAC)
@ -1490,10 +1490,10 @@ bool CefRenderWidgetHostViewOSR::SetDeviceScaleFactor() {
DCHECK(!hold_resize_); DCHECK(!hold_resize_);
const float new_scale_factor = ::GetDeviceScaleFactor(browser_impl_.get()); const float new_scale_factor = ::GetDeviceScaleFactor(browser_impl_.get());
if (new_scale_factor == current_device_scale_factor()) if (new_scale_factor == GetCurrentDeviceScaleFactor())
return false; return false;
set_current_device_scale_factor(new_scale_factor); SetCurrentDeviceScaleFactor(new_scale_factor);
// Notify the guest hosts if any. // Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_) { for (auto guest_host_view : guest_host_views_) {
@ -1503,13 +1503,25 @@ bool CefRenderWidgetHostViewOSR::SetDeviceScaleFactor() {
auto guest_view_osr = auto guest_view_osr =
static_cast<CefRenderWidgetHostViewOSR*>(rwhi->GetView()); static_cast<CefRenderWidgetHostViewOSR*>(rwhi->GetView());
if (guest_view_osr) { if (guest_view_osr) {
guest_view_osr->set_current_device_scale_factor(new_scale_factor); guest_view_osr->SetCurrentDeviceScaleFactor(new_scale_factor);
} }
} }
return true; return true;
} }
void CefRenderWidgetHostViewOSR::SetCurrentDeviceScaleFactor(float scale) {
// Initialize a display struct as needed, to cache the scale factor.
if (display_list_.displays().empty()) {
display_list_ = display::DisplayList(
{display::Display(display::kDefaultDisplayId)},
display::kDefaultDisplayId, display::kDefaultDisplayId);
}
display::Display current_display = display_list_.GetCurrentDisplay();
current_display.set_device_scale_factor(scale);
display_list_.UpdateDisplay(current_display);
}
bool CefRenderWidgetHostViewOSR::SetViewBounds() { bool CefRenderWidgetHostViewOSR::SetViewBounds() {
// This method should not be called while the resize hold is active. // This method should not be called while the resize hold is active.
DCHECK(!hold_resize_); DCHECK(!hold_resize_);
@ -1537,7 +1549,7 @@ bool CefRenderWidgetHostViewOSR::SetRootLayerSize(bool force) {
if (compositor_) { if (compositor_) {
compositor_local_surface_id_allocator_.GenerateId(); compositor_local_surface_id_allocator_.GenerateId();
compositor_->SetScaleAndSize( compositor_->SetScaleAndSize(
current_device_scale_factor(), SizeInPixels(), GetCurrentDeviceScaleFactor(), SizeInPixels(),
compositor_local_surface_id_allocator_.GetCurrentLocalSurfaceId()); compositor_local_surface_id_allocator_.GetCurrentLocalSurfaceId());
} }
@ -1566,7 +1578,8 @@ void CefRenderWidgetHostViewOSR::ReleaseResizeHold() {
hold_resize_ = false; hold_resize_ = false;
if (pending_resize_) { if (pending_resize_) {
pending_resize_ = false; pending_resize_ = false;
CEF_POST_TASK(CEF_UIT, base::Bind(&CefRenderWidgetHostViewOSR::WasResized, CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefRenderWidgetHostViewOSR::WasResized,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
} }

View File

@ -19,7 +19,6 @@
#include "libcef/browser/osr/motion_event_osr.h" #include "libcef/browser/osr/motion_event_osr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/layers/deadline_policy.h" #include "cc/layers/deadline_policy.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h" #include "components/viz/common/frame_sinks/begin_frame_source.h"
@ -29,6 +28,7 @@
#include "content/browser/renderer_host/text_input_manager.h" #include "content/browser/renderer_host/text_input_manager.h"
#include "content/public/browser/render_frame_metadata_provider.h" #include "content/public/browser/render_frame_metadata_provider.h"
#include "content/public/common/widget_type.h" #include "content/public/common/widget_type.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h" #include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
@ -117,9 +117,9 @@ class CefRenderWidgetHostViewOSR
void EnsureSurfaceSynchronizedForWebTest() override; void EnsureSurfaceSynchronizedForWebTest() override;
gfx::Rect GetViewBounds() override; gfx::Rect GetViewBounds() override;
void SetBackgroundColor(SkColor color) override; void SetBackgroundColor(SkColor color) override;
base::Optional<SkColor> GetBackgroundColor() override; absl::optional<SkColor> GetBackgroundColor() override;
void UpdateBackgroundColor() override; void UpdateBackgroundColor() override;
base::Optional<content::DisplayFeature> GetDisplayFeature() override; absl::optional<content::DisplayFeature> GetDisplayFeature() override;
void SetDisplayFeatureForTesting( void SetDisplayFeatureForTesting(
const content::DisplayFeature* display_feature) override; const content::DisplayFeature* display_feature) override;
blink::mojom::PointerLockResult LockMouse( blink::mojom::PointerLockResult LockMouse(
@ -150,7 +150,7 @@ class CefRenderWidgetHostViewOSR
void SetIsLoading(bool is_loading) override; void SetIsLoading(bool is_loading) override;
void RenderProcessGone() override; void RenderProcessGone() override;
void Destroy() override; void Destroy() override;
void SetTooltipText(const std::u16string& tooltip_text) override; void UpdateTooltipUnderCursor(const std::u16string& tooltip_text) override;
content::CursorManager* GetCursorManager() override; content::CursorManager* GetCursorManager() override;
gfx::Size GetCompositorViewportPixelSize() override; gfx::Size GetCompositorViewportPixelSize() override;
void CopyFromSurface( void CopyFromSurface(
@ -215,7 +215,7 @@ class CefRenderWidgetHostViewOSR
void WasResized(); void WasResized();
void SynchronizeVisualProperties( void SynchronizeVisualProperties(
const cc::DeadlinePolicy& deadline_policy, const cc::DeadlinePolicy& deadline_policy,
const base::Optional<viz::LocalSurfaceId>& child_local_surface_id); const absl::optional<viz::LocalSurfaceId>& child_local_surface_id);
void OnScreenInfoChanged(); void OnScreenInfoChanged();
void Invalidate(CefBrowserHost::PaintElementType type); void Invalidate(CefBrowserHost::PaintElementType type);
void SendExternalBeginFrame(); void SendExternalBeginFrame();
@ -277,6 +277,7 @@ class CefRenderWidgetHostViewOSR
private: private:
void SetFrameRate(); void SetFrameRate();
bool SetDeviceScaleFactor(); bool SetDeviceScaleFactor();
void SetCurrentDeviceScaleFactor(float scale);
bool SetViewBounds(); bool SetViewBounds();
bool SetRootLayerSize(bool force); bool SetRootLayerSize(bool force);
@ -315,7 +316,7 @@ class CefRenderWidgetHostViewOSR
// has allocated one. Also sets child sequence number component of the // has allocated one. Also sets child sequence number component of the
// viz::LocalSurfaceId allocator. // viz::LocalSurfaceId allocator.
void UpdateLocalSurfaceIdFromEmbeddedClient( void UpdateLocalSurfaceIdFromEmbeddedClient(
const base::Optional<viz::LocalSurfaceId>& local_surface_id); const absl::optional<viz::LocalSurfaceId>& local_surface_id);
// Returns the current viz::LocalSurfaceIdAllocation. // Returns the current viz::LocalSurfaceIdAllocation.
const viz::LocalSurfaceId& GetOrCreateLocalSurfaceId(); const viz::LocalSurfaceId& GetOrCreateLocalSurfaceId();

View File

@ -66,7 +66,7 @@ void CefVideoConsumerOSR::SizeChanged(const gfx::Size& size_in_pixels) {
} }
void CefVideoConsumerOSR::RequestRefreshFrame( void CefVideoConsumerOSR::RequestRefreshFrame(
const base::Optional<gfx::Rect>& bounds_in_pixels) { const absl::optional<gfx::Rect>& bounds_in_pixels) {
bounds_in_pixels_ = bounds_in_pixels; bounds_in_pixels_ = bounds_in_pixels;
video_capturer_->RequestRefreshFrame(); video_capturer_->RequestRefreshFrame();
} }
@ -112,7 +112,7 @@ void CefVideoConsumerOSR::OnFrameCaptured(
// Use the bounds passed to RequestRefreshFrame(). // Use the bounds passed to RequestRefreshFrame().
damage_rect = gfx::Rect(info->coded_size); damage_rect = gfx::Rect(info->coded_size);
damage_rect.Intersect(*bounds_in_pixels_); damage_rect.Intersect(*bounds_in_pixels_);
bounds_in_pixels_ = base::nullopt; bounds_in_pixels_ = absl::nullopt;
} else { } else {
// Retrieve the rectangular region of the frame that has changed since the // Retrieve the rectangular region of the frame that has changed since the
// frame with the directly preceding CAPTURE_COUNTER. If that frame was not // frame with the directly preceding CAPTURE_COUNTER. If that frame was not

View File

@ -2,9 +2,9 @@
#define LIBCEF_BROWSER_OSR_VIDEO_CONSUMER_OSR_H_ #define LIBCEF_BROWSER_OSR_VIDEO_CONSUMER_OSR_H_
#include "base/callback.h" #include "base/callback.h"
#include "base/optional.h"
#include "components/viz/host/client_frame_sink_video_capturer.h" #include "components/viz/host/client_frame_sink_video_capturer.h"
#include "media/capture/mojom/video_capture_types.mojom.h" #include "media/capture/mojom/video_capture_types.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
class CefRenderWidgetHostViewOSR; class CefRenderWidgetHostViewOSR;
@ -16,7 +16,7 @@ class CefVideoConsumerOSR : public viz::mojom::FrameSinkVideoConsumer {
void SetActive(bool active); void SetActive(bool active);
void SetFrameRate(base::TimeDelta frame_rate); void SetFrameRate(base::TimeDelta frame_rate);
void SizeChanged(const gfx::Size& size_in_pixels); void SizeChanged(const gfx::Size& size_in_pixels);
void RequestRefreshFrame(const base::Optional<gfx::Rect>& bounds_in_pixels); void RequestRefreshFrame(const absl::optional<gfx::Rect>& bounds_in_pixels);
private: private:
// viz::mojom::FrameSinkVideoConsumer implementation. // viz::mojom::FrameSinkVideoConsumer implementation.
@ -33,7 +33,7 @@ class CefVideoConsumerOSR : public viz::mojom::FrameSinkVideoConsumer {
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_; std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
gfx::Size size_in_pixels_; gfx::Size size_in_pixels_;
base::Optional<gfx::Rect> bounds_in_pixels_; absl::optional<gfx::Rect> bounds_in_pixels_;
DISALLOW_COPY_AND_ASSIGN(CefVideoConsumerOSR); DISALLOW_COPY_AND_ASSIGN(CefVideoConsumerOSR);
}; };

View File

@ -249,6 +249,10 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
false); false);
registry->RegisterBooleanPref(prefs::kWebRTCAllowLegacyTLSProtocols, false); registry->RegisterBooleanPref(prefs::kWebRTCAllowLegacyTLSProtocols, false);
// Profile preferences.
// Based on chrome/browser/profiles/profiles_state.cc RegisterPrefs.
registry->RegisterStringPref(prefs::kProfileLastUsed, std::string());
if (profile) { if (profile) {
// Call RegisterProfilePrefs() for all services listed by // Call RegisterProfilePrefs() for all services listed by
// EnsureBrowserContextKeyedServiceFactoriesBuilt(). // EnsureBrowserContextKeyedServiceFactoriesBuilt().
@ -310,10 +314,6 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
registry->SetDefaultPrefValue(spellcheck::prefs::kSpellCheckEnable, registry->SetDefaultPrefValue(spellcheck::prefs::kSpellCheckEnable,
base::Value(!enable_spelling_service_)); base::Value(!enable_spelling_service_));
// Pepper flash preferences.
// Modify defaults from DeviceIDFetcher::RegisterProfilePrefs.
registry->SetDefaultPrefValue(prefs::kEnableDRM, base::Value(false));
// DevTools preferences. // DevTools preferences.
// Based on DevToolsWindow::RegisterProfilePrefs. // Based on DevToolsWindow::RegisterProfilePrefs.
registry->RegisterDictionaryPref(prefs::kDevToolsPreferences); registry->RegisterDictionaryPref(prefs::kDevToolsPreferences);

View File

@ -7,6 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "chrome/browser/platform_util.h" #include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "components/web_modal/web_contents_modal_dialog_host.h" #include "components/web_modal/web_contents_modal_dialog_host.h"

View File

@ -39,8 +39,9 @@ class CefPrintDialogCallbackImpl : public CefPrintDialogCallback {
dialog_ = nullptr; dialog_ = nullptr;
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefPrintDialogCallbackImpl::Continue, CEF_POST_TASK(CEF_UIT,
this, settings)); base::BindOnce(&CefPrintDialogCallbackImpl::Continue, this,
settings));
} }
} }
@ -52,7 +53,7 @@ class CefPrintDialogCallbackImpl : public CefPrintDialogCallback {
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefPrintDialogCallbackImpl::Cancel, this)); base::BindOnce(&CefPrintDialogCallbackImpl::Cancel, this));
} }
} }
@ -78,7 +79,7 @@ class CefPrintJobCallbackImpl : public CefPrintJobCallback {
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefPrintJobCallbackImpl::Continue, this)); base::BindOnce(&CefPrintJobCallbackImpl::Continue, this));
} }
} }
@ -214,8 +215,9 @@ void CefPrintDialogLinux::PrintDocument(
} }
// No errors, continue printing. // No errors, continue printing.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefPrintDialogLinux::SendDocumentToPrinter, CEF_POST_TASK(
this, document_name)); CEF_UIT, base::BindOnce(&CefPrintDialogLinux::SendDocumentToPrinter, this,
document_name));
} }
void CefPrintDialogLinux::AddRefToDialog() { void CefPrintDialogLinux::AddRefToDialog() {

View File

@ -149,7 +149,7 @@ void StopWorker(int document_cookie) {
// Write the PDF file to disk. // Write the PDF file to disk.
void SavePdfFile(scoped_refptr<base::RefCountedSharedMemoryMapping> data, void SavePdfFile(scoped_refptr<base::RefCountedSharedMemoryMapping> data,
const base::FilePath& path, const base::FilePath& path,
const CefPrintViewManager::PdfPrintCallback& callback) { CefPrintViewManager::PdfPrintCallback callback) {
CEF_REQUIRE_BLOCKING(); CEF_REQUIRE_BLOCKING();
DCHECK_GT(data->size(), 0U); DCHECK_GT(data->size(), 0U);
@ -161,8 +161,8 @@ void SavePdfFile(scoped_refptr<base::RefCountedSharedMemoryMapping> data,
bool ok = file.IsValid() && metafile.SaveTo(&file); bool ok = file.IsValid() && metafile.SaveTo(&file);
if (!callback.is_null()) { if (!callback.is_null()) {
content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, content::GetUIThreadTaskRunner({})->PostTask(
base::Bind(callback, ok)); FROM_HERE, base::BindOnce(std::move(callback), ok));
} }
} }
@ -185,7 +185,7 @@ CefPrintViewManager::~CefPrintViewManager() {
bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh, bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh,
const base::FilePath& path, const base::FilePath& path,
const CefPdfPrintSettings& settings, const CefPdfPrintSettings& settings,
const PdfPrintCallback& callback) { PdfPrintCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Don't start print again while printing is currently in progress. // Don't start print again while printing is currently in progress.
@ -200,7 +200,7 @@ bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh,
pdf_print_state_.reset(new PdfPrintState); pdf_print_state_.reset(new PdfPrintState);
pdf_print_state_->printing_rfh_ = rfh; pdf_print_state_->printing_rfh_ = rfh;
pdf_print_state_->output_path_ = path; pdf_print_state_->output_path_ = path;
pdf_print_state_->callback_ = callback; pdf_print_state_->callback_ = std::move(callback);
FillInDictionaryFromPdfPrintSettings(settings, ++next_pdf_request_id_, FillInDictionaryFromPdfPrintSettings(settings, ++next_pdf_request_id_,
pdf_print_state_->settings_); pdf_print_state_->settings_);
@ -276,15 +276,15 @@ void CefPrintViewManager::MetafileReadyForPrinting(
} }
const base::FilePath output_path = pdf_print_state_->output_path_; const base::FilePath output_path = pdf_print_state_->output_path_;
const PdfPrintCallback print_callback = pdf_print_state_->callback_; PdfPrintCallback print_callback = std::move(pdf_print_state_->callback_);
// Reset state information. // Reset state information.
pdf_print_state_.reset(); pdf_print_state_.reset();
pdf_print_receiver_.reset(); pdf_print_receiver_.reset();
// Save the PDF file to disk and then execute the callback. // Save the PDF file to disk and then execute the callback.
CEF_POST_USER_VISIBLE_TASK( CEF_POST_USER_VISIBLE_TASK(base::BindOnce(
base::Bind(&SavePdfFile, shared_buf, output_path, print_callback)); &SavePdfFile, shared_buf, output_path, std::move(print_callback)));
} }
void CefPrintViewManager::PrintPreviewFailed(int32_t document_cookie, void CefPrintViewManager::PrintPreviewFailed(int32_t document_cookie,
@ -350,7 +350,8 @@ void CefPrintViewManager::TerminatePdfPrintJob() {
if (!pdf_print_state_->callback_.is_null()) { if (!pdf_print_state_->callback_.is_null()) {
// Execute the callback. // Execute the callback.
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::Bind(pdf_print_state_->callback_, false)); FROM_HERE,
base::BindOnce(std::move(pdf_print_state_->callback_), false));
} }
// Reset state information. // Reset state information.

View File

@ -7,6 +7,7 @@
#include "include/internal/cef_types_wrappers.h" #include "include/internal/cef_types_wrappers.h"
#include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/printing/print_view_manager.h"
#include "components/printing/common/print.mojom-forward.h" #include "components/printing/common/print.mojom-forward.h"
@ -30,13 +31,13 @@ class CefPrintViewManager : public PrintViewManager,
~CefPrintViewManager() override; ~CefPrintViewManager() override;
// Callback executed on PDF printing completion. // Callback executed on PDF printing completion.
typedef base::Callback<void(bool /*ok*/)> PdfPrintCallback; typedef base::OnceCallback<void(bool /*ok*/)> PdfPrintCallback;
// Print the current document to a PDF file. Execute |callback| on completion. // Print the current document to a PDF file. Execute |callback| on completion.
bool PrintToPDF(content::RenderFrameHost* rfh, bool PrintToPDF(content::RenderFrameHost* rfh,
const base::FilePath& path, const base::FilePath& path,
const CefPdfPrintSettings& settings, const CefPdfPrintSettings& settings,
const PdfPrintCallback& callback); PdfPrintCallback callback);
// mojom::PrintManagerHost methods: // mojom::PrintManagerHost methods:
void GetDefaultPrintSettings( void GetDefaultPrintSettings(

View File

@ -47,8 +47,6 @@ const char* GetTypeString(base::Value::Type type) {
return "DICTIONARY"; return "DICTIONARY";
case base::Value::Type::LIST: case base::Value::Type::LIST:
return "LIST"; return "LIST";
case base::Value::Type::DEAD:
return "DEAD";
} }
NOTREACHED(); NOTREACHED();
@ -62,7 +60,7 @@ struct ResolveHostHelperOld {
void OnResolveCompleted(int result) { void OnResolveCompleted(int result) {
std::vector<CefString> resolved_ips; std::vector<CefString> resolved_ips;
base::Optional<net::AddressList> maybe_address_list = absl::optional<net::AddressList> maybe_address_list =
request_->GetAddressResults(); request_->GetAddressResults();
if (maybe_address_list) { if (maybe_address_list) {
net::AddressList::const_iterator iter = maybe_address_list->begin(); net::AddressList::const_iterator iter = maybe_address_list->begin();
@ -71,7 +69,7 @@ struct ResolveHostHelperOld {
} }
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefResolveCallback::OnResolveCompleted, callback_, base::BindOnce(&CefResolveCallback::OnResolveCompleted, callback_,
static_cast<cef_errorcode_t>(result), resolved_ips)); static_cast<cef_errorcode_t>(result), resolved_ips));
delete this; delete this;
@ -90,11 +88,11 @@ class ResolveHostHelper : public network::ResolveHostClientBase {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
browser_context->GetNetworkContext()->CreateHostResolver( browser_context->GetNetworkContext()->CreateHostResolver(
base::nullopt, host_resolver_.BindNewPipeAndPassReceiver()); absl::nullopt, host_resolver_.BindNewPipeAndPassReceiver());
host_resolver_.set_disconnect_handler(base::BindOnce( host_resolver_.set_disconnect_handler(base::BindOnce(
&ResolveHostHelper::OnComplete, base::Unretained(this), net::ERR_FAILED, &ResolveHostHelper::OnComplete, base::Unretained(this), net::ERR_FAILED,
net::ResolveErrorInfo(net::ERR_FAILED), base::nullopt)); net::ResolveErrorInfo(net::ERR_FAILED), absl::nullopt));
host_resolver_->ResolveHost( host_resolver_->ResolveHost(
net::HostPortPair::FromURL(GURL(origin.ToString())), net::HostPortPair::FromURL(GURL(origin.ToString())),
@ -106,7 +104,7 @@ class ResolveHostHelper : public network::ResolveHostClientBase {
void OnComplete( void OnComplete(
int32_t result, int32_t result,
const ::net::ResolveErrorInfo& resolve_error_info, const ::net::ResolveErrorInfo& resolve_error_info,
const base::Optional<net::AddressList>& resolved_addresses) override { const absl::optional<net::AddressList>& resolved_addresses) override {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
host_resolver_.reset(); host_resolver_.reset();
@ -731,11 +729,11 @@ void CefRequestContextImpl::ClearCertificateExceptionsInternal(
content::SSLHostStateDelegate* ssl_delegate = content::SSLHostStateDelegate* ssl_delegate =
browser_context->AsBrowserContext()->GetSSLHostStateDelegate(); browser_context->AsBrowserContext()->GetSSLHostStateDelegate();
if (ssl_delegate) if (ssl_delegate)
ssl_delegate->Clear(base::Callback<bool(const std::string&)>()); ssl_delegate->Clear(base::NullCallback());
if (callback) { if (callback) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefCompletionCallback::OnComplete, callback)); base::BindOnce(&CefCompletionCallback::OnComplete, callback));
} }
} }
@ -748,7 +746,7 @@ void CefRequestContextImpl::ClearHttpAuthCredentialsInternal(
browser_context->GetNetworkContext()->ClearHttpAuthCache( browser_context->GetNetworkContext()->ClearHttpAuthCache(
/*start_time=*/base::Time(), /*end_time=*/base::Time::Max(), /*start_time=*/base::Time(), /*end_time=*/base::Time::Max(),
base::Bind(&CefCompletionCallback::OnComplete, callback)); base::BindOnce(&CefCompletionCallback::OnComplete, callback));
} }
void CefRequestContextImpl::CloseAllConnectionsInternal( void CefRequestContextImpl::CloseAllConnectionsInternal(
@ -759,7 +757,7 @@ void CefRequestContextImpl::CloseAllConnectionsInternal(
return; return;
browser_context->GetNetworkContext()->CloseAllConnections( browser_context->GetNetworkContext()->CloseAllConnections(
base::Bind(&CefCompletionCallback::OnComplete, callback)); base::BindOnce(&CefCompletionCallback::OnComplete, callback));
} }
void CefRequestContextImpl::ResolveHostInternal( void CefRequestContextImpl::ResolveHostInternal(

View File

@ -421,7 +421,7 @@ bool CefSimpleMenuModelImpl::SetAcceleratorAt(int index,
bool CefSimpleMenuModelImpl::RemoveAccelerator(int command_id) { bool CefSimpleMenuModelImpl::RemoveAccelerator(int command_id) {
if (!VerifyContext() || command_id == kInvalidIndex) if (!VerifyContext() || command_id == kInvalidIndex)
return false; return false;
state_delegate_->SetAccelerator(command_id, base::nullopt); state_delegate_->SetAccelerator(command_id, absl::nullopt);
return true; return true;
} }

View File

@ -23,7 +23,7 @@ class CefSimpleMenuModelImpl : public CefMenuModel {
public: public:
virtual void SetChecked(int command_id, bool checked) = 0; virtual void SetChecked(int command_id, bool checked) = 0;
virtual void SetAccelerator(int command_id, virtual void SetAccelerator(int command_id,
base::Optional<ui::Accelerator> accel) = 0; absl::optional<ui::Accelerator> accel) = 0;
protected: protected:
virtual ~StateDelegate() {} virtual ~StateDelegate() {}

View File

@ -17,12 +17,13 @@ namespace {
// represented by |message_loop_proxy|. // represented by |message_loop_proxy|.
void CreateTemporaryFileOnBackgroundThread( void CreateTemporaryFileOnBackgroundThread(
scoped_refptr<base::SequencedTaskRunner> message_loop_proxy, scoped_refptr<base::SequencedTaskRunner> message_loop_proxy,
base::Callback<void(const base::FilePath&)> callback) { base::OnceCallback<void(const base::FilePath&)> callback) {
CEF_REQUIRE_BLOCKING(); CEF_REQUIRE_BLOCKING();
base::FilePath file_path; base::FilePath file_path;
if (!base::CreateTemporaryFile(&file_path)) if (!base::CreateTemporaryFile(&file_path))
LOG(ERROR) << "Failed to create temporary file."; LOG(ERROR) << "Failed to create temporary file.";
message_loop_proxy->PostTask(FROM_HERE, base::Bind(callback, file_path)); message_loop_proxy->PostTask(FROM_HERE,
base::BindOnce(std::move(callback), file_path));
} }
// Release the wrapped callback object after completion. // Release the wrapped callback object after completion.
@ -102,19 +103,20 @@ bool CefTraceSubscriber::EndTracing(const base::FilePath& tracing_file,
if (tracing_file.empty()) { if (tracing_file.empty()) {
// Create a new temporary file path on the FILE thread, then continue. // Create a new temporary file path on the FILE thread, then continue.
CEF_POST_USER_VISIBLE_TASK( CEF_POST_USER_VISIBLE_TASK(
base::Bind(CreateTemporaryFileOnBackgroundThread, base::BindOnce(CreateTemporaryFileOnBackgroundThread,
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
base::Bind(&CefTraceSubscriber::ContinueEndTracing, base::BindOnce(&CefTraceSubscriber::ContinueEndTracing,
weak_factory_.GetWeakPtr(), callback))); weak_factory_.GetWeakPtr(), callback)));
return true; return true;
} }
base::Closure result_callback = auto result_callback =
base::Bind(&CefTraceSubscriber::OnTracingFileResult, base::BindOnce(&CefTraceSubscriber::OnTracingFileResult,
weak_factory_.GetWeakPtr(), callback, tracing_file); weak_factory_.GetWeakPtr(), callback, tracing_file);
TracingController::GetInstance()->StopTracing( TracingController::GetInstance()->StopTracing(
TracingController::CreateFileEndpoint(tracing_file, result_callback)); TracingController::CreateFileEndpoint(tracing_file,
std::move(result_callback)));
return true; return true;
} }

View File

@ -53,8 +53,8 @@ CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetState(cef_button_state_t state) {
views::Button::ButtonState new_state = views::Button::ButtonState new_state =
static_cast<views::Button::ButtonState>(state); static_cast<views::Button::ButtonState>(state);
if (ParentClass::root_view()->ink_drop_mode() != if (ParentClass::root_view()->ink_drop()->ink_drop_mode() !=
views::Button::InkDropMode::OFF && views::InkDropHost::InkDropMode::OFF &&
!ParentClass::root_view()->IsFocusable()) { !ParentClass::root_view()->IsFocusable()) {
// Ink drop state does not get set properly on state change when the button // Ink drop state does not get set properly on state change when the button
// is non-focusable. // is non-focusable.
@ -64,7 +64,7 @@ CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetState(cef_button_state_t state) {
} else if (old_state == views::Button::STATE_PRESSED) { } else if (old_state == views::Button::STATE_PRESSED) {
ink_state = views::InkDropState::DEACTIVATED; ink_state = views::InkDropState::DEACTIVATED;
} }
ParentClass::root_view()->AnimateInkDrop(ink_state, nullptr); ParentClass::root_view()->ink_drop()->AnimateToState(ink_state, nullptr);
} }
ParentClass::root_view()->SetState(new_state); ParentClass::root_view()->SetState(new_state);
@ -77,11 +77,11 @@ CEF_BUTTON_IMPL_T cef_button_state_t CEF_BUTTON_IMPL_D::GetState() {
CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetInkDropEnabled(bool enabled) { CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetInkDropEnabled(bool enabled) {
CEF_REQUIRE_VALID_RETURN_VOID(); CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::root_view()->SetInkDropMode( ParentClass::root_view()->ink_drop()->SetMode(
enabled ? views::InkDropHostView::InkDropMode::ON enabled ? views::InkDropHost::InkDropMode::ON
: views::InkDropHostView::InkDropMode::OFF); : views::InkDropHost::InkDropMode::OFF);
if (enabled) { if (enabled) {
ParentClass::root_view()->SetInkDropBaseColor( ParentClass::root_view()->ink_drop()->SetBaseColor(
color_utils::BlendTowardMaxContrast( color_utils::BlendTowardMaxContrast(
ParentClass::root_view()->background()->get_color(), 0x61)); ParentClass::root_view()->background()->get_color(), 0x61));
} }

View File

@ -59,15 +59,16 @@ CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::ButtonPressed(
// Callback may trigger new animation state. // Callback may trigger new animation state.
if (ParentClass::cef_delegate()) if (ParentClass::cef_delegate())
ParentClass::cef_delegate()->OnButtonPressed(GetCefButton()); ParentClass::cef_delegate()->OnButtonPressed(GetCefButton());
if (ParentClass::ink_drop_mode() != views::Button::InkDropMode::OFF && if (ParentClass::ink_drop()->ink_drop_mode() !=
views::InkDropHost::InkDropMode::OFF &&
!ParentClass::IsFocusable() && !ParentClass::IsFocusable() &&
ParentClass::GetState() != views::Button::STATE_PRESSED) { ParentClass::GetState() != views::Button::STATE_PRESSED) {
// Ink drop state does not get reset properly on click when the button is // Ink drop state does not get reset properly on click when the button is
// non-focusable. Reset the ink drop state here if the state has not been // non-focusable. Reset the ink drop state here if the state has not been
// explicitly set to pressed by the OnButtonPressed callback calling // explicitly set to pressed by the OnButtonPressed callback calling
// SetState (which also sets the ink drop state). // SetState (which also sets the ink drop state).
ParentClass::AnimateInkDrop(views::InkDropState::HIDDEN, ParentClass::ink_drop()->AnimateToState(
ui::LocatedEvent::FromIfValid(&event)); views::InkDropState::HIDDEN, ui::LocatedEvent::FromIfValid(&event));
} }
} }

View File

@ -13,6 +13,7 @@
#include "libcef/browser/views/window_view.h" #include "libcef/browser/views/window_view.h"
#include "ui/base/test/ui_controls.h" #include "ui/base/test/ui_controls.h"
#include "ui/compositor/compositor.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/menu/menu_runner.h" #include "ui/views/controls/menu/menu_runner.h"
@ -434,11 +435,11 @@ void CefWindowImpl::ShowMenu(views::MenuButton* menu_button,
// We'll send the MenuClosed notification manually for better accuracy. // We'll send the MenuClosed notification manually for better accuracy.
menu_model_->set_auto_notify_menu_closed(false); menu_model_->set_auto_notify_menu_closed(false);
menu_runner_.reset( menu_runner_.reset(new views::MenuRunner(
new views::MenuRunner(menu_model_impl->model(), menu_model_impl->model(),
menu_button ? views::MenuRunner::HAS_MNEMONICS menu_button ? views::MenuRunner::HAS_MNEMONICS
: views::MenuRunner::CONTEXT_MENU, : views::MenuRunner::CONTEXT_MENU,
base::Bind(&CefWindowImpl::MenuClosed, this))); base::BindRepeating(&CefWindowImpl::MenuClosed, this)));
menu_runner_->RunMenuAt( menu_runner_->RunMenuAt(
widget_, menu_button ? menu_button->button_controller() : nullptr, widget_, menu_button ? menu_button->button_controller() : nullptr,

View File

@ -9,7 +9,6 @@
#include "libcef/browser/views/window_impl.h" #include "libcef/browser/views/window_impl.h"
#include "libcef/features/runtime.h" #include "libcef/features/runtime.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/window/native_frame_view.h" #include "ui/views/window/native_frame_view.h"
@ -285,7 +284,7 @@ void CefWindowView::CreateWidget() {
can_activate = can_activate_menu; can_activate = can_activate_menu;
if (can_activate_menu) if (can_activate_menu)
params.activatable = views::Widget::InitParams::ACTIVATABLE_YES; params.activatable = views::Widget::InitParams::Activatable::kYes;
} }
} }
} }

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