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

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

Issue 22264004: Remove ConnectivityStateHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove redundant IsConnected() check Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 25 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
26 #include "chrome/browser/chromeos/boot_times_loader.h" 26 #include "chrome/browser/chromeos/boot_times_loader.h"
27 #include "chrome/browser/chromeos/customization_document.h" 27 #include "chrome/browser/chromeos/customization_document.h"
28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
29 #include "chrome/browser/chromeos/login/helper.h" 29 #include "chrome/browser/chromeos/login/helper.h"
30 #include "chrome/browser/chromeos/login/login_display_host.h" 30 #include "chrome/browser/chromeos/login/login_display_host.h"
31 #include "chrome/browser/chromeos/login/login_utils.h" 31 #include "chrome/browser/chromeos/login/login_utils.h"
32 #include "chrome/browser/chromeos/login/startup_utils.h" 32 #include "chrome/browser/chromeos/login/startup_utils.h"
33 #include "chrome/browser/chromeos/login/user_manager.h" 33 #include "chrome/browser/chromeos/login/user_manager.h"
34 #include "chrome/browser/chromeos/login/wizard_controller.h" 34 #include "chrome/browser/chromeos/login/wizard_controller.h"
35 #include "chrome/browser/chromeos/net/connectivity_state_helper.h"
36 #include "chrome/browser/chromeos/policy/device_local_account.h" 35 #include "chrome/browser/chromeos/policy/device_local_account.h"
37 #include "chrome/browser/chromeos/profiles/profile_helper.h" 36 #include "chrome/browser/chromeos/profiles/profile_helper.h"
38 #include "chrome/browser/chromeos/settings/cros_settings.h" 37 #include "chrome/browser/chromeos/settings/cros_settings.h"
39 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 38 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
40 #include "chrome/browser/chromeos/system/statistics_provider.h" 39 #include "chrome/browser/chromeos/system/statistics_provider.h"
41 #include "chrome/browser/google/google_util.h" 40 #include "chrome/browser/google/google_util.h"
42 #include "chrome/browser/policy/policy_service.h" 41 #include "chrome/browser/policy/policy_service.h"
43 #include "chrome/browser/prefs/session_startup_pref.h" 42 #include "chrome/browser/prefs/session_startup_pref.h"
44 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
45 #include "chrome/common/chrome_version_info.h" 44 #include "chrome/common/chrome_version_info.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 : login_status_consumer_(NULL), 127 : login_status_consumer_(NULL),
129 host_(host), 128 host_(host),
130 login_display_(host_->CreateLoginDisplay(this)), 129 login_display_(host_->CreateLoginDisplay(this)),
131 num_login_attempts_(0), 130 num_login_attempts_(0),
132 cros_settings_(CrosSettings::Get()), 131 cros_settings_(CrosSettings::Get()),
133 weak_factory_(this), 132 weak_factory_(this),
134 offline_failed_(false), 133 offline_failed_(false),
135 is_login_in_progress_(false), 134 is_login_in_progress_(false),
136 password_changed_(false), 135 password_changed_(false),
137 do_auto_enrollment_(false), 136 do_auto_enrollment_(false),
138 signin_screen_ready_(false) { 137 signin_screen_ready_(false),
138 network_state_helper_(new login::NetworkStateHelper) {
139 DCHECK(current_controller_ == NULL); 139 DCHECK(current_controller_ == NULL);
140 current_controller_ = this; 140 current_controller_ = this;
141 141
142 registrar_.Add(this, 142 registrar_.Add(this,
143 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 143 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
144 content::NotificationService::AllSources()); 144 content::NotificationService::AllSources());
145 registrar_.Add(this, 145 registrar_.Add(this,
146 chrome::NOTIFICATION_USER_LIST_CHANGED, 146 chrome::NOTIFICATION_USER_LIST_CHANGED,
147 content::NotificationService::AllSources()); 147 content::NotificationService::AllSources());
148 registrar_.Add(this, 148 registrar_.Add(this,
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // Enable UI for the enrollment screen. SetUIEnabled(true) will post a 381 // Enable UI for the enrollment screen. SetUIEnabled(true) will post a
382 // request to show the sign-in screen again when invoked at the sign-in 382 // request to show the sign-in screen again when invoked at the sign-in
383 // screen; invoke SetUIEnabled() after navigating to the enrollment screen. 383 // screen; invoke SetUIEnabled() after navigating to the enrollment screen.
384 login_display_->SetUIEnabled(true); 384 login_display_->SetUIEnabled(true);
385 } else { 385 } else {
386 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); 386 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION);
387 } 387 }
388 } 388 }
389 389
390 string16 ExistingUserController::GetConnectedNetworkName() { 390 string16 ExistingUserController::GetConnectedNetworkName() {
391 return GetCurrentNetworkName(); 391 return network_state_helper_->GetCurrentNetworkName();
392 } 392 }
393 393
394 bool ExistingUserController::IsSigninInProgress() const { 394 bool ExistingUserController::IsSigninInProgress() const {
395 return is_login_in_progress_; 395 return is_login_in_progress_;
396 } 396 }
397 397
398 void ExistingUserController::Login(const UserContext& user_context) { 398 void ExistingUserController::Login(const UserContext& user_context) {
399 if ((user_context.username.empty() || user_context.password.empty()) && 399 if ((user_context.username.empty() || user_context.password.empty()) &&
400 user_context.auth_code.empty()) 400 user_context.auth_code.empty())
401 return; 401 return;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); 729 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs));
730 } else if (failure.reason() == LoginFailure::TPM_ERROR) { 730 } else if (failure.reason() == LoginFailure::TPM_ERROR) {
731 ShowTPMError(); 731 ShowTPMError();
732 } else if (!online_succeeded_for_.empty()) { 732 } else if (!online_succeeded_for_.empty()) {
733 ShowGaiaPasswordChanged(online_succeeded_for_); 733 ShowGaiaPasswordChanged(online_succeeded_for_);
734 } else { 734 } else {
735 // Check networking after trying to login in case user is 735 // Check networking after trying to login in case user is
736 // cached locally or the local admin account. 736 // cached locally or the local admin account.
737 bool is_known_user = 737 bool is_known_user =
738 UserManager::Get()->IsKnownUser(last_login_attempt_username_); 738 UserManager::Get()->IsKnownUser(last_login_attempt_username_);
739 if (!ConnectivityStateHelper::Get()->IsConnected()) { 739 if (!network_state_helper_->IsConnected()) {
740 if (is_known_user) 740 if (is_known_user)
741 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 741 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
742 else 742 else
743 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); 743 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error);
744 } else { 744 } else {
745 // TODO(nkostylev): Cleanup rest of ClientLogin related code. 745 // TODO(nkostylev): Cleanup rest of ClientLogin related code.
746 if (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && 746 if (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED &&
747 failure.error().state() == 747 failure.error().state() ==
748 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { 748 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) {
749 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); 749 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 } 1085 }
1086 1086
1087 void ExistingUserController::ShowError(int error_id, 1087 void ExistingUserController::ShowError(int error_id,
1088 const std::string& details) { 1088 const std::string& details) {
1089 // TODO(dpolukhin): show detailed error info. |details| string contains 1089 // TODO(dpolukhin): show detailed error info. |details| string contains
1090 // low level error info that is not localized and even is not user friendly. 1090 // low level error info that is not localized and even is not user friendly.
1091 // For now just ignore it because error_text contains all required information 1091 // For now just ignore it because error_text contains all required information
1092 // for end users, developers can see details string in Chrome logs. 1092 // for end users, developers can see details string in Chrome logs.
1093 VLOG(1) << details; 1093 VLOG(1) << details;
1094 HelpAppLauncher::HelpTopic help_topic_id; 1094 HelpAppLauncher::HelpTopic help_topic_id;
1095 bool is_offline = !ConnectivityStateHelper::Get()->IsConnected(); 1095 bool is_offline = !network_state_helper_->IsConnected();
1096 switch (login_performer_->error().state()) { 1096 switch (login_performer_->error().state()) {
1097 case GoogleServiceAuthError::CONNECTION_FAILED: 1097 case GoogleServiceAuthError::CONNECTION_FAILED:
1098 help_topic_id = HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE; 1098 help_topic_id = HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE;
1099 break; 1099 break;
1100 case GoogleServiceAuthError::ACCOUNT_DISABLED: 1100 case GoogleServiceAuthError::ACCOUNT_DISABLED:
1101 help_topic_id = HelpAppLauncher::HELP_ACCOUNT_DISABLED; 1101 help_topic_id = HelpAppLauncher::HELP_ACCOUNT_DISABLED;
1102 break; 1102 break;
1103 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: 1103 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED:
1104 help_topic_id = HelpAppLauncher::HELP_HOSTED_ACCOUNT; 1104 help_topic_id = HelpAppLauncher::HELP_HOSTED_ACCOUNT;
1105 break; 1105 break;
(...skipping 13 matching lines...) Expand all
1119 // changed. 1119 // changed.
1120 UserManager::Get()->SaveUserOAuthStatus( 1120 UserManager::Get()->SaveUserOAuthStatus(
1121 username, 1121 username,
1122 User::OAUTH2_TOKEN_STATUS_INVALID); 1122 User::OAUTH2_TOKEN_STATUS_INVALID);
1123 1123
1124 login_display_->SetUIEnabled(true); 1124 login_display_->SetUIEnabled(true);
1125 login_display_->ShowGaiaPasswordChanged(username); 1125 login_display_->ShowGaiaPasswordChanged(username);
1126 } 1126 }
1127 1127
1128 } // namespace chromeos 1128 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | chrome/browser/chromeos/login/helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698