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