summaryrefslogtreecommitdiffstats
path: root/chrome/browser/first_run
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 20:20:29 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 20:20:29 +0000
commite9d14e7c99f19756cdb91b78bdaa2d001ecf550e (patch)
treeea03775a791fba3f273f3ef87ed803ab85074ea6 /chrome/browser/first_run
parentcb802bc8b1fd1dbf51e6b2262c11c0f2a50635ac (diff)
downloadchromium_src-e9d14e7c99f19756cdb91b78bdaa2d001ecf550e.zip
chromium_src-e9d14e7c99f19756cdb91b78bdaa2d001ecf550e.tar.gz
chromium_src-e9d14e7c99f19756cdb91b78bdaa2d001ecf550e.tar.bz2
Progressively refactor FirstRun to first_run(part 6).
BUG=108137 TEST=NONE Review URL: http://codereview.chromium.org/9317016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/first_run')
-rw-r--r--chrome/browser/first_run/first_run.cc150
-rw-r--r--chrome/browser/first_run/first_run.h14
-rw-r--r--chrome/browser/first_run/first_run_internal.h15
3 files changed, 117 insertions, 62 deletions
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index 0da49ea..2373c05 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -233,6 +233,35 @@ void SetupMasterPrefsFromInstallPrefs(
}
}
+void SetDefaultBrowser(installer::MasterPreferences* install_prefs){
+ // Even on the first run we only allow for the user choice to take effect if
+ // no policy has been set by the admin.
+ if (!g_browser_process->local_state()->IsManagedPreference(
+ prefs::kDefaultBrowserSettingEnabled)) {
+ bool value = false;
+ if (install_prefs->GetBool(
+ installer::master_preferences::kMakeChromeDefaultForUser,
+ &value) && value) {
+ ShellIntegration::SetAsDefaultBrowser();
+ }
+ } else {
+ if (g_browser_process->local_state()->GetBoolean(
+ prefs::kDefaultBrowserSettingEnabled)) {
+ ShellIntegration::SetAsDefaultBrowser();
+ }
+ }
+}
+
+void SetShowWelcomePagePrefIfNeeded(
+ installer::MasterPreferences* install_prefs) {
+ bool value = false;
+ if (install_prefs->GetBool(
+ installer::master_preferences::kDistroShowWelcomePage, &value)
+ && value) {
+ SetShowWelcomePagePref();
+ }
+}
+
// -- Platform-specific functions --
#if !defined(OS_LINUX) && !defined(OS_BSD)
@@ -346,6 +375,21 @@ int ImportBookmarkFromFileIfNeeded(Profile* profile,
return return_code;
}
+// TODO(jennyz): move this fucntion to first_run_win.cc for further refactoring.
+#if defined(OS_WIN)
+void SetRLZPref(first_run::MasterPrefs* out_prefs,
+ installer::MasterPreferences* install_prefs) {
+ // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/
+ // Linux, enable it here.
+ if (!install_prefs->GetInt(installer::master_preferences::kDistroPingDelay,
+ &out_prefs->ping_delay)) {
+ // 90 seconds is the default that we want to use in case master
+ // preferences is missing, corrupt or ping_delay is missing.
+ out_prefs->ping_delay = 90;
+ }
+}
+#endif
+
} // namespace internal
} // namespace first_run
@@ -443,53 +487,15 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
bool value = false;
#if defined(OS_WIN)
- // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/
- // Linux, enable it here.
- if (!install_prefs->GetInt(installer::master_preferences::kDistroPingDelay,
- &out_prefs->ping_delay)) {
- // 90 seconds is the default that we want to use in case master
- // preferences is missing, corrupt or ping_delay is missing.
- out_prefs->ping_delay = 90;
- }
-
- if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
- &value) && value) {
- // Show the post-installation EULA. This is done by setup.exe and the
- // result determines if we continue or not. We wait here until the user
- // dismisses the dialog.
-
- // The actual eula text is in a resource in chrome. We extract it to
- // a text file so setup.exe can use it as an inner frame.
- FilePath inner_html;
- if (WriteEULAtoTempFile(&inner_html)) {
- int retcode = 0;
- if (!LaunchSetupWithParam(installer::switches::kShowEula,
- inner_html.value(), &retcode) ||
- (retcode != installer::EULA_ACCEPTED &&
- retcode != installer::EULA_ACCEPTED_OPT_IN)) {
- LOG(WARNING) << "EULA rejected. Fast exit.";
- ::ExitProcess(1);
- }
- if (retcode == installer::EULA_ACCEPTED) {
- VLOG(1) << "EULA : no collection";
- GoogleUpdateSettings::SetCollectStatsConsent(false);
- } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) {
- VLOG(1) << "EULA : collection consent";
- GoogleUpdateSettings::SetCollectStatsConsent(true);
- }
- }
- }
+ first_run::internal::SetRLZPref(out_prefs, install_prefs.get());
+ ShowPostInstallEULAIfNeeded(install_prefs.get());
#endif
if (!first_run::internal::CopyPrefFile(user_data_dir, master_prefs_path))
return true;
#if defined(OS_WIN)
- DictionaryValue* extensions = 0;
- if (install_prefs->GetExtensionsBlock(&extensions)) {
- VLOG(1) << "Extensions block found in master preferences";
- DoDelayedInstallExtensions();
- }
+ DoDelayedInstallExtensionsIfNeeded(install_prefs.get());
#endif
first_run::internal::SetupMasterPrefsFromInstallPrefs(out_prefs,
@@ -517,11 +523,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
if (!first_run::CreateSentinel())
return false;
- if (install_prefs->GetBool(
- installer::master_preferences::kDistroShowWelcomePage, &value)
- && value) {
- first_run::SetShowWelcomePagePref();
- }
+ first_run::internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get());
std::string import_bookmarks_path;
install_prefs->GetString(
@@ -570,21 +572,49 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
}
#endif
- // Even on the first run we only allow for the user choice to take effect if
- // no policy has been set by the admin.
- if (!g_browser_process->local_state()->IsManagedPreference(
- prefs::kDefaultBrowserSettingEnabled)) {
- if (install_prefs->GetBool(
- installer::master_preferences::kMakeChromeDefaultForUser,
- &value) && value) {
- ShellIntegration::SetAsDefaultBrowser();
- }
- } else {
- if (g_browser_process->local_state()->GetBoolean(
- prefs::kDefaultBrowserSettingEnabled)) {
- ShellIntegration::SetAsDefaultBrowser();
+ first_run::internal::SetDefaultBrowser(install_prefs.get());
+ return false;
+}
+
+#if defined(OS_WIN)
+void FirstRun::ShowPostInstallEULAIfNeeded(
+ installer::MasterPreferences* install_prefs) {
+ bool value = false;
+ if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
+ &value) && value) {
+ // Show the post-installation EULA. This is done by setup.exe and the
+ // result determines if we continue or not. We wait here until the user
+ // dismisses the dialog.
+
+ // The actual eula text is in a resource in chrome. We extract it to
+ // a text file so setup.exe can use it as an inner frame.
+ FilePath inner_html;
+ if (WriteEULAtoTempFile(&inner_html)) {
+ int retcode = 0;
+ if (!LaunchSetupWithParam(installer::switches::kShowEula,
+ inner_html.value(), &retcode) ||
+ (retcode != installer::EULA_ACCEPTED &&
+ retcode != installer::EULA_ACCEPTED_OPT_IN)) {
+ LOG(WARNING) << "EULA rejected. Fast exit.";
+ ::ExitProcess(1);
+ }
+ if (retcode == installer::EULA_ACCEPTED) {
+ VLOG(1) << "EULA : no collection";
+ GoogleUpdateSettings::SetCollectStatsConsent(false);
+ } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) {
+ VLOG(1) << "EULA : collection consent";
+ GoogleUpdateSettings::SetCollectStatsConsent(true);
+ }
}
}
+}
- return false;
+void FirstRun::DoDelayedInstallExtensionsIfNeeded(
+ installer::MasterPreferences* install_prefs) {
+ DictionaryValue* extensions = 0;
+ if (install_prefs->GetExtensionsBlock(&extensions)) {
+ VLOG(1) << "Extensions block found in master preferences";
+ FirstRun::DoDelayedInstallExtensions();
+ }
}
+#endif
diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h
index e9d6ea4..8709bf4 100644
--- a/chrome/browser/first_run/first_run.h
+++ b/chrome/browser/first_run/first_run.h
@@ -23,6 +23,10 @@ class Profile;
class ProcessSingleton;
class TemplateURLService;
+namespace installer {
+class MasterPreferences;
+}
+
// TODO(jennyz): All FirstRun class code will be refactored to first_run
// namespace progressively with several changelists to be landed. Therefore,
// we keep first_run namespace and FirstRun in the same file temporarily.
@@ -136,6 +140,9 @@ class FirstRun {
// -- Platform-specific functions --
#if defined(OS_WIN)
+ // TODO(jennyz): Move the following functions to anonymous namespace of
+ // first_run_win.cc in the future refactoring.
+
// Writes the EULA to a temporary file, returned in |*eula_path|, and returns
// true if successful.
static bool WriteEULAtoTempFile(FilePath* eula_path);
@@ -151,6 +158,13 @@ class FirstRun {
// is running.
static void DoDelayedInstallExtensions();
+ // Shows post installation EULA if needed.
+ static void ShowPostInstallEULAIfNeeded(
+ installer::MasterPreferences* install_prefs);
+
+ static void DoDelayedInstallExtensionsIfNeeded(
+ installer::MasterPreferences* install_prefs);
+
#endif
// This class is for scoping purposes.
diff --git a/chrome/browser/first_run/first_run_internal.h b/chrome/browser/first_run/first_run_internal.h
index b5c2934..869c769 100644
--- a/chrome/browser/first_run/first_run_internal.h
+++ b/chrome/browser/first_run/first_run_internal.h
@@ -58,6 +58,11 @@ void SetupMasterPrefsFromInstallPrefs(
MasterPrefs* out_prefs,
installer::MasterPreferences* install_prefs);
+void SetShowWelcomePagePrefIfNeeded(
+ installer::MasterPreferences* install_prefs);
+
+void SetDefaultBrowser(installer::MasterPreferences* install_prefs);
+
// -- Platform-specific functions --
// Gives the full path to the sentinel file. The file might not exist.
@@ -80,13 +85,19 @@ bool ImportSettings(Profile* profile,
int items_to_import);
#if defined(OS_WIN)
-// TODO(jennyz): This fuction will be moved to first_run_win.cc anonymous
-// namespace once we refactor its calling code in first_run.cc later.
+// TODO(jennyz): The following functions will be moved to first_run_win.cc
+// anonymous namespace once we move ProcessMasterPreferences() to first_run
+// namespace.
+
bool ImportSettingsWin(Profile* profile,
int importer_type,
int items_to_import,
const FilePath& import_bookmarks_path,
bool skip_first_run_ui);
+
+// Sets RLZ preference.
+void SetRLZPref(first_run::MasterPrefs* out_prefs,
+ installer::MasterPreferences* install_prefs);
#endif // OS_WIN
#if !defined(USE_AURA)