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/chromeos/login/startup_utils.h" | 5 #include "chrome/browser/chromeos/login/startup_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" |
10 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
12 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
15 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
16 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
17 | 19 |
18 using content::BrowserThread; | 20 using content::BrowserThread; |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 // A string pref with initial locale set in VPD or manifest. | 24 // A string pref with initial locale set in VPD or manifest. |
23 const char kInitialLocale[] = "intl.initial_locale"; | 25 const char kInitialLocale[] = "intl.initial_locale"; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 83 } |
82 | 84 |
83 // static | 85 // static |
84 void StartupUtils::MarkOobeCompleted() { | 86 void StartupUtils::MarkOobeCompleted() { |
85 SaveBoolPreferenceForced(kOobeComplete, true); | 87 SaveBoolPreferenceForced(kOobeComplete, true); |
86 } | 88 } |
87 | 89 |
88 // Returns the path to flag file indicating that both parts of OOBE were | 90 // Returns the path to flag file indicating that both parts of OOBE were |
89 // completed. | 91 // completed. |
90 // On chrome device, returns /home/chronos/.oobe_completed. | 92 // On chrome device, returns /home/chronos/.oobe_completed. |
91 // On Linux desktop, returns $HOME/.oobe_completed. | 93 // On Linux desktop, returns {DIR_USER_DATA}/.oobe_completed. |
92 static base::FilePath GetOobeCompleteFlagPath() { | 94 static base::FilePath GetOobeCompleteFlagPath() { |
93 // The constant is defined here so it won't be referenced directly. | 95 // The constant is defined here so it won't be referenced directly. |
94 const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed"; | 96 const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed"; |
95 | 97 |
96 if (base::chromeos::IsRunningOnChromeOS()) { | 98 if (base::chromeos::IsRunningOnChromeOS()) { |
97 return base::FilePath(kOobeCompleteFlagFilePath); | 99 return base::FilePath(kOobeCompleteFlagFilePath); |
98 } else { | 100 } else { |
99 const char* home = getenv("HOME"); | 101 base::FilePath user_data_dir; |
100 // Unlikely but if HOME is not defined, use the current directory. | 102 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
101 if (!home) | 103 return user_data_dir.AppendASCII(".oobe_completed"); |
102 home = ""; | |
103 return base::FilePath(home).AppendASCII(".oobe_completed"); | |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 static void CreateOobeCompleteFlagFile() { | 107 static void CreateOobeCompleteFlagFile() { |
108 // Create flag file for boot-time init scripts. | 108 // Create flag file for boot-time init scripts. |
109 base::FilePath oobe_complete_path = GetOobeCompleteFlagPath(); | 109 base::FilePath oobe_complete_path = GetOobeCompleteFlagPath(); |
110 if (!base::PathExists(oobe_complete_path)) { | 110 if (!base::PathExists(oobe_complete_path)) { |
111 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); | 111 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); |
112 if (oobe_flag_file == NULL) | 112 if (oobe_flag_file == NULL) |
113 DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist."; | 113 DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist."; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 // static | 160 // static |
161 void StartupUtils::SetInitialLocale(const std::string& locale) { | 161 void StartupUtils::SetInitialLocale(const std::string& locale) { |
162 if (l10n_util::IsValidLocaleSyntax(locale)) | 162 if (l10n_util::IsValidLocaleSyntax(locale)) |
163 SaveStringPreferenceForced(kInitialLocale, locale); | 163 SaveStringPreferenceForced(kInitialLocale, locale); |
164 else | 164 else |
165 NOTREACHED(); | 165 NOTREACHED(); |
166 } | 166 } |
167 | 167 |
168 } // namespace chromeos | 168 } // namespace chromeos |
OLD | NEW |