Update to Chromium version 122.0.6261.0 (#1250580)

Frame identifiers have changed from int64_t to string type. This is due
to https://crbug.com/1502660 which removes access to frame routing IDs
in the renderer process. New cross-process frame identifiers are 160-bit
values (32-bit child process ID + 128-bit local frame token) and most
easily represented as strings. All other frame-related expectations and
behaviors remain the same.
This commit is contained in:
Marshall Greenblatt
2024-01-25 21:12:43 -05:00
parent 2a86a02bdd
commit 2f1e782f62
156 changed files with 1452 additions and 1436 deletions

View File

@@ -113,12 +113,7 @@ AlloyBrowserContext::AlloyBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings) {}
AlloyBrowserContext::~AlloyBrowserContext() {
if (resource_context_) {
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
}
}
AlloyBrowserContext::~AlloyBrowserContext() = default;
bool AlloyBrowserContext::IsInitialized() const {
CEF_REQUIRE_UIT();
@@ -311,13 +306,6 @@ bool AlloyBrowserContext::IsPrintPreviewSupported() const {
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
}
content::ResourceContext* AlloyBrowserContext::GetResourceContext() {
if (!resource_context_) {
resource_context_ = std::make_unique<content::ResourceContext>();
}
return resource_context_.get();
}
content::ClientHintsControllerDelegate*
AlloyBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;

View File

@@ -59,7 +59,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
bool IsPrintPreviewSupported() const override;
// content::BrowserContext overrides.
content::ResourceContext* GetResourceContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
base::FilePath GetPath() override;
@@ -142,8 +141,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
std::unique_ptr<ProfileKey> key_;
std::unique_ptr<DownloadPrefs> download_prefs_;
std::unique_ptr<content::ResourceContext> resource_context_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_

View File

@@ -50,8 +50,8 @@
#include "ui/native_theme/native_theme.h"
#if BUILDFLAG(IS_LINUX)
#include "ui/ozone/buildflags.h"
#if defined(USE_AURA) && BUILDFLAG(OZONE_PLATFORM_X11)
#include "ui/base/ozone_buildflags.h"
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h"
#endif
#endif
@@ -252,7 +252,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
#if BUILDFLAG(IS_LINUX)
#if defined(USE_AURA) && BUILDFLAG(OZONE_PLATFORM_X11)
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
#endif

View File

@@ -70,6 +70,7 @@
#include "chrome/browser/profiles/renderer_updater.h"
#include "chrome/browser/profiles/renderer_updater_factory.h"
#include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h"
#include "chrome/browser/spellchecker/spell_check_initialization_host_impl.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/pdf/chrome_pdf_document_helper_client.h"
#include "chrome/common/chrome_content_client.h"
@@ -541,7 +542,7 @@ bool AlloyContentBrowserClient::IsHandledURL(const GURL& url) {
return CefAppManager::Get()->HasCustomScheme(scheme);
}
void AlloyContentBrowserClient::SiteInstanceGotProcess(
void AlloyContentBrowserClient::SiteInstanceGotProcessAndSite(
content::SiteInstance* site_instance) {
if (!extensions::ExtensionsEnabled()) {
return;
@@ -570,9 +571,10 @@ void AlloyContentBrowserClient::SiteInstanceGotProcess(
void AlloyContentBrowserClient::BindHostReceiverForRenderer(
content::RenderProcessHost* render_process_host,
mojo::GenericPendingReceiver receiver) {
if (auto host_receiver = receiver.As<spellcheck::mojom::SpellCheckHost>()) {
SpellCheckHostChromeImpl::Create(render_process_host->GetID(),
std::move(host_receiver));
if (auto host_receiver =
receiver.As<spellcheck::mojom::SpellCheckInitializationHost>()) {
SpellCheckInitializationHostImpl::Create(render_process_host->GetID(),
std::move(host_receiver));
return;
}
@@ -1019,7 +1021,8 @@ AlloyContentBrowserClient::CreateURLLoaderThrottles(
content::BrowserContext* browser_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id) {
int frame_tree_node_id,
absl::optional<int64_t> navigation_id) {
std::vector<std::unique_ptr<blink::URLLoaderThrottle>> result;
// Used to substitute View ID for PDF contents when using the PDF plugin.
@@ -1108,6 +1111,7 @@ std::unique_ptr<content::LoginDelegate>
AlloyContentBrowserClient::CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,
@@ -1138,7 +1142,7 @@ void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const absl::optional<url::Origin>& request_initiator_origin,
const std::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) {
if (!extensions::ExtensionsEnabled()) {
return;
@@ -1346,6 +1350,13 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
map->Add<network_hints::mojom::NetworkHintsHandler>(
base::BindRepeating(&BindNetworkHintsHandler));
map->Add<spellcheck::mojom::SpellCheckHost>(base::BindRepeating(
[](content::RenderFrameHost* frame_host,
mojo::PendingReceiver<spellcheck::mojom::SpellCheckHost> receiver) {
SpellCheckHostChromeImpl::Create(frame_host->GetProcess()->GetID(),
std::move(receiver));
}));
if (!extensions::ExtensionsEnabled()) {
return;
}

View File

@@ -64,7 +64,8 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
std::vector<std::string>* additional_allowed_schemes) override;
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
bool IsHandledURL(const GURL& url) override;
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
void SiteInstanceGotProcessAndSite(
content::SiteInstance* site_instance) override;
void BindHostReceiverForRenderer(
content::RenderProcessHost* render_process_host,
mojo::GenericPendingReceiver receiver) override;
@@ -135,7 +136,8 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* browser_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id) override;
int frame_tree_node_id,
absl::optional<int64_t> navigation_id) override;
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateURLLoaderThrottlesForKeepAlive(
const network::ResourceRequest& request,
@@ -162,6 +164,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,
@@ -174,7 +177,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const absl::optional<url::Origin>& request_initiator_origin,
const std::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) override;
bool WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,

View File

@@ -69,10 +69,10 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
// Extension resources will fail to load if we don't use a SiteInstance
// associated with the extension.
// (AlloyContentBrowserClient::SiteInstanceGotProcess won't find the
// extension to register with InfoMap, and AllowExtensionResourceLoad in
// ExtensionProtocolHandler::MaybeCreateJob will return false resulting in
// ERR_BLOCKED_BY_CLIENT).
// (AlloyContentBrowserClient::SiteInstanceGotProcessAndSite won't find
// the extension to register with InfoMap, and AllowExtensionResourceLoad
// in ExtensionProtocolHandler::MaybeCreateJob will return false resulting
// in ERR_BLOCKED_BY_CLIENT).
site_instance = extensions::ProcessManager::Get(browser_context)
->GetSiteInstanceForURL(gurl);
DCHECK(site_instance);

View File

@@ -19,6 +19,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/permissions/chrome_permissions_client.h"
@@ -31,6 +32,7 @@
#include "components/component_updater/component_updater_service.h"
#include "components/component_updater/timer_update_scheduler.h"
#include "components/net_log/chrome_net_log.h"
#include "components/os_crypt/async/browser/os_crypt_async.h"
#include "components/prefs/pref_service.h"
#include "content/browser/startup_helper.h"
#include "content/public/browser/network_service_instance.h"
@@ -39,6 +41,10 @@
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if BUILDFLAG(IS_WIN)
#include "components/os_crypt/async/browser/dpapi_key_provider.h"
#endif
ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy() : locale_("en-US") {}
ChromeBrowserProcessAlloy::~ChromeBrowserProcessAlloy() {
@@ -81,6 +87,30 @@ void ChromeBrowserProcessAlloy::OnContextInitialized() {
DCHECK(!context_initialized_);
DCHECK(!shutdown_);
// OSCryptAsync provider configuration. If empty, this delegates all
// encryption operations to OSCrypt.
std::vector<std::pair<size_t, std::unique_ptr<os_crypt_async::KeyProvider>>>
providers;
#if BUILDFLAG(IS_WIN)
// TODO(crbug.com/1373092): For Windows, continue to add providers behind
// features, as support for them is added.
if (base::FeatureList::IsEnabled(features::kEnableDPAPIEncryptionProvider)) {
// The DPAPI key provider requires OSCrypt::Init to have already been called
// to initialize the key storage. This happens in
// AlloyBrowserMainParts::PreCreateMainMessageLoop.
providers.emplace_back(std::make_pair(
/*precedence=*/10u,
std::make_unique<os_crypt_async::DPAPIKeyProvider>(local_state())));
}
#endif // BUILDFLAG(IS_WIN)
os_crypt_async_ =
std::make_unique<os_crypt_async::OSCryptAsync>(std::move(providers));
// Trigger async initialization of OSCrypt key providers.
std::ignore = os_crypt_async_->GetInstance(base::DoNothing());
// Must be created after the NotificationService.
print_job_manager_ = std::make_unique<printing::PrintJobManager>();
profile_manager_ = std::make_unique<ChromeProfileManagerAlloy>();
@@ -270,9 +300,9 @@ printing::PrintJobManager* ChromeBrowserProcessAlloy::print_job_manager() {
printing::PrintPreviewDialogController*
ChromeBrowserProcessAlloy::print_preview_dialog_controller() {
if (!print_preview_dialog_controller_.get()) {
if (!print_preview_dialog_controller_) {
print_preview_dialog_controller_ =
new printing::PrintPreviewDialogController();
std::make_unique<printing::PrintPreviewDialogController>();
}
return print_preview_dialog_controller_.get();
}
@@ -405,8 +435,8 @@ ChromeBrowserProcessAlloy::resource_coordinator_parts() {
}
os_crypt_async::OSCryptAsync* ChromeBrowserProcessAlloy::os_crypt_async() {
DCHECK(false);
return nullptr;
DCHECK(os_crypt_async_);
return os_crypt_async_.get();
}
BuildState* ChromeBrowserProcessAlloy::GetBuildState() {

View File

@@ -125,7 +125,7 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
std::unique_ptr<ChromeProfileManagerAlloy> profile_manager_;
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
scoped_refptr<printing::PrintPreviewDialogController>
std::unique_ptr<printing::PrintPreviewDialogController>
print_preview_dialog_controller_;
std::unique_ptr<printing::BackgroundPrintingManager>
background_printing_manager_;
@@ -137,6 +137,8 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
std::unique_ptr<base::FieldTrialList> field_trial_list_;
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
std::unique_ptr<os_crypt_async::OSCryptAsync> os_crypt_async_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_

View File

@@ -114,7 +114,9 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
// May return nullptr for omnibox navigations.
auto frame = browser()->GetFrame(params.frame_tree_node_id);
auto frame = browser_info_->browser()->GetFrameForHost(
content::RenderFrameHost::FromID(params.source_render_process_id,
params.source_render_frame_id));
if (!frame) {
frame = browser()->GetMainFrame();
}
@@ -324,11 +326,9 @@ void CefBrowserContentsDelegate::RenderFrameHostStateChanged(
void CefBrowserContentsDelegate::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
const auto frame_id =
frame_util::MakeFrameId(render_frame_host->GetGlobalId());
browser_info_->RemoveFrame(render_frame_host);
if (focused_frame_ && focused_frame_->GetIdentifier() == frame_id) {
if (focused_frame_ && focused_frame_->IsSameFrame(render_frame_host)) {
focused_frame_ = nullptr;
OnStateChanged(State::kFocusedFrame);
}

View File

@@ -148,6 +148,39 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalId(
}
}
// static
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token) {
if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr;
}
if (CEF_CURRENTLY_ON_UIT()) {
// Use the non-thread-safe but potentially faster approach.
content::RenderFrameHost* render_frame_host =
content::RenderFrameHost::FromFrameToken(global_token);
if (!render_frame_host) {
return nullptr;
}
return GetBrowserForHost(render_frame_host);
} else {
// Use the thread-safe approach.
bool is_guest_view = false;
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
global_token, &is_guest_view);
if (info && !is_guest_view) {
auto browser = info->browser();
if (!browser) {
LOG(WARNING) << "Found browser id " << info->browser_id()
<< " but no browser object matching frame "
<< frame_util::GetFrameDebugString(global_token);
}
return browser;
}
return nullptr;
}
}
// static
CefRefPtr<CefBrowserHostBase>
CefBrowserHostBase::GetBrowserForTopLevelNativeWindow(
@@ -905,32 +938,32 @@ bool CefBrowserHostBase::IsPopup() {
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetMainFrame() {
return GetFrame(CefFrameHostImpl::kMainFrameId);
return browser_info_->GetMainFrame();
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFocusedFrame() {
return GetFrame(CefFrameHostImpl::kFocusedFrameId);
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrame(int64_t identifier) {
if (identifier == CefFrameHostImpl::kInvalidFrameId) {
return nullptr;
} else if (identifier == CefFrameHostImpl::kMainFrameId) {
return browser_info_->GetMainFrame();
} else if (identifier == CefFrameHostImpl::kFocusedFrameId) {
{
base::AutoLock lock_scope(state_lock_);
if (!focused_frame_) {
// The main frame is focused by default.
return browser_info_->GetMainFrame();
if (focused_frame_) {
return focused_frame_;
}
return focused_frame_;
}
return browser_info_->GetFrameForGlobalId(
frame_util::MakeGlobalId(identifier));
// The main frame is focused by default.
return browser_info_->GetMainFrame();
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrame(const CefString& name) {
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameByIdentifier(
const CefString& identifier) {
const auto& global_token = frame_util::ParseFrameIdentifier(identifier);
if (!global_token) {
return nullptr;
}
return browser_info_->GetFrameForGlobalToken(*global_token);
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameByName(const CefString& name) {
for (const auto& frame : browser_info_->GetAllFrames()) {
if (frame->GetName() == name) {
return frame;
@@ -944,7 +977,7 @@ size_t CefBrowserHostBase::GetFrameCount() {
}
void CefBrowserHostBase::GetFrameIdentifiers(
std::vector<int64_t>& identifiers) {
std::vector<CefString>& identifiers) {
if (identifiers.size() > 0) {
identifiers.clear();
}
@@ -1018,6 +1051,11 @@ CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalId(
return browser_info_->GetFrameForGlobalId(global_id, nullptr);
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token) {
return browser_info_->GetFrameForGlobalToken(global_token, nullptr);
}
void CefBrowserHostBase::AddObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.AddObserver(observer);

View File

@@ -147,6 +147,9 @@ class CefBrowserHostBase : public CefBrowserHost,
// Returns the browser associated with the specified global ID.
static CefRefPtr<CefBrowserHostBase> GetBrowserForGlobalId(
const content::GlobalRenderFrameHostId& global_id);
// Returns the browser associated with the specified global token.
static CefRefPtr<CefBrowserHostBase> GetBrowserForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token);
// Returns the browser associated with the specified top-level window.
static CefRefPtr<CefBrowserHostBase> GetBrowserForTopLevelNativeWindow(
gfx::NativeWindow owning_window);
@@ -253,10 +256,11 @@ class CefBrowserHostBase : public CefBrowserHost,
bool IsPopup() override;
CefRefPtr<CefFrame> GetMainFrame() override;
CefRefPtr<CefFrame> GetFocusedFrame() override;
CefRefPtr<CefFrame> GetFrame(int64_t identifier) override;
CefRefPtr<CefFrame> GetFrame(const CefString& name) override;
CefRefPtr<CefFrame> GetFrameByIdentifier(
const CefString& identifier) override;
CefRefPtr<CefFrame> GetFrameByName(const CefString& name) override;
size_t GetFrameCount() override;
void GetFrameIdentifiers(std::vector<int64_t>& identifiers) override;
void GetFrameIdentifiers(std::vector<CefString>& identifiers) override;
void GetFrameNames(std::vector<CefString>& names) override;
// CefBrowserContentsDelegate::Observer methods:
@@ -266,11 +270,13 @@ class CefBrowserHostBase : public CefBrowserHost,
// Returns the frame associated with the specified RenderFrameHost.
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
// Returns the frame associated with the specified global ID. See
// documentation on RenderFrameHost::GetFrameTreeNodeId() for why the global
// ID is preferred.
// Returns the frame associated with the specified global ID/token. See
// documentation on RenderFrameHost::GetFrameTreeNodeId/Token() for why the
// global ID/token is preferred.
CefRefPtr<CefFrame> GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id);
CefRefPtr<CefFrame> GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token);
// Manage observer objects. The observer must either outlive this object or
// be removed before destruction. Must be called on the UI thread.

View File

@@ -21,7 +21,7 @@ CefBrowserInfo::FrameInfo::~FrameInfo() {
#if DCHECK_IS_ON()
if (frame_ && !IsCurrentMainFrame()) {
// Should already be Detached.
DCHECK(!frame_->GetRenderFrameHost());
DCHECK(frame_->IsDetached());
}
#endif
}
@@ -154,8 +154,7 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(frame_util::MakeFrameId(global_id),
frame_info->frame_->GetIdentifier());
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
#endif
}
@@ -165,6 +164,8 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
// Populate the lookup maps.
frame_id_map_.insert(std::make_pair(global_id, frame_info));
frame_token_to_id_map_.insert(
std::make_pair(host->GetGlobalFrameToken(), global_id));
// And finally set the ownership.
frame_info_set_.insert(base::WrapUnique(frame_info));
@@ -232,6 +233,12 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
// Remove from the lookup maps.
frame_id_map_.erase(it);
{
auto it2 = frame_token_to_id_map_.find(host->GetGlobalFrameToken());
DCHECK(it2 != frame_token_to_id_map_.end());
frame_token_to_id_map_.erase(it2);
}
// And finally delete the frame info.
{
auto it2 = frame_info_set_.find(frame_info);
@@ -267,7 +274,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
parent = GetMainFrame();
}
// Intentionally not notifying for temporary frames.
return new CefFrameHostImpl(this, parent->GetIdentifier());
return new CefFrameHostImpl(this, parent->frame_token());
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
@@ -329,6 +336,28 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
return nullptr;
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view,
bool prefer_speculative) const {
if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr;
}
content::GlobalRenderFrameHostId global_id;
{
base::AutoLock lock_scope(lock_);
const auto it = frame_token_to_id_map_.find(global_token);
if (it == frame_token_to_id_map_.end()) {
return nullptr;
}
global_id = it->second;
}
return GetFrameForGlobalId(global_id, is_guest_view, prefer_speculative);
}
CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
base::AutoLock lock_scope(lock_);
FrameHostList frames;
@@ -510,6 +539,7 @@ void CefBrowserInfo::RemoveAllFrames(
// Clear the lookup maps.
frame_id_map_.clear();
frame_token_to_id_map_.clear();
// Explicitly Detach everything but the current main frame.
for (auto& info : frame_info_set_) {

View File

@@ -109,15 +109,19 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Safe to call from any
// thread.
// Returns the frame object matching the specified ID/token or nullptr if no
// match is found. Nullptr will also be returned if a guest view match is
// found because we don't create frame objects for guest views. If
// |is_guest_view| is non-nullptr it will be set to true in this case. Safe to
// call from any thread.
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
// Returns all non-speculative frame objects that currently exist. Guest views
// will be excluded because they don't have a frame object. Safe to call from
@@ -248,6 +252,11 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
content::GlobalRenderFrameHostIdHasher>;
FrameIDMap frame_id_map_;
// Map of global token to global ID.
using FrameTokenToIdMap = std::map<content::GlobalRenderFrameHostToken,
content::GlobalRenderFrameHostId>;
FrameTokenToIdMap frame_token_to_id_map_;
// The current main frame.
CefRefPtr<CefFrameHostImpl> main_frame_;

View File

@@ -89,7 +89,8 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
browser_info_list_.push_back(browser_info);
// Continue any pending NewBrowserInfo request.
auto it = pending_new_browser_info_map_.find(frame_host->GetGlobalId());
auto it =
pending_new_browser_info_map_.find(frame_host->GetGlobalFrameToken());
if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(browser_info, /*is_guest_view=*/false,
std::move(it->second->callback),
@@ -289,9 +290,9 @@ bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) {
}
void CefBrowserInfoManager::OnGetNewBrowserInfo(
const content::GlobalRenderFrameHostId& global_id,
const content::GlobalRenderFrameHostToken& global_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
DCHECK(frame_util::IsValidGlobalId(global_id));
DCHECK(frame_util::IsValidGlobalToken(global_token));
DCHECK(callback);
auto callback_runner = base::SequencedTaskRunner::GetCurrentDefault();
@@ -301,7 +302,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> browser_info =
GetBrowserInfoInternal(global_id, &is_guest_view);
GetBrowserInfoInternal(global_token, &is_guest_view);
if (browser_info) {
// Send the response immediately.
@@ -311,19 +312,19 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
}
// Verify that no request for the same route is currently queued.
DCHECK(pending_new_browser_info_map_.find(global_id) ==
DCHECK(pending_new_browser_info_map_.find(global_token) ==
pending_new_browser_info_map_.end());
const int timeout_id = ++next_timeout_id_;
// Queue the request.
std::unique_ptr<PendingNewBrowserInfo> pending(new PendingNewBrowserInfo());
pending->global_id = global_id;
pending->global_token = global_token;
pending->timeout_id = timeout_id;
pending->callback = std::move(callback);
pending->callback_runner = callback_runner;
pending_new_browser_info_map_.insert(
std::make_pair(global_id, std::move(pending)));
std::make_pair(global_token, std::move(pending)));
// Register a timeout for the pending response so that the renderer process
// doesn't hang forever. With the Chrome runtime, timeouts may occur in cases
@@ -334,7 +335,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
CEF_POST_DELAYED_TASK(
CEF_UIT,
base::BindOnce(&CefBrowserInfoManager::TimeoutNewBrowserInfoResponse,
global_id, timeout_id),
global_token, timeout_id),
kNewBrowserInfoResponseTimeoutMs);
}
}
@@ -391,6 +392,13 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
return GetBrowserInfoInternal(global_id, is_guest_view);
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_token, is_guest_view);
}
bool CefBrowserInfoManager::MaybeAllowNavigation(
content::RenderFrameHost* opener,
const content::OpenURLParams& params,
@@ -451,7 +459,7 @@ void CefBrowserInfoManager::RenderProcessHostDestroyed(
pending_new_browser_info_map_.begin();
while (it != pending_new_browser_info_map_.end()) {
const auto& info = it->second;
if (info->global_id.child_id == render_process_id) {
if (info->global_token.child_id == render_process_id) {
CancelNewBrowserInfoResponse(info.get());
it = pending_new_browser_info_map_.erase(it);
} else {
@@ -553,6 +561,34 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
return nullptr;
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view) {
browser_info_lock_.AssertAcquired();
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr;
}
for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp;
auto frame =
browser_info->GetFrameForGlobalToken(global_token, &is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view) {
*is_guest_view = is_guest_view_tmp;
}
return browser_info;
}
}
return nullptr;
}
// static
void CefBrowserInfoManager::SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info,
@@ -601,7 +637,7 @@ void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
// static
void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
const content::GlobalRenderFrameHostId& global_id,
const content::GlobalRenderFrameHostToken& global_token,
int timeout_id) {
CEF_REQUIRE_UIT();
if (!g_info_manager) {
@@ -611,7 +647,7 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
base::AutoLock lock_scope(g_info_manager->browser_info_lock_);
// Continue the NewBrowserInfo request if it's still pending.
auto it = g_info_manager->pending_new_browser_info_map_.find(global_id);
auto it = g_info_manager->pending_new_browser_info_map_.find(global_token);
if (it != g_info_manager->pending_new_browser_info_map_.end()) {
const auto& pending_info = it->second;
// Don't accidentally timeout a new request for the same frame.
@@ -622,12 +658,12 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
#if DCHECK_IS_ON()
// This method should never be called for a PDF renderer.
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(global_id.child_id);
content::RenderProcessHost::FromID(global_token.child_id);
DCHECK(!process || !process->IsPdf());
#endif
LOG(ERROR) << "Timeout of new browser info response for frame "
<< frame_util::GetFrameDebugString(global_id);
<< frame_util::GetFrameDebugString(global_token);
CancelNewBrowserInfoResponse(pending_info.get());
g_info_manager->pending_new_browser_info_map_.erase(it);

View File

@@ -112,7 +112,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// already exist for traditional popup browsers depending on timing. See
// comments on PendingPopup for more information.
void OnGetNewBrowserInfo(
const content::GlobalRenderFrameHostId& global_id,
const content::GlobalRenderFrameHostToken& global_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
// Called from CefBrowserHostBase::DestroyBrowser() when a browser is
@@ -122,15 +122,18 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Called from CefContext::FinishShutdownOnUIThread() to destroy all browsers.
void DestroyAllBrowsers();
// Returns the CefBrowserInfo matching the specified ID or nullptr if no
// Returns the CefBrowserInfo matching the specified ID/token or nullptr if no
// match is found. It is allowed to add new callers of this method but
// consider using CefBrowserHostBase::GetBrowserForGlobalId() or
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() or
// extensions::GetOwnerBrowserForGlobalId() instead. If |is_guest_view| is
// non-nullptr it will be set to true if the ID matches a guest view
// non-nullptr it will be set to true if the ID/token matches a guest view
// associated with the returned browser info instead of the browser itself.
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view = nullptr);
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view = nullptr);
// Returns all existing CefBrowserInfo objects.
using BrowserInfoList = std::list<scoped_refptr<CefBrowserInfo>>;
@@ -213,10 +216,13 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
PendingPopup::Step previous_step,
content::WebContents* new_contents);
// Retrieves the BrowserInfo matching the specified ID.
// Retrieves the BrowserInfo matching the specified ID/token.
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view);
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view);
// Send the response for a pending OnGetNewBrowserInfo request.
static void SendNewBrowserInfoResponse(
@@ -227,7 +233,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Pending request for OnGetNewBrowserInfo.
struct PendingNewBrowserInfo {
content::GlobalRenderFrameHostId global_id;
content::GlobalRenderFrameHostToken global_token;
int timeout_id;
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback;
scoped_refptr<base::SequencedTaskRunner> callback_runner;
@@ -238,7 +244,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Time out a response if it's still pending.
static void TimeoutNewBrowserInfoResponse(
const content::GlobalRenderFrameHostId& global_id,
const content::GlobalRenderFrameHostToken& global_token,
int timeout_id);
mutable base::Lock browser_info_lock_;
@@ -252,7 +258,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// identify a RFH for its complete lifespan. See documentation on
// RenderFrameHost::GetFrameTreeNodeId() for background.
using PendingNewBrowserInfoMap =
std::map<content::GlobalRenderFrameHostId,
std::map<content::GlobalRenderFrameHostToken,
std::unique_ptr<PendingNewBrowserInfo>>;
PendingNewBrowserInfoMap pending_new_browser_info_map_;

View File

@@ -50,9 +50,10 @@ void CefBrowserManager::GetNewRenderThreadInfo(
}
void CefBrowserManager::GetNewBrowserInfo(
int32_t render_frame_routing_id,
const blink::LocalFrameToken& render_frame_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
frame_util::MakeGlobalId(render_process_id_, render_frame_routing_id),
content::GlobalRenderFrameHostToken(render_process_id_,
render_frame_token),
std::move(callback));
}

View File

@@ -46,7 +46,7 @@ class CefBrowserManager : public cef::mojom::BrowserManager {
cef::mojom::BrowserManager::GetNewRenderThreadInfoCallback callback)
override;
void GetNewBrowserInfo(
int32_t render_frame_routing_id,
const blink::LocalFrameToken& render_frame_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) override;
// The process ID of the renderer.

View File

@@ -54,7 +54,7 @@ void HandleExternalProtocolHelper(
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
const network::ResourceRequest& resource_request,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::WeakDocumentPtr initiator_document) {
// May return nullptr if frame has been deleted or a cross-document navigation
// has committed in the same RenderFrameHost.
@@ -232,7 +232,7 @@ bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -325,7 +325,7 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
network::mojom::WebSandboxFlags sandbox_flags,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// |out_factory| will be non-nullptr when this method is initially called
@@ -353,7 +353,7 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
const network::ResourceRequest& resource_request,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
@@ -418,6 +418,7 @@ std::unique_ptr<content::LoginDelegate>
ChromeContentBrowserClientCef::CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,
@@ -434,8 +435,9 @@ ChromeContentBrowserClientCef::CreateLoginDelegate(
}
return ChromeContentBrowserClient::CreateLoginDelegate(
auth_info, web_contents, request_id, is_request_for_main_frame, url,
response_headers, first_auth_attempt, std::move(auth_required_callback));
auth_info, web_contents, browser_context, request_id,
is_request_for_main_frame, url, response_headers, first_auth_attempt,
std::move(auth_required_callback));
}
void ChromeContentBrowserClientCef::BrowserURLHandlerCreated(

View File

@@ -61,7 +61,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -81,7 +81,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
network::mojom::WebSandboxFlags sandbox_flags,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
@@ -93,7 +93,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
const network::ResourceRequest& request,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
@@ -110,6 +110,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,

View File

@@ -41,13 +41,21 @@ CefRefPtr<CefDownloadHandler> GetDownloadHandler(
return nullptr;
}
void RunDownloadTargetCallback(download::DownloadTargetCallback callback,
const base::FilePath& path) {
download::DownloadTargetInfo target_info;
target_info.target_path = path;
target_info.intermediate_path = path;
std::move(callback).Run(std::move(target_info));
}
// CefBeforeDownloadCallback implementation.
class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
public:
CefBeforeDownloadCallbackImpl(const base::WeakPtr<DownloadManager>& manager,
uint32_t download_id,
const base::FilePath& suggested_name,
content::DownloadTargetCallback callback)
download::DownloadTargetCallback callback)
: manager_(manager),
download_id_(download_id),
suggested_name_(suggested_name),
@@ -85,7 +93,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
const base::FilePath& suggested_name,
const base::FilePath& download_path,
bool show_dialog,
content::DownloadTargetCallback callback) {
download::DownloadTargetCallback callback) {
CEF_REQUIRE_BLOCKING();
base::FilePath suggested_path = download_path;
@@ -120,7 +128,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
uint32_t download_id,
const base::FilePath& suggested_path,
bool show_dialog,
content::DownloadTargetCallback callback) {
download::DownloadTargetCallback callback) {
if (!manager) {
return;
}
@@ -159,17 +167,12 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
}
if (!handled) {
std::move(callback).Run(
suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::InsecureDownloadStatus::UNKNOWN,
suggested_path, base::FilePath(), std::string() /*mime_type*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
RunDownloadTargetCallback(std::move(callback), suggested_path);
}
}
static void ChooseDownloadPathCallback(
content::DownloadTargetCallback callback,
download::DownloadTargetCallback callback,
const std::vector<base::FilePath>& file_paths) {
DCHECK_LE(file_paths.size(), (size_t)1);
@@ -179,18 +182,13 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
}
// The download will be cancelled if |path| is empty.
std::move(callback).Run(
path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::InsecureDownloadStatus::UNKNOWN, path,
base::FilePath(), std::string() /*mime_type*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
RunDownloadTargetCallback(std::move(callback), path);
}
base::WeakPtr<DownloadManager> manager_;
uint32_t download_id_;
base::FilePath suggested_name_;
content::DownloadTargetCallback callback_;
download::DownloadTargetCallback callback_;
IMPLEMENT_REFCOUNTING(CefBeforeDownloadCallbackImpl);
};
@@ -375,14 +373,10 @@ void CefDownloadManagerDelegate::ManagerGoingDown(DownloadManager* manager) {
bool CefDownloadManagerDelegate::DetermineDownloadTarget(
DownloadItem* item,
content::DownloadTargetCallback* callback) {
if (!item->GetForcedFilePath().empty()) {
std::move(*callback).Run(
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::InsecureDownloadStatus::UNKNOWN,
item->GetForcedFilePath(), base::FilePath(),
std::string() /*mime_type*/, download::DOWNLOAD_INTERRUPT_REASON_NONE);
download::DownloadTargetCallback* callback) {
const auto& forced_path = item->GetForcedFilePath();
if (!forced_path.empty()) {
RunDownloadTargetCallback(std::move(*callback), forced_path);
return true;
}

View File

@@ -12,6 +12,7 @@
#include "base/memory/weak_ptr.h"
#include "components/download/public/common/download_item.h"
#include "components/download/public/common/download_target_info.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_manager_delegate.h"
@@ -43,7 +44,7 @@ class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
// DownloadManagerDelegate methods.
bool DetermineDownloadTarget(
download::DownloadItem* item,
content::DownloadTargetCallback* callback) override;
download::DownloadTargetCallback* callback) override;
void GetNextId(content::DownloadIdCallback callback) override;
std::string ApplicationClientIdForFileScanning() override;

View File

@@ -409,8 +409,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
auto web_contents = new_browser->web_contents();
auto result = CreateTabObject(new_browser, opener_browser_id, active, index);
auto scrub_tab_behavior = ExtensionTabUtil::GetScrubTabBehavior(
extension, extensions::Feature::Context::UNSPECIFIED_CONTEXT,
web_contents);
extension, extensions::mojom::ContextType::kUnspecified, web_contents);
ExtensionTabUtil::ScrubTabForExtension(extension, web_contents, &result,
scrub_tab_behavior);
return base::WrapUnique(new api::tabs::Tab(std::move(result)));

View File

@@ -246,6 +246,13 @@ ProcessManagerDelegate* CefExtensionsBrowserClient::GetProcessManagerDelegate()
return nullptr;
}
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CefExtensionsBrowserClient::GetControlledFrameEmbedderURLLoader(
int frame_tree_node_id,
content::BrowserContext* browser_context) {
return mojo::PendingRemote<network::mojom::URLLoaderFactory>();
}
std::unique_ptr<ExtensionHostDelegate>
CefExtensionsBrowserClient::CreateExtensionHostDelegate() {
// CEF does not use the ExtensionHost constructor that calls this method.

View File

@@ -83,6 +83,10 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context,
std::vector<EarlyExtensionPrefsObserver*>* observers) const override;
ProcessManagerDelegate* GetProcessManagerDelegate() const override;
mojo::PendingRemote<network::mojom::URLLoaderFactory>
GetControlledFrameEmbedderURLLoader(
int frame_tree_node_id,
content::BrowserContext* browser_context) override;
std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
bool CreateBackgroundExtensionHost(const Extension* extension,
content::BrowserContext* browser_context,

View File

@@ -17,6 +17,7 @@
#include "content/public/browser/file_select_listener.h"
#include "content/public/browser/render_frame_host.h"
#include "ui/shell_dialogs/select_file_policy.h"
#include "ui/shell_dialogs/selected_file_info.h"
using blink::mojom::FileChooserParams;
@@ -224,25 +225,16 @@ class CefSelectFileDialogListener : public ui::SelectFileDialog::Listener {
private:
~CefSelectFileDialogListener() override = default;
void FileSelected(const base::FilePath& path,
void FileSelected(const ui::SelectedFileInfo& file,
int index,
void* params) override {
DCHECK_EQ(params, params_);
executing_ = true;
listener_->FileSelected(path, index, params);
listener_->FileSelected(file, index, params);
Destroy();
}
void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file,
int index,
void* params) override {
DCHECK_EQ(params, params_);
executing_ = true;
listener_->FileSelectedWithExtraInfo(file, index, params);
Destroy();
}
void MultiFilesSelected(const std::vector<base::FilePath>& files,
void MultiFilesSelected(const std::vector<ui::SelectedFileInfo>& files,
void* params) override {
DCHECK_EQ(params, params_);
executing_ = true;
@@ -250,15 +242,6 @@ class CefSelectFileDialogListener : public ui::SelectFileDialog::Listener {
Destroy();
}
void MultiFilesSelectedWithExtraInfo(
const std::vector<ui::SelectedFileInfo>& files,
void* params) override {
DCHECK_EQ(params, params_);
executing_ = true;
listener_->MultiFilesSelectedWithExtraInfo(files, params);
Destroy();
}
void FileSelectionCanceled(void* params) override {
DCHECK_EQ(params, params_);
executing_ = true;
@@ -535,9 +518,10 @@ void CefFileDialogManager::SelectFileDoneByDelegateCallback(
if (paths.empty()) {
listener->FileSelectionCanceled(params);
} else if (paths.size() == 1) {
listener->FileSelected(paths[0], /*index=*/0, params);
listener->FileSelected(ui::SelectedFileInfo(paths[0]), /*index=*/0, params);
} else {
listener->MultiFilesSelected(paths, params);
listener->MultiFilesSelected(ui::FilePathListToSelectedFileInfoList(paths),
params);
}
// |listener| is likely deleted at this point.
}

View File

@@ -75,35 +75,31 @@ void ExecWebContentsCommand(CefFrameHostImpl* fh,
} // namespace
CefFrameHostImpl::CefFrameHostImpl(scoped_refptr<CefBrowserInfo> browser_info,
int64_t parent_frame_id)
CefFrameHostImpl::CefFrameHostImpl(
scoped_refptr<CefBrowserInfo> browser_info,
std::optional<content::GlobalRenderFrameHostToken> parent_frame_token)
: is_main_frame_(false),
frame_id_(kInvalidFrameId),
browser_info_(browser_info),
is_focused_(is_main_frame_), // The main frame always starts focused.
parent_frame_id_(parent_frame_id) {
parent_frame_token_(std::move(parent_frame_token)) {
#if DCHECK_IS_ON()
DCHECK(browser_info_);
if (is_main_frame_) {
DCHECK_EQ(parent_frame_id_, kInvalidFrameId);
} else {
DCHECK_GT(parent_frame_id_, 0);
}
DCHECK_EQ(is_main_frame_, !parent_frame_token_.has_value());
#endif
}
CefFrameHostImpl::CefFrameHostImpl(scoped_refptr<CefBrowserInfo> browser_info,
content::RenderFrameHost* render_frame_host)
: is_main_frame_(render_frame_host->GetParent() == nullptr),
frame_id_(frame_util::MakeFrameId(render_frame_host->GetGlobalId())),
frame_token_(render_frame_host->GetGlobalFrameToken()),
browser_info_(browser_info),
is_focused_(is_main_frame_), // The main frame always starts focused.
url_(render_frame_host->GetLastCommittedURL().spec()),
name_(render_frame_host->GetFrameName()),
parent_frame_id_(
is_main_frame_ ? kInvalidFrameId
: frame_util::MakeFrameId(
render_frame_host->GetParent()->GetGlobalId())),
parent_frame_token_(
is_main_frame_
? std::optional<content::GlobalRenderFrameHostToken>()
: render_frame_host->GetParent()->GetGlobalFrameToken()),
render_frame_host_(render_frame_host) {
DCHECK(browser_info_);
}
@@ -193,25 +189,30 @@ CefString CefFrameHostImpl::GetName() {
return name_;
}
int64_t CefFrameHostImpl::GetIdentifier() {
base::AutoLock lock_scope(state_lock_);
return frame_id_;
CefString CefFrameHostImpl::GetIdentifier() {
if (!frame_token_) {
return CefString();
}
return frame_util::MakeFrameIdentifier(*frame_token_);
}
CefRefPtr<CefFrame> CefFrameHostImpl::GetParent() {
int64_t parent_frame_id;
if (is_main_frame_) {
return nullptr;
}
content::GlobalRenderFrameHostToken parent_frame_token;
{
base::AutoLock lock_scope(state_lock_);
if (is_main_frame_ || parent_frame_id_ == kInvalidFrameId) {
if (!parent_frame_token_) {
return nullptr;
}
parent_frame_id = parent_frame_id_;
parent_frame_token = *parent_frame_token_;
}
auto browser = GetBrowserHostBase();
if (browser) {
return browser->GetFrame(parent_frame_id);
if (auto browser = GetBrowserHostBase()) {
return browser->GetFrameForGlobalToken(parent_frame_token);
}
return nullptr;
@@ -298,6 +299,7 @@ void CefFrameHostImpl::SendProcessMessage(
}
void CefFrameHostImpl::SetFocused(bool focused) {
CEF_REQUIRE_UIT();
base::AutoLock lock_scope(state_lock_);
is_focused_ = focused;
}
@@ -324,8 +326,8 @@ void CefFrameHostImpl::RefreshAttributes() {
}
if (!is_main_frame_) {
parent_frame_id_ =
frame_util::MakeFrameId(render_frame_host_->GetParent()->GetGlobalId());
parent_frame_token_ =
render_frame_host_->GetParent()->GetGlobalFrameToken();
}
}
@@ -359,16 +361,10 @@ void CefFrameHostImpl::LoadURLWithExtras(const std::string& url,
const content::Referrer& referrer,
ui::PageTransition transition,
const std::string& extra_headers) {
// Only known frame ids or kMainFrameId are supported.
const auto frame_id = GetFrameId();
if (frame_id < CefFrameHostImpl::kMainFrameId) {
return;
}
// Any necessary fixup will occur in LoadRequest.
GURL gurl = url_util::MakeGURL(url, /*fixup=*/false);
if (frame_id == CefFrameHostImpl::kMainFrameId) {
if (is_main_frame_) {
// Load via the browser using NavigationController.
auto browser = GetBrowserHostBase();
if (browser) {
@@ -484,6 +480,22 @@ content::RenderFrameHost* CefFrameHostImpl::GetRenderFrameHost() const {
return render_frame_host_;
}
bool CefFrameHostImpl::IsSameFrame(content::RenderFrameHost* frame_host) const {
CEF_REQUIRE_UIT();
// Shortcut in case the RFH objects match.
if (render_frame_host_ == frame_host) {
return true;
}
// Frame tokens should match even if we're currently detached or the RFH
// object has changed.
return frame_token_ && *frame_token_ == frame_host->GetGlobalFrameToken();
}
bool CefFrameHostImpl::IsDetached() const {
return !GetRenderFrameHost();
}
bool CefFrameHostImpl::Detach(DetachReason reason) {
CEF_REQUIRE_UIT();
@@ -549,9 +561,8 @@ void CefFrameHostImpl::MaybeReAttach(
CHECK(!render_frame_.is_bound());
CHECK(!render_frame_host_);
// The RFH may change but the GlobalId should remain the same.
CHECK_EQ(frame_id_,
frame_util::MakeFrameId(render_frame_host->GetGlobalId()));
// The RFH may change but the frame token should remain the same.
CHECK(*frame_token_ == render_frame_host->GetGlobalFrameToken());
{
base::AutoLock lock_scope(state_lock_);
@@ -564,22 +575,11 @@ void CefFrameHostImpl::MaybeReAttach(
// We expect a reconnect to be triggered via FrameAttached().
}
// kMainFrameId must be -1 to align with renderer expectations.
const int64_t CefFrameHostImpl::kMainFrameId = -1;
const int64_t CefFrameHostImpl::kFocusedFrameId = -2;
const int64_t CefFrameHostImpl::kUnspecifiedFrameId = -3;
const int64_t CefFrameHostImpl::kInvalidFrameId = -4;
// This equates to (TT_EXPLICIT | TT_DIRECT_LOAD_FLAG).
const ui::PageTransition CefFrameHostImpl::kPageTransitionExplicit =
static_cast<ui::PageTransition>(ui::PAGE_TRANSITION_TYPED |
ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
int64_t CefFrameHostImpl::GetFrameId() const {
base::AutoLock lock_scope(state_lock_);
return is_main_frame_ ? kMainFrameId : frame_id_;
}
scoped_refptr<CefBrowserInfo> CefFrameHostImpl::GetBrowserInfo() const {
base::AutoLock lock_scope(state_lock_);
return browser_info_;
@@ -711,12 +711,14 @@ void CefFrameHostImpl::UpdateDraggableRegions(
// Delegate to BrowserInfo so that current state is maintained with
// cross-origin navigation.
browser_info_->MaybeNotifyDraggableRegionsChanged(
browser->browser_info()->MaybeNotifyDraggableRegionsChanged(
browser, this, std::move(draggable_regions));
}
std::string CefFrameHostImpl::GetDebugString() const {
return "frame " + frame_util::GetFrameDebugString(frame_id_) +
return "frame " +
(frame_token_ ? frame_util::GetFrameDebugString(*frame_token_)
: "(null)") +
(is_main_frame_ ? " (main)" : " (sub)");
}

View File

@@ -7,6 +7,7 @@
#pragma once
#include <memory>
#include <optional>
#include <queue>
#include <string>
@@ -14,6 +15,7 @@
#include "base/synchronization/lock.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/browser/global_routing_id.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/base/page_transition_types.h"
@@ -33,8 +35,9 @@ class CefBrowserHostBase;
class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
public:
// Create a temporary sub-frame.
CefFrameHostImpl(scoped_refptr<CefBrowserInfo> browser_info,
int64_t parent_frame_id);
CefFrameHostImpl(
scoped_refptr<CefBrowserInfo> browser_info,
std::optional<content::GlobalRenderFrameHostToken> parent_frame_token);
// Create a frame backed by a RFH and owned by CefBrowserInfo.
CefFrameHostImpl(scoped_refptr<CefBrowserInfo> browser_info,
@@ -65,7 +68,7 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
bool IsMain() override;
bool IsFocused() override;
CefString GetName() override;
int64_t GetIdentifier() override;
CefString GetIdentifier() override;
CefRefPtr<CefFrame> GetParent() override;
CefString GetURL() override;
CefRefPtr<CefBrowser> GetBrowser() override;
@@ -77,8 +80,6 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
void SendProcessMessage(CefProcessId target_process,
CefRefPtr<CefProcessMessage> message) override;
bool is_temporary() const { return frame_id_ == kInvalidFrameId; }
void SetFocused(bool focused);
void RefreshAttributes();
@@ -112,10 +113,21 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
void ExecuteJavaScriptWithUserGestureForTests(const CefString& javascript);
// Returns the RFH associated with this frame. Must be called on the UI
// thread.
// Returns the RFH currently associated with this frame. May return nullptr if
// this frame is currenly detached. Do not directly compare RFH pointers; use
// IsSameFrame() instead. Must be called on the UI thread.
content::RenderFrameHost* GetRenderFrameHost() const;
// Returns true if this frame and |frame_host| represent the same frame.
// Frames are considered the same if they share the same frame token value,
// so this method is safe to call even for detached frames. Must be called on
// the UI thread.
bool IsSameFrame(content::RenderFrameHost* frame_host) const;
// Returns true if this frame is currently detached (e.g. no associated RFH).
// Must be called on the UI thread.
bool IsDetached() const;
enum class DetachReason {
RENDER_FRAME_DELETED,
NEW_MAIN_FRAME,
@@ -145,10 +157,10 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
override;
static const int64_t kMainFrameId;
static const int64_t kFocusedFrameId;
static const int64_t kUnspecifiedFrameId;
static const int64_t kInvalidFrameId;
bool is_temporary() const { return !frame_token_.has_value(); }
std::optional<content::GlobalRenderFrameHostToken> frame_token() const {
return frame_token_;
}
// PageTransition type for explicit navigations. This must pass the check in
// ContentBrowserClient::IsExplicitNavigation for debug URLs (HandleDebugURL)
@@ -156,7 +168,6 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
static const ui::PageTransition kPageTransitionExplicit;
private:
int64_t GetFrameId() const;
scoped_refptr<CefBrowserInfo> GetBrowserInfo() const;
CefRefPtr<CefBrowserHostBase> GetBrowserHostBase() const;
@@ -172,16 +183,17 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
std::string GetDebugString() const;
const bool is_main_frame_;
const std::optional<content::GlobalRenderFrameHostToken> frame_token_;
// The following members may be read/modified from any thread. All access must
// be protected by |state_lock_|.
// The following members are only modified on the UI thread but may be read
// from any thread. Any modification on the UI thread, or any access from
// non-UI threads, must be protected by |state_lock_|.
mutable base::Lock state_lock_;
int64_t frame_id_;
scoped_refptr<CefBrowserInfo> browser_info_;
bool is_focused_;
CefString url_;
CefString name_;
int64_t parent_frame_id_;
std::optional<content::GlobalRenderFrameHostToken> parent_frame_token_;
// The following members are only accessed on the UI thread.
content::RenderFrameHost* render_frame_host_ = nullptr;

View File

@@ -20,7 +20,7 @@
#include "ui/gfx/font_render_params.h"
#include "ui/views/widget/widget.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
#include "libcef/browser/native/window_x11.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
@@ -55,7 +55,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
gfx::Rect rect(window_info_.bounds.x, window_info_.bounds.y,
window_info_.bounds.width, window_info_.bounds.height);
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
DCHECK(!window_x11_);
x11::Window parent_window = x11::Window::None;
@@ -87,7 +87,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
window_widget_->Show();
window_x11_->Show();
#endif // BUILDFLAG(OZONE_PLATFORM_X11)
#endif // BUILDFLAG(IS_OZONE_X11)
// As an additional requirement on Linux, we must set the colors for the
// render widgets in webkit.
@@ -115,7 +115,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
}
void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
if (window_x11_) {
window_x11_->Close();
}
@@ -145,14 +145,14 @@ void CefBrowserPlatformDelegateNativeLinux::SetFocus(bool setFocus) {
web_contents_->Focus();
}
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
if (window_x11_) {
// Give native focus to the DesktopNativeWidgetAura for the root window.
// Needs to be done via the ::Window so that keyboard focus is assigned
// correctly.
window_x11_->Focus();
}
#endif // BUILDFLAG(OZONE_PLATFORM_X11)
#endif // BUILDFLAG(IS_OZONE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
@@ -163,7 +163,7 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
return;
}
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
if (!window_x11_) {
return;
}
@@ -183,16 +183,16 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
content::RenderWidgetHostImpl::From(
web_contents_->GetRenderViewHost()->GetWidget())
->SendScreenRects();
#endif // BUILDFLAG(OZONE_PLATFORM_X11)
#endif // BUILDFLAG(IS_OZONE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::SizeTo(int width, int height) {
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
if (window_x11_) {
window_x11_->SetBounds(
gfx::Rect(window_x11_->bounds().origin(), gfx::Size(width, height)));
}
#endif // BUILDFLAG(OZONE_PLATFORM_X11)
#endif // BUILDFLAG(IS_OZONE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
@@ -249,7 +249,7 @@ ui::KeyEvent CefBrowserPlatformDelegateNativeLinux::TranslateUiKeyEvent(
ui::DomCode dom_code =
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code);
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
int keysym = ui::XKeysymForWindowsKeyCode(
key_code, !!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
char16_t character = ui::GetUnicodeCharacterFromXKeySym(keysym);
@@ -277,7 +277,7 @@ ui::KeyEvent CefBrowserPlatformDelegateNativeLinux::TranslateUiKeyEvent(
DCHECK(false);
}
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
ui::DomKey dom_key = ui::XKeySymToDomKey(keysym, character);
#else
ui::DomKey dom_key = ui::DomKey::NONE;

View File

@@ -7,9 +7,9 @@
#include "libcef/browser/native/browser_platform_delegate_native_aura.h"
#include "ui/ozone/buildflags.h"
#include "ui/base/ozone_buildflags.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
class CefWindowX11;
#endif
@@ -44,7 +44,7 @@ class CefBrowserPlatformDelegateNativeLinux
// True if the host window has been created.
bool host_window_created_ = false;
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
CefWindowX11* window_x11_ = nullptr;
#endif
};

View File

@@ -16,8 +16,8 @@
#include "ui/wm/core/cursor_loader.h"
#if BUILDFLAG(IS_LINUX)
#include "ui/ozone/buildflags.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#include "ui/base/ozone_buildflags.h"
#if BUILDFLAG(IS_OZONE_X11)
#include "ui/base/x/x11_cursor.h"
#elif BUILDFLAG(IS_OZONE)
#include "ui/ozone/common/bitmap_cursor.h"
@@ -107,7 +107,7 @@ using CursorType = ui::WinCursor;
inline cef_cursor_handle_t GetCursorHandleImpl(CursorType* cursor) {
return cursor->hcursor();
}
#elif BUILDFLAG(OZONE_PLATFORM_X11)
#elif BUILDFLAG(IS_OZONE_X11)
// See https://crbug.com/1029142 for background.
using CursorType = ui::X11Cursor;
inline cef_cursor_handle_t GetCursorHandleImpl(CursorType* cursor) {

View File

@@ -232,7 +232,8 @@ class CefBrowserURLRequest::Context
url_loader_network_observer =
static_cast<content::StoragePartitionImpl*>(
browser_context->GetDefaultStoragePartition())
->CreateAuthCertObserverForServiceWorker();
->CreateAuthCertObserverForServiceWorker(
content::ChildProcessHost::kInvalidUniqueID);
}
task_runner->PostTask(

View File

@@ -457,7 +457,8 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
url_loader_network_observer =
static_cast<content::StoragePartitionImpl*>(
browser_context->GetDefaultStoragePartition())
->CreateAuthCertObserverForServiceWorker();
->CreateAuthCertObserverForServiceWorker(
content::ChildProcessHost::kInvalidUniqueID);
}
}

View File

@@ -10,7 +10,7 @@
#include "include/cef_base.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "ui/events/gesture_detection/motion_event_generic.h"
#include "ui/events/velocity_tracker/motion_event_generic.h"
// Implementation of MotionEvent which takes a stream of CefTouchEvents.
// This class is based on ui::MotionEventAura.

View File

@@ -49,7 +49,7 @@
#include "ui/compositor/compositor.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/gesture_detection/gesture_provider_config_helper.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/velocity_tracker/motion_event.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/touch_selection/touch_selection_controller.h"
@@ -446,7 +446,7 @@ bool CefRenderWidgetHostViewOSR::IsShowing() {
void CefRenderWidgetHostViewOSR::EnsureSurfaceSynchronizedForWebTest() {
++latest_capture_sequence_number_;
SynchronizeVisualProperties(cc::DeadlinePolicy::UseInfiniteDeadline(),
absl::nullopt);
std::nullopt);
}
content::TouchSelectionControllerClientManager*
@@ -472,15 +472,15 @@ void CefRenderWidgetHostViewOSR::SetBackgroundColor(SkColor color) {
content::RenderWidgetHostViewBase::SetBackgroundColor(color);
}
absl::optional<SkColor> CefRenderWidgetHostViewOSR::GetBackgroundColor() {
std::optional<SkColor> CefRenderWidgetHostViewOSR::GetBackgroundColor() {
return background_color_;
}
void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() {}
absl::optional<content::DisplayFeature>
std::optional<content::DisplayFeature>
CefRenderWidgetHostViewOSR::GetDisplayFeature() {
return absl::nullopt;
return std::nullopt;
}
void CefRenderWidgetHostViewOSR::SetDisplayFeatureForTesting(
@@ -543,7 +543,7 @@ CefRenderWidgetHostViewOSR::GetCurrentLocalSurfaceId() const {
}
void CefRenderWidgetHostViewOSR::UpdateLocalSurfaceIdFromEmbeddedClient(
const absl::optional<viz::LocalSurfaceId>&
const std::optional<viz::LocalSurfaceId>&
embedded_client_local_surface_id) {
if (embedded_client_local_surface_id) {
parent_local_surface_id_allocator_->UpdateFromChild(
@@ -969,7 +969,7 @@ void CefRenderWidgetHostViewOSR::DidNavigate() {
GetLocalSurfaceId());
} else {
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
absl::nullopt);
std::nullopt);
}
}
if (delegated_frame_host_) {
@@ -1053,12 +1053,12 @@ void CefRenderWidgetHostViewOSR::WasResized() {
}
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
absl::nullopt);
std::nullopt);
}
void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties(
const cc::DeadlinePolicy& deadline_policy,
const absl::optional<viz::LocalSurfaceId>& child_local_surface_id) {
const std::optional<viz::LocalSurfaceId>& child_local_surface_id) {
SetFrameRate();
const bool resized = ResizeRootLayer();
@@ -1099,7 +1099,7 @@ void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
}
SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(),
absl::nullopt);
std::nullopt);
if (render_widget_host_->delegate()) {
render_widget_host_->delegate()->SendScreenRects();
@@ -1810,8 +1810,8 @@ void CefRenderWidgetHostViewOSR::RequestImeCompositionUpdate(
void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged(
const gfx::Range& range,
const absl::optional<std::vector<gfx::Rect>>& character_bounds,
const absl::optional<std::vector<gfx::Rect>>& line_bounds) {
const std::optional<std::vector<gfx::Rect>>& character_bounds,
const std::optional<std::vector<gfx::Rect>>& line_bounds) {
if (browser_impl_.get()) {
CefRange cef_range(range.start(), range.end());
CefRenderHandler::RectList rcList;

View File

@@ -37,7 +37,7 @@
#include "ui/events/base_event_utils.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/gesture_detection/motion_event_generic.h"
#include "ui/events/velocity_tracker/motion_event_generic.h"
#include "ui/gfx/geometry/rect.h"
#if BUILDFLAG(IS_MAC)
@@ -128,9 +128,9 @@ class CefRenderWidgetHostViewOSR
GetTouchSelectionControllerClientManager() override;
gfx::Rect GetViewBounds() override;
void SetBackgroundColor(SkColor color) override;
absl::optional<SkColor> GetBackgroundColor() override;
std::optional<SkColor> GetBackgroundColor() override;
void UpdateBackgroundColor() override;
absl::optional<content::DisplayFeature> GetDisplayFeature() override;
std::optional<content::DisplayFeature> GetDisplayFeature() override;
void SetDisplayFeatureForTesting(
const content::DisplayFeature* display_feature) override;
blink::mojom::PointerLockResult LockMouse(
@@ -183,8 +183,8 @@ class CefRenderWidgetHostViewOSR
viz::SurfaceId GetCurrentSurfaceId() const override;
void ImeCompositionRangeChanged(
const gfx::Range& range,
const absl::optional<std::vector<gfx::Rect>>& character_bounds,
const absl::optional<std::vector<gfx::Rect>>& line_bounds) override;
const std::optional<std::vector<gfx::Rect>>& character_bounds,
const std::optional<std::vector<gfx::Rect>>& line_bounds) override;
std::unique_ptr<content::SyntheticGestureTarget>
CreateSyntheticGestureTarget() override;
bool TransformPointToCoordSpaceForView(
@@ -238,7 +238,7 @@ class CefRenderWidgetHostViewOSR
void WasResized();
void SynchronizeVisualProperties(
const cc::DeadlinePolicy& deadline_policy,
const absl::optional<viz::LocalSurfaceId>& child_local_surface_id);
const std::optional<viz::LocalSurfaceId>& child_local_surface_id);
void OnScreenInfoChanged();
void Invalidate(CefBrowserHost::PaintElementType type);
void SendExternalBeginFrame();
@@ -359,7 +359,7 @@ class CefRenderWidgetHostViewOSR
// has allocated one. Also sets child sequence number component of the
// viz::LocalSurfaceId allocator.
void UpdateLocalSurfaceIdFromEmbeddedClient(
const absl::optional<viz::LocalSurfaceId>& local_surface_id);
const std::optional<viz::LocalSurfaceId>& local_surface_id);
// Returns the current viz::LocalSurfaceIdAllocation.
const viz::LocalSurfaceId& GetOrCreateLocalSurfaceId();

View File

@@ -191,6 +191,8 @@ cef_permission_request_types_t GetCefRequestType(
return CEF_PERMISSION_TYPE_CAMERA_PAN_TILT_ZOOM;
case permissions::RequestType::kCameraStream:
return CEF_PERMISSION_TYPE_CAMERA_STREAM;
case permissions::RequestType::kCapturedSurfaceControl:
return CEF_PERMISSION_TYPE_CAPTURED_SURFACE_CONTROL;
case permissions::RequestType::kClipboard:
return CEF_PERMISSION_TYPE_CLIPBOARD;
case permissions::RequestType::kDiskQuota:
@@ -236,7 +238,7 @@ cef_permission_request_types_t GetCefRequestType(
uint32_t GetRequestedPermissions(
permissions::PermissionPrompt::Delegate* delegate) {
uint32_t permissions = CEF_PERMISSION_TYPE_NONE;
for (const auto* request : delegate->Requests()) {
for (const auto& request : delegate->Requests()) {
permissions |= GetCefRequestType(request->request_type());
}
return permissions;

View File

@@ -7,8 +7,8 @@
#include <memory>
#if BUILDFLAG(IS_LINUX)
#include "ui/ozone/buildflags.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#include "ui/base/ozone_buildflags.h"
#if BUILDFLAG(IS_OZONE_X11)
// Include first due to redefinition of x11::EventMask.
#include "ui/base/x/x11_util.h"
#endif
@@ -26,7 +26,7 @@
#include "ui/views/window/native_frame_view.h"
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
#include "ui/gfx/x/atom_cache.h"
#include "ui/linux/linux_ui_delegate.h"
#endif
@@ -536,7 +536,7 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) {
}
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
auto x11window = static_cast<x11::Window>(view_util::GetWindowHandle(widget));
CHECK(x11window != x11::Window::None);
@@ -642,7 +642,7 @@ ui::ImageModel CefWindowView::GetWindowAppIcon() {
void CefWindowView::WindowClosing() {
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(OZONE_PLATFORM_X11)
#if BUILDFLAG(IS_OZONE_X11)
if (host_widget()) {
auto parent = static_cast<gfx::AcceleratedWidget>(
view_util::GetWindowHandle(host_widget()));