From de5a45de018d8388f7479da3adb6472b991bf4f3 Mon Sep 17 00:00:00 2001 From: "joaodasilva@chromium.org" Date: Tue, 20 Sep 2011 00:41:18 +0000 Subject: Removed code duplication on test for search engine selector on first run. Also fixes the test logic on the mac, which currently is ignoring SearchEngineSelectorDisallowed() if the default search provider is not managed, which is the most common case. BUG=None TEST=The search engine selection dialog shows on first run, except when the default search provider is managed by policy or the dialog is disallowed. Review URL: http://codereview.chromium.org/7936009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101877 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/first_run/first_run.cc | 6 ++++++ chrome/browser/first_run/first_run.h | 8 ++++++-- chrome/browser/ui/cocoa/first_run_dialog.mm | 3 +-- chrome/browser/ui/gtk/first_run_dialog.cc | 4 +--- chrome/browser/ui/views/first_run_search_engine_view.cc | 4 +--- 5 files changed, 15 insertions(+), 10 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index f73f179..3cc08bda 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -462,6 +462,12 @@ bool FirstRun::SearchEngineSelectorDisallowed() { } // static +bool FirstRun::ShouldShowSearchEngineSelector(const TemplateURLService* model) { + return !SearchEngineSelectorDisallowed() && + model && !model->is_default_search_managed(); +} + +// static bool FirstRun::SetOEMFirstRunBubblePref() { PrefService* local_state = g_browser_process->local_state(); if (!local_state) diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h index 35c82ac0..235754c 100644 --- a/chrome/browser/first_run/first_run.h +++ b/chrome/browser/first_run/first_run.h @@ -17,10 +17,11 @@ class CommandLine; class FilePath; class GURL; -class Profile; -class ProcessSingleton; class ImporterHost; class ImporterList; +class Profile; +class ProcessSingleton; +class TemplateURLService; // This class contains the chrome first-run installation actions needed to // fully test the custom installer. It also contains the opposite actions to @@ -131,6 +132,9 @@ class FirstRun { // being shown. static bool SearchEngineSelectorDisallowed(); + // Whether the search engine selection dialog should be shown on first run. + static bool ShouldShowSearchEngineSelector(const TemplateURLService* model); + // -- Platform-specific functions -- // Imports settings. This may be done in a separate process depending on the diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm index 9458377..36c5788 100644 --- a/chrome/browser/ui/cocoa/first_run_dialog.mm +++ b/chrome/browser/ui/cocoa/first_run_dialog.mm @@ -151,8 +151,7 @@ void ShowFirstRunDialog(Profile* profile, // If the default search is not managed via policy, ask the user to // choose a default. TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(profile); - if (!FirstRun::SearchEngineSelectorDisallowed() || - (model && !model->is_default_search_managed())) { + if (FirstRun::ShouldShowSearchEngineSelector(model)) { ShowSearchEngineSelectionDialog(profile, randomize_search_engine_experiment); } diff --git a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc index 2143681..07ce629 100644 --- a/chrome/browser/ui/gtk/first_run_dialog.cc +++ b/chrome/browser/ui/gtk/first_run_dialog.cc @@ -111,9 +111,7 @@ bool FirstRunDialog::Show(Profile* profile, const TemplateURLService* search_engines_model = TemplateURLServiceFactory::GetForProfile(profile); bool show_search_engines_dialog = - !FirstRun::SearchEngineSelectorDisallowed() && - search_engines_model && - !search_engines_model->is_default_search_managed(); + FirstRun::ShouldShowSearchEngineSelector(search_engines_model); #if defined(GOOGLE_CHROME_BUILD) // If the metrics reporting is managed, we won't ask. diff --git a/chrome/browser/ui/views/first_run_search_engine_view.cc b/chrome/browser/ui/views/first_run_search_engine_view.cc index 7112f4b..991d699 100644 --- a/chrome/browser/ui/views/first_run_search_engine_view.cc +++ b/chrome/browser/ui/views/first_run_search_engine_view.cc @@ -58,10 +58,8 @@ void ShowFirstRunDialog(Profile* profile, // If the default search is managed via policy, we don't ask the user to // choose. TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(profile); - if (FirstRun::SearchEngineSelectorDisallowed() || !model || - model->is_default_search_managed()) { + if (!FirstRun::ShouldShowSearchEngineSelector(model)) return; - } views::Widget* window = views::Widget::CreateWindow( new FirstRunSearchEngineView( -- cgit v1.1