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

Update OffTheRecord profile API in several tests.

Profile API is being updated (issue 1033903) and the usage of
GetOffTheRecordProfile and HasOffTheRecordProfile without argument is
getting deprecated. Use cases of this call that ONLY refer to incognito
or guest mode can use [Get/Has]PrimaryOTRProfile() instead.

Several tests are updated to use the new API.

This CL does NOT change any behavior.

Bug: 1060940
Change-Id: Ib64d95598959d77cf05f9c2b3beb8fcd8625d779
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214388
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771573}
parent 978a09b2
......@@ -134,7 +134,7 @@ TEST_F(GeolocationPermissionContextDelegateTests,
requesting_frame, requesting_frame)
.content_setting);
Profile* otr_profile = profile()->GetOffTheRecordProfile();
Profile* otr_profile = profile()->GetPrimaryOTRProfile();
// A DSE setting of ALLOW should not flow through to incognito.
ASSERT_EQ(CONTENT_SETTING_ASK,
......
......@@ -21,7 +21,7 @@ TEST(LanguageModelManagerFactoryTest, SharedWithIncognito) {
LanguageModelManagerFactory::GetForBrowserContext(&profile);
EXPECT_THAT(manager, Not(IsNull()));
Profile* const incognito = profile.GetOffTheRecordProfile();
Profile* const incognito = profile.GetPrimaryOTRProfile();
ASSERT_THAT(incognito, Not(IsNull()));
EXPECT_THAT(LanguageModelManagerFactory::GetForBrowserContext(incognito),
Eq(manager));
......
......@@ -18,7 +18,7 @@ TEST(UrlLanguageHistogramFactoryTest, NotCreatedInIncognito) {
EXPECT_THAT(UrlLanguageHistogramFactory::GetForBrowserContext(&profile),
Not(IsNull()));
Profile* incognito = profile.GetOffTheRecordProfile();
Profile* incognito = profile.GetPrimaryOTRProfile();
ASSERT_THAT(incognito, Not(IsNull()));
EXPECT_THAT(UrlLanguageHistogramFactory::GetForBrowserContext(incognito),
IsNull());
......
......@@ -65,7 +65,7 @@ class WindowedIncognitoMonitorTest : public testing::Test {
size_t OpenBrowserWindow(bool incognito) {
auto browser_window = std::make_unique<TestBrowserWindow>();
Profile* browser_profile =
incognito ? profile_->GetOffTheRecordProfile() : profile_.get();
incognito ? profile_->GetPrimaryOTRProfile() : profile_.get();
Browser::CreateParams params(browser_profile, true);
params.type = Browser::TYPE_NORMAL;
params.window = browser_window.get();
......
......@@ -201,8 +201,8 @@ TEST_F(OptimizationGuidePermissionsUtilTest,
SetSyncServiceEnabled(true);
SetUrlKeyedAnonymizedDataCollectionEnabled(true);
Profile* off_the_record_profile = profile()->GetOffTheRecordProfile();
EXPECT_TRUE(off_the_record_profile->IsOffTheRecord());
EXPECT_FALSE(IsUserPermittedToFetchFromRemoteOptimizationGuide(
off_the_record_profile));
Profile* incognito_profile = profile()->GetPrimaryOTRProfile();
EXPECT_TRUE(incognito_profile->IsOffTheRecord());
EXPECT_FALSE(
IsUserPermittedToFetchFromRemoteOptimizationGuide(incognito_profile));
}
......@@ -401,7 +401,7 @@ TEST_F(ChromePasswordManagerClientTest,
SavingAndFillingDisabledConditionsInIncognito) {
std::unique_ptr<WebContents> incognito_web_contents(
content::WebContentsTester::CreateTestWebContents(
profile()->GetOffTheRecordProfile(), nullptr));
profile()->GetPrimaryOTRProfile(), nullptr));
std::unique_ptr<MockChromePasswordManagerClient> client(
new MockChromePasswordManagerClient(incognito_web_contents.get()));
EXPECT_CALL(*client, GetMainFrameCertStatus()).WillRepeatedly(Return(0));
......@@ -423,8 +423,7 @@ TEST_F(ChromePasswordManagerClientTest,
// In guest mode saving is disabled, filling is enabled but there is in fact
// nothing to fill, manual filling is disabled.
profile()->SetGuestSession(true);
profile()->GetOffTheRecordProfile()->AsTestingProfile()->SetGuestSession(
true);
profile()->GetPrimaryOTRProfile()->AsTestingProfile()->SetGuestSession(true);
EXPECT_FALSE(client->IsSavingAndFillingEnabled(kUrlOn));
EXPECT_TRUE(client->IsFillingEnabled(kUrlOn));
EXPECT_FALSE(client->IsFillingFallbackEnabled(kUrlOn));
......
......@@ -166,7 +166,7 @@ TEST_F(SiteDataCacheFacadeTest, IsDataCacheRecordingForTesting) {
EXPECT_TRUE(cache_is_recording);
SiteDataCacheFacade off_record_data_cache_facade(
profile()->GetOffTheRecordProfile());
profile()->GetPrimaryOTRProfile());
{
base::RunLoop run_loop;
auto quit_closure = run_loop.QuitClosure();
......
......@@ -132,7 +132,7 @@ TEST_F(ChromePluginServiceFilterTest,
TEST_F(ChromePluginServiceFilterTest,
PreferHtmlOverPluginsIncognitoHasIndependentSetting) {
Profile* incognito = profile()->GetOffTheRecordProfile();
Profile* incognito = profile()->GetPrimaryOTRProfile();
filter_->RegisterProfile(incognito);
content::WebPluginInfo flash_plugin(
......
......@@ -25,7 +25,7 @@ class TabStateDBFactoryTest : public testing::Test {
TEST_F(TabStateDBFactoryTest, TestIncognitoProfile) {
EXPECT_EQ(nullptr, TabStateDBFactory::GetInstance()->GetForProfile(
profile()->GetOffTheRecordProfile()));
profile()->GetPrimaryOTRProfile()));
}
TEST_F(TabStateDBFactoryTest, TestSameProfile) {
......
......@@ -208,7 +208,7 @@ TEST_F(CookieControlsTest, Incognito) {
// Create incognito web_contents and CookieControlsController.
std::unique_ptr<content::WebContents> incognito_web_contents =
content::WebContentsTester::CreateTestWebContents(
profile()->GetOffTheRecordProfile(), nullptr);
profile()->GetPrimaryOTRProfile(), nullptr);
content_settings::TabSpecificContentSettings::CreateForWebContents(
incognito_web_contents.get(),
std::make_unique<chrome::TabSpecificContentSettingsDelegate>(
......
......@@ -34,7 +34,7 @@ std::unique_ptr<Browser> ExistingWindowSubMenuModelTest::CreateTestBrowser(
bool popup) {
TestBrowserWindow* window = new TestBrowserWindow;
new TestBrowserWindowOwner(window);
Profile* profile = incognito ? browser()->profile()->GetOffTheRecordProfile()
Profile* profile = incognito ? browser()->profile()->GetPrimaryOTRProfile()
: browser()->profile();
Browser::Type type = popup ? Browser::TYPE_POPUP : Browser::TYPE_NORMAL;
......@@ -106,20 +106,20 @@ TEST_F(ExistingWindowSubMenuModelTest, ShouldShowSubmenuIncognito) {
// Shouldn't show menu for one window.
ASSERT_FALSE(ExistingWindowSubMenuModel::ShouldShowSubmenu(profile()));
ASSERT_FALSE(ExistingWindowSubMenuModel::ShouldShowSubmenu(
profile()->GetOffTheRecordProfile()));
profile()->GetPrimaryOTRProfile()));
// Create an incognito browser. We shouldn't show the menu, because we only
// move tabs between windows of the same profile.
std::unique_ptr<Browser> incognito_browser_1(CreateTestBrowser(true, false));
ASSERT_FALSE(ExistingWindowSubMenuModel::ShouldShowSubmenu(profile()));
ASSERT_FALSE(ExistingWindowSubMenuModel::ShouldShowSubmenu(
profile()->GetOffTheRecordProfile()));
profile()->GetPrimaryOTRProfile()));
// Add another incognito browser, and make sure we do show the menu now.
std::unique_ptr<Browser> incognito_browser_2(CreateTestBrowser(true, false));
ASSERT_FALSE(ExistingWindowSubMenuModel::ShouldShowSubmenu(profile()));
ASSERT_TRUE(ExistingWindowSubMenuModel::ShouldShowSubmenu(
profile()->GetOffTheRecordProfile()));
profile()->GetPrimaryOTRProfile()));
}
// Ensure we don't show the menu on a popup window.
......
......@@ -438,7 +438,7 @@ Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
const GURL& url) {
chrome::OpenURLOffTheRecord(profile, url);
Browser* browser =
chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false);
chrome::FindTabbedBrowser(profile->GetPrimaryOTRProfile(), false);
content::TestNavigationObserver observer(
browser->tab_strip_model()->GetActiveWebContents());
observer.Wait();
......@@ -458,8 +458,8 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser(Profile* profile) {
if (!profile)
profile = browser()->profile();
// Create a new browser with using the incognito profile.
Browser* incognito = new Browser(
Browser::CreateParams(profile->GetOffTheRecordProfile(), true));
Browser* incognito =
new Browser(Browser::CreateParams(profile->GetPrimaryOTRProfile(), true));
AddBlankTabAndShow(incognito);
return incognito;
}
......
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