Files
cef/patch/patches/chrome_browser_profiles.patch

147 lines
6.2 KiB
Diff

diff --git chrome/browser/profiles/off_the_record_profile_impl.cc chrome/browser/profiles/off_the_record_profile_impl.cc
index 326da3a5dee4f598527d8ad722f452fdfba9ff02..f22b4aecb3130b6a8f96df6b2301909f97d8ef0a 100644
--- chrome/browser/profiles/off_the_record_profile_impl.cc
+++ chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -644,7 +644,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 c63def4f8bb82c2d76e58b26821b87443f30c97a..3b145cb43dd36feb35218aec5020fb7000af8ff1 100644
--- chrome/browser/profiles/profile.cc
+++ chrome/browser/profiles/profile.cc
@@ -94,6 +94,7 @@ std::set<content::BrowserContext*>& GetProfileInstances() {
namespace {
+const char kCEFOTRProfileIDPrefix[] = "CEF::BrowserContext";
const char kDevToolsOTRProfileIDPrefix[] = "Devtools::BrowserContext";
const char kMediaRouterOTRProfileIDPrefix[] = "MediaRouter::Presentation";
const char kTestOTRProfileIDPrefix[] = "Test::OTR";
@@ -114,6 +115,8 @@ bool Profile::OTRProfileID::AllowsBrowserWindows() const {
// DevTools::BrowserContext, MediaRouter::Presentation, and
// CaptivePortal::Signin are exceptions to this ban.
if (*this == PrimaryID() || IsDevTools() ||
+ base::StartsWith(profile_id_, kCEFOTRProfileIDPrefix,
+ base::CompareCase::SENSITIVE) ||
base::StartsWith(profile_id_, kMediaRouterOTRProfileIDPrefix,
base::CompareCase::SENSITIVE)) {
return true;
@@ -154,6 +157,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 454f7c585c4ae7d9596e358de8ebf23b105d17f4..73195a974c04115ac1852bda5e6019da94f76134 100644
--- chrome/browser/profiles/profile.h
+++ chrome/browser/profiles/profile.h
@@ -91,6 +91,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();
@@ -499,6 +503,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(
@@ -510,7 +517,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 ab155d50897649746f17cd239f1fbe8646a8f942..aadda2ef3043999a712e3df5fb27d7d08ae34299 100644
--- chrome/browser/profiles/profile_impl.cc
+++ chrome/browser/profiles/profile_impl.cc
@@ -40,6 +40,7 @@
#include "base/version.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/background/background_contents_service_factory.h"
#include "chrome/browser/background_fetch/background_fetch_delegate_factory.h"
#include "chrome/browser/background_fetch/background_fetch_delegate_impl.h"
@@ -232,6 +233,10 @@
#include "chrome/browser/background/extensions/background_mode_manager.h"
#endif
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/browser/prefs/pref_names.h"
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS_CORE)
#include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
@@ -271,6 +276,12 @@ class ScopedAllowBlockingForProfile : public base::ScopedAllowBlocking {};
namespace {
+#if BUILDFLAG(ENABLE_CEF)
+BASE_FEATURE(kStorageNotificationService,
+ "StorageNotificationService",
+ base::FEATURE_ENABLED_BY_DEFAULT);
+#endif
+
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
// Delay before we explicitly create the SessionService.
static constexpr base::TimeDelta kCreateSessionServiceDelay =
@@ -997,7 +1008,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;
}
@@ -1319,6 +1332,12 @@ ProfileImpl::GetStorageNotificationService() {
#if BUILDFLAG(IS_ANDROID)
return nullptr;
#else
+#if BUILDFLAG(ENABLE_CEF)
+ if (!base::FeatureList::IsEnabled(kStorageNotificationService) ||
+ !GetPrefs()->GetBoolean(cef::prefs::kEnableStorageNotificationService)) {
+ return nullptr;
+ }
+#endif
return StorageNotificationServiceFactory::GetForBrowserContext(this);
#endif
}