OLD | NEW |
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, | 334 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, |
335 string16* status_label, | 335 string16* status_label, |
336 string16* link_label) { | 336 string16* link_label) { |
337 DCHECK(status_label); | 337 DCHECK(status_label); |
338 DCHECK(link_label); | 338 DCHECK(link_label); |
339 return sync_ui_util::GetStatusInfoForNewTabPage( | 339 return sync_ui_util::GetStatusInfoForNewTabPage( |
340 service, status_label, link_label); | 340 service, status_label, link_label); |
341 } | 341 } |
342 | 342 |
343 MessageType GetStatusLabelsForSyncGlobalError(ProfileSyncService* service, | 343 void GetStatusLabelsForSyncGlobalError(ProfileSyncService* service, |
344 string16* menu_label, | 344 string16* menu_label, |
345 string16* bubble_message, | 345 string16* bubble_message, |
346 string16* bubble_accept_label) { | 346 string16* bubble_accept_label) { |
| 347 DCHECK(menu_label); |
| 348 DCHECK(bubble_message); |
| 349 DCHECK(bubble_accept_label); |
| 350 *menu_label = string16(); |
| 351 *bubble_message = string16(); |
| 352 *bubble_accept_label = string16(); |
| 353 |
347 if (!service->HasSyncSetupCompleted()) | 354 if (!service->HasSyncSetupCompleted()) |
348 return PRE_SYNCED; | 355 return; |
349 | 356 |
350 if (service->IsPassphraseRequired() && | 357 if (service->IsPassphraseRequired() && |
351 service->IsPassphraseRequiredForDecryption()) { | 358 service->IsPassphraseRequiredForDecryption()) { |
352 // This is not the first machine so ask user to enter passphrase. | 359 // This is not the first machine so ask user to enter passphrase. |
353 if (menu_label) { | 360 *menu_label = l10n_util::GetStringUTF16( |
354 *menu_label = l10n_util::GetStringUTF16( | 361 IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM); |
355 IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM); | 362 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
356 } | 363 *bubble_message = l10n_util::GetStringFUTF16( |
357 if (bubble_message) { | 364 IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_MESSAGE, product_name); |
358 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 365 *bubble_accept_label = l10n_util::GetStringUTF16( |
359 *bubble_message = l10n_util::GetStringFUTF16( | 366 IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_ACCEPT); |
360 IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_MESSAGE, product_name); | 367 return; |
361 } | |
362 if (bubble_accept_label) { | |
363 *bubble_accept_label = l10n_util::GetStringUTF16( | |
364 IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_ACCEPT); | |
365 } | |
366 return SYNC_ERROR; | |
367 } | 368 } |
368 | 369 |
369 MessageType status = GetStatus(service); | 370 MessageType status = GetStatus(service); |
370 if (status != SYNC_ERROR) | 371 if (status != SYNC_ERROR) |
371 return status; | 372 return; |
372 | 373 |
373 const AuthError& auth_error = service->GetAuthError(); | 374 const AuthError& auth_error = service->GetAuthError(); |
374 if (auth_error.state() != AuthError::NONE) { | 375 if (auth_error.state() != AuthError::NONE) { |
375 GetStatusLabelsForAuthError(auth_error, *service, NULL, NULL, | 376 GetStatusLabelsForAuthError(auth_error, *service, NULL, NULL, |
376 menu_label, bubble_message, bubble_accept_label); | 377 menu_label, bubble_message, bubble_accept_label); |
377 return SYNC_ERROR; | |
378 } | 378 } |
379 | |
380 return SYNCED; | |
381 } | 379 } |
382 | 380 |
383 MessageType GetStatus(ProfileSyncService* service) { | 381 MessageType GetStatus(ProfileSyncService* service) { |
384 return sync_ui_util::GetStatusInfo(service, NULL, NULL); | 382 return sync_ui_util::GetStatusInfo(service, NULL, NULL); |
385 } | 383 } |
386 | 384 |
387 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { | 385 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { |
388 return service && | 386 return service && |
389 ((!service->IsManaged() && | 387 ((!service->IsManaged() && |
390 service->HasSyncSetupCompleted()) && | 388 service->HasSyncSetupCompleted()) && |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 DictionaryValue* val = new DictionaryValue; | 655 DictionaryValue* val = new DictionaryValue; |
658 val->SetString("model_type", ModelTypeToString(it->first)); | 656 val->SetString("model_type", ModelTypeToString(it->first)); |
659 val->SetString("group", ModelSafeGroupToString(it->second)); | 657 val->SetString("group", ModelSafeGroupToString(it->second)); |
660 routing_info->Append(val); | 658 routing_info->Append(val); |
661 } | 659 } |
662 } | 660 } |
663 } | 661 } |
664 } | 662 } |
665 | 663 |
666 } // namespace sync_ui_util | 664 } // namespace sync_ui_util |
OLD | NEW |