| Index: chrome/browser/ui/webui/sync_setup_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
|
| similarity index 94%
|
| rename from chrome/browser/ui/webui/options/sync_setup_handler.cc
|
| rename to chrome/browser/ui/webui/sync_setup_handler.cc
|
| index d4c0352233c9e8df78f7865dc2c17a72c2f75be7..8dcfaa85384b0cfa83f9f5cb00e0e4ddf6b560a8 100644
|
| --- a/chrome/browser/ui/webui/options/sync_setup_handler.cc
|
| +++ b/chrome/browser/ui/webui/sync_setup_handler.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/ui/webui/options/sync_setup_handler.h"
|
| +#include "chrome/browser/ui/webui/sync_setup_handler.h"
|
|
|
| #include "base/json/json_reader.h"
|
| #include "base/json/json_writer.h"
|
| @@ -157,6 +157,11 @@ SyncSetupHandler::~SyncSetupHandler() {
|
| }
|
|
|
| void SyncSetupHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
|
| + GetStaticLocalizedValues(localized_strings);
|
| +}
|
| +
|
| +void SyncSetupHandler::GetStaticLocalizedValues(
|
| + DictionaryValue* localized_strings) {
|
| DCHECK(localized_strings);
|
|
|
| localized_strings->SetString(
|
| @@ -259,6 +264,8 @@ void SyncSetupHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
|
| { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE },
|
| { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA },
|
| { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA },
|
| + { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA },
|
| + { "statusNotConnected", IDS_SYNC_STATUS_NOT_CONNECTED }
|
| };
|
|
|
| RegisterStrings(localized_strings, resources, arraysize(resources));
|
| @@ -333,10 +340,7 @@ void SyncSetupHandler::Focus() {
|
| }
|
|
|
| void SyncSetupHandler::OnDidClosePage(const ListValue* args) {
|
| - if (flow_) {
|
| - flow_->OnDialogClosed(std::string());
|
| - flow_ = NULL;
|
| - }
|
| + CloseSyncSetup();
|
| }
|
|
|
| void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) {
|
| @@ -411,29 +415,7 @@ void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) {
|
| }
|
|
|
| void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
|
| - DCHECK(web_ui_);
|
| - DCHECK(!flow_);
|
| -
|
| - ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
|
| - if (!service) {
|
| - // If there's no sync service, the user tried to manually invoke a syncSetup
|
| - // URL, but sync features are disabled. We need to close the overlay for
|
| - // this (rare) case.
|
| - web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
|
| - return;
|
| - }
|
| -
|
| - // If the wizard is not visible, step into the appropriate UI state.
|
| - if (!service->get_wizard().IsVisible())
|
| - HandleShowSetupUI(NULL);
|
| -
|
| - // The SyncSetupFlow will set itself as the |flow_|.
|
| - if (!service->get_wizard().AttachSyncSetupHandler(this)) {
|
| - // If attach fails, a wizard is already activated and attached to a flow
|
| - // handler.
|
| - web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
|
| - service->get_wizard().Focus();
|
| - }
|
| + OpenSyncSetup();
|
| }
|
|
|
| void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
|
| @@ -454,26 +436,38 @@ void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
|
|
|
| void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
|
| DCHECK(!flow_);
|
| + ShowSetupUI();
|
| +}
|
|
|
| - ProfileSyncService* service =
|
| - web_ui_->GetProfile()->GetProfileSyncService();
|
| - DCHECK(service);
|
| +void SyncSetupHandler::CloseSyncSetup() {
|
| + if (flow_) {
|
| + flow_->OnDialogClosed(std::string());
|
| + flow_ = NULL;
|
| + }
|
| +}
|
|
|
| - // If the wizard is already visible, focus it.
|
| - if (service->get_wizard().IsVisible()) {
|
| +void SyncSetupHandler::OpenSyncSetup() {
|
| + DCHECK(web_ui_);
|
| + DCHECK(!flow_);
|
| +
|
| + ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
|
| + if (!service) {
|
| + // If there's no sync service, the user tried to manually invoke a syncSetup
|
| + // URL, but sync features are disabled. We need to close the overlay for
|
| + // this (rare) case.
|
| web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
|
| - service->get_wizard().Focus();
|
| return;
|
| }
|
|
|
| - // 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 (service->HasSyncSetupCompleted())
|
| - service->get_wizard().Step(SyncSetupWizard::CONFIGURE);
|
| - else
|
| - service->get_wizard().Step(SyncSetupWizard::GAIA_LOGIN);
|
| + // If the wizard is not visible, step into the appropriate UI state.
|
| + if (!service->get_wizard().IsVisible())
|
| + ShowSetupUI();
|
|
|
| - // Show the Sync Setup page.
|
| - scoped_ptr<Value> page(Value::CreateStringValue("syncSetup"));
|
| - web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page);
|
| + // The SyncSetupFlow will set itself as the |flow_|.
|
| + if (!service->get_wizard().AttachSyncSetupHandler(this)) {
|
| + // If attach fails, a wizard is already activated and attached to a flow
|
| + // handler.
|
| + web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
|
| + service->get_wizard().Focus();
|
| + }
|
| }
|
|
|