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

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: Addressed the comments from Denis. Created 9 years, 3 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 | 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/command_line.h" 8 #include "base/command_line.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
10 #include "base/string_util.h" 11 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/boot_times_loader.h" 15 #include "chrome/browser/chromeos/boot_times_loader.h"
16 #include "chrome/browser/chromeos/cros_settings.h"
15 #include "chrome/browser/chromeos/cros/cros_library.h" 17 #include "chrome/browser/chromeos/cros/cros_library.h"
16 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 18 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
17 #include "chrome/browser/chromeos/cros/login_library.h" 19 #include "chrome/browser/chromeos/cros/login_library.h"
18 #include "chrome/browser/chromeos/cros/network_library.h" 20 #include "chrome/browser/chromeos/cros/network_library.h"
19 #include "chrome/browser/chromeos/customization_document.h" 21 #include "chrome/browser/chromeos/customization_document.h"
20 #include "chrome/browser/chromeos/login/helper.h" 22 #include "chrome/browser/chromeos/login/helper.h"
21 #include "chrome/browser/chromeos/login/login_display_host.h" 23 #include "chrome/browser/chromeos/login/login_display_host.h"
22 #include "chrome/browser/chromeos/login/views_login_display.h" 24 #include "chrome/browser/chromeos/login/views_login_display.h"
23 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" 25 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
24 #include "chrome/browser/chromeos/login/wizard_controller.h" 26 #include "chrome/browser/chromeos/login/wizard_controller.h"
25 #include "chrome/browser/chromeos/status/status_area_view.h" 27 #include "chrome/browser/chromeos/status/status_area_view.h"
26 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
27 #include "chrome/browser/google/google_util.h" 28 #include "chrome/browser/google/google_util.h"
28 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
29 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
30 #include "chrome/browser/ui/views/window.h" 31 #include "chrome/browser/ui/views/window.h"
31 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/net/gaia/google_service_auth_error.h" 34 #include "chrome/common/net/gaia/google_service_auth_error.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
35 #include "content/common/content_notification_types.h" 36 #include "content/common/content_notification_types.h"
36 #include "content/common/notification_service.h" 37 #include "content/common/notification_service.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // static 71 // static
71 ExistingUserController* ExistingUserController::current_controller_ = NULL; 72 ExistingUserController* ExistingUserController::current_controller_ = NULL;
72 73
73 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
74 // ExistingUserController, public: 75 // ExistingUserController, public:
75 76
76 ExistingUserController::ExistingUserController(LoginDisplayHost* host) 77 ExistingUserController::ExistingUserController(LoginDisplayHost* host)
77 : login_status_consumer_(NULL), 78 : login_status_consumer_(NULL),
78 host_(host), 79 host_(host),
79 num_login_attempts_(0), 80 num_login_attempts_(0),
80 user_settings_(new UserCrosSettingsProvider), 81 user_settings_(CrosSettings::Get()),
81 method_factory_(this), 82 pointer_factory_(this),
82 is_owner_login_(false) { 83 is_owner_login_(false) {
83 DCHECK(current_controller_ == NULL); 84 DCHECK(current_controller_ == NULL);
84 current_controller_ = this; 85 current_controller_ = this;
85 86
86 login_display_ = host_->CreateLoginDisplay(this); 87 login_display_ = host_->CreateLoginDisplay(this);
87 88
88 registrar_.Add(this, 89 registrar_.Add(this,
89 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 90 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
90 NotificationService::AllSources()); 91 NotificationService::AllSources());
91 } 92 }
92 93
93 void ExistingUserController::Init(const UserVector& users) { 94 void ExistingUserController::Init(const UserVector& users) {
94 UserVector filtered_users; 95 UserVector filtered_users;
95 if (UserCrosSettingsProvider::cached_show_users_on_signin()) { 96 bool show_users_on_signin;
96 for (size_t i = 0; i < users.size(); ++i) 97
98 user_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
99 &show_users_on_signin);
Mattias Nissler (ping if slow) 2011/09/21 11:12:59 We have a long-standing bug about this value being
pastarmovj 2011/09/23 15:19:32 Actually CrosSettings supports observer interface
100 if (show_users_on_signin) {
101 bool allow_new_user = false;
102 const ListValue *user_list;
103 user_settings_->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
104 user_settings_->GetList(kAccountsPrefUsers, &user_list);
105 for (size_t i = 0; i < users.size(); ++i) {
97 // TODO(xiyuan): Clean user profile whose email is not in whitelist. 106 // TODO(xiyuan): Clean user profile whose email is not in whitelist.
98 if (UserCrosSettingsProvider::cached_allow_new_user() || 107 if (allow_new_user ||
99 UserCrosSettingsProvider::IsEmailInCachedWhitelist( 108 user_list->Find(StringValue(users[i].email())) != user_list->end()) {
100 users[i].email())) {
101 filtered_users.push_back(users[i]); 109 filtered_users.push_back(users[i]);
102 } 110 }
111 }
103 } 112 }
104 113
105 // If no user pods are visible, fallback to single new user pod which will 114 // If no user pods are visible, fallback to single new user pod which will
106 // have guest session link. 115 // have guest session link.
107 bool show_guest = UserCrosSettingsProvider::cached_allow_guest() && 116 bool show_guest;
108 !filtered_users.empty(); 117 user_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest);
118 show_guest &= !filtered_users.empty();
109 bool show_new_user = true; 119 bool show_new_user = true;
110 login_display_->set_parent_window(GetNativeWindow()); 120 login_display_->set_parent_window(GetNativeWindow());
111 login_display_->Init(filtered_users, show_guest, show_new_user); 121 login_display_->Init(filtered_users, show_guest, show_new_user);
112 122
113 LoginUtils::Get()->PrewarmAuthentication(); 123 LoginUtils::Get()->PrewarmAuthentication();
114 if (CrosLibrary::Get()->EnsureLoaded()) 124 if (CrosLibrary::Get()->EnsureLoaded())
115 CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); 125 CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady();
116 StartAutomaticFreeDiskSpaceControl(); 126 StartAutomaticFreeDiskSpaceControl();
117 } 127 }
118 128
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 false, true); 232 false, true);
223 } 233 }
224 234
225 void ExistingUserController::LoginAsGuest() { 235 void ExistingUserController::LoginAsGuest() {
226 SetStatusAreaEnabled(false); 236 SetStatusAreaEnabled(false);
227 // Disable clicking on other windows. 237 // Disable clicking on other windows.
228 login_display_->SetUIEnabled(false); 238 login_display_->SetUIEnabled(false);
229 239
230 // Check allow_guest in case this call is fired from key accelerator. 240 // Check allow_guest in case this call is fired from key accelerator.
231 // Must not proceed without signature verification. 241 // Must not proceed without signature verification.
232 bool trusted_setting_available = user_settings_->RequestTrustedAllowGuest( 242 bool trusted_setting_available = user_settings_->GetTrusted(
233 method_factory_.NewRunnableMethod( 243 kAccountsPrefAllowGuest,
234 &ExistingUserController::LoginAsGuest)); 244 base::Bind(&ExistingUserController::LoginAsGuest,
245 pointer_factory_.GetWeakPtr()));
Denis Lagno 2011/09/22 13:54:05 Are you really sure that this one still works as e
pastarmovj 2011/09/23 15:19:32 The Closure will take care of not calling run on a
235 if (!trusted_setting_available) { 246 if (!trusted_setting_available) {
236 // Value of AllowGuest setting is still not verified. 247 // Value of AllowGuest setting is still not verified.
237 // Another attempt will be invoked again after verification completion. 248 // Another attempt will be invoked again after verification completion.
238 return; 249 return;
239 } 250 }
240 if (!UserCrosSettingsProvider::cached_allow_guest()) { 251 bool allow_guest;
252 user_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
253 if (!allow_guest) {
241 // Disallowed. 254 // Disallowed.
242 return; 255 return;
243 } 256 }
244 257
245 // Only one instance of LoginPerformer should exist at a time. 258 // Only one instance of LoginPerformer should exist at a time.
246 login_performer_.reset(NULL); 259 login_performer_.reset(NULL);
247 login_performer_.reset(new LoginPerformer(this)); 260 login_performer_.reset(new LoginPerformer(this));
248 login_performer_->LoginOffTheRecord(); 261 login_performer_->LoginOffTheRecord();
249 WizardAccessibilityHelper::GetInstance()->MaybeSpeak( 262 WizardAccessibilityHelper::GetInstance()->MaybeSpeak(
250 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD).c_str(), 263 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD).c_str(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); 332 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error);
320 } else if ((active_network && active_network->restricted_pool()) || 333 } else if ((active_network && active_network->restricted_pool()) ||
321 (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && 334 (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED &&
322 failure.error().state() == 335 failure.error().state() ==
323 GoogleServiceAuthError::SERVICE_UNAVAILABLE)) { 336 GoogleServiceAuthError::SERVICE_UNAVAILABLE)) {
324 // Use explicit captive portal state (restricted_pool()) or implicit one. 337 // Use explicit captive portal state (restricted_pool()) or implicit one.
325 // SERVICE_UNAVAILABLE is generated in 2 cases: 338 // SERVICE_UNAVAILABLE is generated in 2 cases:
326 // 1. ClientLogin returns ServiceUnavailable code. 339 // 1. ClientLogin returns ServiceUnavailable code.
327 // 2. Internet connectivity may be behind the captive portal. 340 // 2. Internet connectivity may be behind the captive portal.
328 // Suggesting user to try sign in to a portal in Guest mode. 341 // Suggesting user to try sign in to a portal in Guest mode.
329 if (UserCrosSettingsProvider::cached_allow_guest()) 342 bool allow_guest;
343 user_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
344 if (allow_guest)
330 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL, error); 345 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL, error);
331 else 346 else
332 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL_NO_GUEST_MODE, error); 347 ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL_NO_GUEST_MODE, error);
333 } else { 348 } else {
334 if (!is_known_user) 349 if (!is_known_user)
335 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); 350 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error);
336 else 351 else
337 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 352 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
338 } 353 }
339 } 354 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 ActivateWizard(WizardController::kRegistrationScreenName); 472 ActivateWizard(WizardController::kRegistrationScreenName);
458 } 473 }
459 474
460 if (login_status_consumer_) 475 if (login_status_consumer_)
461 login_status_consumer_->OnOffTheRecordLoginSuccess(); 476 login_status_consumer_->OnOffTheRecordLoginSuccess();
462 } 477 }
463 478
464 void ExistingUserController::OnPasswordChangeDetected( 479 void ExistingUserController::OnPasswordChangeDetected(
465 const GaiaAuthConsumer::ClientLoginResult& credentials) { 480 const GaiaAuthConsumer::ClientLoginResult& credentials) {
466 // Must not proceed without signature verification. 481 // Must not proceed without signature verification.
467 bool trusted_setting_available = user_settings_->RequestTrustedOwner( 482 bool trusted_setting_available = user_settings_->GetTrusted(
468 method_factory_.NewRunnableMethod( 483 kDeviceOwner,
469 &ExistingUserController::OnPasswordChangeDetected, 484 base::Bind(&ExistingUserController::OnPasswordChangeDetected,
470 credentials)); 485 pointer_factory_.GetWeakPtr(),
486 credentials));
471 if (!trusted_setting_available) { 487 if (!trusted_setting_available) {
472 // Value of owner email is still not verified. 488 // Value of owner email is still not verified.
473 // Another attempt will be invoked after verification completion. 489 // Another attempt will be invoked after verification completion.
474 return; 490 return;
475 } 491 }
476 492
477 // Passing 'false' here enables "full sync" mode in the dialog, 493 // Passing 'false' here enables "full sync" mode in the dialog,
478 // which disables the requirement for the old owner password, 494 // which disables the requirement for the old owner password,
479 // allowing us to recover from a lost owner password/homedir. 495 // allowing us to recover from a lost owner password/homedir.
480 // TODO(gspencer): We shouldn't have to erase stateful data when 496 // TODO(gspencer): We shouldn't have to erase stateful data when
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 help_topic_id = login_performer_->login_timed_out() ? 579 help_topic_id = login_performer_->login_timed_out() ?
564 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : 580 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE :
565 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; 581 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT;
566 break; 582 break;
567 } 583 }
568 584
569 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); 585 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id);
570 } 586 }
571 587
572 void ExistingUserController::StartAutomaticFreeDiskSpaceControl() { 588 void ExistingUserController::StartAutomaticFreeDiskSpaceControl() {
573 bool trusted_owner_available = user_settings_->RequestTrustedOwner( 589 bool trusted_owner_available = user_settings_->GetTrusted(
574 method_factory_.NewRunnableMethod( 590 kDeviceOwner,
575 &ExistingUserController::StartAutomaticFreeDiskSpaceControl)); 591 base::Bind(&ExistingUserController::StartAutomaticFreeDiskSpaceControl,
592 pointer_factory_.GetWeakPtr()));
576 if (!trusted_owner_available) { 593 if (!trusted_owner_available) {
577 // Value of owner email is still not verified. 594 // Value of owner email is still not verified.
578 // Another attempt will be invoked after verification completion. 595 // Another attempt will be invoked after verification completion.
579 return; 596 return;
580 } 597 }
581 if (CrosLibrary::Get()->EnsureLoaded()) { 598 if (CrosLibrary::Get()->EnsureLoaded()) {
582 CryptohomeLibrary* cryptohomed = CrosLibrary::Get()->GetCryptohomeLibrary(); 599 CryptohomeLibrary* cryptohomed = CrosLibrary::Get()->GetCryptohomeLibrary();
583 cryptohomed->AsyncSetOwnerUser( 600 std::string owner;
584 UserCrosSettingsProvider::cached_owner(), NULL); 601 user_settings_->GetString(kDeviceOwner, &owner);
602 cryptohomed->AsyncSetOwnerUser(owner, NULL);
585 cryptohomed->AsyncDoAutomaticFreeDiskSpaceControl(NULL); 603 cryptohomed->AsyncDoAutomaticFreeDiskSpaceControl(NULL);
586 } 604 }
587 } 605 }
588 606
589 } // namespace chromeos 607 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698