| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login_screen.h" | 5 #include "chrome/browser/chromeos/login/login_screen.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
| 16 #include "chrome/browser/chromeos/boot_times_loader.h" | 16 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 17 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 18 #include "chrome/browser/chromeos/cros/network_library.h" | 18 #include "chrome/browser/chromeos/cros/network_library.h" |
| 19 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 19 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
| 20 #include "chrome/browser/chromeos/login/helper.h" |
| 20 #include "chrome/browser/chromeos/login/login_utils.h" | 21 #include "chrome/browser/chromeos/login/login_utils.h" |
| 21 #include "chrome/browser/chromeos/login/message_bubble.h" | 22 #include "chrome/browser/chromeos/login/message_bubble.h" |
| 22 #include "chrome/browser/chromeos/login/screen_observer.h" | 23 #include "chrome/browser/chromeos/login/screen_observer.h" |
| 23 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
| 24 #include "chrome/browser/profile_manager.h" | 25 #include "chrome/browser/profile_manager.h" |
| 25 #include "chrome/common/notification_service.h" | 26 #include "chrome/common/notification_service.h" |
| 26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 28 | 29 |
| 29 namespace chromeos { | 30 namespace chromeos { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 LOG(INFO) << "LoginManagerView: OnLoginFailure() " << error; | 80 LOG(INFO) << "LoginManagerView: OnLoginFailure() " << error; |
| 80 NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary(); | 81 NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary(); |
| 81 | 82 |
| 82 // Check networking after trying to login in case user is | 83 // Check networking after trying to login in case user is |
| 83 // cached locally or the local admin account. | 84 // cached locally or the local admin account. |
| 84 if (!network || !CrosLibrary::Get()->EnsureLoaded()) { | 85 if (!network || !CrosLibrary::Get()->EnsureLoaded()) { |
| 85 ShowError(IDS_LOGIN_ERROR_NO_NETWORK_LIBRARY, error); | 86 ShowError(IDS_LOGIN_ERROR_NO_NETWORK_LIBRARY, error); |
| 86 } else if (!network->Connected()) { | 87 } else if (!network->Connected()) { |
| 87 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); | 88 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); |
| 88 } else { | 89 } else { |
| 89 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 90 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
| 90 } | 91 } |
| 91 | 92 |
| 92 view()->ClearAndEnablePassword(); | 93 view()->ClearAndEnablePassword(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void LoginScreen::OnLoginSuccess(const std::string& username, | 96 void LoginScreen::OnLoginSuccess(const std::string& username, |
| 96 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 97 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| 97 | 98 |
| 98 delegate()->GetObserver(this)->OnExit(ScreenObserver::LOGIN_SIGN_IN_SELECTED); | 99 delegate()->GetObserver(this)->OnExit(ScreenObserver::LOGIN_SIGN_IN_SELECTED); |
| 99 AppendStartUrlToCmdline(); | 100 AppendStartUrlToCmdline(); |
| 100 LoginUtils::Get()->CompleteLogin(username, credentials); | 101 LoginUtils::Get()->CompleteLogin(username, credentials); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void LoginScreen::OnOffTheRecordLoginSuccess() { | 104 void LoginScreen::OnOffTheRecordLoginSuccess() { |
| 104 delegate()->GetObserver(this)->OnExit(ScreenObserver::LOGIN_GUEST_SELECTED); | 105 delegate()->GetObserver(this)->OnExit(ScreenObserver::LOGIN_GUEST_SELECTED); |
| 105 LoginUtils::Get()->CompleteOffTheRecordLogin(start_url_); | 106 LoginUtils::Get()->CompleteOffTheRecordLogin(start_url_); |
| 106 } | 107 } |
| 107 | 108 |
| 109 void LoginScreen::OnHelpLinkActivated() { |
| 110 AddStartUrl(GetAccountRecoveryHelpUrl()); |
| 111 OnLoginOffTheRecord(); |
| 112 } |
| 113 |
| 108 void LoginScreen::AppendStartUrlToCmdline() { | 114 void LoginScreen::AppendStartUrlToCmdline() { |
| 109 if (start_url_.is_valid()) | 115 if (start_url_.is_valid()) |
| 110 CommandLine::ForCurrentProcess()->AppendArg(start_url_.spec()); | 116 CommandLine::ForCurrentProcess()->AppendArg(start_url_.spec()); |
| 111 } | 117 } |
| 112 | 118 |
| 113 void LoginScreen::ShowError(int error_id, const std::string& details) { | 119 void LoginScreen::ShowError(int error_id, const std::string& details) { |
| 114 ClearErrors(); | 120 ClearErrors(); |
| 115 std::wstring error_text = l10n_util::GetString(error_id); | 121 std::wstring error_text = l10n_util::GetString(error_id); |
| 116 // TODO(dpolukhin): show detailed error info. |details| string contains | 122 // TODO(dpolukhin): show detailed error info. |details| string contains |
| 117 // low level error info that is not localized and even is not user friendly. | 123 // low level error info that is not localized and even is not user friendly. |
| 118 // For now just ignore it because error_text contains all required information | 124 // For now just ignore it because error_text contains all required information |
| 119 // for end users, developers can see details string in Chrome logs. | 125 // for end users, developers can see details string in Chrome logs. |
| 120 bubble_ = MessageBubble::Show( | 126 bubble_ = MessageBubble::Show( |
| 121 view()->GetWidget(), | 127 view()->GetWidget(), |
| 122 view()->GetPasswordBounds(), | 128 view()->GetPasswordBounds(), |
| 123 BubbleBorder::LEFT_TOP, | 129 BubbleBorder::LEFT_TOP, |
| 124 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING), | 130 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING), |
| 125 error_text, | 131 error_text, |
| 132 l10n_util::GetString(IDS_CANT_ACCESS_ACCOUNT_BUTTON), |
| 126 this); | 133 this); |
| 127 } | 134 } |
| 128 | 135 |
| 129 } // namespace chromeos | 136 } // namespace chromeos |
| OLD | NEW |