Revert "Reland "Reland "[waffle]Don't show the dialog in a guest session if the pref is set"""
This reverts commit af53608af082f3e5a5e4cfaa92f64eb6197d7d98.
Reason for revert: I added the ifdefs in the wrong place
https://ci.chromium.org/ui/p/chromium/builders/ci/Mac13%20Tests/21176/overview
Original change's description:
> Reland "Reland "[waffle]Don't show the dialog in a guest session if the pref is set""
>
> This is a reland of commit 328052ff5cc3a07d33332b3f77513bb2e12d4295
>
> Original change's description:
> > Reland "[waffle]Don't show the dialog in a guest session if the pref is set"
> >
> > This is a reland of commit cf18d29dd6d004879f57685a452eb92bc1fe9f39
> >
> > Original change's description:
> > > [waffle]Don't show the dialog in a guest session if the pref is set
> > >
> > > The search engine choice dialog should not be displayed in all guest
> > > sessions if the users decide to share the default search engine across
> > > guest sessions.
> > >
> > > Demo: http://b/364254781#comment2
> > > Fixed: b:364254781
> > > Change-Id: I196b7c75b357fb351167e933f58d2ef777939e44
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5829416
> > > Commit-Queue: Nicolas Dossou-Gbété <dgn@chromium.org>
> > > Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org>
> > > Auto-Submit: Jack Yammine <jyammine@google.com>
> > > Cr-Commit-Position: refs/heads/main@{#1353983}
> >
> > Cq-Include-Trybots: luci.chromium.try:mac13-tests
> > Change-Id: Ic886af24761256c90c14640c0bdad7cb020c3660
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5891297
> > Auto-Submit: Christian Dullweber <dullweber@chromium.org>
> > Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org>
> > Commit-Queue: Nicolas Dossou-Gbété <dgn@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1361083}
>
> Change-Id: I5e8d7bef9a461ca410aab08a07190b4187082835
> Cq-Include-Trybots: luci.chromium.try:mac13-tests
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5893497
> Commit-Queue: Christian Dullweber <dullweber@chromium.org>
> Auto-Submit: Christian Dullweber <dullweber@chromium.org>
> Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1361709}
Change-Id: I90d411ed1c98b69d344510798736568c4a443106
Cq-Include-Trybots: luci.chromium.try:mac13-tests
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5898733
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Owners-Override: Tom Van Goethem <tov@chromium.org>
Auto-Submit: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1361740}
diff --git a/chrome/browser/resources/search_engine_choice/app.ts b/chrome/browser/resources/search_engine_choice/app.ts
index 71bc84d..0fc6092 100644
--- a/chrome/browser/resources/search_engine_choice/app.ts
+++ b/chrome/browser/resources/search_engine_choice/app.ts
@@ -3,9 +3,10 @@
// found in the LICENSE file.
import 'chrome://resources/cr_components/localized_link/localized_link.js';
-import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js';
import 'chrome://resources/cr_elements/cr_button/cr_button.js';
+import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js';
import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js';
+import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js';
import 'chrome://resources/cr_elements/cr_radio_group/cr_radio_group.js';
import 'chrome://resources/cr_elements/cr_radio_button/cr_radio_button.js';
import './strings.m.js';
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc b/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc
index 4689cfbd..fadf5f1 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc
@@ -134,10 +134,10 @@
class SearchEngineChoiceDialogBrowserTest : public InProcessBrowserTest {
public:
explicit SearchEngineChoiceDialogBrowserTest(bool use_spy_service = true)
- : use_spy_service_(use_spy_service) {}
+ : use_spy_service_(use_spy_service) {
+ }
- SearchEngineChoiceDialogBrowserTest(
- const SearchEngineChoiceDialogBrowserTest&) = delete;
+ SearchEngineChoiceDialogBrowserTest(const SearchEngineChoiceDialogBrowserTest&) = delete;
SearchEngineChoiceDialogBrowserTest& operator=(
const SearchEngineChoiceDialogBrowserTest&) = delete;
@@ -265,7 +265,6 @@
profiles::SwitchToGuestProfile(browser_future.GetCallback());
Browser* guest_browser = browser_future.Get();
CHECK(guest_browser);
- EXPECT_TRUE(guest_browser->profile()->IsGuestSession());
content::WebContents* ntp_contents =
guest_browser->tab_strip_model()->GetActiveWebContents();
content::WaitForLoadStop(ntp_contents);
@@ -279,8 +278,6 @@
SearchEngineChoiceDialogServiceFactory::
ScopedChromeBuildOverrideForTesting(
/*force_chrome_build=*/true);
- base::test::ScopedFeatureList feature_list_{
- switches::kSearchEngineChoiceGuestExperience};
bool use_spy_service_;
base::CallbackListSubscription create_services_subscription_;
base::HistogramTester histogram_tester_;
@@ -674,17 +671,11 @@
#if !BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(SearchEngineChoiceDialogBrowserTest,
DialogIsDisplayedOnEveryGuestSession) {
-#if !BUILDFLAG(IS_MAC)
// Initial browser
- // This initial browser is sometimes missing on mac. We don't really need that
- // browser, so if the guest browser works, then the test might still succeed.
EXPECT_EQ(BrowserList::GetInstance()->size(), 1u);
-#endif
Browser* first_guest_session = CreateGuestBrowserAndLoadNTP();
-#if !BUILDFLAG(IS_MAC)
EXPECT_EQ(BrowserList::GetInstance()->size(), 2u);
-#endif
auto* first_service = static_cast<MockSearchEngineChoiceDialogService*>(
SearchEngineChoiceDialogServiceFactory::GetForProfile(
first_guest_session->profile()));
@@ -712,56 +703,6 @@
TemplateURLPrepopulateData::bing.id, /*save_guest_mode_selection=*/false,
SearchEngineChoiceDialogService::EntryPoint::kDialog);
EXPECT_FALSE(second_service->IsShowingDialog(*second_guest_session));
-
- CheckNavigationConditionRecorded(
- search_engines::SearchEngineChoiceScreenConditions::
- kUsingPersistedGuestSessionChoice,
- 0);
-}
-
-IN_PROC_BROWSER_TEST_F(SearchEngineChoiceDialogBrowserTest,
- PRE_SearchEngineIsSavedBetweenGuestSessionsIfNeeded) {
- // Initial browser
- EXPECT_EQ(BrowserList::GetInstance()->size(), 1u);
-
- Browser* guest_session = CreateGuestBrowserAndLoadNTP();
- EXPECT_EQ(BrowserList::GetInstance()->size(), 2u);
- auto* first_service = static_cast<MockSearchEngineChoiceDialogService*>(
- SearchEngineChoiceDialogServiceFactory::GetForProfile(
- guest_session->profile()));
-
- // Complete the choice for the first guest profile and choose to save the
- // choice between guest sessions.
- first_service->NotifyChoiceMade(
- TemplateURLPrepopulateData::bing.id, /*save_guest_mode_selection=*/true,
- SearchEngineChoiceDialogService::EntryPoint::kDialog);
- EXPECT_FALSE(first_service->IsShowingDialog(*guest_session));
-
- CloseBrowserSynchronously(guest_session);
- EXPECT_EQ(BrowserList::GetInstance()->size(), 1u);
-}
-
-IN_PROC_BROWSER_TEST_F(SearchEngineChoiceDialogBrowserTest,
- SearchEngineIsSavedBetweenGuestSessionsIfNeeded) {
- // Initial browser
- EXPECT_EQ(BrowserList::GetInstance()->size(), 1u);
-
- Browser* guest_session = CreateGuestBrowserAndLoadNTP();
- EXPECT_EQ(BrowserList::GetInstance()->size(), 2u);
- auto* second_service = static_cast<MockSearchEngineChoiceDialogService*>(
- SearchEngineChoiceDialogServiceFactory::GetForProfile(
- guest_session->profile()));
-
- // The search engine choice dialog doesn't get displayed for the second guest
- // profile and the previously chosen default search engine is used.
- EXPECT_FALSE(second_service->IsShowingDialog(*guest_session));
- EXPECT_EQ(g_browser_process->local_state()->GetInt64(
- prefs::kDefaultSearchProviderGuestModePrepopulatedId),
- TemplateURLPrepopulateData::bing.id);
- CheckNavigationConditionRecorded(
- search_engines::SearchEngineChoiceScreenConditions::
- kUsingPersistedGuestSessionChoice,
- 1);
}
#endif
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc
index b71d2c9..e92a03b 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc
@@ -195,11 +195,11 @@
NOTREACHED(base::NotFatalUntil::M127);
} else {
- if (search_engine_choice_service_
- ->IsProfileEligibleForDseGuestPropagation() &&
- save_guest_mode_selection) {
- search_engine_choice_service_->PropagateSearchEngineBetweenGuestSessions(
- prepopulate_id);
+ if (base::FeatureList::IsEnabled(
+ switches::kSearchEngineChoiceGuestExperience) &&
+ profile_->IsGuestSession() && save_guest_mode_selection) {
+ g_browser_process->local_state()->SetInt64(
+ prefs::kDefaultSearchProviderGuestModePrepopulatedId, prepopulate_id);
}
template_url_service_->SetUserSelectedDefaultSearchProvider(
selected_engine, search_engines::ChoiceMadeLocation::kChoiceScreen);
@@ -336,13 +336,6 @@
kAlreadyCompleted;
}
- if (search_engine_choice_service_
- ->IsProfileEligibleForDseGuestPropagation() &&
- search_engine_choice_service_->ShouldPropagateDseBetweenGuestSessions()) {
- return search_engines::SearchEngineChoiceScreenConditions::
- kUsingPersistedGuestSessionChoice;
- }
-
if (web_app::AppBrowserController::IsWebApp(&browser)) {
// Showing a Chrome-specific search engine dialog on top of a window
// dedicated to a specific web app is a horrible UX, we suppress it for this
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_unittest.cc b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_unittest.cc
index 03eb1f2..a6dbdd5 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_unittest.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_unittest.cc
@@ -15,10 +15,8 @@
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/dialog_test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
-#include "chrome/test/base/testing_profile_manager.h"
#include "components/country_codes/country_codes.h"
#include "components/search_engines/prepopulated_engines.h"
-#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
#include "components/search_engines/search_engine_choice/search_engine_choice_utils.h"
#include "components/search_engines/search_engine_utils.h"
#include "components/search_engines/search_engines_pref_names.h"
@@ -348,16 +346,10 @@
EXPECT_FALSE(g_browser_process->local_state()->HasPrefPath(
prefs::kDefaultSearchProviderGuestModePrepopulatedId));
- TestingProfile* parent_guest = profile_manager()->CreateGuestProfile();
- Profile* child_guest = parent_guest->GetOffTheRecordProfile(
- Profile::OTRProfileID::PrimaryID(), false);
-
- TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
- parent_guest,
- base::BindRepeating(&TemplateURLServiceFactory::BuildInstanceFor));
-
SearchEngineChoiceDialogService* search_engine_choice_dialog_service =
- SearchEngineChoiceDialogServiceFactory::GetForProfile(child_guest);
+ SearchEngineChoiceDialogServiceFactory::GetForProfile(profile());
+ profile()->SetGuestSession(/*guest=*/true);
+
const int kPrepopulatedId =
search_engine_choice_dialog_service->GetSearchEngines()
.at(0)
@@ -379,16 +371,10 @@
EXPECT_FALSE(g_browser_process->local_state()->HasPrefPath(
prefs::kDefaultSearchProviderGuestModePrepopulatedId));
- TestingProfile* parent_guest = profile_manager()->CreateGuestProfile();
- Profile* child_guest = parent_guest->GetOffTheRecordProfile(
- Profile::OTRProfileID::PrimaryID(), false);
-
- TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
- parent_guest,
- base::BindRepeating(&TemplateURLServiceFactory::BuildInstanceFor));
-
SearchEngineChoiceDialogService* search_engine_choice_dialog_service =
- SearchEngineChoiceDialogServiceFactory::GetForProfile(child_guest);
+ SearchEngineChoiceDialogServiceFactory::GetForProfile(profile());
+ profile()->SetGuestSession(/*guest=*/true);
+
const int kPrepopulatedId =
search_engine_choice_dialog_service->GetSearchEngines()
.at(0)
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc b/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc
index e60c9bc3..13d95b17 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc
@@ -6,12 +6,10 @@
#include "base/check_deref.h"
#include "base/check_is_test.h"
-#include "base/feature_list.h"
#include "base/strings/string_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
-#include "components/search_engines/search_engines_switches.h"
#include "components/variations/service/variations_service.h"
namespace search_engines {
@@ -19,19 +17,8 @@
std::unique_ptr<KeyedService> BuildSearchEngineChoiceService(
content::BrowserContext* context) {
Profile& profile = CHECK_DEREF(Profile::FromBrowserContext(context));
-
-#if !BUILDFLAG(IS_ANDROID)
- const bool is_profile_elibile_for_dse_guest_propagation =
- base::FeatureList::IsEnabled(
- switches::kSearchEngineChoiceGuestExperience) &&
- profile.IsGuestSession();
-#endif
-
return std::make_unique<SearchEngineChoiceService>(
CHECK_DEREF(profile.GetPrefs()), g_browser_process->local_state(),
-#if !BUILDFLAG(IS_ANDROID)
- is_profile_elibile_for_dse_guest_propagation,
-#endif
g_browser_process->variations_service());
}
} // namespace
diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc
index 52ca1470..7a31311d 100644
--- a/chrome/browser/search_engines/template_url_service_test_util.cc
+++ b/chrome/browser/search_engines/template_url_service_test_util.cc
@@ -167,8 +167,7 @@
search_engine_choice_service_ =
std::make_unique<search_engines::SearchEngineChoiceService>(
- *profile_->GetPrefs(), local_state_,
- /*is_profile_eligible_for_dse_guest_propagation=*/false);
+ *profile_->GetPrefs(), local_state_);
ResetModel(false);
}
diff --git a/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc b/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc
index 86c1f22..3fe311f 100644
--- a/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc
+++ b/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.h"
#include "base/check_deref.h"
+#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/json/json_writer.h"
@@ -38,11 +39,13 @@
#include "content/public/browser/web_ui_data_source.h"
namespace {
-std::string GetChoiceListJSON(
- SearchEngineChoiceDialogService& search_engine_choice_dialog_service) {
+std::string GetChoiceListJSON(Profile& profile) {
base::Value::List choice_value_list;
+ SearchEngineChoiceDialogService* search_engine_choice_dialog_service =
+ SearchEngineChoiceDialogServiceFactory::GetForProfile(&profile);
+ CHECK(search_engine_choice_dialog_service);
const TemplateURL::TemplateURLVector choices =
- search_engine_choice_dialog_service.GetSearchEngines();
+ search_engine_choice_dialog_service->GetSearchEngines();
for (const auto& choice : choices) {
base::Value::Dict choice_value;
@@ -118,18 +121,11 @@
IDR_SIGNIN_TANGIBLE_SYNC_STYLE_SHARED_LIT_CSS_JS);
source->AddResourcePath("signin_vars.css.js", IDR_SIGNIN_SIGNIN_VARS_CSS_JS);
- SearchEngineChoiceDialogService* search_engine_choice_dialog_service =
- SearchEngineChoiceDialogServiceFactory::GetForProfile(&profile_.get());
- source->AddString(
- "choiceList",
- GetChoiceListJSON(CHECK_DEREF(search_engine_choice_dialog_service)));
-
- search_engines::SearchEngineChoiceService* search_engine_choice_service =
- search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
- &profile_.get());
- source->AddBoolean(
- "showGuestCheckbox",
- search_engine_choice_service->IsProfileEligibleForDseGuestPropagation());
+ source->AddString("choiceList", GetChoiceListJSON(profile_.get()));
+ source->AddBoolean("showGuestCheckbox",
+ base::FeatureList::IsEnabled(
+ switches::kSearchEngineChoiceGuestExperience) &&
+ profile_->IsGuestSession());
webui::SetupWebUIDataSource(
source,
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_service.cc b/components/search_engines/search_engine_choice/search_engine_choice_service.cc
index 8dc2651..170bc82 100644
--- a/components/search_engines/search_engine_choice/search_engine_choice_service.cc
+++ b/components/search_engines/search_engine_choice/search_engine_choice_service.cc
@@ -14,7 +14,6 @@
#include "base/check_is_test.h"
#include "base/command_line.h"
#include "base/debug/dump_without_crashing.h"
-#include "base/feature_list.h"
#include "base/json/json_reader.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
@@ -169,36 +168,21 @@
} // namespace
-SearchEngineChoiceService::SearchEngineChoiceService(
- PrefService& profile_prefs,
- PrefService* local_state,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- bool is_profile_eligbile_for_dse_guest_propagation,
-#endif
- int variations_country_id)
+SearchEngineChoiceService::SearchEngineChoiceService(PrefService& profile_prefs,
+ PrefService* local_state,
+ int variations_country_id)
: profile_prefs_(profile_prefs),
- local_state_(local_state),
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- is_profile_eligible_for_dse_guest_propagation_(
- is_profile_eligbile_for_dse_guest_propagation),
-#endif
variations_country_id_(variations_country_id) {
- ProcessPendingChoiceScreenDisplayState();
+ ProcessPendingChoiceScreenDisplayState(local_state);
PreprocessPrefsForReprompt();
}
SearchEngineChoiceService::SearchEngineChoiceService(
PrefService& profile_prefs,
PrefService* local_state,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- bool is_profile_eligible_for_dse_guest_propagation,
-#endif
variations::VariationsService* variations_service)
: SearchEngineChoiceService(profile_prefs,
local_state,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- is_profile_eligible_for_dse_guest_propagation,
-#endif
#if BUILDFLAG(IS_FUCHSIA)
// We can't add a dependency from Fuchsia to
// `//components/variations/service`.
@@ -554,18 +538,19 @@
}
}
-void SearchEngineChoiceService::ProcessPendingChoiceScreenDisplayState() {
+void SearchEngineChoiceService::ProcessPendingChoiceScreenDisplayState(
+ PrefService* local_state) {
if (!profile_prefs_->HasPrefPath(
prefs::kDefaultSearchProviderPendingChoiceScreenDisplayState)) {
return;
}
- if (!local_state_) {
+ if (!local_state) {
// `g_browser_process->local_state()` is null in unit tests unless properly
// set up.
CHECK_IS_TEST();
} else if (!SearchEngineChoiceMetricsServiceAccessor::
- IsMetricsReportingEnabled(local_state_)) {
+ IsMetricsReportingEnabled(local_state)) {
// The display state should not be cached when UMA is disabled.
profile_prefs_->ClearPref(
@@ -663,35 +648,6 @@
country_id_cache_.reset();
}
-#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
-bool SearchEngineChoiceService::IsProfileEligibleForDseGuestPropagation()
- const {
- return base::FeatureList::IsEnabled(
- switches::kSearchEngineChoiceGuestExperience) &&
- is_profile_eligible_for_dse_guest_propagation_;
-}
-
-bool SearchEngineChoiceService::ShouldPropagateDseBetweenGuestSessions() const {
- return base::FeatureList::IsEnabled(
- switches::kSearchEngineChoiceGuestExperience) &&
- local_state_->HasPrefPath(
- prefs::kDefaultSearchProviderGuestModePrepopulatedId);
-}
-
-void SearchEngineChoiceService::PropagateSearchEngineBetweenGuestSessions(
- int prepopulated_id) {
- CHECK(prepopulated_id > 0 &&
- prepopulated_id <=
- TemplateURLPrepopulateData::kMaxPrepopulatedEngineID);
- if (!base::FeatureList::IsEnabled(
- switches::kSearchEngineChoiceGuestExperience)) {
- return;
- }
- local_state_->SetInt64(prefs::kDefaultSearchProviderGuestModePrepopulatedId,
- prepopulated_id);
-}
-#endif
-
#if BUILDFLAG(IS_ANDROID)
void SearchEngineChoiceService::ProcessGetCountryResponseFromPlayApi(
int country_id) {
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_service.h b/components/search_engines/search_engine_choice/search_engine_choice_service.h
index d562561..f00c8b8 100644
--- a/components/search_engines/search_engine_choice/search_engine_choice_service.h
+++ b/components/search_engines/search_engine_choice/search_engine_choice_service.h
@@ -36,15 +36,9 @@
SearchEngineChoiceService(
PrefService& profile_prefs,
PrefService* local_state,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- bool is_profile_eligible_for_dse_guest_propagation,
-#endif
int variations_country_id = country_codes::kCountryIDUnknown);
SearchEngineChoiceService(PrefService& profile_prefs,
PrefService* local_state,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- bool is_profile_eligible_for_dse_guest_propagation,
-#endif
variations::VariationsService* variations_service);
~SearchEngineChoiceService() override;
@@ -100,20 +94,6 @@
// in tests.
void ClearCountryIdCacheForTesting();
-#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
- // Returns whether the profile is eligible for the default search engine to be
- // used across all guest sessions.
- bool IsProfileEligibleForDseGuestPropagation() const;
-
- // Returns whether there is a default search engine configured to be
- // propagated to new guest sessions.
- bool ShouldPropagateDseBetweenGuestSessions() const;
-
- // Save the `prepopulated_id` of the chosen search engine to be used for all
- // guest sessions.
- void PropagateSearchEngineBetweenGuestSessions(int prepopulated_id);
-#endif
-
// Register Local state preferences in `registry`.
static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
@@ -123,7 +103,7 @@
// the choice are cleared, which triggers a reprompt on the next page load.
void PreprocessPrefsForReprompt();
- void ProcessPendingChoiceScreenDisplayState();
+ void ProcessPendingChoiceScreenDisplayState(PrefService* local_state);
int GetCountryIdInternal();
@@ -132,10 +112,6 @@
#endif
const raw_ref<PrefService> profile_prefs_;
- const raw_ptr<PrefService> local_state_;
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- bool is_profile_eligible_for_dse_guest_propagation_ = false;
-#endif
const int variations_country_id_;
// Used to ensure that the value returned from `GetCountryId` never changes
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc b/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc
index f7f43ee..e9c68f7 100644
--- a/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc
+++ b/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc
@@ -93,10 +93,6 @@
TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
local_state_.registry()->RegisterBooleanPref(
metrics::prefs::kMetricsReportingEnabled, true);
-#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
- local_state_.registry()->RegisterInt64Pref(
- prefs::kDefaultSearchProviderGuestModePrepopulatedId, 0);
-#endif
// Override the country checks to simulate being in Belgium.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
@@ -120,11 +116,7 @@
CHECK(!search_engine_choice_service_);
}
search_engine_choice_service_ = std::make_unique<SearchEngineChoiceService>(
- pref_service_, &local_state_,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- /*is_profile_eligible_for_dse_guest_propagation=*/false,
-#endif
- variation_country_id);
+ pref_service_, &local_state_, variation_country_id);
}
policy::MockPolicyService& policy_service() { return policy_service_; }
@@ -147,8 +139,6 @@
return CHECK_DEREF(search_engine_choice_service_.get());
}
- TestingPrefServiceSimple& local_state() { return local_state_; }
-
base::HistogramTester histogram_tester_;
private:
@@ -296,27 +286,6 @@
#endif
}
-#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
-TEST_F(SearchEngineChoiceServiceTest, GuestSessionDsePropagation) {
- base::test::ScopedFeatureList scoped_feature_list{
- switches::kSearchEngineChoiceGuestExperience};
-
- EXPECT_FALSE(local_state().HasPrefPath(
- prefs::kDefaultSearchProviderGuestModePrepopulatedId));
- EXPECT_FALSE(
- search_engine_choice_service().ShouldPropagateDseBetweenGuestSessions());
-
- constexpr int prepopulated_id = 1;
- search_engine_choice_service().PropagateSearchEngineBetweenGuestSessions(
- prepopulated_id);
- EXPECT_EQ(local_state().GetInt64(
- prefs::kDefaultSearchProviderGuestModePrepopulatedId),
- prepopulated_id);
- EXPECT_TRUE(
- search_engine_choice_service().ShouldPropagateDseBetweenGuestSessions());
-}
-#endif
-
// Test that the choice screen doesn't get displayed if the
// 'DefaultSearchProviderEnabled' policy is set to true and the
// DefaultSearchProviderSearchURL' is set.
@@ -1434,12 +1403,7 @@
metrics::prefs::kMetricsReportingEnabled, true);
search_engine_choice_service_ = std::make_unique<SearchEngineChoiceService>(
- pref_service_, &local_state_
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- ,
- /*is_profile_eligible_for_dse_guest_propagation=*/false
-#endif
- );
+ pref_service_, &local_state_);
}
~SearchEngineChoiceUtilsResourceIdsTest() override = default;
@@ -1505,11 +1469,7 @@
ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSearchEngineChoiceCountry));
SearchEngineChoiceService search_engine_choice_service(
- pref_service(), &local_state(),
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- /*is_profile_eligible_for_dse_guest_propagation=*/false,
-#endif
- country_codes::kCountryIDUnknown);
+ pref_service(), &local_state(), country_codes::kCountryIDUnknown);
EXPECT_EQ(search_engine_choice_service.GetCountryId(),
country_codes::GetCurrentCountryID());
@@ -1527,11 +1487,7 @@
}
SearchEngineChoiceService search_engine_choice_service(
- pref_service(), &local_state(),
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- /*is_profile_eligible_for_dse_guest_propagation=*/false,
-#endif
- variation_country_id);
+ pref_service(), &local_state(), variation_country_id);
EXPECT_EQ(variation_country_id, search_engine_choice_service.GetCountryId());
}
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_utils.h b/components/search_engines/search_engine_choice/search_engine_choice_utils.h
index e384fcc..d63cdd1 100644
--- a/components/search_engines/search_engine_choice/search_engine_choice_utils.h
+++ b/components/search_engines/search_engine_choice/search_engine_choice_utils.h
@@ -92,11 +92,8 @@
// The browser attempting to show the choice screen in a dialog is already
// showing a choice screen.
kAlreadyBeingShown = 16,
- // The user made the choice in the guest session and opted to save it across
- // guest sessions.
- kUsingPersistedGuestSessionChoice = 17,
- kMaxValue = kUsingPersistedGuestSessionChoice,
+ kMaxValue = kAlreadyBeingShown,
};
// LINT.ThenChange(/tools/metrics/histograms/enums.xml:SearchEngineChoiceScreenConditions)
diff --git a/components/search_engines/search_engines_test_environment.cc b/components/search_engines/search_engines_test_environment.cc
index b47a5632..fab14bc 100644
--- a/components/search_engines/search_engines_test_environment.cc
+++ b/components/search_engines/search_engines_test_environment.cc
@@ -37,13 +37,8 @@
country_codes::CountryCharsToCountryID('U', 'S'));
}
- search_engine_choice_service_ = std::make_unique<SearchEngineChoiceService>(
- *pref_service_, local_state_
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- ,
- /*is_profile_eligible_for_dse_guest_propagation=*/false
-#endif
- );
+ search_engine_choice_service_ =
+ std::make_unique<SearchEngineChoiceService>(*pref_service_, local_state_);
template_url_service_ = std::make_unique<TemplateURLService>(
*pref_service_, *search_engine_choice_service_,
diff --git a/components/search_engines/template_url_service_test_util.cc b/components/search_engines/template_url_service_test_util.cc
index 8e5fd91a..cb1c733 100644
--- a/components/search_engines/template_url_service_test_util.cc
+++ b/components/search_engines/template_url_service_test_util.cc
@@ -79,11 +79,7 @@
search_engine_choice_service_ =
std::make_unique<search_engines::SearchEngineChoiceService>(
- pref_service_, &local_state_,
-#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
- /*is_profile_eligible_for_dse_guest_propagation=*/false,
-#endif
- country_codes::kCountryIDUnknown);
+ pref_service_, &local_state_, country_codes::kCountryIDUnknown);
template_url_service_ = CreateService();
}
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 250dc6f..0cd826ce 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -30929,8 +30929,6 @@
<int value="15"
label="Choice Screen dialog skipped as app stared by external intent"/>
<int value="16" label="Dialog is already shown in the same browser"/>
- <int value="17"
- label="Skipped by using a choice persisted across guest sessions"/>
</enum>
<!-- LINT.ThenChange(/components/search_engines/search_engine_choice/search_engine_choice_utils.h:SearchEngineChoiceScreenConditions) -->