mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			102 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| diff --git chrome/browser/profiles/off_the_record_profile_impl.cc chrome/browser/profiles/off_the_record_profile_impl.cc
 | |
| index cf4597e671afe..a9693c4e10d8e 100644
 | |
| --- chrome/browser/profiles/off_the_record_profile_impl.cc
 | |
| +++ chrome/browser/profiles/off_the_record_profile_impl.cc
 | |
| @@ -647,7 +647,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 4385d5d90f9c8..88aca5519660e 100644
 | |
| --- chrome/browser/profiles/profile.cc
 | |
| +++ chrome/browser/profiles/profile.cc
 | |
| @@ -84,6 +84,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";
 | |
| @@ -104,6 +105,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,
 | |
| @@ -141,6 +144,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 8e96e47754dc7..c65184775fba7 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();
 | |
|  
 | |
| @@ -506,6 +510,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(
 | |
| @@ -517,7 +524,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 3dd5f9818cfa0..7b3e3697f4ce3 100644
 | |
| --- chrome/browser/profiles/profile_impl.cc
 | |
| +++ chrome/browser/profiles/profile_impl.cc
 | |
| @@ -1038,7 +1038,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;
 | |
|  }
 |