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( ...@@ -14,13 +14,13 @@ OptionsSyncSetupHandler::OptionsSyncSetupHandler(
OptionsSyncSetupHandler::~OptionsSyncSetupHandler() { OptionsSyncSetupHandler::~OptionsSyncSetupHandler() {
} }
void OptionsSyncSetupHandler::ShowSetupUI() { void OptionsSyncSetupHandler::StepWizardForShowSetupUI() {
ProfileSyncService* service = ProfileSyncService* service =
Profile::FromWebUI(web_ui_)->GetProfileSyncService(); Profile::FromWebUI(web_ui_)->GetProfileSyncService();
DCHECK(service); DCHECK(service);
// The user is trying to manually load a syncSetup URL. We should bring up // We should bring up either a login or a configure flow based on the state of
// either a login or a configure flow based on the state of sync. // sync.
if (service->HasSyncSetupCompleted()) { if (service->HasSyncSetupCompleted()) {
if (service->IsPassphraseRequiredForDecryption()) { if (service->IsPassphraseRequiredForDecryption()) {
service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE);
...@@ -30,7 +30,9 @@ void OptionsSyncSetupHandler::ShowSetupUI() { ...@@ -30,7 +30,9 @@ void OptionsSyncSetupHandler::ShowSetupUI() {
} else { } else {
service->get_wizard().Step(SyncSetupWizard::GetLoginState()); service->get_wizard().Step(SyncSetupWizard::GetLoginState());
} }
}
void OptionsSyncSetupHandler::ShowSetupUI() {
// Show the Sync Setup page. // Show the Sync Setup page.
scoped_ptr<Value> page(Value::CreateStringValue("syncSetup")); scoped_ptr<Value> page(Value::CreateStringValue("syncSetup"));
web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page); web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page);
......
...@@ -15,6 +15,8 @@ class OptionsSyncSetupHandler : public SyncSetupHandler { ...@@ -15,6 +15,8 @@ class OptionsSyncSetupHandler : public SyncSetupHandler {
virtual ~OptionsSyncSetupHandler(); virtual ~OptionsSyncSetupHandler();
protected: protected:
virtual void StepWizardForShowSetupUI() OVERRIDE;
virtual void ShowSetupUI() OVERRIDE; virtual void ShowSetupUI() OVERRIDE;
}; };
......
...@@ -179,12 +179,17 @@ void SyncPromoHandler::Observe(int type, ...@@ -179,12 +179,17 @@ void SyncPromoHandler::Observe(int type,
} }
} }
void SyncPromoHandler::ShowSetupUI() { void SyncPromoHandler::StepWizardForShowSetupUI() {
ProfileSyncService* service = ProfileSyncService* service =
Profile::FromWebUI(web_ui_)->GetProfileSyncService(); Profile::FromWebUI(web_ui_)->GetProfileSyncService();
service->get_wizard().Step(SyncSetupWizard::GetLoginState()); 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) { void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) {
CloseSyncSetup(); CloseSyncSetup();
......
...@@ -35,6 +35,8 @@ class SyncPromoHandler : public SyncSetupHandler { ...@@ -35,6 +35,8 @@ class SyncPromoHandler : public SyncSetupHandler {
const content::NotificationDetails& details) OVERRIDE; const content::NotificationDetails& details) OVERRIDE;
protected: protected:
virtual void StepWizardForShowSetupUI() OVERRIDE;
virtual void ShowSetupUI() OVERRIDE; virtual void ShowSetupUI() OVERRIDE;
private: private:
......
...@@ -673,6 +673,8 @@ void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) { ...@@ -673,6 +673,8 @@ void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
CloseOverlay(); CloseOverlay();
return; return;
} }
StepWizardForShowSetupUI();
ShowSetupUI(); ShowSetupUI();
} }
...@@ -704,6 +706,10 @@ void SyncSetupHandler::OpenSyncSetup() { ...@@ -704,6 +706,10 @@ void SyncSetupHandler::OpenSyncSetup() {
return; 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(). // Attach this as the sync setup handler, before calling ShowSetupUI().
if (!service->get_wizard().AttachSyncSetupHandler(this)) { if (!service->get_wizard().AttachSyncSetupHandler(this)) {
LOG(ERROR) << "SyncSetupHandler attach failed!"; LOG(ERROR) << "SyncSetupHandler attach failed!";
......
...@@ -81,6 +81,10 @@ class SyncSetupHandler : public GaiaOAuthConsumer, ...@@ -81,6 +81,10 @@ class SyncSetupHandler : public GaiaOAuthConsumer,
SyncSetupFlow* flow() { return flow_; } 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 // Subclasses must implement this to show the setup UI that's appropriate
// for the page this is contained in. // for the page this is contained in.
virtual void ShowSetupUI() = 0; 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