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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 prefs->CommitPendingWrite(); | 43 prefs->CommitPendingWrite(); |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 namespace chromeos { | 48 namespace chromeos { |
49 | 49 |
50 // static | 50 // static |
51 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 51 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
52 registry->RegisterBooleanPref(prefs::kOobeComplete, false); | 52 registry->RegisterBooleanPref(prefs::kOobeComplete, false); |
| 53 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); |
53 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); | 54 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); |
54 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); | 55 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); |
55 } | 56 } |
56 | 57 |
57 // static | 58 // static |
58 bool StartupUtils::IsEulaAccepted() { | 59 bool StartupUtils::IsEulaAccepted() { |
59 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 60 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
60 } | 61 } |
61 | 62 |
62 // static | 63 // static |
63 bool StartupUtils::IsOobeCompleted() { | 64 bool StartupUtils::IsOobeCompleted() { |
64 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); | 65 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); |
65 } | 66 } |
66 | 67 |
67 // static | 68 // static |
68 void StartupUtils::MarkEulaAccepted() { | 69 void StartupUtils::MarkEulaAccepted() { |
69 SaveBoolPreferenceForced(prefs::kEulaAccepted, true); | 70 SaveBoolPreferenceForced(prefs::kEulaAccepted, true); |
70 } | 71 } |
71 | 72 |
72 // static | 73 // static |
73 void StartupUtils::MarkOobeCompleted() { | 74 void StartupUtils::MarkOobeCompleted() { |
| 75 // Forcing the second pref will force this one as well. Even if this one |
| 76 // doesn't end up synced it is only going to eat up a couple of bytes with no |
| 77 // side-effects. |
| 78 g_browser_process->local_state()->ClearPref(prefs::kOobeScreenPending); |
74 SaveBoolPreferenceForced(prefs::kOobeComplete, true); | 79 SaveBoolPreferenceForced(prefs::kOobeComplete, true); |
75 } | 80 } |
76 | 81 |
| 82 void StartupUtils::SaveOobePendingScreen(const std::string& screen) { |
| 83 SaveStringPreferenceForced(prefs::kOobeScreenPending, screen); |
| 84 } |
| 85 |
77 // Returns the path to flag file indicating that both parts of OOBE were | 86 // Returns the path to flag file indicating that both parts of OOBE were |
78 // completed. | 87 // completed. |
79 // On chrome device, returns /home/chronos/.oobe_completed. | 88 // On chrome device, returns /home/chronos/.oobe_completed. |
80 // On Linux desktop, returns {DIR_USER_DATA}/.oobe_completed. | 89 // On Linux desktop, returns {DIR_USER_DATA}/.oobe_completed. |
81 static base::FilePath GetOobeCompleteFlagPath() { | 90 static base::FilePath GetOobeCompleteFlagPath() { |
82 // The constant is defined here so it won't be referenced directly. | 91 // The constant is defined here so it won't be referenced directly. |
83 const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed"; | 92 const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed"; |
84 | 93 |
85 if (base::SysInfo::IsRunningOnChromeOS()) { | 94 if (base::SysInfo::IsRunningOnChromeOS()) { |
86 return base::FilePath(kOobeCompleteFlagFilePath); | 95 return base::FilePath(kOobeCompleteFlagFilePath); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 156 |
148 // static | 157 // static |
149 void StartupUtils::SetInitialLocale(const std::string& locale) { | 158 void StartupUtils::SetInitialLocale(const std::string& locale) { |
150 if (l10n_util::IsValidLocaleSyntax(locale)) | 159 if (l10n_util::IsValidLocaleSyntax(locale)) |
151 SaveStringPreferenceForced(prefs::kInitialLocale, locale); | 160 SaveStringPreferenceForced(prefs::kInitialLocale, locale); |
152 else | 161 else |
153 NOTREACHED(); | 162 NOTREACHED(); |
154 } | 163 } |
155 | 164 |
156 } // namespace chromeos | 165 } // namespace chromeos |
OLD | NEW |