summaryrefslogtreecommitdiffstats
path: root/chrome/browser/first_run
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 19:58:08 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 19:58:08 +0000
commit4bca888c46607d4cb85e38b2cb1d553db3b984b2 (patch)
treeebac02602bfc18c0f720235dca314ea1d22461c6 /chrome/browser/first_run
parentff3d0c3a57b0be4f333bbbc5caeb95cd10f42f96 (diff)
downloadchromium_src-4bca888c46607d4cb85e38b2cb1d553db3b984b2.zip
chromium_src-4bca888c46607d4cb85e38b2cb1d553db3b984b2.tar.gz
chromium_src-4bca888c46607d4cb85e38b2cb1d553db3b984b2.tar.bz2
Reworked Avi's patch for master prefs implemented on mac (http://codereview.chromium.org/2903014/show), so that it will work with new first run sequence on Windows and Mac.
BUG=44901 TEST=in bug Review URL: http://codereview.chromium.org/3148001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/first_run')
-rw-r--r--chrome/browser/first_run/first_run.cc233
-rw-r--r--chrome/browser/first_run/first_run.h14
-rw-r--r--chrome/browser/first_run/first_run_gtk.cc89
-rw-r--r--chrome/browser/first_run/first_run_mac.mm11
-rw-r--r--chrome/browser/first_run/first_run_win.cc278
5 files changed, 298 insertions, 327 deletions
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index ddc4724..ba2011e 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -9,23 +9,42 @@
// TODO(port): move more code in back from the first_run_win.cc module.
#if defined(OS_WIN)
+#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h"
#endif
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/importer/importer.h"
#include "chrome/browser/pref_service.h"
+#include "chrome/browser/profile_manager.h"
+#include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "chrome/installer/util/master_preferences.h"
+#include "chrome/installer/util/util_constants.h"
namespace {
// The kSentinelFile file absence will tell us it is a first run.
const char kSentinelFile[] = "First Run";
+FilePath GetDefaultPrefFilePath(bool create_profile_dir,
+ const FilePath& user_data_dir) {
+ FilePath default_pref_dir =
+ ProfileManager::GetDefaultProfileDir(user_data_dir);
+ if (create_profile_dir) {
+ if (!file_util::PathExists(default_pref_dir)) {
+ if (!file_util::CreateDirectory(default_pref_dir))
+ return FilePath();
+ }
+ }
+ return ProfileManager::GetProfilePrefsPath(default_pref_dir);
+}
+
} // namespace
FirstRun::FirstRunState FirstRun::first_run_ = FIRST_RUN_UNKNOWN;
@@ -51,6 +70,220 @@ int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) {
}
// static
+bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
+ MasterPrefs* out_prefs) {
+ DCHECK(!user_data_dir.empty());
+
+ // The standard location of the master prefs is next to the chrome binary.
+ FilePath master_prefs;
+ if (!PathService::Get(base::DIR_EXE, &master_prefs))
+ return true;
+ master_prefs = master_prefs.AppendASCII(installer_util::kDefaultMasterPrefs);
+
+ scoped_ptr<DictionaryValue> prefs(
+ installer_util::ParseDistributionPreferences(master_prefs));
+ if (!prefs.get())
+ return true;
+
+ out_prefs->new_tabs = installer_util::GetFirstRunTabs(prefs.get());
+
+ 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 (!installer_util::GetDistroIntegerPreference(prefs.get(),
+ installer_util::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 (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::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_util::switches::kShowEula,
+ inner_html.ToWStringHack(), &retcode) ||
+ (retcode == installer_util::EULA_REJECTED)) {
+ LOG(WARNING) << "EULA rejected. Fast exit.";
+ ::ExitProcess(1);
+ }
+ if (retcode == installer_util::EULA_ACCEPTED) {
+ LOG(INFO) << "EULA : no collection";
+ GoogleUpdateSettings::SetCollectStatsConsent(false);
+ } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
+ LOG(INFO) << "EULA : collection consent";
+ GoogleUpdateSettings::SetCollectStatsConsent(true);
+ }
+ }
+ }
+#endif
+
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kAltFirstRunBubble, &value) && value)
+ FirstRun::SetOEMFirstRunBubblePref();
+
+ FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
+ if (user_prefs.empty())
+ return true;
+
+ // The master prefs are regular prefs so we can just copy the file
+ // to the default place and they just work.
+ if (!file_util::CopyFile(master_prefs, user_prefs))
+ return true;
+
+#if defined(OS_WIN)
+ DictionaryValue* extensions = 0;
+ if (installer_util::HasExtensionsBlock(prefs.get(), &extensions)) {
+ LOG(INFO) << "Extensions block found in master preferences";
+ DoDelayedInstallExtensions();
+ }
+#endif
+
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportSearchPref, &value)) {
+ if (value) {
+ out_prefs->do_import_items |= importer::SEARCH_ENGINES;
+ } else {
+ out_prefs->dont_import_items |= importer::SEARCH_ENGINES;
+ }
+ }
+
+ // Check to see if search engine logos should be randomized.
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kSearchEngineExperimentRandomizePref,
+ &value) && value)
+ out_prefs->randomize_search_engine_experiment = true;
+
+ // If we're suppressing the first-run bubble, set that preference now.
+ // Otherwise, wait until the user has completed first run to set it, so the
+ // user is guaranteed to see the bubble iff he or she has completed the first
+ // run process.
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroSuppressFirstRunBubble,
+ &value) && value)
+ FirstRun::SetShowFirstRunBubblePref(false);
+
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportHistoryPref, &value)) {
+ if (value) {
+ out_prefs->do_import_items |= importer::HISTORY;
+ } else {
+ out_prefs->dont_import_items |= importer::HISTORY;
+ }
+ }
+
+ std::string not_used;
+ out_prefs->homepage_defined = prefs->GetString(prefs::kHomePage, &not_used);
+
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportHomePagePref, &value)) {
+ if (value) {
+ out_prefs->do_import_items |= importer::HOME_PAGE;
+ } else {
+ out_prefs->dont_import_items |= importer::HOME_PAGE;
+ }
+ }
+
+ // Bookmarks are never imported unless specifically turned on.
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportBookmarksPref, &value)
+ && value) {
+ out_prefs->do_import_items |= importer::FAVORITES;
+ }
+
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kMakeChromeDefaultForUser, &value) &&
+ value)
+ ShellIntegration::SetAsDefaultBrowser();
+
+ // TODO(mirandac): Refactor skip-first-run-ui process into regular first run
+ // import process. http://crbug.com/49647
+ // Note we are skipping all other master preferences if skip-first-run-ui
+ // is *not* specified. (That is, we continue only if skipping first run ui.)
+ if (!installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroSkipFirstRunPref, &value) ||
+ !value)
+ return true;
+
+#if !defined(OS_WIN)
+ // From here on we won't show first run so we need to do the work to show the
+ // bubble anyway, unless it's already been explicitly suppressed.
+ FirstRun::SetShowFirstRunBubblePref(true);
+#endif
+
+ // We need to be able to create the first run sentinel or else we cannot
+ // proceed because ImportSettings will launch the importer process which
+ // would end up here if the sentinel is not present.
+ if (!FirstRun::CreateSentinel())
+ return false;
+
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroShowWelcomePage, &value) &&
+ value)
+ FirstRun::SetShowWelcomePagePref();
+
+ std::string import_bookmarks_path;
+ installer_util::GetDistroStringPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportBookmarksFromFilePref,
+ &import_bookmarks_path);
+
+#if defined(OS_WIN)
+ std::wstring brand;
+ GoogleUpdateSettings::GetBrand(&brand);
+ // This should generally be true, as skip_first_run_ui is a setting used for
+ // non-organic builds.
+ if (!GoogleUpdateSettings::IsOrganic(brand)) {
+ // If search engines aren't explicitly imported, don't import.
+ if (!(out_prefs->do_import_items & importer::SEARCH_ENGINES)) {
+ out_prefs->dont_import_items |= importer::SEARCH_ENGINES;
+ }
+ // If home page isn't explicitly imported, don't import.
+ if (!(out_prefs->do_import_items & importer::HOME_PAGE)) {
+ out_prefs->dont_import_items |= importer::HOME_PAGE;
+ }
+ // If history isn't explicitly forbidden, do import.
+ if (!(out_prefs->dont_import_items & importer::HISTORY)) {
+ out_prefs->do_import_items |= importer::HISTORY;
+ }
+ }
+
+ if (out_prefs->do_import_items || !import_bookmarks_path.empty()) {
+ // There is something to import from the default browser. This launches
+ // the importer process and blocks until done or until it fails.
+ scoped_refptr<ImporterHost> importer_host = new ImporterHost();
+ if (!FirstRun::ImportSettings(NULL,
+ importer_host->GetSourceProfileInfoAt(0).browser_type,
+ out_prefs->do_import_items,
+ FilePath::FromWStringHack(UTF8ToWide(import_bookmarks_path)),
+ true, NULL)) {
+ LOG(WARNING) << "silent import failed";
+ }
+ }
+#else
+ if (!import_bookmarks_path.empty()) {
+ // There are bookmarks to import from a file.
+ FilePath path = FilePath::FromWStringHack(UTF8ToWide(
+ import_bookmarks_path));
+ if (!FirstRun::ImportBookmarks(path)) {
+ LOG(WARNING) << "silent bookmark import failed";
+ }
+ }
+#endif
+
+ return false;
+}
+
+// static
bool FirstRun::IsChromeFirstRun() {
if (first_run_ != FIRST_RUN_UNKNOWN)
return first_run_ == FIRST_RUN_TRUE;
diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h
index 9289176..05fd070 100644
--- a/chrome/browser/first_run/first_run.h
+++ b/chrome/browser/first_run/first_run.h
@@ -131,6 +131,18 @@ class FirstRun {
FRIEND_TEST_ALL_PREFIXES(Toolbar5ImporterTest, BookmarkParse);
#if defined(OS_WIN)
+ // Writes the EULA to a temporary file, returned in |*eula_path|, and returns
+ // true if successful.
+ static bool WriteEULAtoTempFile(FilePath* eula_path);
+ // Launches the setup exe with the given parameter/value on the command-line,
+ // waits for its termination, returns its exit code in |*ret_code|, and
+ // returns true if the exit code is valid.
+ static bool LaunchSetupWithParam(const std::string& param,
+ const std::wstring& value,
+ int* ret_code);
+ // Installs a task to do an extensions update check once the extensions system
+ // is running.
+ static void DoDelayedInstallExtensions();
// Imports settings in a separate process. It is the implementation of the
// public version. |skip_first_run_ui| is true if no first run UI should
// appear (search engine dialog, Firefox import warning dialog).
@@ -142,7 +154,7 @@ class FirstRun {
// Import browser items in this process. The browser and the items to
// import are encoded int the command line.
static int ImportFromBrowser(Profile* profile, const CommandLine& cmdline);
-#elif defined(OS_LINUX)
+#else
static bool ImportBookmarks(const FilePath& import_bookmarks_path);
#endif
diff --git a/chrome/browser/first_run/first_run_gtk.cc b/chrome/browser/first_run/first_run_gtk.cc
index 0f6e7db..b4044ce7 100644
--- a/chrome/browser/first_run/first_run_gtk.cc
+++ b/chrome/browser/first_run/first_run_gtk.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/first_run/first_run.h"
#include "app/app_switches.h"
+#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -14,14 +15,11 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/gtk/first_run_dialog.h"
-#include "chrome/browser/profile_manager.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/result_codes.h"
#include "chrome/installer/util/google_update_settings.h"
-#include "chrome/installer/util/master_preferences.h"
-#include "chrome/installer/util/util_constants.h"
#include "googleurl/src/gurl.h"
// TODO(estade): pay attention to the args between |profile| and
@@ -36,91 +34,6 @@ bool OpenFirstRunDialog(Profile* profile,
return FirstRunDialog::Show(profile, process_singleton);
}
-FilePath GetDefaultPrefFilePath(bool create_profile_dir,
- const FilePath& user_data_dir) {
- FilePath default_pref_dir =
- ProfileManager::GetDefaultProfileDir(user_data_dir);
- if (create_profile_dir) {
- if (!file_util::PathExists(default_pref_dir)) {
- if (!file_util::CreateDirectory(default_pref_dir))
- return FilePath();
- }
- }
- return ProfileManager::GetProfilePrefsPath(default_pref_dir);
-}
-
-bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
- MasterPrefs* out_prefs) {
- DCHECK(!user_data_dir.empty());
-
- // The standard location of the master prefs is next to the chrome binary.
- FilePath master_prefs;
- if (!PathService::Get(base::DIR_EXE, &master_prefs))
- return true;
- master_prefs = master_prefs.AppendASCII(installer_util::kDefaultMasterPrefs);
-
- scoped_ptr<DictionaryValue> prefs(
- installer_util::ParseDistributionPreferences(master_prefs));
- if (!prefs.get())
- return true;
-
- out_prefs->new_tabs = installer_util::GetFirstRunTabs(prefs.get());
-
- std::string not_used;
- out_prefs->homepage_defined = prefs->GetString(prefs::kHomePage, &not_used);
-
- bool value = false;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltFirstRunBubble, &value) && value)
- FirstRun::SetOEMFirstRunBubblePref();
-
- FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
- if (user_prefs.empty())
- return true;
-
- // The master prefs are regular prefs so we can just copy the file
- // to the default place and they just work.
- if (!file_util::CopyFile(master_prefs, user_prefs))
- return true;
-
- // Note we are skipping all other master preferences if skip-first-run-ui
- // is *not* specified.
- if (!installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref, &value) ||
- !value)
- return true;
-
- // From here on we won't show first run so we need to do the work to set the
- // required state given that FirstRunView is not going to be called.
- FirstRun::SetShowFirstRunBubblePref(true);
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage, &value) &&
- value)
- FirstRun::SetShowWelcomePagePref();
-
- // We need to be able to create the first run sentinel or else we cannot
- // proceed because ImportSettings will launch the importer process which
- // would end up here if the sentinel is not present.
- if (!FirstRun::CreateSentinel())
- return false;
-
- std::string import_bookmarks_path;
- installer_util::GetDistroStringPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksFromFilePref,
- &import_bookmarks_path);
-
- if (!import_bookmarks_path.empty()) {
- // There are bookmarks to import from a file.
- FilePath path = FilePath::FromWStringHack(
- UTF8ToWide(import_bookmarks_path));
- if (!FirstRun::ImportBookmarks(path)) {
- LOG(WARNING) << "silent bookmark import failed";
- }
- }
- return false;
-}
-
// TODO(port): This is just a piece of the silent import functionality from
// ImportSettings for Windows. It would be nice to get the rest of it ported.
bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) {
diff --git a/chrome/browser/first_run/first_run_mac.mm b/chrome/browser/first_run/first_run_mac.mm
index 725784c..e982903 100644
--- a/chrome/browser/first_run/first_run_mac.mm
+++ b/chrome/browser/first_run/first_run_mac.mm
@@ -57,13 +57,6 @@ bool OpenFirstRunDialog(Profile* profile,
return controller->DoFirstRun(profile, process_singleton);
}
-bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
- MasterPrefs* out_prefs) {
- // TODO(jeremy,viettrungluu): http://crbug.com/44901
- NOTIMPLEMENTED();
- return true;
-}
-
FirstRunController::FirstRunController()
: importer_host_(new ExternalProcessImporterHost) {
}
@@ -156,3 +149,7 @@ bool FirstRunController::DoFirstRun(Profile* profile,
return true;
}
+bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) {
+ // http://crbug.com/48880
+ return false;
+}
diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc
index cd12032..fd21d32 100644
--- a/chrome/browser/first_run/first_run_win.cc
+++ b/chrome/browser/first_run/first_run_win.cc
@@ -11,65 +11,44 @@
#include <set>
#include <sstream>
-// TODO(port): trim this include list once first run has been refactored fully.
#include "app/app_switches.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "base/command_line.h"
#include "base/environment.h"
#include "base/file_util.h"
-#include "base/logging.h"
#include "base/object_watcher.h"
#include "base/path_service.h"
-#include "base/process.h"
-#include "base/process_util.h"
#include "base/registry.h"
#include "base/scoped_comptr_win.h"
#include "base/scoped_ptr.h"
#include "base/string_number_conversions.h"
-#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/win_util.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/extension_updater.h"
-#include "chrome/browser/hang_monitor/hung_window_detector.h"
#include "chrome/browser/importer/importer.h"
-#include "chrome/browser/importer/importer_data_types.h"
#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/pref_service.h"
#include "chrome/browser/process_singleton.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/profile_manager.h"
-#include "chrome/browser/shell_integration.h"
#include "chrome/browser/views/first_run_search_engine_view.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/result_codes.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/worker_thread_ticker.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h"
-#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
#include "google_update_idl.h"
-#include "grit/app_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
-#include "views/background.h"
#include "views/controls/button/image_button.h"
-#include "views/controls/button/native_button.h"
#include "views/controls/button/radio_button.h"
#include "views/controls/image_view.h"
-#include "views/controls/label.h"
#include "views/controls/link.h"
#include "views/focus/accelerator_handler.h"
#include "views/grid_layout.h"
@@ -77,8 +56,6 @@
#include "views/widget/root_view.h"
#include "views/widget/widget_win.h"
#include "views/window/window.h"
-#include "views/window/window_delegate.h"
-#include "views/window/window_win.h"
namespace {
@@ -96,19 +73,6 @@ bool GetBackupChromeFile(std::wstring* path) {
return true;
}
-FilePath GetDefaultPrefFilePath(bool create_profile_dir,
- const FilePath& user_data_dir) {
- FilePath default_pref_dir =
- ProfileManager::GetDefaultProfileDir(user_data_dir);
- if (create_profile_dir) {
- if (!file_util::PathExists(default_pref_dir)) {
- if (!file_util::CreateDirectory(default_pref_dir))
- return FilePath();
- }
- }
- return ProfileManager::GetProfilePrefsPath(default_pref_dir);
-}
-
bool InvokeGoogleUpdateForRename() {
ScopedComPtr<IProcessLauncher> ipl;
if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) {
@@ -213,6 +177,48 @@ class FirstRunDelayedTasks : public NotificationObserver {
} // namespace
+bool FirstRun::LaunchSetupWithParam(const std::string& param,
+ const std::wstring& value,
+ int* ret_code) {
+ FilePath exe_path;
+ if (!PathService::Get(base::DIR_MODULE, &exe_path))
+ return false;
+ exe_path = exe_path.Append(installer_util::kInstallerDir);
+ exe_path = exe_path.Append(installer_util::kSetupExe);
+ base::ProcessHandle ph;
+ CommandLine cl(exe_path);
+ cl.AppendSwitchNative(param, value);
+
+ CommandLine* browser_command_line = CommandLine::ForCurrentProcess();
+ if (browser_command_line->HasSwitch(switches::kChromeFrame)) {
+ cl.AppendSwitch(switches::kChromeFrame);
+ }
+
+ if (!base::LaunchApp(cl, false, false, &ph))
+ return false;
+ DWORD wr = ::WaitForSingleObject(ph, INFINITE);
+ if (wr != WAIT_OBJECT_0)
+ return false;
+ return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code)));
+}
+
+bool FirstRun::WriteEULAtoTempFile(FilePath* eula_path) {
+ base::StringPiece terms =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_TERMS_HTML);
+ if (terms.empty())
+ return false;
+ FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path);
+ if (!file)
+ return false;
+ bool good = fwrite(terms.data(), terms.size(), 1, file) == 1;
+ fclose(file);
+ return good;
+}
+
+void FirstRun::DoDelayedInstallExtensions() {
+ new FirstRunDelayedTasks(FirstRunDelayedTasks::INSTALL_EXTENSIONS);
+}
+
CommandLine* Upgrade::new_command_line_ = NULL;
bool FirstRun::CreateChromeDesktopShortcut() {
@@ -236,196 +242,6 @@ bool FirstRun::CreateChromeQuickLaunchShortcut() {
true); // create if doesn't exist.
}
-bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
- MasterPrefs* out_prefs) {
- DCHECK(!user_data_dir.empty());
-
- // The standard location of the master prefs is next to the chrome exe.
- FilePath master_prefs;
- if (!PathService::Get(base::DIR_EXE, &master_prefs))
- return true;
- master_prefs = master_prefs.AppendASCII(installer_util::kDefaultMasterPrefs);
-
- scoped_ptr<DictionaryValue> prefs(
- installer_util::ParseDistributionPreferences(master_prefs));
- if (!prefs.get())
- return true;
-
- out_prefs->new_tabs = installer_util::GetFirstRunTabs(prefs.get());
-
- if (!installer_util::GetDistroIntegerPreference(prefs.get(),
- installer_util::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;
- }
-
- std::string not_used;
- out_prefs->homepage_defined = prefs->GetString(prefs::kHomePage, &not_used);
-
- bool value = false;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::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_util::switches::kShowEula,
- inner_html.ToWStringHack(), &retcode) ||
- (retcode == installer_util::EULA_REJECTED)) {
- LOG(WARNING) << "EULA rejected. Fast exit.";
- ::ExitProcess(1);
- }
- if (retcode == installer_util::EULA_ACCEPTED) {
- LOG(INFO) << "EULA : no collection";
- GoogleUpdateSettings::SetCollectStatsConsent(false);
- } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
- LOG(INFO) << "EULA : collection consent";
- GoogleUpdateSettings::SetCollectStatsConsent(true);
- }
- }
- }
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltFirstRunBubble, &value) && value)
- FirstRun::SetOEMFirstRunBubblePref();
-
- FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
- if (user_prefs.empty())
- return true;
-
- // The master prefs are regular prefs so we can just copy the file
- // to the default place and they just work.
- if (!file_util::CopyFile(master_prefs, user_prefs))
- return true;
-
- DictionaryValue* extensions = 0;
- if (installer_util::HasExtensionsBlock(prefs.get(), &extensions)) {
- LOG(INFO) << "Extensions block found in master preferences";
- new FirstRunDelayedTasks(FirstRunDelayedTasks::INSTALL_EXTENSIONS);
- }
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportSearchPref, &value)) {
- if (value) {
- out_prefs->do_import_items |= importer::SEARCH_ENGINES;
- } else {
- out_prefs->dont_import_items |= importer::SEARCH_ENGINES;
- }
- }
-
- // Check to see if search engine logos should be randomized.
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSearchEngineExperimentRandomizePref,
- &value) && value)
- out_prefs->randomize_search_engine_experiment = true;
-
- // If we're suppressing the first-run bubble, set that preference now.
- // Otherwise, wait until the user has completed first run to set it, so the
- // user is guaranteed to see the bubble iff he or she has completed the first
- // run process.
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSuppressFirstRunBubble,
- &value) && value)
- FirstRun::SetShowFirstRunBubblePref(false);
-
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHistoryPref, &value)) {
- if (value) {
- out_prefs->do_import_items |= importer::HISTORY;
- } else {
- out_prefs->dont_import_items |= importer::HISTORY;
- }
- }
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHomePagePref, &value)) {
- if (value) {
- out_prefs->do_import_items |= importer::HOME_PAGE;
- } else {
- out_prefs->dont_import_items |= importer::HOME_PAGE;
- }
- }
-
- // Bookmarks are never imported unless specifically turned on.
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksPref, &value)
- && value) {
- out_prefs->do_import_items |= importer::FAVORITES;
- }
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefaultForUser, &value) &&
- value)
- ShellIntegration::SetAsDefaultBrowser();
-
- // TODO(mirandac): Refactor skip-first-run-ui process into regular first run
- // import process. http://crbug.com/49647
- // Note we are skipping all other master preferences if skip-first-run-ui
- // is *not* specified. (That is, we continue only if skipping first run ui.)
- if (!installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref, &value) ||
- !value)
- return true;
-
- // We need to be able to create the first run sentinel or else we cannot
- // proceed because ImportSettings will launch the importer process which
- // would end up here if the sentinel is not present.
- if (!FirstRun::CreateSentinel())
- return false;
-
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage, &value) &&
- value)
- FirstRun::SetShowWelcomePagePref();
-
- std::string import_bookmarks_path;
- installer_util::GetDistroStringPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksFromFilePref,
- &import_bookmarks_path);
-
- std::wstring brand;
- GoogleUpdateSettings::GetBrand(&brand);
- // This should generally be true, as skip_first_run_ui is a setting used for
- // non-organic builds.
- if (!GoogleUpdateSettings::IsOrganic(brand)) {
- // If search engines aren't explicitly imported, don't import.
- if (!(out_prefs->do_import_items & importer::SEARCH_ENGINES)) {
- out_prefs->dont_import_items |= importer::SEARCH_ENGINES;
- }
- // If home page isn't explicitly imported, don't import.
- if (!(out_prefs->do_import_items & importer::HOME_PAGE)) {
- out_prefs->dont_import_items |= importer::HOME_PAGE;
- }
- // If history isn't explicitly forbidden, do import.
- if (!(out_prefs->dont_import_items & importer::HISTORY)) {
- out_prefs->do_import_items |= importer::HISTORY;
- }
- }
-
- if (out_prefs->do_import_items || !import_bookmarks_path.empty()) {
- // There is something to import from the default browser. This launches
- // the importer process and blocks until done or until it fails.
- scoped_refptr<ImporterHost> importer_host = new ImporterHost();
- if (!FirstRun::ImportSettings(NULL,
- importer_host->GetSourceProfileInfoAt(0).browser_type,
- out_prefs->do_import_items,
- FilePath::FromWStringHack(UTF8ToWide(import_bookmarks_path)),
- true, NULL)) {
- LOG(WARNING) << "silent import failed";
- }
- }
-
- return false;
-}
-
bool Upgrade::IsBrowserAlreadyRunning() {
static HANDLE handle = NULL;
std::wstring exe;
@@ -846,7 +662,7 @@ const wchar_t kHelpCenterUrl[] =
// | [o] Give the new version a try |
// | [ ] Uninstall Google Chrome |
// | [ OK ] [Don't bug me] |
-// | _why_am_I_seeign this?__ |
+// | _why_am_I_seeing this?__ |
// ------------------------------------------
class TryChromeDialog : public views::ButtonListener,
public views::LinkController {