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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 prefs->CommitPendingWrite(); | 32 prefs->CommitPendingWrite(); |
33 } | 33 } |
34 | 34 |
35 // Saves integer "Local State" preference and forces its persistence to disk. | 35 // Saves integer "Local State" preference and forces its persistence to disk. |
36 void SaveIntegerPreferenceForced(const char* pref_name, int value) { | 36 void SaveIntegerPreferenceForced(const char* pref_name, int value) { |
37 PrefService* prefs = g_browser_process->local_state(); | 37 PrefService* prefs = g_browser_process->local_state(); |
38 prefs->SetInteger(pref_name, value); | 38 prefs->SetInteger(pref_name, value); |
39 prefs->CommitPendingWrite(); | 39 prefs->CommitPendingWrite(); |
40 } | 40 } |
41 | 41 |
42 // Saves 64 bit signed integer "Local State" preference and forces its | |
43 // persistence to disk. | |
44 void SaveInt64PreferenceForced(const char* pref_name, int64_t value) { | |
45 PrefService* prefs = g_browser_process->local_state(); | |
46 prefs->SetInt64(pref_name, value); | |
47 prefs->CommitPendingWrite(); | |
48 } | |
49 | |
50 // Saves string "Local State" preference and forces its persistence to disk. | 42 // Saves string "Local State" preference and forces its persistence to disk. |
51 void SaveStringPreferenceForced(const char* pref_name, | 43 void SaveStringPreferenceForced(const char* pref_name, |
52 const std::string& value) { | 44 const std::string& value) { |
53 PrefService* prefs = g_browser_process->local_state(); | 45 PrefService* prefs = g_browser_process->local_state(); |
54 prefs->SetString(pref_name, value); | 46 prefs->SetString(pref_name, value); |
55 prefs->CommitPendingWrite(); | 47 prefs->CommitPendingWrite(); |
56 } | 48 } |
57 | 49 |
58 // Returns the path to flag file indicating that both parts of OOBE were | 50 // Returns the path to flag file indicating that both parts of OOBE were |
59 // completed. | 51 // completed. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // static | 83 // static |
92 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 84 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
93 registry->RegisterBooleanPref(prefs::kOobeComplete, false); | 85 registry->RegisterBooleanPref(prefs::kOobeComplete, false); |
94 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); | 86 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); |
95 registry->RegisterBooleanPref(prefs::kOobeMdMode, false); | 87 registry->RegisterBooleanPref(prefs::kOobeMdMode, false); |
96 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); | 88 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); |
97 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); | 89 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); |
98 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); | 90 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); |
99 registry->RegisterBooleanPref(prefs::kIsBootstrappingSlave, false); | 91 registry->RegisterBooleanPref(prefs::kIsBootstrappingSlave, false); |
100 registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false); | 92 registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false); |
101 registry->RegisterInt64Pref(prefs::kOobeTimeOfLastUpdateCheckWithoutUpdate, | |
102 0); | |
103 } | 93 } |
104 | 94 |
105 // static | 95 // static |
106 bool StartupUtils::IsEulaAccepted() { | 96 bool StartupUtils::IsEulaAccepted() { |
107 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 97 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
108 } | 98 } |
109 | 99 |
110 // static | 100 // static |
111 bool StartupUtils::IsOobeCompleted() { | 101 bool StartupUtils::IsOobeCompleted() { |
112 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); | 102 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 191 } |
202 | 192 |
203 // static | 193 // static |
204 void StartupUtils::SetInitialLocale(const std::string& locale) { | 194 void StartupUtils::SetInitialLocale(const std::string& locale) { |
205 if (l10n_util::IsValidLocaleSyntax(locale)) | 195 if (l10n_util::IsValidLocaleSyntax(locale)) |
206 SaveStringPreferenceForced(prefs::kInitialLocale, locale); | 196 SaveStringPreferenceForced(prefs::kInitialLocale, locale); |
207 else | 197 else |
208 NOTREACHED(); | 198 NOTREACHED(); |
209 } | 199 } |
210 | 200 |
211 // static | |
212 void StartupUtils::SaveTimeOfLastUpdateCheckWithoutUpdate(base::Time time) { | |
213 SaveInt64PreferenceForced(prefs::kOobeTimeOfLastUpdateCheckWithoutUpdate, | |
214 time.ToInternalValue()); | |
215 } | |
216 | |
217 // static | |
218 void StartupUtils::ClearTimeOfLastUpdateCheckWithoutUpdate() { | |
219 PrefService* prefs = g_browser_process->local_state(); | |
220 prefs->ClearPref(prefs::kOobeTimeOfLastUpdateCheckWithoutUpdate); | |
221 prefs->CommitPendingWrite(); | |
222 } | |
223 | |
224 // static | |
225 base::Time StartupUtils::GetTimeOfLastUpdateCheckWithoutUpdate() { | |
226 return base::Time::FromInternalValue( | |
227 g_browser_process->local_state()->GetInt64( | |
228 prefs::kOobeTimeOfLastUpdateCheckWithoutUpdate)); | |
229 } | |
230 | |
231 } // namespace chromeos | 201 } // namespace chromeos |
OLD | NEW |