Chromium Code Reviews| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( | 143 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( |
| 144 profile); | 144 profile); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool IsGuestModeEnabled() { | 147 bool IsGuestModeEnabled() { |
| 148 PrefService* service = g_browser_process->local_state(); | 148 PrefService* service = g_browser_process->local_state(); |
| 149 DCHECK(service); | 149 DCHECK(service); |
| 150 return service->GetBoolean(prefs::kBrowserGuestModeEnabled); | 150 return service->GetBoolean(prefs::kBrowserGuestModeEnabled); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool IsAddPersonEnabled() { | |
| 154 PrefService* service = g_browser_process->local_state(); | |
| 155 DCHECK(service); | |
| 156 return service->GetBoolean(prefs::kBrowserAddPersonEnabled); | |
| 157 } | |
| 158 | |
| 153 } // namespace | 159 } // namespace |
| 154 | 160 |
| 155 // ProfileUpdateObserver ------------------------------------------------------ | 161 // ProfileUpdateObserver ------------------------------------------------------ |
| 156 | 162 |
| 157 class UserManagerScreenHandler::ProfileUpdateObserver | 163 class UserManagerScreenHandler::ProfileUpdateObserver |
| 158 : public ProfileInfoCacheObserver { | 164 : public ProfileInfoCacheObserver { |
| 159 public: | 165 public: |
| 160 ProfileUpdateObserver( | 166 ProfileUpdateObserver( |
| 161 ProfileManager* profile_manager, UserManagerScreenHandler* handler) | 167 ProfileManager* profile_manager, UserManagerScreenHandler* handler) |
| 162 : profile_manager_(profile_manager), | 168 : profile_manager_(profile_manager), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 info_cache, base::UTF8ToUTF16(user_email), base::string16()); | 290 info_cache, base::UTF8ToUTF16(user_email), base::string16()); |
| 285 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); | 291 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); |
| 286 | 292 |
| 287 authenticating_profile_index_ = profile_index; | 293 authenticating_profile_index_ = profile_index; |
| 288 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); | 294 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); |
| 289 } | 295 } |
| 290 | 296 |
| 291 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { | 297 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
| 292 SendUserList(); | 298 SendUserList(); |
| 293 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", | 299 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", |
| 294 base::FundamentalValue(IsGuestModeEnabled())); | 300 base::FundamentalValue(IsGuestModeEnabled()), |
| 301 base::FundamentalValue(IsAddPersonEnabled())); | |
| 295 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( | 302 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( |
| 296 web_ui()->GetWebContents()->GetNativeView()); | 303 web_ui()->GetWebContents()->GetNativeView()); |
| 297 | 304 |
| 298 ScreenlockBridge::Get()->SetLockHandler(this); | 305 ScreenlockBridge::Get()->SetLockHandler(this); |
| 299 } | 306 } |
| 300 | 307 |
| 301 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { | 308 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { |
| 302 profiles::CreateAndSwitchToNewProfile(desktop_type_, | 309 if (IsAddPersonEnabled()) { |
|
Evan Stade
2014/08/30 01:15:37
nit: invert this check and return early
Mike Lerman
2014/09/02 16:58:29
Done.
| |
| 303 base::Bind(&OnSwitchToProfileComplete), | 310 profiles::CreateAndSwitchToNewProfile( |
| 304 ProfileMetrics::ADD_NEW_USER_MANAGER); | 311 desktop_type_, |
| 312 base::Bind(&OnSwitchToProfileComplete), | |
| 313 ProfileMetrics::ADD_NEW_USER_MANAGER); | |
| 314 } else { | |
| 315 // The UI should have prevented the user from adding a user. | |
| 316 NOTREACHED(); | |
| 317 } | |
| 305 } | 318 } |
| 306 | 319 |
| 307 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( | 320 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( |
| 308 const base::ListValue* args) { | 321 const base::ListValue* args) { |
| 309 base::string16 email_address; | 322 base::string16 email_address; |
| 310 if (!args->GetString(0, &email_address)) | 323 if (!args->GetString(0, &email_address)) |
| 311 return; | 324 return; |
| 312 | 325 |
| 313 base::string16 display_name; | 326 base::string16 display_name; |
| 314 if (!args->GetString(1, &display_name)) | 327 if (!args->GetString(1, &display_name)) |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 } else { | 686 } else { |
| 674 web_ui()->CallJavascriptFunction( | 687 web_ui()->CallJavascriptFunction( |
| 675 "cr.ui.Oobe.showSignInError", | 688 "cr.ui.Oobe.showSignInError", |
| 676 base::FundamentalValue(0), | 689 base::FundamentalValue(0), |
| 677 base::StringValue( | 690 base::StringValue( |
| 678 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), | 691 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), |
| 679 base::StringValue(""), | 692 base::StringValue(""), |
| 680 base::FundamentalValue(0)); | 693 base::FundamentalValue(0)); |
| 681 } | 694 } |
| 682 } | 695 } |
| OLD | NEW |