cef/patch/patches/chrome_browser_profiles.patch

185 lines
8.2 KiB
Diff

diff --git chrome/browser/profiles/off_the_record_profile_impl.cc chrome/browser/profiles/off_the_record_profile_impl.cc
index 941d4bf2d302d..7d41044d01d9b 100644
--- chrome/browser/profiles/off_the_record_profile_impl.cc
+++ chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -660,7 +660,9 @@ std::unique_ptr<Profile> Profile::CreateOffTheRecordProfile(
#endif
if (!profile)
profile = std::make_unique<OffTheRecordProfileImpl>(parent, otr_profile_id);
- profile->Init();
+ // With CEF we want to delay initialization.
+ if (!otr_profile_id.IsUniqueForCEF())
+ profile->Init();
return std::move(profile);
}
diff --git chrome/browser/profiles/profile.cc chrome/browser/profiles/profile.cc
index cd4fd8104866c..5cf5853d6632b 100644
--- chrome/browser/profiles/profile.cc
+++ chrome/browser/profiles/profile.cc
@@ -91,6 +91,7 @@ base::LazyInstance<std::set<content::BrowserContext*>>::Leaky
namespace {
+const char kCEFOTRProfileIDPrefix[] = "CEF::BrowserContext";
const char kDevToolsOTRProfileIDPrefix[] = "Devtools::BrowserContext";
const char kMediaRouterOTRProfileIDPrefix[] = "MediaRouter::Presentation";
const char kTestOTRProfileIDPrefix[] = "Test::OTR";
@@ -111,6 +112,8 @@ bool Profile::OTRProfileID::AllowsBrowserWindows() const {
// DevTools::BrowserContext, MediaRouter::Presentation, and
// CaptivePortal::Signin are exceptions to this ban.
if (*this == PrimaryID() ||
+ base::StartsWith(profile_id_, kCEFOTRProfileIDPrefix,
+ base::CompareCase::SENSITIVE) ||
base::StartsWith(profile_id_, kDevToolsOTRProfileIDPrefix,
base::CompareCase::SENSITIVE) ||
base::StartsWith(profile_id_, kMediaRouterOTRProfileIDPrefix,
@@ -148,6 +151,16 @@ Profile::OTRProfileID Profile::OTRProfileID::CreateUnique(
base::Uuid::GenerateRandomV4().AsLowercaseString().c_str()));
}
+// static
+Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForCEF() {
+ return CreateUnique(kCEFOTRProfileIDPrefix);
+}
+
+bool Profile::OTRProfileID::IsUniqueForCEF() const {
+ return base::StartsWith(profile_id_, kCEFOTRProfileIDPrefix,
+ base::CompareCase::SENSITIVE);
+}
+
// static
Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForDevTools() {
return CreateUnique(kDevToolsOTRProfileIDPrefix);
diff --git chrome/browser/profiles/profile.h chrome/browser/profiles/profile.h
index 02454f4e780b5..4641f33c26f5f 100644
--- chrome/browser/profiles/profile.h
+++ chrome/browser/profiles/profile.h
@@ -94,6 +94,10 @@ class Profile : public content::BrowserContext {
// be applicable to run. Please see crbug.com/1098697#c3 for more details.
static OTRProfileID CreateUnique(const std::string& profile_id_prefix);
+ // Creates a unique OTR profile id to be used for CEF browser contexts.
+ static OTRProfileID CreateUniqueForCEF();
+ bool IsUniqueForCEF() const;
+
// Creates a unique OTR profile id to be used for DevTools browser contexts.
static OTRProfileID CreateUniqueForDevTools();
@@ -519,6 +523,9 @@ class Profile : public content::BrowserContext {
static Profile* FromJavaObject(const jni_zero::JavaRef<jobject>& obj);
jni_zero::ScopedJavaLocalRef<jobject> GetJavaObject() const;
#endif // BUILDFLAG(IS_ANDROID)
+
+ void NotifyOffTheRecordProfileCreated(Profile* off_the_record);
+
protected:
// Creates an OffTheRecordProfile which points to this Profile.
static std::unique_ptr<Profile> CreateOffTheRecordProfile(
@@ -530,7 +537,6 @@ class Profile : public content::BrowserContext {
static PrefStore* CreateExtensionPrefStore(Profile*,
bool incognito_pref_store);
- void NotifyOffTheRecordProfileCreated(Profile* off_the_record);
void NotifyProfileInitializationComplete();
// Returns whether the user has signed in this profile to an account.
diff --git chrome/browser/profiles/profile_impl.cc chrome/browser/profiles/profile_impl.cc
index a7d35836cb9da..a73eca3fc66d0 100644
--- chrome/browser/profiles/profile_impl.cc
+++ chrome/browser/profiles/profile_impl.cc
@@ -1036,7 +1036,9 @@ Profile* ProfileImpl::GetOffTheRecordProfile(const OTRProfileID& otr_profile_id,
otr_profiles_[otr_profile_id] = std::move(otr_profile);
- NotifyOffTheRecordProfileCreated(raw_otr_profile);
+ // With CEF we want to delay initialization.
+ if (!otr_profile_id.IsUniqueForCEF())
+ NotifyOffTheRecordProfileCreated(raw_otr_profile);
return raw_otr_profile;
}
diff --git chrome/browser/profiles/profile_manager.cc chrome/browser/profiles/profile_manager.cc
index 35ed366d5e749..da51d2e0081f5 100644
--- chrome/browser/profiles/profile_manager.cc
+++ chrome/browser/profiles/profile_manager.cc
@@ -437,7 +437,7 @@ ProfileManager::ProfileManager(const base::FilePath& user_data_dir)
profile_manager_android_ = std::make_unique<ProfileManagerAndroid>(this);
#endif
- if (ProfileShortcutManager::IsFeatureEnabled() && !user_data_dir_.empty())
+ if (!user_data_dir_.empty() && ProfileShortcutManager::IsFeatureEnabled())
profile_shortcut_manager_ = ProfileShortcutManager::Create(this);
zombie_metrics_timer_.Start(FROM_HERE, base::Minutes(30), this,
diff --git chrome/browser/profiles/profile_manager.h chrome/browser/profiles/profile_manager.h
index 3d5fd0d5ca858..965ab69b3fe8f 100644
--- chrome/browser/profiles/profile_manager.h
+++ chrome/browser/profiles/profile_manager.h
@@ -134,7 +134,7 @@ class ProfileManager : public Profile::Delegate {
// acceptable. Returns nullptr if loading the new profile fails.
// TODO(bauerb): Migrate calls from other code to `GetProfileByPath()`, then
// make this method private.
- Profile* GetProfile(const base::FilePath& profile_dir);
+ virtual Profile* GetProfile(const base::FilePath& profile_dir);
// Returns regular or off-the-record profile given its profile key.
static Profile* GetProfileFromProfileKey(ProfileKey* profile_key);
@@ -175,7 +175,7 @@ class ProfileManager : public Profile::Delegate {
// Returns true if the profile pointer is known to point to an existing
// profile.
- bool IsValidProfile(const void* profile);
+ virtual bool IsValidProfile(const void* profile);
// Returns the directory where the first created profile is stored,
// relative to the user data directory currently in use.
diff --git chrome/browser/profiles/renderer_updater.cc chrome/browser/profiles/renderer_updater.cc
index 1154f4f02cc16..4c9e5128cd177 100644
--- chrome/browser/profiles/renderer_updater.cc
+++ chrome/browser/profiles/renderer_updater.cc
@@ -10,6 +10,7 @@
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/runtime.h"
#include "chrome/browser/content_settings/content_settings_manager_delegate.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -46,6 +47,9 @@ RendererUpdater::RendererUpdater(Profile* profile)
#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
,
bound_session_cookie_refresh_service_(
+#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
+ cef::IsAlloyRuntimeEnabled() ? nullptr :
+#endif
BoundSessionCookieRefreshServiceFactory::GetForProfile(profile))
#endif
{
diff --git chrome/browser/profiles/renderer_updater_factory.cc chrome/browser/profiles/renderer_updater_factory.cc
index a836288d08abc..26219d19f0973 100644
--- chrome/browser/profiles/renderer_updater_factory.cc
+++ chrome/browser/profiles/renderer_updater_factory.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/profiles/renderer_updater_factory.h"
+#include "cef/libcef/features/runtime.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/renderer_updater.h"
@@ -25,7 +26,13 @@ RendererUpdaterFactory::RendererUpdaterFactory()
DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(HostContentSettingsMapFactory::GetInstance());
#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
+#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
+ if (!cef::IsAlloyRuntimeEnabled()) {
+#endif
DependsOn(BoundSessionCookieRefreshServiceFactory::GetInstance());
+#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
+ }
+#endif
#endif // BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
}