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

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

Issue 8613001: Revert 110905 - Adding parameter to GetStatusLabels to indicate if links are acceptable, as some ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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/sync/sync_ui_util.h ('k') | chrome/browser/sync/sync_ui_util_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 global_error_bubble_accept_label->assign(l10n_util::GetStringUTF16( 125 global_error_bubble_accept_label->assign(l10n_util::GetStringUTF16(
126 IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT)); 126 IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT));
127 } 127 }
128 break; 128 break;
129 } 129 }
130 } 130 }
131 131
132 // Returns the message that should be displayed when the user is authenticated 132 // Returns the message that should be displayed when the user is authenticated
133 // and can connect to the sync server. If the user hasn't yet authenticated, an 133 // and can connect to the sync server. If the user hasn't yet authenticated, an
134 // empty string is returned. 134 // empty string is returned.
135 string16 GetSyncedStateStatusLabel(ProfileSyncService* service, 135 string16 GetSyncedStateStatusLabel(ProfileSyncService* service) {
136 StatusLabelStyle style) {
137 string16 label; 136 string16 label;
138 string16 user_name(service->GetAuthenticatedUsername()); 137 string16 user_name(service->GetAuthenticatedUsername());
139 if (user_name.empty()) 138 if (user_name.empty())
140 return label; 139 return label;
141 140
142 // Message may also carry additional advice with an HTML link, if acceptable. 141 return l10n_util::GetStringFUTF16(
143 switch (style) { 142 IDS_SYNC_ACCOUNT_SYNCING_TO_USER,
144 case PLAIN_TEXT: 143 user_name,
145 return l10n_util::GetStringFUTF16( 144 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL));
146 IDS_SYNC_ACCOUNT_SYNCING_TO_USER,
147 user_name);
148 case WITH_HTML:
149 return l10n_util::GetStringFUTF16(
150 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK,
151 user_name,
152 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL));
153 default:
154 NOTREACHED();
155 return NULL;
156 }
157 } 145 }
158 146
159 void GetStatusForActionableError( 147 void GetStatusForActionableError(
160 const browser_sync::SyncProtocolError& error, 148 const browser_sync::SyncProtocolError& error,
161 string16* status_label) { 149 string16* status_label) {
162 DCHECK(status_label); 150 DCHECK(status_label);
163 switch (error.action) { 151 switch (error.action) {
164 case browser_sync::STOP_AND_RESTART_SYNC: 152 case browser_sync::STOP_AND_RESTART_SYNC:
165 status_label->assign( 153 status_label->assign(
166 l10n_util::GetStringUTF16(IDS_SYNC_STOP_AND_RESTART_SYNC)); 154 l10n_util::GetStringUTF16(IDS_SYNC_STOP_AND_RESTART_SYNC));
(...skipping 13 matching lines...) Expand all
180 break; 168 break;
181 default: 169 default:
182 NOTREACHED(); 170 NOTREACHED();
183 } 171 }
184 } 172 }
185 173
186 // TODO(akalin): Write unit tests for these three functions below. 174 // TODO(akalin): Write unit tests for these three functions below.
187 175
188 // status_label and link_label must either be both NULL or both non-NULL. 176 // status_label and link_label must either be both NULL or both non-NULL.
189 MessageType GetStatusInfo(ProfileSyncService* service, 177 MessageType GetStatusInfo(ProfileSyncService* service,
190 StatusLabelStyle style,
191 string16* status_label, 178 string16* status_label,
192 string16* link_label) { 179 string16* link_label) {
193 DCHECK_EQ(status_label == NULL, link_label == NULL); 180 DCHECK_EQ(status_label == NULL, link_label == NULL);
194 181
195 MessageType result_type(SYNCED); 182 MessageType result_type(SYNCED);
196 183
197 if (!service) { 184 if (!service) {
198 return PRE_SYNCED; 185 return PRE_SYNCED;
199 } 186 }
200 187
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 230
244 // Now finally passphrase error. 231 // Now finally passphrase error.
245 if (service->IsPassphraseRequired()) { 232 if (service->IsPassphraseRequired()) {
246 if (service->IsPassphraseRequiredForDecryption()) { 233 if (service->IsPassphraseRequiredForDecryption()) {
247 // TODO(lipalani) : Ask tim if this is still needed. 234 // TODO(lipalani) : Ask tim if this is still needed.
248 // NOT first machine. 235 // NOT first machine.
249 // Show a link ("needs attention"), but still indicate the 236 // Show a link ("needs attention"), but still indicate the
250 // current synced status. Return SYNC_PROMO so that 237 // current synced status. Return SYNC_PROMO so that
251 // the configure link will still be shown. 238 // the configure link will still be shown.
252 if (status_label && link_label) { 239 if (status_label && link_label) {
253 status_label->assign(GetSyncedStateStatusLabel(service, style)); 240 status_label->assign(GetSyncedStateStatusLabel(service));
254 link_label->assign( 241 link_label->assign(
255 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION)); 242 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION));
256 } 243 }
257 return SYNC_PROMO; 244 return SYNC_PROMO;
258 } 245 }
259 } 246 }
260 247
261 // There is no error. Display "Last synced..." message. 248 // There is no error. Display "Last synced..." message.
262 if (status_label) 249 if (status_label)
263 status_label->assign(GetSyncedStateStatusLabel(service, style)); 250 status_label->assign(GetSyncedStateStatusLabel(service));
264 return SYNCED; 251 return SYNCED;
265 } else { 252 } else {
266 // Either show auth error information with a link to re-login, auth in prog, 253 // Either show auth error information with a link to re-login, auth in prog,
267 // or provide a link to continue with setup. 254 // or provide a link to continue with setup.
268 result_type = PRE_SYNCED; 255 result_type = PRE_SYNCED;
269 if (service->SetupInProgress()) { 256 if (service->SetupInProgress()) {
270 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 257 ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
271 const AuthError& auth_error = service->GetAuthError(); 258 const AuthError& auth_error = service->GetAuthError();
272 if (status_label) { 259 if (status_label) {
273 status_label->assign( 260 status_label->assign(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (status_label && link_label) { 322 if (status_label && link_label) {
336 status_label->assign(string16()); 323 status_label->assign(string16());
337 link_label->assign( 324 link_label->assign(
338 l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION)); 325 l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION));
339 } 326 }
340 return SYNC_ERROR; 327 return SYNC_ERROR;
341 } 328 }
342 } 329 }
343 330
344 // Fallback to default. 331 // Fallback to default.
345 return GetStatusInfo(service, WITH_HTML, status_label, link_label); 332 return GetStatusInfo(service, status_label, link_label);
346 } 333 }
347 334
348 } // namespace 335 } // namespace
349 336
350 MessageType GetStatusLabels(ProfileSyncService* service, 337 MessageType GetStatusLabels(ProfileSyncService* service,
351 StatusLabelStyle style,
352 string16* status_label, 338 string16* status_label,
353 string16* link_label) { 339 string16* link_label) {
354 DCHECK(status_label); 340 DCHECK(status_label);
355 DCHECK(link_label); 341 DCHECK(link_label);
356 return sync_ui_util::GetStatusInfo(service, style, status_label, link_label); 342 return sync_ui_util::GetStatusInfo(service, status_label, link_label);
357 } 343 }
358 344
359 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, 345 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
360 string16* status_label, 346 string16* status_label,
361 string16* link_label) { 347 string16* link_label) {
362 DCHECK(status_label); 348 DCHECK(status_label);
363 DCHECK(link_label); 349 DCHECK(link_label);
364 return sync_ui_util::GetStatusInfoForNewTabPage( 350 return sync_ui_util::GetStatusInfoForNewTabPage(
365 service, status_label, link_label); 351 service, status_label, link_label);
366 } 352 }
(...skipping 30 matching lines...) Expand all
397 return; 383 return;
398 384
399 const AuthError& auth_error = service->GetAuthError(); 385 const AuthError& auth_error = service->GetAuthError();
400 if (auth_error.state() != AuthError::NONE) { 386 if (auth_error.state() != AuthError::NONE) {
401 GetStatusLabelsForAuthError(auth_error, *service, NULL, NULL, 387 GetStatusLabelsForAuthError(auth_error, *service, NULL, NULL,
402 menu_label, bubble_message, bubble_accept_label); 388 menu_label, bubble_message, bubble_accept_label);
403 } 389 }
404 } 390 }
405 391
406 MessageType GetStatus(ProfileSyncService* service) { 392 MessageType GetStatus(ProfileSyncService* service) {
407 return sync_ui_util::GetStatusInfo(service, WITH_HTML, NULL, NULL); 393 return sync_ui_util::GetStatusInfo(service, NULL, NULL);
408 } 394 }
409 395
410 string16 GetSyncMenuLabel(ProfileSyncService* service) { 396 string16 GetSyncMenuLabel(ProfileSyncService* service) {
411 MessageType type = GetStatus(service); 397 MessageType type = GetStatus(service);
412 398
413 if (type == sync_ui_util::SYNCED) 399 if (type == sync_ui_util::SYNCED)
414 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); 400 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL);
415 else if (type == sync_ui_util::SYNC_ERROR) 401 else if (type == sync_ui_util::SYNC_ERROR)
416 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); 402 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL);
417 else 403 else
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 687 }
702 } else { 688 } else {
703 version_modifier = " " + version_modifier; 689 version_modifier = " " + version_modifier;
704 } 690 }
705 return chrome_version.Name() + " " + chrome_version.OSType() + " " + 691 return chrome_version.Name() + " " + chrome_version.OSType() + " " +
706 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" + 692 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" +
707 version_modifier; 693 version_modifier;
708 } 694 }
709 695
710 } // namespace sync_ui_util 696 } // namespace sync_ui_util
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_ui_util.h ('k') | chrome/browser/sync/sync_ui_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698