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/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // Even if the user is signed in, don't display the "signed in as..." | 75 // Even if the user is signed in, don't display the "signed in as..." |
76 // label if we're still setting up sync. | 76 // label if we're still setting up sync. |
77 if (!service || !service->FirstSetupInProgress()) { | 77 if (!service || !service->FirstSetupInProgress()) { |
78 std::string username; | 78 std::string username; |
79 SigninManagerBase* signin_manager = | 79 SigninManagerBase* signin_manager = |
80 SigninManagerFactory::GetForProfileIfExists(profile); | 80 SigninManagerFactory::GetForProfileIfExists(profile); |
81 if (signin_manager) | 81 if (signin_manager) |
82 username = signin_manager->GetAuthenticatedUsername(); | 82 username = signin_manager->GetAuthenticatedUsername(); |
83 if (!username.empty() && !signin_manager->AuthInProgress()) { | 83 if (!username.empty() && !signin_manager->AuthInProgress()) { |
84 base::string16 elided_username = gfx::ElideEmail( | 84 const base::string16 elided = gfx::ElideText(base::UTF8ToUTF16(username), |
85 base::UTF8ToUTF16(username), gfx::FontList(), kUsernameMaxWidth); | 85 gfx::FontList(), kUsernameMaxWidth, gfx::ELIDE_EMAIL); |
86 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, | 86 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, elided); |
87 elided_username); | |
88 } | 87 } |
89 } | 88 } |
90 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, | 89 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, |
91 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 90 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
92 } | 91 } |
93 | 92 |
94 // Given an authentication state this helper function returns various labels | 93 // Given an authentication state this helper function returns various labels |
95 // that can be used to display information about the state. | 94 // that can be used to display information about the state. |
96 void GetStatusLabelsForAuthError(Profile* profile, | 95 void GetStatusLabelsForAuthError(Profile* profile, |
97 const SigninManagerBase& signin_manager, | 96 const SigninManagerBase& signin_manager, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 default: | 147 default: |
149 if (status_label) { | 148 if (status_label) { |
150 status_label->assign(l10n_util::GetStringUTF16( | 149 status_label->assign(l10n_util::GetStringUTF16( |
151 IDS_SYNC_ERROR_SIGNING_IN)); | 150 IDS_SYNC_ERROR_SIGNING_IN)); |
152 } | 151 } |
153 break; | 152 break; |
154 } | 153 } |
155 } | 154 } |
156 | 155 |
157 } // namespace signin_ui_util | 156 } // namespace signin_ui_util |
OLD | NEW |