Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/signin/signin_ui_util.cc

Issue 12502017: signin: pull basic SigninManager functionality into new SigninManagerBase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deal with new enterprise_platform_keys_private_api Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/signin/signin_ui_util.h ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/utf_string_conversions.h" 8 #include "base/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 12 matching lines...) Expand all
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) {
31 // Auth errors have the highest priority - after that, individual service 31 // Auth errors have the highest priority - after that, individual service
32 // errors. 32 // errors.
33 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); 33 SigninManagerBase* signin_manager =
34 SigninManagerFactory::GetForProfile(profile);
34 SigninGlobalError* signin_error = signin_manager->signin_global_error(); 35 SigninGlobalError* signin_error = signin_manager->signin_global_error();
35 if (signin_error && signin_error->HasMenuItem()) 36 if (signin_error && signin_error->HasMenuItem())
36 return signin_error; 37 return signin_error;
37 38
38 // No auth error - now try other services. Currently the list is just hard- 39 // No auth error - now try other services. Currently the list is just hard-
39 // coded but in the future if we add more we can create some kind of 40 // coded but in the future if we add more we can create some kind of
40 // registration framework. 41 // registration framework.
41 if (profile->IsSyncAccessible()) { 42 if (profile->IsSyncAccessible()) {
42 ProfileSyncService* service = 43 ProfileSyncService* service =
43 ProfileSyncServiceFactory::GetForProfile(profile); 44 ProfileSyncServiceFactory::GetForProfile(profile);
(...skipping 10 matching lines...) Expand all
54 return error->MenuItemLabel(); 55 return error->MenuItemLabel();
55 56
56 // No errors, so just display the signed in user, if any. 57 // No errors, so just display the signed in user, if any.
57 ProfileSyncService* service = profile->IsSyncAccessible() ? 58 ProfileSyncService* service = profile->IsSyncAccessible() ?
58 ProfileSyncServiceFactory::GetForProfile(profile) : NULL; 59 ProfileSyncServiceFactory::GetForProfile(profile) : NULL;
59 60
60 // Even if the user is signed in, don't display the "signed in as..." 61 // Even if the user is signed in, don't display the "signed in as..."
61 // label if we're still setting up sync. 62 // label if we're still setting up sync.
62 if (!service || !service->FirstSetupInProgress()) { 63 if (!service || !service->FirstSetupInProgress()) {
63 std::string username; 64 std::string username;
64 SigninManager* signin_manager = 65 SigninManagerBase* signin_manager =
65 SigninManagerFactory::GetForProfileIfExists(profile); 66 SigninManagerFactory::GetForProfileIfExists(profile);
66 if (signin_manager) 67 if (signin_manager)
67 username = signin_manager->GetAuthenticatedUsername(); 68 username = signin_manager->GetAuthenticatedUsername();
68 if (!username.empty() && !signin_manager->AuthInProgress()) { 69 if (!username.empty() && !signin_manager->AuthInProgress()) {
69 string16 elided_username = ui::ElideEmail(UTF8ToUTF16(username), 70 string16 elided_username = ui::ElideEmail(UTF8ToUTF16(username),
70 gfx::Font(), 71 gfx::Font(),
71 kUsernameMaxWidth); 72 kUsernameMaxWidth);
72 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, 73 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL,
73 elided_username); 74 elided_username);
74 } 75 }
75 } 76 }
76 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, 77 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL,
77 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); 78 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
78 } 79 }
79 80
80 // Given an authentication state this helper function returns various labels 81 // Given an authentication state this helper function returns various labels
81 // that can be used to display information about the state. 82 // that can be used to display information about the state.
82 void GetStatusLabelsForAuthError(const SigninManager& signin_manager, 83 void GetStatusLabelsForAuthError(const SigninManagerBase& signin_manager,
83 string16* status_label, 84 string16* status_label,
84 string16* link_label) { 85 string16* link_label) {
85 string16 username = UTF8ToUTF16(signin_manager.GetAuthenticatedUsername()); 86 string16 username = UTF8ToUTF16(signin_manager.GetAuthenticatedUsername());
86 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 87 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
87 if (link_label) 88 if (link_label)
88 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL)); 89 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL));
89 90
90 switch (signin_manager.signin_global_error()->GetLastAuthError().state()) { 91 switch (signin_manager.signin_global_error()->GetLastAuthError().state()) {
91 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: 92 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
92 case GoogleServiceAuthError::ACCOUNT_DELETED: 93 case GoogleServiceAuthError::ACCOUNT_DELETED:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (status_label) { 128 if (status_label) {
128 status_label->assign(l10n_util::GetStringUTF16( 129 status_label->assign(l10n_util::GetStringUTF16(
129 IDS_SYNC_ERROR_SIGNING_IN)); 130 IDS_SYNC_ERROR_SIGNING_IN));
130 } 131 }
131 break; 132 break;
132 } 133 }
133 } 134 }
134 135
135 136
136 } // namespace signin_ui_util 137 } // namespace signin_ui_util
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_ui_util.h ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698