Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/settings/people_handler.h" | 5 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 return; | 655 return; |
| 656 } | 656 } |
| 657 #endif | 657 #endif |
| 658 if (!service) { | 658 if (!service) { |
| 659 // This can happen if the user directly navigates to /settings/syncSetup. | 659 // This can happen if the user directly navigates to /settings/syncSetup. |
| 660 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; | 660 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; |
| 661 CloseUI(); | 661 CloseUI(); |
| 662 return; | 662 return; |
| 663 } | 663 } |
| 664 | 664 |
| 665 if (!service->IsEngineInitialized()) { | |
| 666 // Requesting the sync service to start may trigger call to PushSyncPrefs. | |
| 667 // Setting up the startup tracker beforehand correctly signals the | |
| 668 // re-entrant call to early exit. | |
| 669 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); | |
| 670 service->RequestStart(); | |
| 671 | |
| 672 // See if it's even possible to bring up the sync engine - if not | |
| 673 // (unrecoverable error?), don't bother displaying a spinner that will be | |
| 674 // immediately closed because this leads to some ugly infinite UI loop (see | |
| 675 // http://crbug.com/244769). | |
| 676 if (SyncStartupTracker::GetSyncServiceState(profile_) != | |
| 677 SyncStartupTracker::SYNC_STARTUP_ERROR) { | |
| 678 DisplaySpinner(); | |
| 679 } | |
| 680 return; | |
| 681 } | |
| 682 | |
| 665 // User is already logged in. They must have brought up the config wizard | 683 // User is already logged in. They must have brought up the config wizard |
| 666 // via the "Advanced..." button or through One-Click signin (cases 4-6), or | 684 // via the "Advanced..." button or through One-Click signin (cases 4-6), or |
| 667 // they are re-enabling sync after having disabled it (case 7). | 685 // they are re-enabling sync after having disabled it (case 7). |
| 668 PushSyncPrefs(); | 686 PushSyncPrefs(); |
| 669 } | 687 } |
| 670 | 688 |
| 671 void PeopleHandler::FocusUI() { | 689 void PeopleHandler::FocusUI() { |
| 672 WebContents* web_contents = web_ui()->GetWebContents(); | 690 WebContents* web_contents = web_ui()->GetWebContents(); |
| 673 web_contents->GetDelegate()->ActivateContents(web_contents); | 691 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 674 } | 692 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 #if !defined(OS_CHROMEOS) | 783 #if !defined(OS_CHROMEOS) |
| 766 // Early exit if the user has not signed in yet. | 784 // Early exit if the user has not signed in yet. |
| 767 if (!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated() || | 785 if (!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated() || |
| 768 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) { | 786 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) { |
| 769 return; | 787 return; |
| 770 } | 788 } |
| 771 #endif | 789 #endif |
| 772 | 790 |
| 773 // Early exit if there is already a preferences push pending sync startup. | 791 // Early exit if there is already a preferences push pending sync startup. |
| 774 if (sync_startup_tracker_) | 792 if (sync_startup_tracker_) |
| 775 return; | 793 return; |
|
tommycli
2017/02/27 21:46:04
I think you will have to move this early-exit to t
pavely
2017/02/28 01:02:54
Yes, you are right.
Done.
| |
| 776 | 794 |
| 777 ProfileSyncService* service = GetSyncService(); | 795 ProfileSyncService* service = GetSyncService(); |
| 778 // The sync service may be nullptr if it has been just disabled by policy. | 796 // The sync service may be nullptr if it has been just disabled by policy. |
| 779 if (!service) | 797 if (!service || !service->IsEngineInitialized()) { |
| 780 return; | |
| 781 | |
| 782 if (!service->IsEngineInitialized()) { | |
| 783 // Requesting the sync service to start may trigger another reentrant call | |
| 784 // to PushSyncPrefs. Setting up the startup tracker beforehand correctly | |
| 785 // signals the re-entrant call to early exit. | |
| 786 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); | |
| 787 service->RequestStart(); | |
| 788 | |
| 789 // See if it's even possible to bring up the sync engine - if not | |
| 790 // (unrecoverable error?), don't bother displaying a spinner that will be | |
| 791 // immediately closed because this leads to some ugly infinite UI loop (see | |
| 792 // http://crbug.com/244769). | |
| 793 if (SyncStartupTracker::GetSyncServiceState(profile_) != | |
| 794 SyncStartupTracker::SYNC_STARTUP_ERROR) { | |
| 795 DisplaySpinner(); | |
| 796 } | |
| 797 return; | 798 return; |
| 798 } | 799 } |
| 799 | 800 |
| 800 configuring_sync_ = true; | 801 configuring_sync_ = true; |
| 801 DCHECK(service->IsEngineInitialized()) | 802 DCHECK(service->IsEngineInitialized()) |
| 802 << "Cannot configure sync until the sync engine is initialized"; | 803 << "Cannot configure sync until the sync engine is initialized"; |
| 803 | 804 |
| 804 // Setup args for the sync configure screen: | 805 // Setup args for the sync configure screen: |
| 805 // syncAllDataTypes: true if the user wants to sync everything | 806 // syncAllDataTypes: true if the user wants to sync everything |
| 806 // <data_type>Registered: true if the associated data type is supported | 807 // <data_type>Registered: true if the associated data type is supported |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 base::FilePath profile_file_path = profile_->GetPath(); | 915 base::FilePath profile_file_path = profile_->GetPath(); |
| 915 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 916 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 916 | 917 |
| 917 // We're done configuring, so notify ProfileSyncService that it is OK to | 918 // We're done configuring, so notify ProfileSyncService that it is OK to |
| 918 // start syncing. | 919 // start syncing. |
| 919 sync_blocker_.reset(); | 920 sync_blocker_.reset(); |
| 920 service->SetFirstSetupComplete(); | 921 service->SetFirstSetupComplete(); |
| 921 } | 922 } |
| 922 | 923 |
| 923 } // namespace settings | 924 } // namespace settings |
| OLD | NEW |