| 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" |
| 11 #include "chrome/browser/signin/signin_manager.h" | 11 #include "chrome/browser/signin/signin_manager.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
| 14 #include "chrome/browser/sync/profile_sync_service_factory.h" | 14 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 15 #include "chrome/browser/sync/sync_global_error.h" | 15 #include "chrome/browser/sync/sync_global_error.h" |
| 16 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/text/text_elider.h" | |
| 20 #include "ui/gfx/font.h" | 19 #include "ui/gfx/font.h" |
| 20 #include "ui/gfx/text_elider.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 // Maximum width of a username - we trim emails that are wider than this so | 23 // Maximum width of a username - we trim emails that are wider than this so |
| 24 // the wrench menu doesn't get ridiculously wide. | 24 // the wrench menu doesn't get ridiculously wide. |
| 25 const int kUsernameMaxWidth = 200; | 25 const int kUsernameMaxWidth = 200; |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 namespace signin_ui_util { | 28 namespace signin_ui_util { |
| 29 | 29 |
| 30 GlobalError* GetSignedInServiceError(Profile* profile) { | 30 GlobalError* GetSignedInServiceError(Profile* profile) { |
| (...skipping 37 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 string16 elided_username = ui::ElideEmail(UTF8ToUTF16(username), | 78 string16 elided_username = gfx::ElideEmail(UTF8ToUTF16(username), |
| 79 gfx::Font(), | 79 gfx::Font(), |
| 80 kUsernameMaxWidth); | 80 kUsernameMaxWidth); |
| 81 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, | 81 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, |
| 82 elided_username); | 82 elided_username); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, | 85 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, |
| 86 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 86 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 87 } | 87 } |
| 88 | 88 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 default: | 140 default: |
| 141 if (status_label) { | 141 if (status_label) { |
| 142 status_label->assign(l10n_util::GetStringUTF16( | 142 status_label->assign(l10n_util::GetStringUTF16( |
| 143 IDS_SYNC_ERROR_SIGNING_IN)); | 143 IDS_SYNC_ERROR_SIGNING_IN)); |
| 144 } | 144 } |
| 145 break; | 145 break; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace signin_ui_util | 149 } // namespace signin_ui_util |
| OLD | NEW |