| 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/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/signin_global_error.h" | 10 #include "chrome/browser/signin/signin_global_error.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // Even if the user is signed in, don't display the "signed in as..." | 69 // Even if the user is signed in, don't display the "signed in as..." |
| 70 // label if we're still setting up sync. | 70 // label if we're still setting up sync. |
| 71 if (!service || !service->FirstSetupInProgress()) { | 71 if (!service || !service->FirstSetupInProgress()) { |
| 72 std::string username; | 72 std::string username; |
| 73 SigninManagerBase* signin_manager = | 73 SigninManagerBase* signin_manager = |
| 74 SigninManagerFactory::GetForProfileIfExists(profile); | 74 SigninManagerFactory::GetForProfileIfExists(profile); |
| 75 if (signin_manager) | 75 if (signin_manager) |
| 76 username = signin_manager->GetAuthenticatedUsername(); | 76 username = signin_manager->GetAuthenticatedUsername(); |
| 77 if (!username.empty() && !signin_manager->AuthInProgress()) { | 77 if (!username.empty() && !signin_manager->AuthInProgress()) { |
| 78 base::string16 elided_username = gfx::ElideEmail(UTF8ToUTF16(username), | 78 base::string16 elided_username = gfx::ElideEmail( |
| 79 gfx::FontList(), | 79 base::UTF8ToUTF16(username), gfx::FontList(), kUsernameMaxWidth); |
| 80 kUsernameMaxWidth); | |
| 81 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, | 80 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, |
| 82 elided_username); | 81 elided_username); |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, | 84 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, |
| 86 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 85 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 87 } | 86 } |
| 88 | 87 |
| 89 // Given an authentication state this helper function returns various labels | 88 // Given an authentication state this helper function returns various labels |
| 90 // that can be used to display information about the state. | 89 // that can be used to display information about the state. |
| 91 void GetStatusLabelsForAuthError(Profile* profile, | 90 void GetStatusLabelsForAuthError(Profile* profile, |
| 92 const SigninManagerBase& signin_manager, | 91 const SigninManagerBase& signin_manager, |
| 93 base::string16* status_label, | 92 base::string16* status_label, |
| 94 base::string16* link_label) { | 93 base::string16* link_label) { |
| 95 base::string16 username = | 94 base::string16 username = |
| 96 UTF8ToUTF16(signin_manager.GetAuthenticatedUsername()); | 95 base::UTF8ToUTF16(signin_manager.GetAuthenticatedUsername()); |
| 97 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 96 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
| 98 if (link_label) | 97 if (link_label) |
| 99 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL)); | 98 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL)); |
| 100 | 99 |
| 101 const GoogleServiceAuthError::State state = | 100 const GoogleServiceAuthError::State state = |
| 102 SigninGlobalError::GetForProfile(profile)->GetLastAuthError().state(); | 101 SigninGlobalError::GetForProfile(profile)->GetLastAuthError().state(); |
| 103 switch (state) { | 102 switch (state) { |
| 104 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 103 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
| 105 case GoogleServiceAuthError::SERVICE_ERROR: | 104 case GoogleServiceAuthError::SERVICE_ERROR: |
| 106 case GoogleServiceAuthError::ACCOUNT_DELETED: | 105 case GoogleServiceAuthError::ACCOUNT_DELETED: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 default: | 141 default: |
| 143 if (status_label) { | 142 if (status_label) { |
| 144 status_label->assign(l10n_util::GetStringUTF16( | 143 status_label->assign(l10n_util::GetStringUTF16( |
| 145 IDS_SYNC_ERROR_SIGNING_IN)); | 144 IDS_SYNC_ERROR_SIGNING_IN)); |
| 146 } | 145 } |
| 147 break; | 146 break; |
| 148 } | 147 } |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace signin_ui_util | 150 } // namespace signin_ui_util |
| OLD | NEW |