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

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

Issue 7057038: dom-ui sync: Eliminate jank when customizing sync settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: comment tweak Created 9 years, 7 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/profile_sync_service.h ('k') | chrome/browser/sync/sync_setup_flow.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/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <map> 8 #include <map>
9 #include <ostream> 9 #include <ostream>
10 #include <set> 10 #include <set>
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/sync/js_event_details.h" 36 #include "chrome/browser/sync/js_event_details.h"
37 #include "chrome/browser/sync/profile_sync_factory.h" 37 #include "chrome/browser/sync/profile_sync_factory.h"
38 #include "chrome/browser/sync/signin_manager.h" 38 #include "chrome/browser/sync/signin_manager.h"
39 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/browser_list.h" 40 #include "chrome/browser/ui/browser_list.h"
41 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/net/gaia/gaia_constants.h" 42 #include "chrome/common/net/gaia/gaia_constants.h"
43 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
44 #include "chrome/common/time_format.h" 44 #include "chrome/common/time_format.h"
45 #include "chrome/common/url_constants.h" 45 #include "chrome/common/url_constants.h"
46 #include "content/browser/webui/web_ui.h"
46 #include "content/common/notification_details.h" 47 #include "content/common/notification_details.h"
47 #include "content/common/notification_source.h" 48 #include "content/common/notification_source.h"
48 #include "content/common/notification_type.h" 49 #include "content/common/notification_type.h"
49 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
50 #include "ui/base/l10n/l10n_util.h" 51 #include "ui/base/l10n/l10n_util.h"
51 52
52 using browser_sync::ChangeProcessor; 53 using browser_sync::ChangeProcessor;
53 using browser_sync::DataTypeController; 54 using browser_sync::DataTypeController;
54 using browser_sync::DataTypeManager; 55 using browser_sync::DataTypeManager;
55 using browser_sync::SyncBackendHost; 56 using browser_sync::SyncBackendHost;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 // The very first time the backend initializes is effectively the first time 533 // The very first time the backend initializes is effectively the first time
533 // we can say we successfully "synced". last_synced_time_ will only be null 534 // we can say we successfully "synced". last_synced_time_ will only be null
534 // in this case, because the pref wasn't restored on StartUp. 535 // in this case, because the pref wasn't restored on StartUp.
535 if (last_synced_time_.is_null()) { 536 if (last_synced_time_.is_null()) {
536 UpdateLastSyncedTime(); 537 UpdateLastSyncedTime();
537 } 538 }
538 NotifyObservers(); 539 NotifyObservers();
539 540
540 if (!cros_user_.empty()) { 541 if (!cros_user_.empty()) {
541 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) { 542 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) {
542 ShowConfigure(true); 543 ShowConfigure(NULL, true);
543 } else { 544 } else {
544 SetSyncSetupCompleted(); 545 SetSyncSetupCompleted();
545 } 546 }
546 } 547 }
547 548
548 if (HasSyncSetupCompleted()) { 549 if (HasSyncSetupCompleted()) {
549 ConfigureDataTypeManager(); 550 ConfigureDataTypeManager();
550 } 551 }
551 } 552 }
552 553
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 void ProfileSyncService::OnMigrationNeededForTypes( 703 void ProfileSyncService::OnMigrationNeededForTypes(
703 const syncable::ModelTypeSet& types) { 704 const syncable::ModelTypeSet& types) {
704 DCHECK(backend_initialized_); 705 DCHECK(backend_initialized_);
705 DCHECK(data_type_manager_.get()); 706 DCHECK(data_type_manager_.get());
706 707
707 // Migrator must be valid, because we don't sync until it is created and this 708 // Migrator must be valid, because we don't sync until it is created and this
708 // callback originates from a sync cycle. 709 // callback originates from a sync cycle.
709 migrator_->MigrateTypes(types); 710 migrator_->MigrateTypes(types);
710 } 711 }
711 712
712 void ProfileSyncService::ShowLoginDialog() { 713 void ProfileSyncService::ShowLoginDialog(WebUI* web_ui) {
713 if (WizardIsVisible()) { 714 if (WizardIsVisible()) {
714 wizard_.Focus(); 715 wizard_.Focus();
715 // Force the wizard to step to the login screen (which will only actually 716 // Force the wizard to step to the login screen (which will only actually
716 // happen if the transition is valid). 717 // happen if the transition is valid).
717 wizard_.Step(SyncSetupWizard::GAIA_LOGIN); 718 wizard_.Step(SyncSetupWizard::GAIA_LOGIN);
718 return; 719 return;
719 } 720 }
720 721
721 if (!auth_error_time_.is_null()) { 722 if (!auth_error_time_.is_null()) {
722 UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime", 723 UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime",
723 base::TimeTicks::Now() - auth_error_time_); 724 base::TimeTicks::Now() - auth_error_time_);
724 auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null. 725 auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null.
725 } 726 }
726 727
727 wizard_.Step(SyncSetupWizard::GAIA_LOGIN); 728 wizard_.Step(SyncSetupWizard::GAIA_LOGIN);
728 729
730 if (web_ui) {
731 web_ui->CallJavascriptFunction("options.SyncSetupOverlay.showSyncDialog");
732 } else {
733 BrowserList::GetLastActive()->ShowOptionsTab(chrome::kSyncSetupSubPage);
734 }
735
729 NotifyObservers(); 736 NotifyObservers();
730 } 737 }
731 738
732 void ProfileSyncService::ShowErrorUI() { 739 void ProfileSyncService::ShowErrorUI(WebUI* web_ui) {
733 if (IsPassphraseRequired()) { 740 if (IsPassphraseRequired()) {
734 if (IsUsingSecondaryPassphrase()) 741 if (IsUsingSecondaryPassphrase())
735 PromptForExistingPassphrase(); 742 PromptForExistingPassphrase();
736 else 743 else
737 NOTREACHED(); // Migration no longer supported. 744 NOTREACHED(); // Migration no longer supported.
738 745
739 return; 746 return;
740 } 747 }
741 748
742 const GoogleServiceAuthError& error = GetAuthError(); 749 const GoogleServiceAuthError& error = GetAuthError();
743 if (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || 750 if (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
744 error.state() == GoogleServiceAuthError::CAPTCHA_REQUIRED || 751 error.state() == GoogleServiceAuthError::CAPTCHA_REQUIRED ||
745 error.state() == GoogleServiceAuthError::ACCOUNT_DELETED || 752 error.state() == GoogleServiceAuthError::ACCOUNT_DELETED ||
746 error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED || 753 error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED ||
747 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { 754 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) {
748 ShowLoginDialog(); 755 ShowLoginDialog(web_ui);
749 } 756 }
750 } 757 }
751 758
752 759 void ProfileSyncService::ShowConfigure(WebUI* web_ui, bool sync_everything) {
753 void ProfileSyncService::ShowConfigure(bool sync_everything) {
754 if (WizardIsVisible()) { 760 if (WizardIsVisible()) {
755 wizard_.Focus(); 761 wizard_.Focus();
756 return; 762 return;
757 } 763 }
758 764
759 if (sync_everything) 765 if (sync_everything)
760 wizard_.Step(SyncSetupWizard::SYNC_EVERYTHING); 766 wizard_.Step(SyncSetupWizard::SYNC_EVERYTHING);
761 else 767 else
762 wizard_.Step(SyncSetupWizard::CONFIGURE); 768 wizard_.Step(SyncSetupWizard::CONFIGURE);
769
770 if (web_ui)
771 web_ui->CallJavascriptFunction("options.SyncSetupOverlay.showSyncDialog");
772 else
773 BrowserList::GetLastActive()->ShowOptionsTab(chrome::kSyncSetupSubPage);
763 } 774 }
764 775
765 void ProfileSyncService::PromptForExistingPassphrase() { 776 void ProfileSyncService::PromptForExistingPassphrase() {
766 if (WizardIsVisible()) { 777 if (WizardIsVisible()) {
767 wizard_.Focus(); 778 wizard_.Focus();
768 return; 779 return;
769 } 780 }
770 781
771 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); 782 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE);
772 } 783 }
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 return false; 1346 return false;
1336 1347
1337 return data_type_manager_->state() == DataTypeManager::CONFIGURED; 1348 return data_type_manager_->state() == DataTypeManager::CONFIGURED;
1338 } 1349 }
1339 1350
1340 ProfileSyncService::EncryptedTypes::EncryptedTypes() { 1351 ProfileSyncService::EncryptedTypes::EncryptedTypes() {
1341 current.insert(syncable::PASSWORDS); 1352 current.insert(syncable::PASSWORDS);
1342 } 1353 }
1343 1354
1344 ProfileSyncService::EncryptedTypes::~EncryptedTypes() {} 1355 ProfileSyncService::EncryptedTypes::~EncryptedTypes() {}
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/sync_setup_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698