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

Unified Diff: chrome/browser/ui/webui/settings/people_handler.cc

Issue 1967883002: Settings People Revamp: Fix some small bugs in the handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the failing test Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/people_handler.cc
diff --git a/chrome/browser/ui/webui/settings/people_handler.cc b/chrome/browser/ui/webui/settings/people_handler.cc
index e24047bdbd55122077eb9a5f4f46666cb1c45e44..02f02a1bd1c3a06cd654172f78e8558c4d1f9688 100644
--- a/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chrome/browser/ui/webui/settings/people_handler.cc
@@ -162,6 +162,7 @@ const char PeopleHandler::kPassphraseFailedPageStatus[] = "passphraseFailed";
PeopleHandler::PeopleHandler(Profile* profile)
: profile_(profile),
configuring_sync_(false),
+ signin_observer_(this),
sync_service_observer_(this) {}
PeopleHandler::~PeopleHandler() {
@@ -225,6 +226,11 @@ void PeopleHandler::OnJavascriptAllowed() {
prefs::kSigninAllowed,
base::Bind(&PeopleHandler::UpdateSyncStatus, base::Unretained(this)));
+ SigninManagerBase* signin_manager(
+ SigninManagerFactory::GetInstance()->GetForProfile(profile_));
+ if (signin_manager)
+ signin_observer_.Add(signin_manager);
+
ProfileSyncService* sync_service(
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_));
if (sync_service)
@@ -233,6 +239,7 @@ void PeopleHandler::OnJavascriptAllowed() {
void PeopleHandler::OnJavascriptDisallowed() {
profile_pref_registrar_.RemoveAll();
+ signin_observer_.RemoveAll();
sync_service_observer_.RemoveAll();
}
@@ -364,6 +371,8 @@ void PeopleHandler::SyncStartupCompleted() {
// Stop a timer to handle timeout in waiting for checking network connection.
backend_start_timer_.reset();
+ sync_startup_tracker_.reset();
+
PushSyncPrefs();
}
@@ -577,6 +586,8 @@ void PeopleHandler::HandleCloseTimeout(const base::ListValue* args) {
}
void PeopleHandler::HandleGetSyncStatus(const base::ListValue* args) {
+ AllowJavascript();
+
CHECK_EQ(1U, args->GetSize());
const base::Value* callback_id;
CHECK(args->Get(0, &callback_id));
@@ -659,7 +670,6 @@ void PeopleHandler::OpenSyncSetup(bool creating_supervised_user) {
// 7) User re-enables sync after disabling it via advanced settings.
#if !defined(OS_CHROMEOS)
SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_);
-
if (!signin->IsAuthenticated() ||
SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) {
// User is not logged in (cases 1-2), or login has been specially requested
@@ -688,14 +698,6 @@ void PeopleHandler::OpenSyncSetup(bool creating_supervised_user) {
FocusUI();
}
-void PeopleHandler::OpenConfigureSync() {
- if (!PrepareSyncSetup())
- return;
-
- PushSyncPrefs();
- FocusUI();
-}
-
void PeopleHandler::FocusUI() {
DCHECK(IsActiveLogin());
WebContents* web_contents = web_ui()->GetWebContents();
@@ -799,8 +801,18 @@ bool PeopleHandler::FocusExistingWizardIfPresent() {
}
void PeopleHandler::PushSyncPrefs() {
- // Should never call this when we are not signed in.
- DCHECK(SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated());
+#if !defined(OS_CHROMEOS)
+ // Early exit if the user has not signed in yet.
+ if (!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated() ||
+ SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) {
+ return;
+ }
+#endif
+
+ // Early exit if there is already a preferences push pending sync startup.
+ if (sync_startup_tracker_)
+ return;
+
ProfileSyncService* service = GetSyncService();
DCHECK(service);
if (!service->IsBackendInitialized()) {
@@ -820,9 +832,6 @@ void PeopleHandler::PushSyncPrefs() {
return;
}
- // Should only get here if user is signed in and sync is initialized, so no
- // longer need a SyncStartupTracker.
- sync_startup_tracker_.reset();
configuring_sync_ = true;
DCHECK(service->IsBackendInitialized())
<< "Cannot configure sync until the sync backend is initialized";
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.h ('k') | chrome/browser/ui/webui/settings/people_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698