Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1457)

Unified Diff: chrome/browser/first_run/first_run_internal_win.cc

Issue 208393020: Fix the new First Run sentinel file path determination. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase; re-upload to kick CQ. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/first_run/first_run_internal_win.cc
diff --git a/chrome/browser/first_run/first_run_internal_win.cc b/chrome/browser/first_run/first_run_internal_win.cc
index 2225cc86624c52ee7e175a3c9d7a92a4cc88999f..494a01deb7f3eaf6b0782db036fb274d1e664d4e 100644
--- a/chrome/browser/first_run/first_run_internal_win.cc
+++ b/chrome/browser/first_run/first_run_internal_win.cc
@@ -145,21 +145,28 @@ void DoPostImportPlatformSpecificTasks(Profile* /* profile */) {
}
}
-bool GetFirstRunSentinelFilePath(base::FilePath* path) {
- return InstallUtil::GetSentinelFilePath(
- chrome::kFirstRunSentinel, BrowserDistribution::GetDistribution(), path);
-}
+bool IsFirstRunSentinelPresent() {
+ base::FilePath sentinel;
+ if (!GetFirstRunSentinelFilePath(&sentinel) || base::PathExists(sentinel))
+ return true;
-bool GetLegacyFirstRunSentinelFilePath(base::FilePath* path) {
- // The first run sentinel for user-level installs on Windows used to
- // be in the application directory.
+ // Copy any legacy first run sentinel file for Windows user-level installs
+ // from the application directory to the user data directory.
base::FilePath exe_path;
- if (!PathService::Get(base::DIR_EXE, &exe_path) ||
- !InstallUtil::IsPerUserInstall(exe_path.value().c_str())) {
- return false;
+ if (PathService::Get(base::DIR_EXE, &exe_path) &&
+ InstallUtil::IsPerUserInstall(exe_path.value().c_str())) {
+ base::FilePath legacy_sentinel = exe_path.Append(chrome::kFirstRunSentinel);
+ if (base::PathExists(legacy_sentinel)) {
+ // Copy the file instead of moving it to avoid breaking developer builds
+ // where the sentinel is dropped beside chrome.exe by a build action.
+ bool migrated = base::CopyFile(legacy_sentinel, sentinel);
+ DPCHECK(migrated);
+ // The sentinel is present regardless of whether or not it was migrated.
+ return true;
+ }
}
- *path = exe_path.Append(chrome::kFirstRunSentinel);
- return true;
+
+ return false;
}
bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) {

Powered by Google App Engine
This is Rietveld 408576698