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

Unified Diff: chrome/browser/ui/webui/options/sync_setup_handler.cc

Issue 7093004: Sync: Refactor the ProfileSyncService and sync setup flow to remove use of WebUI from PSS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests, fixes. Created 9 years, 6 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/options/sync_setup_handler.cc
diff --git a/chrome/browser/ui/webui/options/sync_setup_handler.cc b/chrome/browser/ui/webui/options/sync_setup_handler.cc
index 4193c2947b41ab4228c066742a41bb4e9fe915d4..01fe7a4261367a0885d725c90144a465ade15dac 100644
--- a/chrome/browser/ui/webui/options/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/options/sync_setup_handler.cc
@@ -275,6 +275,8 @@ void SyncSetupHandler::RegisterMessages() {
NewCallback(this, &SyncSetupHandler::HandlePassphraseCancel));
web_ui_->RegisterMessageCallback("SyncSetupAttachHandler",
NewCallback(this, &SyncSetupHandler::HandleAttachHandler));
+ web_ui_->RegisterMessageCallback("SyncSetupShowErrorUI",
+ NewCallback(this, &SyncSetupHandler::HandleShowErrorUI));
}
void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) {
@@ -397,6 +399,7 @@ void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) {
flow_->OnPassphraseCancel();
}
+// TODO(jhawkins): Too much logic going on in this method: refactor.
void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
DCHECK(web_ui_);
@@ -410,21 +413,29 @@ void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
return;
}
- if (sync_service->get_wizard().IsVisible()) {
- // The wizard and setup flow have been configured, all we need to do is
- // attach the handler if we haven't already done so.
- if (!flow_)
- flow_ = sync_service->get_wizard().AttachSyncSetupHandler(this);
- return;
- }
+ SyncSetupWizard::State state;
// The user is trying to manually load a syncSetup URL. We should bring up
// either a login or a configure flow based on the state of sync.
- if (sync_service->HasSyncSetupCompleted()) {
- sync_service->ShowConfigure(web_ui_, false);
- } else {
- sync_service->ShowLoginDialog(web_ui_);
- ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_URL);
- }
+ if (sync_service->HasSyncSetupCompleted())
+ state = SyncSetupWizard::CONFIGURE;
+ else
+ state = SyncSetupWizard::GAIA_LOGIN;
+
+ DCHECK(!flow_);
+ sync_service->get_wizard().Step(state);
+
+ // The SyncSetupFlow will set itself as the |flow_|.
+ sync_service->get_wizard().AttachSyncSetupHandler(this);
}
+void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
+ if (!flow_) {
+ ProfileSyncService* service =
+ web_ui_->GetProfile()->GetProfileSyncService();
+ service->get_wizard().Step(SyncSetupWizard::NONFATAL_ERROR);
+ flow_ = service->get_wizard().AttachSyncSetupHandler(this);
+ }
+
+ flow_->Advance(SyncSetupWizard::NONFATAL_ERROR);
+}

Powered by Google App Engine
This is Rietveld 408576698