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

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: win/linux tweaks 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
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // The very first time the backend initializes is effectively the first time 525 // The very first time the backend initializes is effectively the first time
525 // we can say we successfully "synced". last_synced_time_ will only be null 526 // we can say we successfully "synced". last_synced_time_ will only be null
526 // in this case, because the pref wasn't restored on StartUp. 527 // in this case, because the pref wasn't restored on StartUp.
527 if (last_synced_time_.is_null()) { 528 if (last_synced_time_.is_null()) {
528 UpdateLastSyncedTime(); 529 UpdateLastSyncedTime();
529 } 530 }
530 NotifyObservers(); 531 NotifyObservers();
531 532
532 if (!cros_user_.empty()) { 533 if (!cros_user_.empty()) {
533 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) { 534 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) {
534 ShowConfigure(true); 535 ShowConfigure(NULL, true);
535 } else { 536 } else {
536 SetSyncSetupCompleted(); 537 SetSyncSetupCompleted();
537 } 538 }
538 } 539 }
539 540
540 if (HasSyncSetupCompleted()) { 541 if (HasSyncSetupCompleted()) {
541 ConfigureDataTypeManager(); 542 ConfigureDataTypeManager();
542 } 543 }
543 } 544 }
544 545
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 void ProfileSyncService::OnMigrationNeededForTypes( 685 void ProfileSyncService::OnMigrationNeededForTypes(
685 const syncable::ModelTypeSet& types) { 686 const syncable::ModelTypeSet& types) {
686 DCHECK(backend_initialized_); 687 DCHECK(backend_initialized_);
687 DCHECK(data_type_manager_.get()); 688 DCHECK(data_type_manager_.get());
688 689
689 // Migrator must be valid, because we don't sync until it is created and this 690 // Migrator must be valid, because we don't sync until it is created and this
690 // callback originates from a sync cycle. 691 // callback originates from a sync cycle.
691 migrator_->MigrateTypes(types); 692 migrator_->MigrateTypes(types);
692 } 693 }
693 694
694 void ProfileSyncService::ShowLoginDialog() { 695 void ProfileSyncService::ShowLoginDialog(WebUI* web_ui) {
695 if (WizardIsVisible()) { 696 if (WizardIsVisible()) {
696 wizard_.Focus(); 697 wizard_.Focus();
697 // Force the wizard to step to the login screen (which will only actually 698 // Force the wizard to step to the login screen (which will only actually
698 // happen if the transition is valid). 699 // happen if the transition is valid).
699 wizard_.Step(SyncSetupWizard::GAIA_LOGIN); 700 wizard_.Step(SyncSetupWizard::GAIA_LOGIN);
700 return; 701 return;
701 } 702 }
702 703
703 if (!auth_error_time_.is_null()) { 704 if (!auth_error_time_.is_null()) {
704 UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime", 705 UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime",
705 base::TimeTicks::Now() - auth_error_time_); 706 base::TimeTicks::Now() - auth_error_time_);
706 auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null. 707 auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null.
707 } 708 }
708 709
709 wizard_.Step(SyncSetupWizard::GAIA_LOGIN); 710 wizard_.Step(SyncSetupWizard::GAIA_LOGIN);
710 711
712 if (web_ui) {
713 web_ui->CallJavascriptFunction("options.SyncSetupOverlay.showSyncDialog");
714 } else {
715 BrowserList::GetLastActive()->ShowOptionsTab(chrome::kSyncSetupSubPage);
716 }
717
711 NotifyObservers(); 718 NotifyObservers();
712 } 719 }
713 720
714 void ProfileSyncService::ShowErrorUI() { 721 void ProfileSyncService::ShowErrorUI(WebUI* web_ui) {
715 if (IsPassphraseRequired()) { 722 if (IsPassphraseRequired()) {
716 if (IsUsingSecondaryPassphrase()) 723 if (IsUsingSecondaryPassphrase())
717 PromptForExistingPassphrase(); 724 PromptForExistingPassphrase();
718 else 725 else
719 NOTREACHED(); // Migration no longer supported. 726 NOTREACHED(); // Migration no longer supported.
720 727
721 return; 728 return;
722 } 729 }
723 730
724 const GoogleServiceAuthError& error = GetAuthError(); 731 const GoogleServiceAuthError& error = GetAuthError();
725 if (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || 732 if (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
726 error.state() == GoogleServiceAuthError::CAPTCHA_REQUIRED || 733 error.state() == GoogleServiceAuthError::CAPTCHA_REQUIRED ||
727 error.state() == GoogleServiceAuthError::ACCOUNT_DELETED || 734 error.state() == GoogleServiceAuthError::ACCOUNT_DELETED ||
728 error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED || 735 error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED ||
729 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { 736 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) {
730 ShowLoginDialog(); 737 ShowLoginDialog(web_ui);
731 } 738 }
732 } 739 }
733 740
734 741 void ProfileSyncService::ShowConfigure(WebUI* web_ui, bool sync_everything) {
735 void ProfileSyncService::ShowConfigure(bool sync_everything) {
736 if (WizardIsVisible()) { 742 if (WizardIsVisible()) {
737 wizard_.Focus(); 743 wizard_.Focus();
738 return; 744 return;
739 } 745 }
740 746
741 if (sync_everything) 747 if (sync_everything)
742 wizard_.Step(SyncSetupWizard::SYNC_EVERYTHING); 748 wizard_.Step(SyncSetupWizard::SYNC_EVERYTHING);
743 else 749 else
744 wizard_.Step(SyncSetupWizard::CONFIGURE); 750 wizard_.Step(SyncSetupWizard::CONFIGURE);
751
752 if (web_ui)
753 web_ui->CallJavascriptFunction("options.SyncSetupOverlay.showSyncDialog");
754 else
755 BrowserList::GetLastActive()->ShowOptionsTab(chrome::kSyncSetupSubPage);
745 } 756 }
746 757
747 void ProfileSyncService::PromptForExistingPassphrase() { 758 void ProfileSyncService::PromptForExistingPassphrase() {
748 if (WizardIsVisible()) { 759 if (WizardIsVisible()) {
749 wizard_.Focus(); 760 wizard_.Focus();
750 return; 761 return;
751 } 762 }
752 763
753 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); 764 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE);
754 } 765 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 // is initialized, all enabled data types are consistent with one 1313 // is initialized, all enabled data types are consistent with one
1303 // another, and no unrecoverable error has transpired. 1314 // another, and no unrecoverable error has transpired.
1304 if (unrecoverable_error_detected_) 1315 if (unrecoverable_error_detected_)
1305 return false; 1316 return false;
1306 1317
1307 if (!data_type_manager_.get()) 1318 if (!data_type_manager_.get())
1308 return false; 1319 return false;
1309 1320
1310 return data_type_manager_->state() == DataTypeManager::CONFIGURED; 1321 return data_type_manager_->state() == DataTypeManager::CONFIGURED;
1311 } 1322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698