OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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.h" | 5 #include "chrome/browser/first_run.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 // TODO(port): move more code in back from the first_run_win.cc module. | 9 // TODO(port): move more code in back from the first_run_win.cc module. |
10 | 10 |
11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
12 #include "chrome/installer/util/install_util.h" | 12 #include "chrome/installer/util/install_util.h" |
13 #endif | 13 #endif |
14 | 14 |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // The kSentinelFile file absence will tell us it is a first run. | 21 // The kSentinelFile file absence will tell us it is a first run. |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 const char kSentinelFile[] = "First Run"; | 23 const char kSentinelFile[] = "First Run"; |
24 #else | 24 #else |
25 // On other platforms de intentionally use a different file name, so | 25 // On other platforms de intentionally use a different file name, so |
26 // when the remainder of this file is implemented, we can switch to | 26 // when the remainder of this file is implemented, we can switch to |
27 // the proper file name and users will get the first run interface again. | 27 // the proper file name and users will get the first run interface again. |
28 const char kSentinelFile[] = "First Run Alpha"; | 28 const char kSentinelFile[] = "First Run Dev"; |
29 #endif | 29 #endif |
30 | 30 |
31 // Gives the full path to the sentinel file. The file might not exist. | 31 // Gives the full path to the sentinel file. The file might not exist. |
32 bool GetFirstRunSentinelFilePath(FilePath* path) { | 32 bool GetFirstRunSentinelFilePath(FilePath* path) { |
33 FilePath first_run_sentinel; | 33 FilePath first_run_sentinel; |
34 | 34 |
35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
36 FilePath exe_path; | 36 FilePath exe_path; |
37 if (!PathService::Get(base::DIR_EXE, &exe_path)) | 37 if (!PathService::Get(base::DIR_EXE, &exe_path)) |
38 return false; | 38 return false; |
39 if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) { | 39 if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) { |
40 first_run_sentinel = exe_path; | 40 first_run_sentinel = exe_path; |
41 } else { | 41 } else { |
42 if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) | 42 if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) |
43 return false; | 43 return false; |
44 } | 44 } |
45 #else | 45 #else |
46 // TODO(port): logic as above. Not important for our "First Run Alpha" file. | 46 // TODO(port): logic as above. Not important for our "First Run Dev" file. |
47 if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) | 47 if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) |
48 return false; | 48 return false; |
49 #endif | 49 #endif |
50 | 50 |
51 first_run_sentinel = first_run_sentinel.AppendASCII(kSentinelFile); | 51 first_run_sentinel = first_run_sentinel.AppendASCII(kSentinelFile); |
52 *path = first_run_sentinel; | 52 *path = first_run_sentinel; |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
(...skipping 23 matching lines...) Expand all Loading... |
80 return false; | 80 return false; |
81 return file_util::Delete(first_run_sentinel, false); | 81 return file_util::Delete(first_run_sentinel, false); |
82 } | 82 } |
83 | 83 |
84 bool FirstRun::CreateSentinel() { | 84 bool FirstRun::CreateSentinel() { |
85 FilePath first_run_sentinel; | 85 FilePath first_run_sentinel; |
86 if (!GetFirstRunSentinelFilePath(&first_run_sentinel)) | 86 if (!GetFirstRunSentinelFilePath(&first_run_sentinel)) |
87 return false; | 87 return false; |
88 return file_util::WriteFile(first_run_sentinel, "", 0) != -1; | 88 return file_util::WriteFile(first_run_sentinel, "", 0) != -1; |
89 } | 89 } |
OLD | NEW |