Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 471973003: Make the user manager UI not permit guest mode when preferences dictate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove an unneeded header Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/user_manager/user_manager.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ProfileInfoCache& info_cache = 137 ProfileInfoCache& info_cache =
138 g_browser_process->profile_manager()->GetProfileInfoCache(); 138 g_browser_process->profile_manager()->GetProfileInfoCache();
139 const size_t profile_index = GetIndexOfProfileWithEmailAndName( 139 const size_t profile_index = GetIndexOfProfileWithEmailAndName(
140 info_cache, base::UTF8ToUTF16(email), base::string16()); 140 info_cache, base::UTF8ToUTF16(email), base::string16());
141 Profile* profile = g_browser_process->profile_manager() 141 Profile* profile = g_browser_process->profile_manager()
142 ->GetProfileByPath(info_cache.GetPathOfProfileAtIndex(profile_index)); 142 ->GetProfileByPath(info_cache.GetPathOfProfileAtIndex(profile_index));
143 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( 143 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
144 profile); 144 profile);
145 } 145 }
146 146
147 bool IsGuestModeEnabled() {
148 PrefService* service = g_browser_process->local_state();
149 DCHECK(service);
150 return service->GetBoolean(prefs::kBrowserGuestModeEnabled);
151 }
152
147 } // namespace 153 } // namespace
148 154
149 // ProfileUpdateObserver ------------------------------------------------------ 155 // ProfileUpdateObserver ------------------------------------------------------
150 156
151 class UserManagerScreenHandler::ProfileUpdateObserver 157 class UserManagerScreenHandler::ProfileUpdateObserver
152 : public ProfileInfoCacheObserver { 158 : public ProfileInfoCacheObserver {
153 public: 159 public:
154 ProfileUpdateObserver( 160 ProfileUpdateObserver(
155 ProfileManager* profile_manager, UserManagerScreenHandler* handler) 161 ProfileManager* profile_manager, UserManagerScreenHandler* handler)
156 : profile_manager_(profile_manager), 162 : profile_manager_(profile_manager),
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 const size_t profile_index = GetIndexOfProfileWithEmailAndName( 279 const size_t profile_index = GetIndexOfProfileWithEmailAndName(
274 info_cache, base::UTF8ToUTF16(user_email), base::string16()); 280 info_cache, base::UTF8ToUTF16(user_email), base::string16());
275 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); 281 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles());
276 282
277 authenticating_profile_index_ = profile_index; 283 authenticating_profile_index_ = profile_index;
278 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); 284 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL);
279 } 285 }
280 286
281 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { 287 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
282 SendUserList(); 288 SendUserList();
283 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen"); 289 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen",
290 base::FundamentalValue(IsGuestModeEnabled()));
284 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( 291 desktop_type_ = chrome::GetHostDesktopTypeForNativeView(
285 web_ui()->GetWebContents()->GetNativeView()); 292 web_ui()->GetWebContents()->GetNativeView());
286 293
287 ScreenlockBridge::Get()->SetLockHandler(this); 294 ScreenlockBridge::Get()->SetLockHandler(this);
288 } 295 }
289 296
290 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { 297 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) {
291 profiles::CreateAndSwitchToNewProfile(desktop_type_, 298 profiles::CreateAndSwitchToNewProfile(desktop_type_,
292 base::Bind(&OnSwitchToProfileComplete), 299 base::Bind(&OnSwitchToProfileComplete),
293 ProfileMetrics::ADD_NEW_USER_MANAGER); 300 ProfileMetrics::ADD_NEW_USER_MANAGER);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return; 368 return;
362 369
363 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 370 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
364 profile_path, 371 profile_path,
365 base::Bind(&OpenNewWindowForProfile, desktop_type_)); 372 base::Bind(&OpenNewWindowForProfile, desktop_type_));
366 ProfileMetrics::LogProfileDeleteUser( 373 ProfileMetrics::LogProfileDeleteUser(
367 ProfileMetrics::DELETE_PROFILE_USER_MANAGER); 374 ProfileMetrics::DELETE_PROFILE_USER_MANAGER);
368 } 375 }
369 376
370 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { 377 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) {
371 profiles::SwitchToGuestProfile(desktop_type_, 378 if (IsGuestModeEnabled()) {
372 base::Bind(&OnSwitchToProfileComplete)); 379 profiles::SwitchToGuestProfile(desktop_type_,
373 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); 380 base::Bind(&OnSwitchToProfileComplete));
381 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST);
382 } else {
383 // The UI should have prevented the user from allowing the selection of
384 // guest mode.
385 NOTREACHED();
386 }
374 } 387 }
375 388
376 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { 389 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
377 base::string16 email_address; 390 base::string16 email_address;
378 base::string16 display_name; 391 base::string16 display_name;
379 392
380 if (!args->GetString(0, &email_address) || 393 if (!args->GetString(0, &email_address) ||
381 !args->GetString(1, &display_name)) { 394 !args->GetString(1, &display_name)) {
382 NOTREACHED(); 395 NOTREACHED();
383 return; 396 return;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); 630 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache));
618 631
619 // The row of user pods should display the active user first. 632 // The row of user pods should display the active user first.
620 if (is_active_user) 633 if (is_active_user)
621 users_list.Insert(0, profile_value); 634 users_list.Insert(0, profile_value);
622 else 635 else
623 users_list.Append(profile_value); 636 users_list.Append(profile_value);
624 } 637 }
625 638
626 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", 639 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers",
627 users_list, base::FundamentalValue(true)); 640 users_list, base::FundamentalValue(IsGuestModeEnabled()));
628 } 641 }
629 642
630 void UserManagerScreenHandler::ReportAuthenticationResult( 643 void UserManagerScreenHandler::ReportAuthenticationResult(
631 bool success, 644 bool success,
632 ProfileMetrics::ProfileAuth auth) { 645 ProfileMetrics::ProfileAuth auth) {
633 ProfileMetrics::LogProfileAuthResult(auth); 646 ProfileMetrics::LogProfileAuthResult(auth);
634 password_attempt_.clear(); 647 password_attempt_.clear();
635 648
636 if (success) { 649 if (success) {
637 ProfileInfoCache& info_cache = 650 ProfileInfoCache& info_cache =
638 g_browser_process->profile_manager()->GetProfileInfoCache(); 651 g_browser_process->profile_manager()->GetProfileInfoCache();
639 info_cache.SetProfileSigninRequiredAtIndex( 652 info_cache.SetProfileSigninRequiredAtIndex(
640 authenticating_profile_index_, false); 653 authenticating_profile_index_, false);
641 base::FilePath path = info_cache.GetPathOfProfileAtIndex( 654 base::FilePath path = info_cache.GetPathOfProfileAtIndex(
642 authenticating_profile_index_); 655 authenticating_profile_index_);
643 profiles::SwitchToProfile(path, desktop_type_, true, 656 profiles::SwitchToProfile(path, desktop_type_, true,
644 base::Bind(&OnSwitchToProfileComplete), 657 base::Bind(&OnSwitchToProfileComplete),
645 ProfileMetrics::SWITCH_PROFILE_UNLOCK); 658 ProfileMetrics::SWITCH_PROFILE_UNLOCK);
646 } else { 659 } else {
647 web_ui()->CallJavascriptFunction( 660 web_ui()->CallJavascriptFunction(
648 "cr.ui.Oobe.showSignInError", 661 "cr.ui.Oobe.showSignInError",
649 base::FundamentalValue(0), 662 base::FundamentalValue(0),
650 base::StringValue( 663 base::StringValue(
651 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), 664 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)),
652 base::StringValue(""), 665 base::StringValue(""),
653 base::FundamentalValue(0)); 666 base::FundamentalValue(0));
654 } 667 }
655 } 668 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/user_manager/user_manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698