OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/signin/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/value_conversions.h" | 10 #include "base/value_conversions.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( | 141 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( |
142 profile); | 142 profile); |
143 } | 143 } |
144 | 144 |
145 bool IsGuestModeEnabled() { | 145 bool IsGuestModeEnabled() { |
146 PrefService* service = g_browser_process->local_state(); | 146 PrefService* service = g_browser_process->local_state(); |
147 DCHECK(service); | 147 DCHECK(service); |
148 return service->GetBoolean(prefs::kBrowserGuestModeEnabled); | 148 return service->GetBoolean(prefs::kBrowserGuestModeEnabled); |
149 } | 149 } |
150 | 150 |
151 bool IsAddPersonEnabled() { | |
Evan Stade
2014/09/02 18:18:18
wasn't this already added in some previous cl
Mike Lerman
2014/09/04 14:37:08
The IsGuestModeEnabled (function directly above) w
| |
152 PrefService* service = g_browser_process->local_state(); | |
153 DCHECK(service); | |
154 return service->GetBoolean(prefs::kBrowserAddPersonEnabled); | |
155 } | |
156 | |
151 } // namespace | 157 } // namespace |
152 | 158 |
153 // ProfileUpdateObserver ------------------------------------------------------ | 159 // ProfileUpdateObserver ------------------------------------------------------ |
154 | 160 |
155 class UserManagerScreenHandler::ProfileUpdateObserver | 161 class UserManagerScreenHandler::ProfileUpdateObserver |
156 : public ProfileInfoCacheObserver { | 162 : public ProfileInfoCacheObserver { |
157 public: | 163 public: |
158 ProfileUpdateObserver( | 164 ProfileUpdateObserver( |
159 ProfileManager* profile_manager, UserManagerScreenHandler* handler) | 165 ProfileManager* profile_manager, UserManagerScreenHandler* handler) |
160 : profile_manager_(profile_manager), | 166 : profile_manager_(profile_manager), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 info_cache, base::UTF8ToUTF16(user_email), base::string16()); | 288 info_cache, base::UTF8ToUTF16(user_email), base::string16()); |
283 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); | 289 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); |
284 | 290 |
285 authenticating_profile_index_ = profile_index; | 291 authenticating_profile_index_ = profile_index; |
286 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); | 292 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); |
287 } | 293 } |
288 | 294 |
289 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { | 295 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
290 SendUserList(); | 296 SendUserList(); |
291 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", | 297 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", |
292 base::FundamentalValue(IsGuestModeEnabled())); | 298 base::FundamentalValue(IsGuestModeEnabled()), |
299 base::FundamentalValue(IsAddPersonEnabled())); | |
293 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( | 300 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( |
294 web_ui()->GetWebContents()->GetNativeView()); | 301 web_ui()->GetWebContents()->GetNativeView()); |
295 | 302 |
296 ScreenlockBridge::Get()->SetLockHandler(this); | 303 ScreenlockBridge::Get()->SetLockHandler(this); |
297 } | 304 } |
298 | 305 |
299 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { | 306 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { |
300 profiles::CreateAndSwitchToNewProfile(desktop_type_, | 307 if (!IsAddPersonEnabled()) { |
301 base::Bind(&OnSwitchToProfileComplete), | 308 // The UI should have prevented the user from adding a user. |
302 ProfileMetrics::ADD_NEW_USER_MANAGER); | 309 NOTREACHED(); |
310 return; | |
311 } | |
312 profiles::CreateAndSwitchToNewProfile( | |
313 desktop_type_, | |
314 base::Bind(&OnSwitchToProfileComplete), | |
315 ProfileMetrics::ADD_NEW_USER_MANAGER); | |
303 } | 316 } |
304 | 317 |
305 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( | 318 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( |
306 const base::ListValue* args) { | 319 const base::ListValue* args) { |
307 base::string16 email_address; | 320 base::string16 email_address; |
308 if (!args->GetString(0, &email_address)) | 321 if (!args->GetString(0, &email_address)) |
309 return; | 322 return; |
310 | 323 |
311 base::string16 display_name; | 324 base::string16 display_name; |
312 if (!args->GetString(1, &display_name)) | 325 if (!args->GetString(1, &display_name)) |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 } else { | 684 } else { |
672 web_ui()->CallJavascriptFunction( | 685 web_ui()->CallJavascriptFunction( |
673 "cr.ui.Oobe.showSignInError", | 686 "cr.ui.Oobe.showSignInError", |
674 base::FundamentalValue(0), | 687 base::FundamentalValue(0), |
675 base::StringValue( | 688 base::StringValue( |
676 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), | 689 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), |
677 base::StringValue(""), | 690 base::StringValue(""), |
678 base::FundamentalValue(0)); | 691 base::FundamentalValue(0)); |
679 } | 692 } |
680 } | 693 } |
OLD | NEW |