Commit ee5a21bc authored by binji@chromium.org's avatar binji@chromium.org

[Sync Setup UI] Separate stepping the SyncSetupWizard from syncSetup page navigation.

BUG=102591
TEST=type chrome://settings/syncSetup. You should see a sync dialog, not the personal options page.


Review URL: http://codereview.chromium.org/8571022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114147 0039d316-1c4b-4281-b951-d872f2087c98
parent 041d14a0
......@@ -14,13 +14,13 @@ OptionsSyncSetupHandler::OptionsSyncSetupHandler(
OptionsSyncSetupHandler::~OptionsSyncSetupHandler() {
}
void OptionsSyncSetupHandler::ShowSetupUI() {
void OptionsSyncSetupHandler::StepWizardForShowSetupUI() {
ProfileSyncService* service =
Profile::FromWebUI(web_ui_)->GetProfileSyncService();
DCHECK(service);
// 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.
// We should bring up either a login or a configure flow based on the state of
// sync.
if (service->HasSyncSetupCompleted()) {
if (service->IsPassphraseRequiredForDecryption()) {
service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE);
......@@ -30,7 +30,9 @@ void OptionsSyncSetupHandler::ShowSetupUI() {
} else {
service->get_wizard().Step(SyncSetupWizard::GetLoginState());
}
}
void OptionsSyncSetupHandler::ShowSetupUI() {
// Show the Sync Setup page.
scoped_ptr<Value> page(Value::CreateStringValue("syncSetup"));
web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page);
......
......@@ -15,6 +15,8 @@ class OptionsSyncSetupHandler : public SyncSetupHandler {
virtual ~OptionsSyncSetupHandler();
protected:
virtual void StepWizardForShowSetupUI() OVERRIDE;
virtual void ShowSetupUI() OVERRIDE;
};
......
......@@ -179,12 +179,17 @@ void SyncPromoHandler::Observe(int type,
}
}
void SyncPromoHandler::ShowSetupUI() {
void SyncPromoHandler::StepWizardForShowSetupUI() {
ProfileSyncService* service =
Profile::FromWebUI(web_ui_)->GetProfileSyncService();
service->get_wizard().Step(SyncSetupWizard::GetLoginState());
}
void SyncPromoHandler::ShowSetupUI() {
// We don't need to do anything here; The UI for the sync promo is already
// displayed.
}
void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) {
CloseSyncSetup();
......
......@@ -35,6 +35,8 @@ class SyncPromoHandler : public SyncSetupHandler {
const content::NotificationDetails& details) OVERRIDE;
protected:
virtual void StepWizardForShowSetupUI() OVERRIDE;
virtual void ShowSetupUI() OVERRIDE;
private:
......
......@@ -673,6 +673,8 @@ void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
CloseOverlay();
return;
}
StepWizardForShowSetupUI();
ShowSetupUI();
}
......@@ -704,6 +706,10 @@ void SyncSetupHandler::OpenSyncSetup() {
return;
}
// The wizard must be stepped before attaching. Allow subclasses to step the
// wizard to appropriate state.
StepWizardForShowSetupUI();
// Attach this as the sync setup handler, before calling ShowSetupUI().
if (!service->get_wizard().AttachSyncSetupHandler(this)) {
LOG(ERROR) << "SyncSetupHandler attach failed!";
......
......@@ -81,6 +81,10 @@ class SyncSetupHandler : public GaiaOAuthConsumer,
SyncSetupFlow* flow() { return flow_; }
// Subclasses must implement to step the SyncSetupWizard to the correct state
// before showing the Setup UI.
virtual void StepWizardForShowSetupUI() = 0;
// Subclasses must implement this to show the setup UI that's appropriate
// for the page this is contained in.
virtual void ShowSetupUI() = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment