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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 7867044: PART1: Initiated the SignedSettings refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final rebase to ToT before hitting the CQ. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chromeos/boot_times_loader.h" 17 #include "chrome/browser/chromeos/boot_times_loader.h"
18 #include "chrome/browser/chromeos/cros_settings.h"
18 #include "chrome/browser/chromeos/cros/cros_library.h" 19 #include "chrome/browser/chromeos/cros/cros_library.h"
19 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 20 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
20 #include "chrome/browser/chromeos/cros/network_library.h" 21 #include "chrome/browser/chromeos/cros/network_library.h"
21 #include "chrome/browser/chromeos/customization_document.h" 22 #include "chrome/browser/chromeos/customization_document.h"
22 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" 23 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
23 #include "chrome/browser/chromeos/dbus/session_manager_client.h" 24 #include "chrome/browser/chromeos/dbus/session_manager_client.h"
24 #include "chrome/browser/chromeos/login/helper.h" 25 #include "chrome/browser/chromeos/login/helper.h"
25 #include "chrome/browser/chromeos/login/login_display_host.h" 26 #include "chrome/browser/chromeos/login/login_display_host.h"
26 #include "chrome/browser/chromeos/login/user_manager.h" 27 #include "chrome/browser/chromeos/login/user_manager.h"
27 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" 28 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
28 #include "chrome/browser/chromeos/login/wizard_controller.h" 29 #include "chrome/browser/chromeos/login/wizard_controller.h"
29 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
30 #include "chrome/browser/google/google_util.h" 30 #include "chrome/browser/google/google_util.h"
31 #include "chrome/browser/prefs/pref_service.h" 31 #include "chrome/browser/prefs/pref_service.h"
32 #include "chrome/browser/profiles/profile_manager.h" 32 #include "chrome/browser/profiles/profile_manager.h"
33 #include "chrome/browser/ui/views/window.h" 33 #include "chrome/browser/ui/views/window.h"
34 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/net/gaia/google_service_auth_error.h" 36 #include "chrome/common/net/gaia/google_service_auth_error.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/notification_types.h" 39 #include "content/public/browser/notification_types.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ExistingUserController* ExistingUserController::current_controller_ = NULL; 74 ExistingUserController* ExistingUserController::current_controller_ = NULL;
75 75
76 //////////////////////////////////////////////////////////////////////////////// 76 ////////////////////////////////////////////////////////////////////////////////
77 // ExistingUserController, public: 77 // ExistingUserController, public:
78 78
79 ExistingUserController::ExistingUserController(LoginDisplayHost* host) 79 ExistingUserController::ExistingUserController(LoginDisplayHost* host)
80 : login_status_consumer_(NULL), 80 : login_status_consumer_(NULL),
81 host_(host), 81 host_(host),
82 login_display_(host_->CreateLoginDisplay(this)), 82 login_display_(host_->CreateLoginDisplay(this)),
83 num_login_attempts_(0), 83 num_login_attempts_(0),
84 user_settings_(new UserCrosSettingsProvider), 84 cros_settings_(CrosSettings::Get()),
85 weak_factory_(this), 85 weak_factory_(this),
86 is_owner_login_(false) { 86 is_owner_login_(false) {
87 DCHECK(current_controller_ == NULL); 87 DCHECK(current_controller_ == NULL);
88 current_controller_ = this; 88 current_controller_ = this;
89 89
90 registrar_.Add(this, 90 registrar_.Add(this,
91 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 91 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
92 content::NotificationService::AllSources()); 92 content::NotificationService::AllSources());
93 } 93 }
94 94
95 void ExistingUserController::Init(const UserList& users) { 95 void ExistingUserController::Init(const UserList& users) {
96 UserList filtered_users; 96 UserList filtered_users;
97 if (UserCrosSettingsProvider::cached_show_users_on_signin()) { 97 bool show_users_on_signin;
98
99 // TODO(pastarmovj): Make this class an observer of the CrosSettings to be
100 // able to update the UI whenever policy is loaded.
101 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
102 &show_users_on_signin);
103 if (show_users_on_signin) {
104 bool allow_new_user = false;
105 const base::ListValue *user_list;
106 cros_settings_->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
107 cros_settings_->GetList(kAccountsPrefUsers, &user_list);
98 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 108 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
109 base::StringValue email((*it)->email());
99 // TODO(xiyuan): Clean user profile whose email is not in whitelist. 110 // TODO(xiyuan): Clean user profile whose email is not in whitelist.
100 if (UserCrosSettingsProvider::cached_allow_new_user() || 111 if (allow_new_user ||
101 UserCrosSettingsProvider::IsEmailInCachedWhitelist((*it)->email())) { 112 user_list->Find(email) != user_list->end()) {
102 filtered_users.push_back(*it); 113 filtered_users.push_back(*it);
103 } 114 }
104 } 115 }
105 } 116 }
106 117
107 // If no user pods are visible, fallback to single new user pod which will 118 // If no user pods are visible, fallback to single new user pod which will
108 // have guest session link. 119 // have guest session link.
109 bool show_guest = UserCrosSettingsProvider::cached_allow_guest() && 120 bool show_guest;
110 !filtered_users.empty(); 121 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest);
122 show_guest &= !filtered_users.empty();
111 bool show_new_user = true; 123 bool show_new_user = true;
112 login_display_->set_parent_window(GetNativeWindow()); 124 login_display_->set_parent_window(GetNativeWindow());
113 login_display_->Init(filtered_users, show_guest, show_new_user); 125 login_display_->Init(filtered_users, show_guest, show_new_user);
114 126
115 LoginUtils::Get()->PrewarmAuthentication(); 127 LoginUtils::Get()->PrewarmAuthentication();
116 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); 128 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady();
117 } 129 }
118 130
119 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
120 // ExistingUserController, content::NotificationObserver implementation: 132 // ExistingUserController, content::NotificationObserver implementation:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 234 }
223 235
224 void ExistingUserController::LoginAsGuest() { 236 void ExistingUserController::LoginAsGuest() {
225 SetStatusAreaEnabled(false); 237 SetStatusAreaEnabled(false);
226 // Disable clicking on other windows. 238 // Disable clicking on other windows.
227 login_display_->SetUIEnabled(false); 239 login_display_->SetUIEnabled(false);
228 SetOwnerUserInCryptohome(); 240 SetOwnerUserInCryptohome();
229 241
230 // Check allow_guest in case this call is fired from key accelerator. 242 // Check allow_guest in case this call is fired from key accelerator.
231 // Must not proceed without signature verification. 243 // Must not proceed without signature verification.
232 bool trusted_setting_available = user_settings_->RequestTrustedAllowGuest( 244 bool trusted_setting_available = cros_settings_->GetTrusted(
245 kAccountsPrefAllowGuest,
233 base::Bind(&ExistingUserController::LoginAsGuest, 246 base::Bind(&ExistingUserController::LoginAsGuest,
234 weak_factory_.GetWeakPtr())); 247 weak_factory_.GetWeakPtr()));
235 if (!trusted_setting_available) { 248 if (!trusted_setting_available) {
236 // Value of AllowGuest setting is still not verified. 249 // Value of AllowGuest setting is still not verified.
237 // Another attempt will be invoked again after verification completion. 250 // Another attempt will be invoked again after verification completion.
238 return; 251 return;
239 } 252 }
240 if (!UserCrosSettingsProvider::cached_allow_guest()) { 253 bool allow_guest;
254 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
255 if (!allow_guest) {
241 // Disallowed. 256 // Disallowed.
242 return; 257 return;
243 } 258 }
244 259
245 // Only one instance of LoginPerformer should exist at a time. 260 // Only one instance of LoginPerformer should exist at a time.
246 login_performer_.reset(NULL); 261 login_performer_.reset(NULL);
247 login_performer_.reset(new LoginPerformer(this)); 262 login_performer_.reset(new LoginPerformer(this));
248 login_performer_->LoginOffTheRecord(); 263 login_performer_->LoginOffTheRecord();
249 WizardAccessibilityHelper::GetInstance()->MaybeSpeak( 264 WizardAccessibilityHelper::GetInstance()->MaybeSpeak(
250 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD).c_str(), 265 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD).c_str(),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); 336 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error);
322 } else if ((active_network && active_network->restricted_pool()) || 337 } else if ((active_network && active_network->restricted_pool()) ||
323 (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && 338 (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED &&
324 failure.error().state() == 339 failure.error().state() ==
325 GoogleServiceAuthError::SERVICE_UNAVAILABLE)) { 340 GoogleServiceAuthError::SERVICE_UNAVAILABLE)) {
326 // Use explicit captive portal state (restricted_pool()) or implicit one. 341 // Use explicit captive portal state (restricted_pool()) or implicit one.
327 // SERVICE_UNAVAILABLE is generated in 2 cases: 342 // SERVICE_UNAVAILABLE is generated in 2 cases:
328 // 1. ClientLogin returns ServiceUnavailable code. 343 // 1. ClientLogin returns ServiceUnavailable code.
329 // 2. Internet connectivity may be behind the captive portal. 344 // 2. Internet connectivity may be behind the captive portal.
330 // Suggesting user to try sign in to a portal in Guest mode. 345 // Suggesting user to try sign in to a portal in Guest mode.
331 if (UserCrosSettingsProvider::cached_allow_guest()) 346 bool allow_guest;
347 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
348 if (allow_guest)
332 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL, error); 349 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL, error);
333 else 350 else
334 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL_NO_GUEST_MODE, error); 351 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL_NO_GUEST_MODE, error);
335 } else { 352 } else {
336 if (!is_known_user) 353 if (!is_known_user)
337 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); 354 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error);
338 else 355 else
339 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 356 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
340 } 357 }
341 } 358 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 ActivateWizard(WizardController::kRegistrationScreenName); 483 ActivateWizard(WizardController::kRegistrationScreenName);
467 } 484 }
468 485
469 if (login_status_consumer_) 486 if (login_status_consumer_)
470 login_status_consumer_->OnOffTheRecordLoginSuccess(); 487 login_status_consumer_->OnOffTheRecordLoginSuccess();
471 } 488 }
472 489
473 void ExistingUserController::OnPasswordChangeDetected( 490 void ExistingUserController::OnPasswordChangeDetected(
474 const GaiaAuthConsumer::ClientLoginResult& credentials) { 491 const GaiaAuthConsumer::ClientLoginResult& credentials) {
475 // Must not proceed without signature verification. 492 // Must not proceed without signature verification.
476 bool trusted_setting_available = user_settings_->RequestTrustedOwner( 493 bool trusted_setting_available = cros_settings_->GetTrusted(
494 kDeviceOwner,
477 base::Bind(&ExistingUserController::OnPasswordChangeDetected, 495 base::Bind(&ExistingUserController::OnPasswordChangeDetected,
478 weak_factory_.GetWeakPtr(), credentials)); 496 weak_factory_.GetWeakPtr(), credentials));
497
479 if (!trusted_setting_available) { 498 if (!trusted_setting_available) {
480 // Value of owner email is still not verified. 499 // Value of owner email is still not verified.
481 // Another attempt will be invoked after verification completion. 500 // Another attempt will be invoked after verification completion.
482 return; 501 return;
483 } 502 }
484 503
485 // Passing 'false' here enables "full sync" mode in the dialog, 504 // Passing 'false' here enables "full sync" mode in the dialog,
486 // which disables the requirement for the old owner password, 505 // which disables the requirement for the old owner password,
487 // allowing us to recover from a lost owner password/homedir. 506 // allowing us to recover from a lost owner password/homedir.
488 // TODO(gspencer): We shouldn't have to erase stateful data when 507 // TODO(gspencer): We shouldn't have to erase stateful data when
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 help_topic_id = login_performer_->login_timed_out() ? 590 help_topic_id = login_performer_->login_timed_out() ?
572 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : 591 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE :
573 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; 592 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT;
574 break; 593 break;
575 } 594 }
576 595
577 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); 596 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id);
578 } 597 }
579 598
580 void ExistingUserController::SetOwnerUserInCryptohome() { 599 void ExistingUserController::SetOwnerUserInCryptohome() {
581 bool trusted_owner_available = user_settings_->RequestTrustedOwner( 600 bool trusted_owner_available = cros_settings_->GetTrusted(
601 kDeviceOwner,
582 base::Bind(&ExistingUserController::SetOwnerUserInCryptohome, 602 base::Bind(&ExistingUserController::SetOwnerUserInCryptohome,
583 weak_factory_.GetWeakPtr())); 603 weak_factory_.GetWeakPtr()));
584 if (!trusted_owner_available) { 604 if (!trusted_owner_available) {
585 // Value of owner email is still not verified. 605 // Value of owner email is still not verified.
586 // Another attempt will be invoked after verification completion. 606 // Another attempt will be invoked after verification completion.
587 return; 607 return;
588 } 608 }
589 CryptohomeLibrary* cryptohomed = CrosLibrary::Get()->GetCryptohomeLibrary(); 609 CryptohomeLibrary* cryptohomed = CrosLibrary::Get()->GetCryptohomeLibrary();
590 cryptohomed->AsyncSetOwnerUser( 610 std::string owner;
591 UserCrosSettingsProvider::cached_owner(), NULL); 611 cros_settings_->GetString(kDeviceOwner, &owner);
612 cryptohomed->AsyncSetOwnerUser(owner, NULL);
592 613
593 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here 614 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here
594 // so it does not delay the following mount. Cleanup will be 615 // so it does not delay the following mount. Cleanup will be
595 // started in Cryptohomed by timer. 616 // started in Cryptohomed by timer.
596 } 617 }
597 618
598 } // namespace chromeos 619 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | chrome/browser/chromeos/login/login_performer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698