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

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

Issue 7399015: Sync Promo: Add a way to collapse the sync promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review feedback Created 9 years, 5 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/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();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698