Commit ddece083 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Remove DestroyOffTheRecordProfile() function.

Profile::DestroyOffTheRecordProfile function without arguments is
deprecated and replaced with a function that receives the OTR profile.
The few remaining use cases of the function are replaced with the new
API and the old function is removed.

Bug: 1033903
Change-Id: Ie417f4ef12f449774c658228dc3850b65811b3bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2196168Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769615}
parent 15a10211
...@@ -904,7 +904,8 @@ IN_PROC_BROWSER_TEST_P(ExtensionContextMenuLazyTest, ...@@ -904,7 +904,8 @@ IN_PROC_BROWSER_TEST_P(ExtensionContextMenuLazyTest,
false); false);
// Create an incognito profile. // Create an incognito profile.
ASSERT_TRUE(browser()->profile()->GetOffTheRecordProfile()); Profile* incognito = browser()->profile()->GetPrimaryOTRProfile();
ASSERT_TRUE(incognito);
ASSERT_TRUE(LoadContextMenuExtensionWithIncognitoFlags("incognito")); ASSERT_TRUE(LoadContextMenuExtensionWithIncognitoFlags("incognito"));
// Wait for the extension's processes to tell us they've created an item. // Wait for the extension's processes to tell us they've created an item.
...@@ -912,7 +913,7 @@ IN_PROC_BROWSER_TEST_P(ExtensionContextMenuLazyTest, ...@@ -912,7 +913,7 @@ IN_PROC_BROWSER_TEST_P(ExtensionContextMenuLazyTest,
ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); ASSERT_TRUE(created_incognito.WaitUntilSatisfied());
ASSERT_EQ(2u, GetItems().size()); ASSERT_EQ(2u, GetItems().size());
browser()->profile()->DestroyOffTheRecordProfile(); browser()->profile()->DestroyOffTheRecordProfile(incognito);
ASSERT_EQ(1u, GetItems().size()); ASSERT_EQ(1u, GetItems().size());
} }
......
...@@ -50,12 +50,12 @@ TEST_F(MediaRouterFactoryTest, CreateForIncognitoProfile) { ...@@ -50,12 +50,12 @@ TEST_F(MediaRouterFactoryTest, CreateForIncognitoProfile) {
TEST_F(MediaRouterFactoryTest, IncognitoBrowserContextShutdown) { TEST_F(MediaRouterFactoryTest, IncognitoBrowserContextShutdown) {
// Creates an incognito profile. // Creates an incognito profile.
profile()->GetOffTheRecordProfile(); Profile* incognito = profile()->GetPrimaryOTRProfile();
MockMediaRouter* router = static_cast<MockMediaRouter*>( MockMediaRouter* router = static_cast<MockMediaRouter*>(
MediaRouterFactory::GetApiForBrowserContext(profile())); MediaRouterFactory::GetApiForBrowserContext(profile()));
ASSERT_TRUE(router); ASSERT_TRUE(router);
EXPECT_CALL(*router, OnIncognitoProfileShutdown()); EXPECT_CALL(*router, OnIncognitoProfileShutdown());
profile()->DestroyOffTheRecordProfile(); profile()->DestroyOffTheRecordProfile(incognito);
} }
} // namespace media_router } // namespace media_router
...@@ -1202,7 +1202,7 @@ class WebRtcEventLogManagerTestIncognito ...@@ -1202,7 +1202,7 @@ class WebRtcEventLogManagerTestIncognito
incognito_rph_.reset(); incognito_rph_.reset();
if (incognito_profile_) { if (incognito_profile_) {
DCHECK(browser_context_); DCHECK(browser_context_);
browser_context_->DestroyOffTheRecordProfile(); browser_context_->DestroyOffTheRecordProfile(incognito_profile_);
} }
} }
......
...@@ -493,10 +493,3 @@ variations::VariationsClient* Profile::GetVariationsClient() { ...@@ -493,10 +493,3 @@ variations::VariationsClient* Profile::GetVariationsClient() {
chrome_variations_client_ = std::make_unique<ChromeVariationsClient>(this); chrome_variations_client_ = std::make_unique<ChromeVariationsClient>(this);
return chrome_variations_client_.get(); return chrome_variations_client_.get();
} }
void Profile::DestroyOffTheRecordProfile() {
OTRProfileID primary_otr_id = OTRProfileID::PrimaryID();
if (!HasOffTheRecordProfile(primary_otr_id))
return;
DestroyOffTheRecordProfile(GetOffTheRecordProfile(primary_otr_id));
}
...@@ -254,11 +254,6 @@ class Profile : public content::BrowserContext { ...@@ -254,11 +254,6 @@ class Profile : public content::BrowserContext {
// Destroys the OffTheRecord profile. // Destroys the OffTheRecord profile.
virtual void DestroyOffTheRecordProfile(Profile* otr_profile) = 0; virtual void DestroyOffTheRecordProfile(Profile* otr_profile) = 0;
// TODO(https://crbug.com/1033903): Remove this function when all the use
// cases are migrated to above version. The parameter-less version destroys
// the primary OffTheRecord profile.
void DestroyOffTheRecordProfile();
// True if an OffTheRecord profile with given id exists. // True if an OffTheRecord profile with given id exists.
// TODO(https://crbug.com/1033903): Remove the default value. // TODO(https://crbug.com/1033903): Remove the default value.
virtual bool HasOffTheRecordProfile( virtual bool HasOffTheRecordProfile(
......
...@@ -693,8 +693,10 @@ IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, Notifications) { ...@@ -693,8 +693,10 @@ IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, Notifications) {
chrome::NOTIFICATION_PROFILE_DESTROYED, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::Source<Profile>(otr_profile)); content::Source<Profile>(otr_profile));
profile->DestroyOffTheRecordProfile(); if (profile->HasPrimaryOTRProfile()) {
profile_destroyed_observer.Wait(); profile->DestroyOffTheRecordProfile(profile->GetPrimaryOTRProfile());
profile_destroyed_observer.Wait();
}
EXPECT_FALSE(profile->HasOffTheRecordProfile()); EXPECT_FALSE(profile->HasOffTheRecordProfile());
} }
......
...@@ -800,10 +800,6 @@ void TestingProfile::DestroyOffTheRecordProfile(Profile* otr_profile) { ...@@ -800,10 +800,6 @@ void TestingProfile::DestroyOffTheRecordProfile(Profile* otr_profile) {
incognito_profile_.reset(); incognito_profile_.reset();
} }
void TestingProfile::DestroyOffTheRecordProfile() {
DestroyOffTheRecordProfile(incognito_profile_.get());
}
bool TestingProfile::HasOffTheRecordProfile( bool TestingProfile::HasOffTheRecordProfile(
const OTRProfileID& otr_profile_id) { const OTRProfileID& otr_profile_id) {
// TODO(https://crbug.com//1033903): Add support for non-primary OTRs. // TODO(https://crbug.com//1033903): Add support for non-primary OTRs.
......
...@@ -320,10 +320,6 @@ class TestingProfile : public Profile { ...@@ -320,10 +320,6 @@ class TestingProfile : public Profile {
const OTRProfileID& otr_profile_id = OTRProfileID::PrimaryID()) override; const OTRProfileID& otr_profile_id = OTRProfileID::PrimaryID()) override;
std::vector<Profile*> GetAllOffTheRecordProfiles() override; std::vector<Profile*> GetAllOffTheRecordProfiles() override;
void DestroyOffTheRecordProfile(Profile* otr_profile) override; void DestroyOffTheRecordProfile(Profile* otr_profile) override;
// TODO(https://crbug.com/1033903): Remove this function when all the use
// cases are migrated to above version. The parameter-less version destroys
// the primary off the record profile.
void DestroyOffTheRecordProfile();
// TODO(https://crbug.com/1033903): Remove the default value. // TODO(https://crbug.com/1033903): Remove the default value.
bool HasOffTheRecordProfile( bool HasOffTheRecordProfile(
const OTRProfileID& otr_profile_id = OTRProfileID::PrimaryID()) override; const OTRProfileID& otr_profile_id = OTRProfileID::PrimaryID()) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment