summaryrefslogtreecommitdiffstats
path: root/chrome/browser/first_run
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 22:32:18 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 22:32:18 +0000
commit9de26c9b71ca8e7637580953040a61fdd2b77bdb (patch)
tree0df503e00cc110980ceea22626029b89b183d0c3 /chrome/browser/first_run
parent419a0571dda6e5cc297331c845f68da7485302da (diff)
downloadchromium_src-9de26c9b71ca8e7637580953040a61fdd2b77bdb.zip
chromium_src-9de26c9b71ca8e7637580953040a61fdd2b77bdb.tar.gz
chromium_src-9de26c9b71ca8e7637580953040a61fdd2b77bdb.tar.bz2
first-run: Move ShowFirstRunDialog() function to first_run_dialog.h
So first_run doesn't need to depend on chrome/browser/ui/. BUG=79586 TEST=None R=jhawkins@chromium.org Review URL: http://codereview.chromium.org/6871032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82014 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/first_run')
-rw-r--r--chrome/browser/first_run/first_run.cc3
-rw-r--r--chrome/browser/first_run/first_run.h5
-rw-r--r--chrome/browser/first_run/first_run_dialog.h20
-rw-r--r--chrome/browser/first_run/first_run_gtk.cc7
-rw-r--r--chrome/browser/first_run/first_run_mac.mm97
-rw-r--r--chrome/browser/first_run/first_run_win.cc35
6 files changed, 26 insertions, 141 deletions
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index af3c1a7..243732f 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -11,6 +11,7 @@
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/first_run/first_run_dialog.h"
#include "chrome/browser/first_run/first_run_import_observer.h"
#include "chrome/browser/importer/external_process_importer_host.h"
#include "chrome/browser/importer/importer_host.h"
@@ -552,7 +553,7 @@ void FirstRun::AutoImport(
// The home page string may be set in the preferences, but the user should
// initially use Chrome with the NTP as home page in organic builds.
profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true);
- ShowFirstRunDialog(profile, randomize_search_engine_experiment);
+ first_run::ShowFirstRunDialog(profile, randomize_search_engine_experiment);
}
if (make_chrome_default)
diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h
index 481ce0e..5e9d80e 100644
--- a/chrome/browser/first_run/first_run.h
+++ b/chrome/browser/first_run/first_run.h
@@ -88,11 +88,6 @@ class FirstRun {
// Returns whether the first run should be "organic".
static bool IsOrganicFirstRun();
- // Shows the search engine choice dialog, and any other platform dialogs.
- // Only called if IsOrganicFirstRun is true.
- static void ShowFirstRunDialog(Profile* profile,
- bool randomize_search_engine_experiment);
-
// The master preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function locates this file from a standard
// location and processes it so it becomes the default preferences in the
diff --git a/chrome/browser/first_run/first_run_dialog.h b/chrome/browser/first_run/first_run_dialog.h
new file mode 100644
index 0000000..a5801b7
--- /dev/null
+++ b/chrome/browser/first_run/first_run_dialog.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_FIRST_RUN_FIRST_RUN_DIALOG_H_
+#define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_DIALOG_H_
+#pragma once
+
+class Profile;
+
+namespace first_run {
+
+// Shows the search engine choice dialog. Only called if IsOrganicFirstRun()
+// is true.
+void ShowFirstRunDialog(Profile* profile,
+ bool randomize_search_engine_experiment);
+
+} // namespace first_run
+
+#endif // CHROME_BROWSER_FIRST_RUN_FIRST_RUN_DIALOG_H_
diff --git a/chrome/browser/first_run/first_run_gtk.cc b/chrome/browser/first_run/first_run_gtk.cc
index 031be77..6db2da0 100644
--- a/chrome/browser/first_run/first_run_gtk.cc
+++ b/chrome/browser/first_run/first_run_gtk.cc
@@ -14,7 +14,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/shell_integration.h"
-#include "chrome/browser/ui/gtk/first_run_dialog.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/common/result_codes.h"
@@ -46,12 +45,6 @@ bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) {
}
// static
-void FirstRun::ShowFirstRunDialog(Profile* profile,
- bool randomize_search_engine_experiment) {
- FirstRunDialog::Show(profile, randomize_search_engine_experiment);
-}
-
-// static
bool FirstRun::IsOrganicFirstRun() {
// We treat all installs as organic.
return true;
diff --git a/chrome/browser/first_run/first_run_mac.mm b/chrome/browser/first_run/first_run_mac.mm
index 14555bd..c866583 100644
--- a/chrome/browser/first_run/first_run_mac.mm
+++ b/chrome/browser/first_run/first_run_mac.mm
@@ -4,102 +4,7 @@
#include "chrome/browser/first_run/first_run.h"
-#import "base/memory/scoped_nsobject.h"
-#import "chrome/app/breakpad_mac.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/shell_integration.h"
-#import "chrome/browser/ui/cocoa/first_run_dialog.h"
-#import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/installer/util/google_update_constants.h"
-#include "chrome/installer/util/google_update_settings.h"
-
-#if defined(GOOGLE_CHROME_BUILD)
-#include "chrome/browser/browser_process.h"
-#endif
-
-namespace {
-
-// Show the search engine selection dialog.
-void ShowSearchEngineSelectionDialog(Profile* profile,
- bool randomize_search_engine_experiment) {
- scoped_nsobject<SearchEngineDialogController> dialog(
- [[SearchEngineDialogController alloc] init]);
- [dialog.get() setProfile:profile];
- [dialog.get() setRandomize:randomize_search_engine_experiment];
-
- [dialog.get() showWindow:nil];
-}
-
-// Show the first run UI.
-void ShowFirstRun(Profile* profile) {
-#if defined(GOOGLE_CHROME_BUILD)
- // The purpose of the dialog is to ask the user to enable stats and crash
- // reporting. This setting may be controlled through configuration management
- // in enterprise scenarios. If that is the case, skip the dialog entirely, as
- // it's not worth bothering the user for only the default browser question
- // (which is likely to be forced in enterprise deployments anyway).
- const PrefService::Preference* metrics_reporting_pref =
- g_browser_process->local_state()->FindPreference(
- prefs::kMetricsReportingEnabled);
- if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) {
- scoped_nsobject<FirstRunDialogController> dialog(
- [[FirstRunDialogController alloc] init]);
-
- [dialog.get() showWindow:nil];
-
- // If the dialog asked the user to opt-in for stats and crash reporting,
- // record the decision and enable the crash reporter if appropriate.
- bool stats_enabled = [dialog.get() statsEnabled];
- GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled);
-
- // Breakpad is normally enabled very early in the startup process. However,
- // on the first run it may not have been enabled due to the missing opt-in
- // from the user. If the user agreed now, enable breakpad if necessary.
- if (!IsCrashReporterEnabled() && stats_enabled) {
- InitCrashReporter();
- InitCrashProcessInfo();
- }
-
- // If selected set as default browser.
- BOOL make_default_browser = [dialog.get() makeDefaultBrowser];
- if (make_default_browser) {
- bool success = ShellIntegration::SetAsDefaultBrowser();
- DCHECK(success);
- }
- }
-#else // GOOGLE_CHROME_BUILD
- // We don't show the dialog in Chromium.
-#endif // GOOGLE_CHROME_BUILD
-
- FirstRun::CreateSentinel();
-
- // Set preference to show first run bubble and welcome page.
- // Don't display the minimal bubble if there is no default search provider.
- TemplateURLModel* search_engines_model = profile->GetTemplateURLModel();
- if (search_engines_model &&
- search_engines_model->GetDefaultSearchProvider()) {
- FirstRun::SetShowFirstRunBubblePref(true);
- }
- FirstRun::SetShowWelcomePagePref();
-}
-
-} // namespace
-
-// static
-void FirstRun::ShowFirstRunDialog(Profile* profile,
- bool randomize_search_engine_experiment) {
- // If the default search is not managed via policy, ask the user to
- // choose a default.
- TemplateURLModel* model = profile->GetTemplateURLModel();
- if (model && !model->is_default_search_managed()) {
- ShowSearchEngineSelectionDialog(profile,
- randomize_search_engine_experiment);
- }
- ShowFirstRun(profile);
-}
+#include "base/file_path.h"
bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) {
// http://crbug.com/48880
diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc
index 486d868..0e321dd 100644
--- a/chrome/browser/first_run/first_run_win.cc
+++ b/chrome/browser/first_run/first_run_win.cc
@@ -12,10 +12,10 @@
#include "base/environment.h"
#include "base/file_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
+#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "base/win/object_watcher.h"
#include "base/win/windows_version.h"
@@ -26,11 +26,7 @@
#include "chrome/browser/importer/importer_host.h"
#include "chrome/browser/importer/importer_list.h"
#include "chrome/browser/importer/importer_progress_dialog.h"
-#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/ui/views/first_run_search_engine_view.h"
-#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/worker_thread_ticker.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -46,11 +42,8 @@
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
-#include "views/focus/accelerator_handler.h"
-#include "views/window/window.h"
namespace {
@@ -255,8 +248,8 @@ std::string EncodeImportParams(int importer_type,
int options,
int skip_first_run_ui,
HWND window) {
- return StringPrintf("%d@%d@%d@%d", importer_type, options, skip_first_run_ui,
- window);
+ return base::StringPrintf(
+ "%d@%d@%d@%d", importer_type, options, skip_first_run_ui, window);
}
bool DecodeImportParams(const std::string& encoded,
@@ -302,28 +295,6 @@ bool FirstRun::IsOrganicFirstRun() {
}
// static
-void FirstRun::ShowFirstRunDialog(Profile* profile,
- bool randomize_search_engine_experiment) {
- // If the default search is managed via policy, we don't ask the user to
- // choose.
- TemplateURLModel* model = profile->GetTemplateURLModel();
- if (NULL == model || model->is_default_search_managed())
- return;
-
- views::Window* search_engine_dialog = views::Window::CreateChromeWindow(
- NULL,
- gfx::Rect(),
- new FirstRunSearchEngineView(profile,
- randomize_search_engine_experiment));
- DCHECK(search_engine_dialog);
-
- search_engine_dialog->Show();
- views::AcceleratorHandler accelerator_handler;
- MessageLoopForUI::current()->Run(&accelerator_handler);
- search_engine_dialog->CloseWindow();
-}
-
-// static
bool FirstRun::ImportSettings(Profile* profile,
int importer_type,
int items_to_import,