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

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

Issue 10696107: sync: Track validity of about:sync fields (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another rebase Created 8 years, 5 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/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) 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 "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"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/signin/signin_manager.h" 14 #include "chrome/browser/signin/signin_manager.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 15 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 16 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 19 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
20 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 20 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/chrome_version_info.h"
23 #include "chrome/common/net/gaia/google_service_auth_error.h" 22 #include "chrome/common/net/gaia/google_service_auth_error.h"
24 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
26 #include "grit/browser_resources.h" 25 #include "grit/browser_resources.h"
27 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
29 #include "grit/locale_settings.h" 28 #include "grit/locale_settings.h"
30 #include "sync/internal_api/public/base/model_type.h" 29 #include "sync/internal_api/public/base/model_type.h"
31 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 30 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
32 #include "sync/protocol/proto_enum_conversions.h" 31 #include "sync/protocol/proto_enum_conversions.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 string16* link_label) { 201 string16* link_label) {
203 DCHECK_EQ(status_label == NULL, link_label == NULL); 202 DCHECK_EQ(status_label == NULL, link_label == NULL);
204 203
205 MessageType result_type(SYNCED); 204 MessageType result_type(SYNCED);
206 205
207 if (!service) { 206 if (!service) {
208 return PRE_SYNCED; 207 return PRE_SYNCED;
209 } 208 }
210 209
211 if (service->HasSyncSetupCompleted()) { 210 if (service->HasSyncSetupCompleted()) {
212 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 211 ProfileSyncService::Status status;
212 service->QueryDetailedSyncStatus(&status);
213 const AuthError& auth_error = service->GetAuthError(); 213 const AuthError& auth_error = service->GetAuthError();
214 214
215 // The order or priority is going to be: 1. Unrecoverable errors. 215 // The order or priority is going to be: 1. Unrecoverable errors.
216 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. 216 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors.
217 217
218 if (service->HasUnrecoverableError()) { 218 if (service->HasUnrecoverableError()) {
219 if (status_label) { 219 if (status_label) {
220 status_label->assign(l10n_util::GetStringFUTF16( 220 status_label->assign(l10n_util::GetStringFUTF16(
221 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR, 221 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR,
222 l10n_util::GetStringUTF16(IDS_SYNC_UNRECOVERABLE_ERROR_HELP_URL))); 222 l10n_util::GetStringUTF16(IDS_SYNC_UNRECOVERABLE_ERROR_HELP_URL)));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 // There is no error. Display "Last synced..." message. 271 // There is no error. Display "Last synced..." message.
272 if (status_label) 272 if (status_label)
273 status_label->assign(GetSyncedStateStatusLabel(service, style)); 273 status_label->assign(GetSyncedStateStatusLabel(service, style));
274 return SYNCED; 274 return SYNCED;
275 } else { 275 } else {
276 // Either show auth error information with a link to re-login, auth in prog, 276 // Either show auth error information with a link to re-login, auth in prog,
277 // or provide a link to continue with setup. 277 // or provide a link to continue with setup.
278 result_type = PRE_SYNCED; 278 result_type = PRE_SYNCED;
279 if (service->FirstSetupInProgress()) { 279 if (service->FirstSetupInProgress()) {
280 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 280 ProfileSyncService::Status status;
281 service->QueryDetailedSyncStatus(&status);
281 const AuthError& auth_error = service->GetAuthError(); 282 const AuthError& auth_error = service->GetAuthError();
282 if (status_label) { 283 if (status_label) {
283 status_label->assign( 284 status_label->assign(
284 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); 285 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS));
285 } 286 }
286 if (signin.AuthInProgress()) { 287 if (signin.AuthInProgress()) {
287 if (status_label) { 288 if (status_label) {
288 status_label->assign( 289 status_label->assign(
289 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); 290 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
290 } 291 }
291 } else if (auth_error.state() != AuthError::NONE && 292 } else if (auth_error.state() != AuthError::NONE &&
292 auth_error.state() != AuthError::TWO_FACTOR) { 293 auth_error.state() != AuthError::TWO_FACTOR) {
293 if (status_label) { 294 if (status_label) {
294 status_label->clear(); 295 status_label->clear();
295 GetStatusLabelsForAuthError(auth_error, *service, status_label, NULL, 296 GetStatusLabelsForAuthError(auth_error, *service, status_label, NULL,
296 NULL, NULL, NULL); 297 NULL, NULL, NULL);
297 } 298 }
298 result_type = SYNC_ERROR; 299 result_type = SYNC_ERROR;
299 } 300 }
300 } else if (service->HasUnrecoverableError()) { 301 } else if (service->HasUnrecoverableError()) {
301 result_type = SYNC_ERROR; 302 result_type = SYNC_ERROR;
302 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 303 ProfileSyncService::Status status;
304 service->QueryDetailedSyncStatus(&status);
303 if (ShouldShowActionOnUI(status.sync_protocol_error)) { 305 if (ShouldShowActionOnUI(status.sync_protocol_error)) {
304 if (status_label) { 306 if (status_label) {
305 GetStatusForActionableError(status.sync_protocol_error, 307 GetStatusForActionableError(status.sync_protocol_error,
306 status_label); 308 status_label);
307 } 309 }
308 } else if (status_label) { 310 } else if (status_label) {
309 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); 311 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR));
310 } 312 }
311 } 313 }
312 } 314 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 MessageType type = GetStatus(service, signin); 428 MessageType type = GetStatus(service, signin);
427 429
428 if (type == sync_ui_util::SYNCED) 430 if (type == sync_ui_util::SYNCED)
429 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); 431 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL);
430 else if (type == sync_ui_util::SYNC_ERROR) 432 else if (type == sync_ui_util::SYNC_ERROR)
431 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); 433 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL);
432 else 434 else
433 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); 435 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL);
434 } 436 }
435 437
436 void AddBoolSyncDetail(ListValue* details,
437 const std::string& stat_name,
438 bool stat_value) {
439 DictionaryValue* val = new DictionaryValue;
440 val->SetString("stat_name", stat_name);
441 val->SetBoolean("stat_value", stat_value);
442 details->Append(val);
443 }
444
445 void AddStringSyncDetails(ListValue* details, const std::string& stat_name,
446 const string16& stat_value) {
447 DictionaryValue* val = new DictionaryValue;
448 val->SetString("stat_name", stat_name);
449 val->SetString("stat_value", stat_value);
450 details->Append(val);
451 }
452
453 void AddStringSyncDetails(ListValue* details, const std::string& stat_name,
454 const std::string& stat_value) {
455 DictionaryValue* val = new DictionaryValue;
456 val->SetString("stat_name", stat_name);
457 val->SetString("stat_value", stat_value);
458 details->Append(val);
459 }
460
461 ListValue* AddSyncDetailsSection(ListValue* details,
462 const std::string& name) {
463 DictionaryValue* val = new DictionaryValue;
464 details->Append(val);
465 val->SetString("title", name);
466 ListValue* list = new ListValue;
467 val->Set("data", list);
468 return list;
469 }
470
471 void AddIntSyncDetail(ListValue* details, const std::string& stat_name,
472 int64 stat_value) {
473 DictionaryValue* val = new DictionaryValue;
474 val->SetString("stat_name", stat_name);
475 val->SetString("stat_value", base::FormatNumber(stat_value));
476 details->Append(val);
477 }
478
479 string16 ConstructTime(int64 time_in_int) { 438 string16 ConstructTime(int64 time_in_int) {
480 base::Time time = base::Time::FromInternalValue(time_in_int); 439 base::Time time = base::Time::FromInternalValue(time_in_int);
481 440
482 // If time is null the format function returns a time in 1969. 441 // If time is null the format function returns a time in 1969.
483 if (time.is_null()) 442 if (time.is_null())
484 return string16(); 443 return string16();
485 return base::TimeFormatFriendlyDateAndTime(time); 444 return base::TimeFormatFriendlyDateAndTime(time);
486 } 445 }
487 446
488 std::string MakeSyncAuthErrorText( 447 std::string MakeSyncAuthErrorText(
489 const GoogleServiceAuthError::State& state) { 448 const GoogleServiceAuthError::State& state) {
490 switch (state) { 449 switch (state) {
491 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: 450 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
492 case GoogleServiceAuthError::ACCOUNT_DELETED: 451 case GoogleServiceAuthError::ACCOUNT_DELETED:
493 case GoogleServiceAuthError::ACCOUNT_DISABLED: 452 case GoogleServiceAuthError::ACCOUNT_DISABLED:
494 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: 453 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
495 return "INVALID_GAIA_CREDENTIALS"; 454 return "INVALID_GAIA_CREDENTIALS";
496 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: 455 case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
497 return "USER_NOT_SIGNED_UP"; 456 return "USER_NOT_SIGNED_UP";
498 case GoogleServiceAuthError::CONNECTION_FAILED: 457 case GoogleServiceAuthError::CONNECTION_FAILED:
499 return "CONNECTION_FAILED"; 458 return "CONNECTION_FAILED";
500 default: 459 default:
501 return std::string(); 460 return std::string();
502 } 461 }
503 } 462 }
504 463
505 void ConstructAboutInformation(ProfileSyncService* service,
506 DictionaryValue* strings) {
507
508 ListValue* details = new ListValue();
509 strings->Set("details", details);
510 ListValue* sync_summary = AddSyncDetailsSection(details, "Summary");
511
512 CHECK(strings);
513 if (!service) {
514 sync_ui_util::AddStringSyncDetails(sync_summary, "Summary",
515 "Sync service does not exist");
516 } else {
517 // This bypasses regular inter-thread communication mechanisms to grab a
518 // very recent snapshot from the syncer thread. It should be up to date
519 // with the last snapshot emitted by the syncer. Keep in mind, though, that
520 // not all events that update these values will ping the UI thread, so you
521 // might not see all intermediate values.
522 syncer::SyncStatus full_status(service->QueryDetailedSyncStatus());
523
524 // This is a cache of the last snapshot of type SYNC_CYCLE_ENDED where
525 // !snapshot.has_more_to_sync(). In other words, it's the last in this
526 // series of sync cycles. The series ends only when we've done all we can
527 // to resolve conflicts and there is nothing left to commit, or an error
528 // occurs.
529 //
530 // Despite the fact that it is updated only at the end of a series of
531 // commits, its values do not reflect the series. Its counters are based on
532 // the values from a single sync cycle.
533 //
534 // |snapshot| could be NULL if sync is not yet initialized.
535 const syncer::sessions::SyncSessionSnapshot& snapshot =
536 service->sync_initialized() ?
537 service->GetLastSessionSnapshot() :
538 syncer::sessions::SyncSessionSnapshot();
539
540 sync_ui_util::AddStringSyncDetails(sync_summary, "Summary",
541 service->QuerySyncStatusSummary());
542
543 ListValue* version_info = AddSyncDetailsSection(details, "Version Info");
544 sync_ui_util::AddStringSyncDetails(version_info, "Client Version",
545 GetVersionString());
546 sync_ui_util::AddStringSyncDetails(version_info, "Server URL",
547 service->sync_service_url().spec());
548
549 ListValue* user_state = AddSyncDetailsSection(details, "Credentials");
550 sync_ui_util::AddStringSyncDetails(user_state, "Client ID",
551 full_status.unique_id.empty() ? "none" : full_status.unique_id);
552 sync_ui_util::AddStringSyncDetails(
553 user_state, "Username",
554 service->signin() ? service->signin()->GetAuthenticatedUsername() : "");
555 sync_ui_util::AddBoolSyncDetail(
556 user_state, "Sync Token Available", service->IsSyncTokenAvailable());
557
558 ListValue* local_state = AddSyncDetailsSection(details, "Local State");
559 sync_ui_util::AddStringSyncDetails(local_state, "Last Synced",
560 service->GetLastSyncedTimeString());
561
562 // Some global status indicators. These will change only in exceptional
563 // circumstances, like encryption changes, new data types, throttling, etc.
564 sync_ui_util::AddBoolSyncDetail(local_state,
565 "Sync First-Time Setup Complete",
566 service->HasSyncSetupCompleted());
567 sync_ui_util::AddBoolSyncDetail(local_state, "Initial Download Complete",
568 full_status.initial_sync_ended);
569 sync_ui_util::AddBoolSyncDetail(local_state, "Sync Backend Initialized",
570 service->sync_initialized());
571
572 // Whether or not we're currently syncing. Will almost always be false
573 // because we do not usually update about:sync until a sync cycle has
574 // completed.
575 sync_ui_util::AddBoolSyncDetail(local_state, "Syncing",
576 full_status.syncing);
577
578 // Network status indicators.
579 ListValue* network = AddSyncDetailsSection(details, "Network");
580 sync_ui_util::AddBoolSyncDetail(network, "Throttled",
581 snapshot.is_silenced());
582 sync_ui_util::AddBoolSyncDetail(network, "Notifications Enabled",
583 full_status.notifications_enabled);
584
585 // Encryption status indicators.
586 //
587 // Only safe to call IsUsingSecondaryPassphrase() if the backend is
588 // initialized already - otherwise, we have no idea whether we are
589 // using a secondary passphrase or not.
590 ListValue* encryption = AddSyncDetailsSection(details, "Encryption");
591 if (service->sync_initialized()) {
592 sync_ui_util::AddBoolSyncDetail(encryption,
593 "Explicit Passphrase",
594 service->IsUsingSecondaryPassphrase());
595 }
596 sync_ui_util::AddBoolSyncDetail(encryption,
597 "Passphrase Required",
598 service->IsPassphraseRequired());
599 sync_ui_util::AddBoolSyncDetail(encryption,
600 "Cryptographer Ready",
601 full_status.cryptographer_ready);
602 sync_ui_util::AddBoolSyncDetail(encryption,
603 "Cryptographer Has Pending Keys",
604 full_status.crypto_has_pending_keys);
605 sync_ui_util::AddStringSyncDetails(encryption,
606 "Encrypted Types",
607 syncer::ModelTypeSetToString(full_status.encrypted_types));
608
609
610 ListValue* cycles = AddSyncDetailsSection(
611 details, "Status from Last Completed Session");
612 sync_ui_util::AddStringSyncDetails(
613 cycles, "Sync Source",
614 syncer::GetUpdatesSourceString(
615 snapshot.source().updates_source));
616 sync_ui_util::AddStringSyncDetails(
617 cycles, "Download Step Result",
618 GetSyncerErrorString(
619 snapshot.model_neutral_state().last_download_updates_result));
620 sync_ui_util::AddStringSyncDetails(
621 cycles, "Commit Step Result",
622 GetSyncerErrorString(snapshot.model_neutral_state().commit_result));
623
624 // Strictly increasing counters.
625 ListValue* counters = AddSyncDetailsSection(details, "Running Totals");
626 sync_ui_util::AddIntSyncDetail(counters,
627 "Notifications Received",
628 full_status.notifications_received);
629
630 sync_ui_util::AddIntSyncDetail(counters,
631 "Cycles Without Updates",
632 full_status.empty_get_updates);
633 sync_ui_util::AddIntSyncDetail(counters,
634 "Cycles With Updates",
635 full_status.nonempty_get_updates);
636 sync_ui_util::AddIntSyncDetail(counters,
637 "Cycles Without Commits",
638 full_status.sync_cycles_without_commits);
639 sync_ui_util::AddIntSyncDetail(counters,
640 "Cycles With Commits",
641 full_status.sync_cycles_with_commits);
642 sync_ui_util::AddIntSyncDetail(counters,
643 "Cycles Without Commits or Updates",
644 full_status.useless_sync_cycles);
645 sync_ui_util::AddIntSyncDetail(counters,
646 "Cycles With Commit or Update",
647 full_status.useful_sync_cycles);
648
649 sync_ui_util::AddIntSyncDetail(counters,
650 "Updates Downloaded",
651 full_status.updates_received);
652 sync_ui_util::AddIntSyncDetail(
653 counters, "Tombstone Updates",
654 full_status.tombstone_updates_received);
655 sync_ui_util::AddIntSyncDetail(
656 counters, "Reflected Updates",
657 full_status.reflected_updates_received);
658
659 sync_ui_util::AddIntSyncDetail(
660 counters, "Successful Commits",
661 full_status.num_commits_total);
662
663 sync_ui_util::AddIntSyncDetail(
664 counters, "Conflict Resolved: Client Wins",
665 full_status.num_local_overwrites_total);
666 sync_ui_util::AddIntSyncDetail(
667 counters, "Conflict Resolved: Server Wins",
668 full_status.num_server_overwrites_total);
669
670 // This is counted when we prepare the commit message.
671 ListValue* transient_cycle = AddSyncDetailsSection(
672 details, "Transient Counters (this cycle)");
673
674 // These are counted during the ApplyUpdates step.
675 sync_ui_util::AddIntSyncDetail(
676 transient_cycle, "Encryption Conflicts",
677 full_status.encryption_conflicts);
678 sync_ui_util::AddIntSyncDetail(
679 transient_cycle, "Hierarchy Conflicts",
680 full_status.hierarchy_conflicts);
681 sync_ui_util::AddIntSyncDetail(
682 transient_cycle, "Simple Conflicts",
683 full_status.simple_conflicts);
684 sync_ui_util::AddIntSyncDetail(
685 transient_cycle, "Server Conflicts",
686 full_status.server_conflicts);
687
688 sync_ui_util::AddIntSyncDetail(
689 transient_cycle, "Committed Items",
690 full_status.committed_count);
691 sync_ui_util::AddIntSyncDetail(
692 transient_cycle, "Updates Remaining",
693 full_status.updates_available);
694
695 ListValue* transient_session = AddSyncDetailsSection(
696 details, "Transient Counters (last cycle of last completed session)");
697 sync_ui_util::AddIntSyncDetail(
698 transient_session, "Updates Downloaded",
699 snapshot.model_neutral_state().num_updates_downloaded_total);
700 sync_ui_util::AddIntSyncDetail(
701 transient_session, "Committed Count",
702 snapshot.model_neutral_state().num_successful_commits);
703
704 // This counter is stale. The warnings related to the snapshot still
705 // apply, see the comments near call to GetLastSessionSnapshot() above.
706 // Also, because this is updated only following a complete sync cycle,
707 // local changes affecting this count will not be displayed until the
708 // syncer has attempted to commit those changes.
709 sync_ui_util::AddIntSyncDetail(transient_session, "Entries",
710 snapshot.num_entries());
711
712 if (!full_status.throttled_types.Empty()) {
713 strings->Set("throttled_data_types", base::Value::CreateStringValue(
714 ModelTypeSetToString(full_status.throttled_types)));
715 }
716
717 // Now set the actionable errors.
718 if ((full_status.sync_protocol_error.error_type !=
719 syncer::UNKNOWN_ERROR) &&
720 (full_status.sync_protocol_error.error_type !=
721 syncer::SYNC_SUCCESS)) {
722 strings->Set("actionable_error_detected",
723 base::Value::CreateBooleanValue(true));
724 ListValue* actionable_error = new ListValue();
725 strings->Set("actionable_error", actionable_error);
726 sync_ui_util::AddStringSyncDetails(actionable_error, "Error Type",
727 syncer::GetSyncErrorTypeString(
728 full_status.sync_protocol_error.error_type));
729 sync_ui_util::AddStringSyncDetails(actionable_error, "Action",
730 syncer::GetClientActionString(
731 full_status.sync_protocol_error.action));
732 sync_ui_util::AddStringSyncDetails(actionable_error, "url",
733 full_status.sync_protocol_error.url);
734 sync_ui_util::AddStringSyncDetails(actionable_error, "Error Description",
735 full_status.sync_protocol_error.error_description);
736 } else {
737 strings->Set("actionable_error_detected",
738 base::Value::CreateBooleanValue(false));
739 }
740
741 if (service->HasUnrecoverableError()) {
742 strings->Set("unrecoverable_error_detected",
743 new base::FundamentalValue(true));
744 tracked_objects::Location loc(service->unrecoverable_error_location());
745 std::string location_str;
746 loc.Write(true, true, &location_str);
747 std::string unrecoverable_error_message =
748 "Unrecoverable error detected at " + location_str +
749 ": " + service->unrecoverable_error_message();
750 strings->SetString("unrecoverable_error_message",
751 unrecoverable_error_message);
752 }
753
754 if (service->sync_initialized()) {
755 strings->Set("type_status", service->GetTypeStatusMap());
756 }
757 }
758 }
759
760 std::string GetVersionString() {
761 // Build a version string that matches MakeUserAgentForSyncApi with the
762 // addition of channel info and proper OS names.
763 chrome::VersionInfo chrome_version;
764 if (!chrome_version.is_valid())
765 return "invalid";
766 // GetVersionStringModifier returns empty string for stable channel or
767 // unofficial builds, the channel string otherwise. We want to have "-devel"
768 // for unofficial builds only.
769 std::string version_modifier =
770 chrome::VersionInfo::GetVersionStringModifier();
771 if (version_modifier.empty()) {
772 if (chrome::VersionInfo::GetChannel() !=
773 chrome::VersionInfo::CHANNEL_STABLE) {
774 version_modifier = "-devel";
775 }
776 } else {
777 version_modifier = " " + version_modifier;
778 }
779 return chrome_version.Name() + " " + chrome_version.OSType() + " " +
780 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" +
781 version_modifier;
782 }
783
784 } // namespace sync_ui_util 464 } // 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