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/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Unlikely but if HOME is not defined, use the current directory. | 100 // Unlikely but if HOME is not defined, use the current directory. |
101 if (!home) | 101 if (!home) |
102 home = ""; | 102 home = ""; |
103 return base::FilePath(home).AppendASCII(".oobe_completed"); | 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 (!file_util::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."; |
114 else | 114 else |
115 file_util::CloseFile(oobe_flag_file); | 115 file_util::CloseFile(oobe_flag_file); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 // static | 119 // static |
120 bool StartupUtils::IsDeviceRegistered() { | 120 bool StartupUtils::IsDeviceRegistered() { |
121 int value = g_browser_process->local_state()->GetInteger(kDeviceRegistered); | 121 int value = g_browser_process->local_state()->GetInteger(kDeviceRegistered); |
122 if (value > 0) { | 122 if (value > 0) { |
123 // Recreate flag file in case it was lost. | 123 // Recreate flag file in case it was lost. |
124 BrowserThread::PostTask( | 124 BrowserThread::PostTask( |
125 BrowserThread::FILE, | 125 BrowserThread::FILE, |
126 FROM_HERE, | 126 FROM_HERE, |
127 base::Bind(&CreateOobeCompleteFlagFile)); | 127 base::Bind(&CreateOobeCompleteFlagFile)); |
128 return true; | 128 return true; |
129 } else if (value == 0) { | 129 } else if (value == 0) { |
130 return false; | 130 return false; |
131 } else { | 131 } else { |
132 // Pref is not set. For compatibility check flag file. It causes blocking | 132 // Pref is not set. For compatibility check flag file. It causes blocking |
133 // IO on UI thread. But it's required for update from old versions. | 133 // IO on UI thread. But it's required for update from old versions. |
134 base::ThreadRestrictions::ScopedAllowIO allow_io; | 134 base::ThreadRestrictions::ScopedAllowIO allow_io; |
135 base::FilePath oobe_complete_flag_file_path = GetOobeCompleteFlagPath(); | 135 base::FilePath oobe_complete_flag_file_path = GetOobeCompleteFlagPath(); |
136 bool file_exists = file_util::PathExists(oobe_complete_flag_file_path); | 136 bool file_exists = base::PathExists(oobe_complete_flag_file_path); |
137 SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0); | 137 SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0); |
138 return file_exists; | 138 return file_exists; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 // static | 142 // static |
143 void StartupUtils::MarkDeviceRegistered() { | 143 void StartupUtils::MarkDeviceRegistered() { |
144 SaveIntegerPreferenceForced(kDeviceRegistered, 1); | 144 SaveIntegerPreferenceForced(kDeviceRegistered, 1); |
145 BrowserThread::PostTask( | 145 BrowserThread::PostTask( |
146 BrowserThread::FILE, | 146 BrowserThread::FILE, |
(...skipping 12 matching lines...) Expand all 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 |