OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/first_run/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 if (!base::LaunchProcess(setup_path, launch_options, &ph) || | 146 if (!base::LaunchProcess(setup_path, launch_options, &ph) || |
147 !::GetExitCodeProcess(ph, &exit_code)) { | 147 !::GetExitCodeProcess(ph, &exit_code)) { |
148 return false; | 148 return false; |
149 } | 149 } |
150 | 150 |
151 *ret_code = exit_code; | 151 *ret_code = exit_code; |
152 return true; | 152 return true; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
| 156 // Populates |path| with the path to |file| in the sentinel directory. This is |
| 157 // the application directory for user-level installs, and the default user data |
| 158 // dir for system-level installs. Returns false on error. |
| 159 bool GetSentinelFilePath(const wchar_t* file, FilePath* path) { |
| 160 FilePath exe_path; |
| 161 if (!PathService::Get(base::DIR_EXE, &exe_path)) |
| 162 return false; |
| 163 if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) |
| 164 *path = exe_path; |
| 165 else if (!PathService::Get(chrome::DIR_USER_DATA, path)) |
| 166 return false; |
| 167 *path = path->Append(file); |
| 168 return true; |
| 169 } |
| 170 |
156 bool GetEULASentinelFilePath(FilePath* path) { | 171 bool GetEULASentinelFilePath(FilePath* path) { |
157 return InstallUtil::GetSentinelFilePath( | 172 return GetSentinelFilePath(installer::kEULASentinelFile, path); |
158 installer::kEULASentinelFile, | |
159 BrowserDistribution::GetDistribution(), | |
160 path); | |
161 } | 173 } |
162 | 174 |
163 // Returns true if the EULA is required but has not been accepted by this user. | 175 // Returns true if the EULA is required but has not been accepted by this user. |
164 // The EULA is considered having been accepted if the user has gotten past | 176 // The EULA is considered having been accepted if the user has gotten past |
165 // first run in the "other" environment (desktop or metro). | 177 // first run in the "other" environment (desktop or metro). |
166 bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { | 178 bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { |
167 bool value = false; | 179 bool value = false; |
168 if (install_prefs->GetBool(installer::master_preferences::kRequireEula, | 180 if (install_prefs->GetBool(installer::master_preferences::kRequireEula, |
169 &value) && value) { | 181 &value) && value) { |
170 FilePath eula_sentinel; | 182 FilePath eula_sentinel; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 int items_to_import) { | 476 int items_to_import) { |
465 return ImportSettingsWin( | 477 return ImportSettingsWin( |
466 profile, | 478 profile, |
467 importer_list->GetSourceProfileAt(0).importer_type, | 479 importer_list->GetSourceProfileAt(0).importer_type, |
468 items_to_import, | 480 items_to_import, |
469 FilePath(), | 481 FilePath(), |
470 false); | 482 false); |
471 } | 483 } |
472 | 484 |
473 bool GetFirstRunSentinelFilePath(FilePath* path) { | 485 bool GetFirstRunSentinelFilePath(FilePath* path) { |
474 return InstallUtil::GetSentinelFilePath( | 486 return GetSentinelFilePath(chrome::kFirstRunSentinel, path); |
475 chrome::kFirstRunSentinel, | |
476 BrowserDistribution::GetDistribution(), | |
477 path); | |
478 } | 487 } |
479 | 488 |
480 void SetImportPreferencesAndLaunchImport( | 489 void SetImportPreferencesAndLaunchImport( |
481 MasterPrefs* out_prefs, | 490 MasterPrefs* out_prefs, |
482 installer::MasterPreferences* install_prefs) { | 491 installer::MasterPreferences* install_prefs) { |
483 std::string import_bookmarks_path; | 492 std::string import_bookmarks_path; |
484 install_prefs->GetString( | 493 install_prefs->GetString( |
485 installer::master_preferences::kDistroImportBookmarksFromFilePref, | 494 installer::master_preferences::kDistroImportBookmarksFromFilePref, |
486 &import_bookmarks_path); | 495 &import_bookmarks_path); |
487 | 496 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 return SKIP_FIRST_RUN; | 613 return SKIP_FIRST_RUN; |
605 | 614 |
606 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); | 615 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); |
607 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 616 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
608 internal::SetDefaultBrowser(install_prefs.get()); | 617 internal::SetDefaultBrowser(install_prefs.get()); |
609 | 618 |
610 return SKIP_FIRST_RUN; | 619 return SKIP_FIRST_RUN; |
611 } | 620 } |
612 | 621 |
613 } // namespace first_run | 622 } // namespace first_run |
OLD | NEW |