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" |
| 11 #include "chrome/browser/signin/account_tracker_service_factory.h" |
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
12 #include "chrome/browser/signin/signin_global_error.h" | 13 #include "chrome/browser/signin/signin_global_error.h" |
13 #include "chrome/browser/signin/signin_global_error_factory.h" | 14 #include "chrome/browser/signin/signin_global_error_factory.h" |
14 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
15 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
17 #include "chrome/browser/sync/sync_global_error.h" | 18 #include "chrome/browser/sync/sync_global_error.h" |
18 #include "chrome/browser/sync/sync_global_error_factory.h" | 19 #include "chrome/browser/sync/sync_global_error_factory.h" |
19 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 24 #include "components/signin/core/browser/account_tracker_service.h" |
23 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 25 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
24 #include "components/signin/core/browser/signin_manager.h" | 26 #include "components/signin/core/browser/signin_manager.h" |
25 #include "components/signin/core/common/profile_management_switches.h" | 27 #include "components/signin/core/common/profile_management_switches.h" |
26 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/gfx/font_list.h" | 29 #include "ui/gfx/font_list.h" |
28 #include "ui/gfx/text_elider.h" | 30 #include "ui/gfx/text_elider.h" |
29 | 31 |
30 namespace { | 32 namespace { |
31 // Maximum width of a username - we trim emails that are wider than this so | 33 // Maximum width of a username - we trim emails that are wider than this so |
32 // the wrench menu doesn't get ridiculously wide. | 34 // the wrench menu doesn't get ridiculously wide. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 169 |
168 void ShowSigninErrorLearnMorePage(Profile* profile) { | 170 void ShowSigninErrorLearnMorePage(Profile* profile) { |
169 static const char kSigninErrorLearnMoreUrl[] = | 171 static const char kSigninErrorLearnMoreUrl[] = |
170 "https://support.google.com/chrome/answer/1181420?"; | 172 "https://support.google.com/chrome/answer/1181420?"; |
171 chrome::NavigateParams params( | 173 chrome::NavigateParams params( |
172 profile, GURL(kSigninErrorLearnMoreUrl), content::PAGE_TRANSITION_LINK); | 174 profile, GURL(kSigninErrorLearnMoreUrl), content::PAGE_TRANSITION_LINK); |
173 params.disposition = NEW_FOREGROUND_TAB; | 175 params.disposition = NEW_FOREGROUND_TAB; |
174 chrome::Navigate(¶ms); | 176 chrome::Navigate(¶ms); |
175 } | 177 } |
176 | 178 |
| 179 std::string GetDisplayEmail(Profile* profile, const std::string& account_id) { |
| 180 AccountTrackerService* account_tracker = |
| 181 AccountTrackerServiceFactory::GetForProfile(profile); |
| 182 std::string email = account_tracker->GetAccountInfo(account_id).email; |
| 183 if (email.empty()) { |
| 184 DCHECK_EQ(AccountTrackerService::MIGRATION_NOT_STARTED, |
| 185 account_tracker->GetMigrationState()); |
| 186 return account_id; |
| 187 } |
| 188 return email; |
| 189 } |
| 190 |
177 } // namespace signin_ui_util | 191 } // namespace signin_ui_util |
OLD | NEW |