Index: chrome/browser/ui/webui/sync_setup_handler.cc |
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc |
index 2663f5f8a90e502a7f09b9e5e1f1a0a9f710b84b..d938db5efcb5e8e67406488ff59cc87e7e1f1d8c 100644 |
--- a/chrome/browser/ui/webui/sync_setup_handler.cc |
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc |
@@ -490,6 +490,14 @@ void SyncSetupHandler::DisplayGaiaLoginWithErrorMessage( |
"SyncSetupOverlay.showSyncSetupPage", page, args); |
} |
+// TODO(kochi): Handle error conditions (timeout, other failures). |
+void SyncSetupHandler::DisplaySpinner() { |
+ configuring_sync_ = true; |
+ StringValue page("spinner"); |
+ web_ui()->CallJavascriptFunction( |
+ "SyncSetupOverlay.showSyncSetupPage", page, DictionaryValue()); |
+} |
+ |
void SyncSetupHandler::RecordSignin() { |
// By default, do nothing - subclasses can override. |
} |
@@ -507,7 +515,9 @@ void SyncSetupHandler::DisplayGaiaSuccessAndSettingUp() { |
void SyncSetupHandler::ShowFatalError() { |
// For now, just send the user back to the login page. Ultimately may want |
// to give different feedback (especially for chromeos). |
+#if !defined(OS_CHROMEOS) |
DisplayGaiaLogin(true); |
+#endif |
} |
void SyncSetupHandler::OnDidClosePage(const ListValue* args) { |
@@ -586,7 +596,13 @@ void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { |
last_signin_error_ = error; |
// Got a failed signin - this is either just a typical auth error, or a |
// sync error (treat sync errors as "fatal errors" - i.e. non-auth errors). |
+ // On ChromeOS, this condition should trigger the orange badge on wrench menu |
+ // and prompt to sign out. |
+#if !defined(OS_CHROMEOS) |
DisplayGaiaLogin(GetSyncService()->unrecoverable_error_detected()); |
+#else |
+ CloseOverlay(); |
+#endif |
} |
Profile* SyncSetupHandler::GetProfile() const { |
@@ -598,14 +614,16 @@ ProfileSyncService* SyncSetupHandler::GetSyncService() const { |
} |
void SyncSetupHandler::SigninSuccess() { |
+ LOG(WARNING) << "SigninSuccess()"; |
DCHECK(GetSyncService()->sync_initialized()); |
// If we have signed in while sync is already setup, it must be due to some |
// kind of re-authentication flow. In that case, just close the signin dialog |
// rather than forcing the user to go through sync configuration. |
- if (GetSyncService()->HasSyncSetupCompleted()) |
+ if (GetSyncService()->HasSyncSetupCompleted()) { |
Andrew T Wilson (Slow)
2012/04/03 22:22:33
nit: No need to modify this code by adding braces.
kochi
2012/04/03 23:21:48
Done.
|
DisplayGaiaSuccessAndClose(); |
- else |
+ } else { |
DisplayConfigureSync(false, false); |
+ } |
} |
void SyncSetupHandler::HandleConfigure(const ListValue* args) { |
@@ -756,11 +774,12 @@ void SyncSetupHandler::CloseSyncSetup() { |
// Make sure user isn't left half-logged-in (signed in, but without sync |
// started up). If the user hasn't finished setting up sync, then sign out |
// and shut down sync. |
- |
if (sync_service && !sync_service->HasSyncSetupCompleted()) { |
DVLOG(1) << "Signin aborted by user action"; |
sync_service->DisableForUser(); |
+#if !defined(OS_CHROMEOS) |
GetSignin()->SignOut(); |
+#endif |
} |
} |
@@ -795,13 +814,40 @@ void SyncSetupHandler::OpenSyncSetup(bool force_login) { |
// via the "Advanced..." button or the wrench menu. |
DisplayConfigureSync(true, false); |
} else { |
+#if !defined(OS_CHROMEOS) |
// User is not logged in - need to display login UI. |
DisplayGaiaLogin(false); |
+#else |
+ PrepareConfigDialog(); |
+#endif |
} |
ShowSetupUI(); |
} |
+void SyncSetupHandler::PrepareConfigDialog() { |
+ // On Chrome OS user is always logged in. Instead of showing login dialog, |
+ // show spinner until the backend gets ready to configure sync. |
+ |
+ // To make PSS:AreCredentialsAvailable() to return true, first we need |
+ // to unsppress the flag. |
+ browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); |
+ sync_prefs.SetStartSuppressed(false); |
Andrew T Wilson (Slow)
2012/04/03 22:22:33
Do we need to call SetStartSuppressed? Doesn't Uns
kochi
2012/04/03 23:21:48
I think so. Removed.
This was done when I did som
|
+ |
+ ProfileSyncService* service = GetSyncService(); |
+ if (!service->sync_initialized()) { |
+ // To listen to the token available notifications, start SigninTracker. |
+ signin_tracker_.reset( |
+ new SigninTracker(GetProfile(), this, |
+ SigninTracker::SERVICES_INITIALIZING)); |
+ service->set_setup_in_progress(true); |
+ service->UnsuppressAndStart(); |
+ DisplaySpinner(); |
+ } else { |
+ DisplayConfigureSync(true, false); |
+ } |
+} |
+ |
// Private member functions. |
bool SyncSetupHandler::FocusExistingWizardIfPresent() { |