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

Side by Side Diff: chrome/browser/ui/webui/settings/people_handler.cc

Issue 2598073002: MD Settings: Fix policy-related ProfileSyncService crashes. (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) { 768 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) {
769 return; 769 return;
770 } 770 }
771 #endif 771 #endif
772 772
773 // Early exit if there is already a preferences push pending sync startup. 773 // Early exit if there is already a preferences push pending sync startup.
774 if (sync_startup_tracker_) 774 if (sync_startup_tracker_)
775 return; 775 return;
776 776
777 ProfileSyncService* service = GetSyncService(); 777 ProfileSyncService* service = GetSyncService();
778 DCHECK(service); 778 // The sync service may be nullptr if it has been just disabled by policy.
779 if (!service)
780 return;
781
779 if (!service->IsEngineInitialized()) { 782 if (!service->IsEngineInitialized()) {
780 // Requesting the sync service to start may trigger another reentrant call 783 // Requesting the sync service to start may trigger another reentrant call
781 // to PushSyncPrefs. Setting up the startup tracker beforehand correctly 784 // to PushSyncPrefs. Setting up the startup tracker beforehand correctly
782 // signals the re-entrant call to early exit. 785 // signals the re-entrant call to early exit.
783 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); 786 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this));
784 service->RequestStart(); 787 service->RequestStart();
785 788
786 // See if it's even possible to bring up the sync engine - if not 789 // See if it's even possible to bring up the sync engine - if not
787 // (unrecoverable error?), don't bother displaying a spinner that will be 790 // (unrecoverable error?), don't bother displaying a spinner that will be
788 // immediately closed because this leads to some ugly infinite UI loop (see 791 // immediately closed because this leads to some ugly infinite UI loop (see
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 base::StringValue("sync-status-changed"), 899 base::StringValue("sync-status-changed"),
897 *GetSyncStatusDictionary()); 900 *GetSyncStatusDictionary());
898 } 901 }
899 902
900 void PeopleHandler::MarkFirstSetupComplete() { 903 void PeopleHandler::MarkFirstSetupComplete() {
901 // Suppress the sign in promo once the user starts sync. This way the user 904 // Suppress the sign in promo once the user starts sync. This way the user
902 // doesn't see the sign in promo even if they sign out later on. 905 // doesn't see the sign in promo even if they sign out later on.
903 signin::SetUserSkippedPromo(profile_); 906 signin::SetUserSkippedPromo(profile_);
904 907
905 ProfileSyncService* service = GetSyncService(); 908 ProfileSyncService* service = GetSyncService();
906 DCHECK(service); 909 // The sync service may be nullptr if it has been just disabled by policy.
907 if (service->IsFirstSetupComplete()) 910 if (!service || service->IsFirstSetupComplete())
Dan Beam 2016/12/22 22:07:40 nit: is there somehow we can check that if !servic
tommycli 2016/12/22 22:46:16 Well... it's more like, GetSyncService() returns n
908 return; 911 return;
909 912
910 // This is the first time configuring sync, so log it. 913 // This is the first time configuring sync, so log it.
911 base::FilePath profile_file_path = profile_->GetPath(); 914 base::FilePath profile_file_path = profile_->GetPath();
912 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); 915 ProfileMetrics::LogProfileSyncSignIn(profile_file_path);
913 916
914 // We're done configuring, so notify ProfileSyncService that it is OK to 917 // We're done configuring, so notify ProfileSyncService that it is OK to
915 // start syncing. 918 // start syncing.
916 sync_blocker_.reset(); 919 sync_blocker_.reset();
917 service->SetFirstSetupComplete(); 920 service->SetFirstSetupComplete();
918 } 921 }
919 922
920 } // namespace settings 923 } // namespace settings
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698