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

Side by Side Diff: chrome/browser/sync/sync_ui_util.cc

Issue 2393643004: [MD Settings][People] Updates positions of username and sync status message (Closed)
Patch Set: rebase Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync/sync_ui_util.h" 5 #include "chrome/browser/sync/sync_ui_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 base::FieldTrialList::FindFullName("ChromeDashboard"); 60 base::FieldTrialList::FindFullName("ChromeDashboard");
61 return group_name == "Enabled"; 61 return group_name == "Enabled";
62 } 62 }
63 63
64 // Returns the message that should be displayed when the user is authenticated 64 // Returns the message that should be displayed when the user is authenticated
65 // and can connect to the sync server. If the user hasn't yet authenticated, an 65 // and can connect to the sync server. If the user hasn't yet authenticated, an
66 // empty string is returned. 66 // empty string is returned.
67 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, 67 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service,
68 const SigninManagerBase& signin, 68 const SigninManagerBase& signin,
69 StatusLabelStyle style) { 69 StatusLabelStyle style) {
70 std::string user_display_name = signin.GetAuthenticatedAccountInfo().email; 70 if (!service || service->IsManaged()) {
71 71 // User is signed in, but sync is disabled.
72 #if defined(OS_CHROMEOS) 72 return l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED);
73 if (user_manager::UserManager::IsInitialized()) { 73 } else if (!service->IsSyncRequested()) {
74 // On CrOS user email is sanitized and then passed to the signin manager. 74 // User is signed in, but sync has been stopped.
75 // Original email (containing dots) is stored as "display email". 75 return l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED);
76 user_display_name = user_manager::UserManager::Get()->GetUserDisplayEmail( 76 } else if (!service->IsSyncActive()) {
77 AccountId::FromUserEmail(user_display_name));
78 }
79 #endif // defined(OS_CHROMEOS)
80
81 base::string16 user_name = base::UTF8ToUTF16(user_display_name);
82
83 if (!user_name.empty()) {
84 if (!service || service->IsManaged()) {
85 // User is signed in, but sync is disabled.
86 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED,
87 user_name);
88 } else if (!service->IsSyncRequested()) {
89 // User is signed in, but sync has been stopped.
90 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED,
91 user_name);
92 }
93 }
94
95 if (!service || !service->IsSyncActive()) {
96 // User is not signed in, or sync is still initializing. 77 // User is not signed in, or sync is still initializing.
97 return base::string16(); 78 return base::string16();
98 } 79 }
99 80
100 DCHECK(!user_name.empty());
101
102 // Message may also carry additional advice with an HTML link, if acceptable. 81 // Message may also carry additional advice with an HTML link, if acceptable.
103 switch (style) { 82 switch (style) {
104 case PLAIN_TEXT: 83 case PLAIN_TEXT:
105 return l10n_util::GetStringFUTF16( 84 return l10n_util::GetStringUTF16(IDS_SYNC_ACCOUNT_SYNCING);
106 IDS_SYNC_ACCOUNT_SYNCING_TO_USER,
107 user_name);
108 case WITH_HTML: 85 case WITH_HTML:
109 if (IsChromeDashboardEnabled()) { 86 if (IsChromeDashboardEnabled()) {
110 return l10n_util::GetStringFUTF16( 87 return l10n_util::GetStringFUTF16(
111 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK_NEW, 88 IDS_SYNC_ACCOUNT_SYNCING_WITH_MANAGE_LINK_NEW,
112 user_name,
113 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); 89 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL));
114 } 90 }
115 return l10n_util::GetStringFUTF16( 91 return l10n_util::GetStringFUTF16(
116 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, 92 IDS_SYNC_ACCOUNT_SYNCING_WITH_MANAGE_LINK,
117 user_name,
118 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); 93 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL));
119 default: 94 default:
120 NOTREACHED(); 95 NOTREACHED();
121 return NULL; 96 return NULL;
122 } 97 }
123 } 98 }
124 99
125 void GetStatusForActionableError( 100 void GetStatusForActionableError(
126 const syncer::SyncProtocolError& error, 101 const syncer::SyncProtocolError& error,
127 base::string16* status_label) { 102 base::string16* status_label) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (status_label) { 266 if (status_label) {
292 GetStatusForActionableError(status.sync_protocol_error, 267 GetStatusForActionableError(status.sync_protocol_error,
293 status_label); 268 status_label);
294 } 269 }
295 } else if (status_label) { 270 } else if (status_label) {
296 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); 271 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR));
297 } 272 }
298 } else if (signin.IsAuthenticated()) { 273 } else if (signin.IsAuthenticated()) {
299 // The user is signed in, but sync has been stopped. 274 // The user is signed in, but sync has been stopped.
300 if (status_label) { 275 if (status_label) {
301 base::string16 label = l10n_util::GetStringFUTF16( 276 base::string16 label = l10n_util::GetStringUTF16(
302 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, 277 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED);
303 base::UTF8ToUTF16(signin.GetAuthenticatedAccountInfo().email));
304 status_label->assign(label); 278 status_label->assign(label);
305 result_type = PRE_SYNCED; 279 result_type = PRE_SYNCED;
306 } 280 }
307 } 281 }
308 } 282 }
309 return result_type; 283 return result_type;
310 } 284 }
311 285
312 // Returns the status info for use on the new tab page, where we want slightly 286 // Returns the status info for use on the new tab page, where we want slightly
313 // different information than in the settings panel. 287 // different information than in the settings panel.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 base::string16 ConstructTime(int64_t time_in_int) { 462 base::string16 ConstructTime(int64_t time_in_int) {
489 base::Time time = base::Time::FromInternalValue(time_in_int); 463 base::Time time = base::Time::FromInternalValue(time_in_int);
490 464
491 // If time is null the format function returns a time in 1969. 465 // If time is null the format function returns a time in 1969.
492 if (time.is_null()) 466 if (time.is_null())
493 return base::string16(); 467 return base::string16();
494 return base::TimeFormatFriendlyDateAndTime(time); 468 return base::TimeFormatFriendlyDateAndTime(time);
495 } 469 }
496 470
497 } // namespace sync_ui_util 471 } // namespace sync_ui_util
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_android.cc ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698