| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/signin/signin_ui_util.h" | 5 #include "chrome/browser/signin/signin_ui_util.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, | 95 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, |
| 96 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 96 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Given an authentication state this helper function returns various labels | 99 // Given an authentication state this helper function returns various labels |
| 100 // that can be used to display information about the state. | 100 // that can be used to display information about the state. |
| 101 void GetStatusLabelsForAuthError(Profile* profile, | 101 void GetStatusLabelsForAuthError(Profile* profile, |
| 102 const SigninManagerBase& signin_manager, | 102 const SigninManagerBase& signin_manager, |
| 103 base::string16* status_label, | 103 base::string16* status_label, |
| 104 base::string16* link_label) { | 104 base::string16* link_label) { |
| 105 base::string16 username = | |
| 106 base::UTF8ToUTF16(signin_manager.GetAuthenticatedUsername()); | |
| 107 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 105 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
| 108 if (link_label) | 106 if (link_label) |
| 109 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL)); | 107 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL)); |
| 110 | 108 |
| 111 const GoogleServiceAuthError::State state = | 109 const GoogleServiceAuthError::State state = |
| 112 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | 110 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 113 signin_error_controller()->auth_error().state(); | 111 signin_error_controller()->auth_error().state(); |
| 114 switch (state) { | 112 switch (state) { |
| 115 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 113 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
| 116 case GoogleServiceAuthError::SERVICE_ERROR: | 114 case GoogleServiceAuthError::SERVICE_ERROR: |
| 117 case GoogleServiceAuthError::ACCOUNT_DELETED: | 115 case GoogleServiceAuthError::ACCOUNT_DELETED: |
| 118 case GoogleServiceAuthError::ACCOUNT_DISABLED: | 116 case GoogleServiceAuthError::ACCOUNT_DISABLED: |
| 119 // If the user name is empty then the first login failed, otherwise the | 117 // If the user name is empty then the first login failed, otherwise the |
| 120 // credentials are out-of-date. | 118 // credentials are out-of-date. |
| 121 if (username.empty()) { | 119 if (!signin_manager.IsAuthenticated()) { |
| 122 if (status_label) { | 120 if (status_label) { |
| 123 status_label->assign( | 121 status_label->assign( |
| 124 l10n_util::GetStringUTF16(IDS_SYNC_INVALID_USER_CREDENTIALS)); | 122 l10n_util::GetStringUTF16(IDS_SYNC_INVALID_USER_CREDENTIALS)); |
| 125 } | 123 } |
| 126 } else { | 124 } else { |
| 127 if (status_label) { | 125 if (status_label) { |
| 128 status_label->assign( | 126 status_label->assign( |
| 129 l10n_util::GetStringUTF16(IDS_SYNC_LOGIN_INFO_OUT_OF_DATE)); | 127 l10n_util::GetStringUTF16(IDS_SYNC_LOGIN_INFO_OUT_OF_DATE)); |
| 130 } | 128 } |
| 131 } | 129 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 std::string email = account_tracker->GetAccountInfo(account_id).email; | 180 std::string email = account_tracker->GetAccountInfo(account_id).email; |
| 183 if (email.empty()) { | 181 if (email.empty()) { |
| 184 DCHECK_EQ(AccountTrackerService::MIGRATION_NOT_STARTED, | 182 DCHECK_EQ(AccountTrackerService::MIGRATION_NOT_STARTED, |
| 185 account_tracker->GetMigrationState()); | 183 account_tracker->GetMigrationState()); |
| 186 return account_id; | 184 return account_id; |
| 187 } | 185 } |
| 188 return email; | 186 return email; |
| 189 } | 187 } |
| 190 | 188 |
| 191 } // namespace signin_ui_util | 189 } // namespace signin_ui_util |
| OLD | NEW |