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 |
42 // Saves string "Local State" preference and forces its persistence to disk. | 50 // Saves string "Local State" preference and forces its persistence to disk. |
43 void SaveStringPreferenceForced(const char* pref_name, | 51 void SaveStringPreferenceForced(const char* pref_name, |
44 const std::string& value) { | 52 const std::string& value) { |
45 PrefService* prefs = g_browser_process->local_state(); | 53 PrefService* prefs = g_browser_process->local_state(); |
46 prefs->SetString(pref_name, value); | 54 prefs->SetString(pref_name, value); |
47 prefs->CommitPendingWrite(); | 55 prefs->CommitPendingWrite(); |
48 } | 56 } |
49 | 57 |
50 // Returns the path to flag file indicating that both parts of OOBE were | 58 // Returns the path to flag file indicating that both parts of OOBE were |
51 // completed. | 59 // completed. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // static | 91 // static |
84 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 92 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
85 registry->RegisterBooleanPref(prefs::kOobeComplete, false); | 93 registry->RegisterBooleanPref(prefs::kOobeComplete, false); |
86 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); | 94 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); |
87 registry->RegisterBooleanPref(prefs::kOobeMdMode, false); | 95 registry->RegisterBooleanPref(prefs::kOobeMdMode, false); |
88 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); | 96 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); |
89 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); | 97 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); |
90 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); | 98 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); |
91 registry->RegisterBooleanPref(prefs::kIsBootstrappingSlave, false); | 99 registry->RegisterBooleanPref(prefs::kIsBootstrappingSlave, false); |
92 registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false); | 100 registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false); |
| 101 registry->RegisterInt64Pref(prefs::kOobeTimeOfLastUpdateCheckWithoutUpdate, |
| 102 0); |
93 } | 103 } |
94 | 104 |
95 // static | 105 // static |
96 bool StartupUtils::IsEulaAccepted() { | 106 bool StartupUtils::IsEulaAccepted() { |
97 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 107 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
98 } | 108 } |
99 | 109 |
100 // static | 110 // static |
101 bool StartupUtils::IsOobeCompleted() { | 111 bool StartupUtils::IsOobeCompleted() { |
102 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); | 112 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 201 } |
192 | 202 |
193 // static | 203 // static |
194 void StartupUtils::SetInitialLocale(const std::string& locale) { | 204 void StartupUtils::SetInitialLocale(const std::string& locale) { |
195 if (l10n_util::IsValidLocaleSyntax(locale)) | 205 if (l10n_util::IsValidLocaleSyntax(locale)) |
196 SaveStringPreferenceForced(prefs::kInitialLocale, locale); | 206 SaveStringPreferenceForced(prefs::kInitialLocale, locale); |
197 else | 207 else |
198 NOTREACHED(); | 208 NOTREACHED(); |
199 } | 209 } |
200 | 210 |
| 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 |
201 } // namespace chromeos | 231 } // namespace chromeos |
OLD | NEW |