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" |
11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
16 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/extensions/features/feature_channel.h" | 18 #include "chrome/common/extensions/features/feature_channel.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
20 #include "components/web_resource/web_resource_pref_names.h" | 21 #include "components/web_resource/web_resource_pref_names.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 | 24 |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 | 26 |
(...skipping 26 matching lines...) Expand all Loading... |
52 namespace chromeos { | 53 namespace chromeos { |
53 | 54 |
54 // static | 55 // static |
55 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 56 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
56 registry->RegisterBooleanPref(prefs::kOobeComplete, false); | 57 registry->RegisterBooleanPref(prefs::kOobeComplete, false); |
57 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); | 58 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); |
58 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); | 59 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); |
59 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); | 60 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); |
60 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); | 61 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); |
61 registry->RegisterBooleanPref(prefs::kNewOobe, false); | 62 registry->RegisterBooleanPref(prefs::kNewOobe, false); |
62 registry->RegisterBooleanPref(prefs::kWebviewSigninEnabled, false); | 63 registry->RegisterBooleanPref(prefs::kWebviewSigninDisabled, false); |
63 } | 64 } |
64 | 65 |
65 // static | 66 // static |
66 bool StartupUtils::IsEulaAccepted() { | 67 bool StartupUtils::IsEulaAccepted() { |
67 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 68 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
68 } | 69 } |
69 | 70 |
70 // static | 71 // static |
71 bool StartupUtils::IsOobeCompleted() { | 72 bool StartupUtils::IsOobeCompleted() { |
72 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); | 73 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 std::string StartupUtils::GetInitialLocale() { | 173 std::string StartupUtils::GetInitialLocale() { |
173 std::string locale = | 174 std::string locale = |
174 g_browser_process->local_state()->GetString(prefs::kInitialLocale); | 175 g_browser_process->local_state()->GetString(prefs::kInitialLocale); |
175 if (!l10n_util::IsValidLocaleSyntax(locale)) | 176 if (!l10n_util::IsValidLocaleSyntax(locale)) |
176 locale = "en-US"; | 177 locale = "en-US"; |
177 return locale; | 178 return locale; |
178 } | 179 } |
179 | 180 |
180 // static | 181 // static |
181 bool StartupUtils::IsWebviewSigninAllowed() { | 182 bool StartupUtils::IsWebviewSigninAllowed() { |
182 return extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 183 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
183 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 184 switches::kDisableWebviewSigninFlow); |
184 switches::kDisableWebviewSigninFlow); | |
185 } | 185 } |
186 | 186 |
187 // static | 187 // static |
188 bool StartupUtils::IsWebviewSigninEnabled() { | 188 bool StartupUtils::IsWebviewSigninEnabled() { |
189 return IsWebviewSigninAllowed() && | 189 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
190 g_browser_process->local_state()->GetBoolean( | 190 g_browser_process |
191 prefs::kWebviewSigninEnabled); | 191 ? g_browser_process->platform_part() |
| 192 ->browser_policy_connector_chromeos() |
| 193 ->GetDeviceCloudPolicyManager() |
| 194 : nullptr; |
| 195 |
| 196 bool is_remora_or_shark_requisition = |
| 197 policy_manager |
| 198 ? policy_manager->IsRemoraRequisition() || |
| 199 policy_manager->IsSharkRequisition() |
| 200 : false; |
| 201 |
| 202 bool is_webview_disabled_pref = g_browser_process->local_state()->GetBoolean( |
| 203 prefs::kWebviewSigninDisabled); |
| 204 |
| 205 // TODO(dzhioev): Re-enable webview signin for remora/shark requisition |
| 206 // http://crbug.com/464049 |
| 207 return !is_remora_or_shark_requisition && IsWebviewSigninAllowed() && |
| 208 !is_webview_disabled_pref; |
192 } | 209 } |
193 | 210 |
194 // static | 211 // static |
195 bool StartupUtils::EnableWebviewSignin(bool is_enabled) { | 212 bool StartupUtils::EnableWebviewSignin(bool is_enabled) { |
196 if (!IsWebviewSigninAllowed()) | 213 if (is_enabled && !IsWebviewSigninAllowed()) |
197 return false; | 214 return false; |
198 | 215 |
199 g_browser_process->local_state()->SetBoolean(prefs::kWebviewSigninEnabled, | 216 g_browser_process->local_state()->SetBoolean(prefs::kWebviewSigninDisabled, |
200 is_enabled); | 217 !is_enabled); |
201 return true; | 218 return true; |
202 } | 219 } |
203 | 220 |
204 // static | 221 // static |
205 void StartupUtils::SetInitialLocale(const std::string& locale) { | 222 void StartupUtils::SetInitialLocale(const std::string& locale) { |
206 if (l10n_util::IsValidLocaleSyntax(locale)) | 223 if (l10n_util::IsValidLocaleSyntax(locale)) |
207 SaveStringPreferenceForced(prefs::kInitialLocale, locale); | 224 SaveStringPreferenceForced(prefs::kInitialLocale, locale); |
208 else | 225 else |
209 NOTREACHED(); | 226 NOTREACHED(); |
210 } | 227 } |
211 | 228 |
212 // static | 229 // static |
213 bool StartupUtils::IsNewOobeAllowed() { | 230 bool StartupUtils::IsNewOobeAllowed() { |
214 return extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV; | 231 return extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV; |
215 } | 232 } |
216 | 233 |
217 // static | 234 // static |
218 bool StartupUtils::IsNewOobeActivated() { | 235 bool StartupUtils::IsNewOobeActivated() { |
219 return g_browser_process->local_state()->GetBoolean(prefs::kNewOobe) && | 236 return g_browser_process->local_state()->GetBoolean(prefs::kNewOobe) && |
220 IsNewOobeAllowed(); | 237 IsNewOobeAllowed(); |
221 } | 238 } |
222 | 239 |
223 } // namespace chromeos | 240 } // namespace chromeos |
OLD | NEW |