Commit c1594e4e authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

Sync UI: Remove the StopSyncingHandler.

Move the few strings and one message handler into SyncSetupHandler, where
the rest of the UI lives.

BUG=none
TEST=none
R=csilv


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133965 0039d316-1c4b-4281-b951-d872f2087c98
parent bc920304
...@@ -59,7 +59,7 @@ cr.define('options', function() { ...@@ -59,7 +59,7 @@ cr.define('options', function() {
self.sendConfiguration_(); self.sendConfiguration_();
}; };
$('stop-syncing-ok').onclick = function() { $('stop-syncing-ok').onclick = function() {
chrome.send('stopSyncing'); chrome.send('SyncSetupStopSyncing');
self.closeOverlay_(); self.closeOverlay_();
}; };
}, },
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "chrome/browser/ui/webui/options2/password_manager_handler2.h" #include "chrome/browser/ui/webui/options2/password_manager_handler2.h"
#include "chrome/browser/ui/webui/options2/search_engine_manager_handler2.h" #include "chrome/browser/ui/webui/options2/search_engine_manager_handler2.h"
#include "chrome/browser/ui/webui/options2/startup_pages_handler2.h" #include "chrome/browser/ui/webui/options2/startup_pages_handler2.h"
#include "chrome/browser/ui/webui/options2/stop_syncing_handler.h"
#include "chrome/browser/ui/webui/options2/web_intents_settings_handler2.h" #include "chrome/browser/ui/webui/options2/web_intents_settings_handler2.h"
#include "chrome/browser/ui/webui/theme_source.h" #include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/jstemplate_builder.h" #include "chrome/common/jstemplate_builder.h"
...@@ -248,7 +247,6 @@ OptionsUI::OptionsUI(content::WebUI* web_ui) ...@@ -248,7 +247,6 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler()); AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler());
AddOptionsPageUIHandler(localized_strings, new ImportDataHandler()); AddOptionsPageUIHandler(localized_strings, new ImportDataHandler());
AddOptionsPageUIHandler(localized_strings, new StartupPagesHandler()); AddOptionsPageUIHandler(localized_strings, new StartupPagesHandler());
AddOptionsPageUIHandler(localized_strings, new StopSyncingHandler());
AddOptionsPageUIHandler(localized_strings, new OptionsSyncSetupHandler( AddOptionsPageUIHandler(localized_strings, new OptionsSyncSetupHandler(
g_browser_process->profile_manager())); g_browser_process->profile_manager()));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// 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/options2/stop_syncing_handler.h"
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_ui.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
namespace options2 {
StopSyncingHandler::StopSyncingHandler() {
}
StopSyncingHandler::~StopSyncingHandler() {
}
void StopSyncingHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
localized_strings->SetString("stopSyncingExplanation",
l10n_util::GetStringFUTF16(
IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam(
chrome::kSyncGoogleDashboardURL))));
localized_strings->SetString("stopSyncingTitle",
l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE));
localized_strings->SetString("stopSyncingConfirm",
l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL));
}
void StopSyncingHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("stopSyncing",
base::Bind(&StopSyncingHandler::StopSyncing, base::Unretained(this)));
}
void StopSyncingHandler::StopSyncing(const ListValue* args){
ProfileSyncService* service(ProfileSyncServiceFactory::
GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
if (service != NULL && ProfileSyncService::IsSyncEnabled()) {
service->DisableForUser();
ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
}
}
} // namespace options2
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_STOP_SYNCING_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_STOP_SYNCING_HANDLER_H_
#include "chrome/browser/ui/webui/options2/options_ui2.h"
namespace options2 {
// Chrome personal stuff stop syncing overlay UI handler.
class StopSyncingHandler : public OptionsPageUIHandler {
public:
StopSyncingHandler();
virtual ~StopSyncingHandler();
// OptionsPageUIHandler implementation.
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
private:
void StopSyncing(const base::ListValue* args);
DISALLOW_COPY_AND_ASSIGN(StopSyncingHandler);
};
} // namespace options2
#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_STOP_SYNCING_HANDLER_H_
...@@ -33,7 +33,7 @@ using content::Referrer; ...@@ -33,7 +33,7 @@ using content::Referrer;
namespace { namespace {
// User actions on the sync promo (aka "Sign in to Chrome"). // User actions on the sync promo, i.e., "Sign in to Chrome".
enum SyncPromoUserFlowActionEnums { enum SyncPromoUserFlowActionEnums {
SYNC_PROMO_VIEWED, SYNC_PROMO_VIEWED,
SYNC_PROMO_LEARN_MORE_CLICKED, SYNC_PROMO_LEARN_MORE_CLICKED,
...@@ -55,8 +55,8 @@ enum SyncPromoUserFlowActionEnums { ...@@ -55,8 +55,8 @@ enum SyncPromoUserFlowActionEnums {
}; };
// This was added because of the need to change the existing UMA enum for the // This was added because of the need to change the existing UMA enum for the
// sync promo mid-flight. Ideally these values would be contiguous, but the // sync promo mid-flight. Ideally these values would be contiguous, but the real
// real world is not always ideal. // world is not always ideal.
static bool IsValidUserFlowAction(int action) { static bool IsValidUserFlowAction(int action) {
return (action >= SYNC_PROMO_FIRST_VALID_JS_ACTION && return (action >= SYNC_PROMO_FIRST_VALID_JS_ACTION &&
action <= SYNC_PROMO_LAST_VALID_JS_ACTION) || action <= SYNC_PROMO_LAST_VALID_JS_ACTION) ||
...@@ -67,6 +67,7 @@ static bool IsValidUserFlowAction(int action) { ...@@ -67,6 +67,7 @@ static bool IsValidUserFlowAction(int action) {
SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager)
: SyncSetupHandler(profile_manager), : SyncSetupHandler(profile_manager),
prefs_(NULL),
window_already_closed_(false) { window_already_closed_(false) {
} }
...@@ -99,25 +100,32 @@ void SyncPromoHandler::RegisterMessages() { ...@@ -99,25 +100,32 @@ void SyncPromoHandler::RegisterMessages() {
content::NotificationService::AllSources()); content::NotificationService::AllSources());
} }
web_ui()->RegisterMessageCallback("SyncPromo:Close", web_ui()->RegisterMessageCallback(
"SyncPromo:Close",
base::Bind(&SyncPromoHandler::HandleCloseSyncPromo, base::Bind(&SyncPromoHandler::HandleCloseSyncPromo,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncPromo:Initialize", web_ui()->RegisterMessageCallback(
"SyncPromo:Initialize",
base::Bind(&SyncPromoHandler::HandleInitializeSyncPromo, base::Bind(&SyncPromoHandler::HandleInitializeSyncPromo,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncPromo:RecordSignInAttempts", web_ui()->RegisterMessageCallback(
"SyncPromo:RecordSignInAttempts",
base::Bind(&SyncPromoHandler::HandleRecordSignInAttempts, base::Bind(&SyncPromoHandler::HandleRecordSignInAttempts,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncPromo:RecordThrobberTime", web_ui()->RegisterMessageCallback(
"SyncPromo:RecordThrobberTime",
base::Bind(&SyncPromoHandler::HandleRecordThrobberTime, base::Bind(&SyncPromoHandler::HandleRecordThrobberTime,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncPromo:ShowAdvancedSettings", web_ui()->RegisterMessageCallback(
"SyncPromo:ShowAdvancedSettings",
base::Bind(&SyncPromoHandler::HandleShowAdvancedSettings, base::Bind(&SyncPromoHandler::HandleShowAdvancedSettings,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncPromo:UserFlowAction", web_ui()->RegisterMessageCallback(
"SyncPromo:UserFlowAction",
base::Bind(&SyncPromoHandler::HandleUserFlowAction, base::Bind(&SyncPromoHandler::HandleUserFlowAction,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncPromo:UserSkipped", web_ui()->RegisterMessageCallback(
"SyncPromo:UserSkipped",
base::Bind(&SyncPromoHandler::HandleUserSkipped, base::Bind(&SyncPromoHandler::HandleUserSkipped,
base::Unretained(this))); base::Unretained(this)));
SyncSetupHandler::RegisterMessages(); SyncSetupHandler::RegisterMessages();
...@@ -136,9 +144,9 @@ void SyncPromoHandler::DisplayConfigureSync(bool show_advanced, ...@@ -136,9 +144,9 @@ void SyncPromoHandler::DisplayConfigureSync(bool show_advanced,
SyncSetupHandler::DisplayConfigureSync(true, passphrase_failed); SyncSetupHandler::DisplayConfigureSync(true, passphrase_failed);
} else { } else {
// If no passphrase is required then skip the configure pane and sync // If no passphrase is required then skip the configure pane and sync
// everything by default. This makes the first run experience simpler. // everything by default. This makes the first run experience simpler. Note,
// Note, there's an advanced link in the sync promo that takes users // there's an advanced link in the sync promo that takes users to Settings
// to Settings where the configure pane is not skipped. // where the configure pane is not skipped.
service->OnUserChoseDatatypes(true, syncable::ModelTypeSet()); service->OnUserChoseDatatypes(true, syncable::ModelTypeSet());
ConfigureSyncDone(); ConfigureSyncDone();
} }
...@@ -181,9 +189,8 @@ void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { ...@@ -181,9 +189,8 @@ void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) {
if (!username.empty()) if (!username.empty())
prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true);
// If the browser window is being closed then don't try to navigate to // If the browser window is being closed then don't try to navigate to another
// another URL. This prevents the browser window from flashing during // URL. This prevents the browser window from flashing during close.
// close.
Browser* browser = Browser* browser =
BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents());
if (!browser || !browser->IsAttemptingToCloseBrowser()) { if (!browser || !browser->IsAttemptingToCloseBrowser()) {
......
...@@ -229,6 +229,17 @@ void SyncSetupHandler::GetStaticLocalizedValues( ...@@ -229,6 +229,17 @@ void SyncSetupHandler::GetStaticLocalizedValues(
GetStringFUTF16(IDS_SYNC_PASSPHRASE_RECOVER, GetStringFUTF16(IDS_SYNC_PASSPHRASE_RECOVER,
ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam( ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam(
chrome::kSyncGoogleDashboardURL)))); chrome::kSyncGoogleDashboardURL))));
localized_strings->SetString("stopSyncingExplanation",
l10n_util::GetStringFUTF16(
IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam(
chrome::kSyncGoogleDashboardURL))));
localized_strings->SetString("stopSyncingTitle",
l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE));
localized_strings->SetString("stopSyncingConfirm",
l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL));
bool is_start_page = false; bool is_start_page = false;
if (web_ui) { if (web_ui) {
SyncPromoUI::Source source = SyncPromoUI::GetSourceForSyncPromoURL( SyncPromoUI::Source source = SyncPromoUI::GetSourceForSyncPromoURL(
...@@ -438,6 +449,9 @@ void SyncSetupHandler::RegisterMessages() { ...@@ -438,6 +449,9 @@ void SyncSetupHandler::RegisterMessages() {
"SyncSetupShowSetupUI", "SyncSetupShowSetupUI",
base::Bind(&SyncSetupHandler::HandleShowSetupUI, base::Bind(&SyncSetupHandler::HandleShowSetupUI,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncSetupStopSyncing",
base::Bind(&SyncSetupHandler::HandleStopSyncing,
base::Unretained(this)));
} }
SigninManager* SyncSetupHandler::GetSignin() const { SigninManager* SyncSetupHandler::GetSignin() const {
...@@ -462,7 +476,6 @@ void SyncSetupHandler::DisplayGaiaLoginWithErrorMessage( ...@@ -462,7 +476,6 @@ void SyncSetupHandler::DisplayGaiaLoginWithErrorMessage(
// user: The email the user most recently entered. // user: The email the user most recently entered.
// editable_user: Whether the username field should be editable. // editable_user: Whether the username field should be editable.
// captchaUrl: The captcha image to display to the user (empty if none). // captchaUrl: The captcha image to display to the user (empty if none).
// TODO(atwilson): Convert all to unix_hacker style (http://crbug.com/119646).
std::string user, captcha; std::string user, captcha;
int error; int error;
bool editable_user; bool editable_user;
...@@ -751,6 +764,16 @@ void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) { ...@@ -751,6 +764,16 @@ void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
OpenSyncSetup(false); OpenSyncSetup(false);
} }
void SyncSetupHandler::HandleStopSyncing(const ListValue* args) {
ProfileSyncService* service = GetSyncService();
DCHECK(service);
if (ProfileSyncService::IsSyncEnabled()) {
service->DisableForUser();
ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
}
}
void SyncSetupHandler::CloseSyncSetup() { void SyncSetupHandler::CloseSyncSetup() {
// TODO(atwilson): Move UMA tracking of signin events out of sync module. // TODO(atwilson): Move UMA tracking of signin events out of sync module.
if (IsActiveLogin()) { if (IsActiveLogin()) {
......
...@@ -99,6 +99,7 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler, ...@@ -99,6 +99,7 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler,
void HandleAttachHandler(const base::ListValue* args); void HandleAttachHandler(const base::ListValue* args);
void HandleShowErrorUI(const base::ListValue* args); void HandleShowErrorUI(const base::ListValue* args);
void HandleShowSetupUI(const base::ListValue* args); void HandleShowSetupUI(const base::ListValue* args);
void HandleStopSyncing(const base::ListValue* args);
// Helper routine that gets the Profile associated with this object (virtual // Helper routine that gets the Profile associated with this object (virtual
// so tests can override). // so tests can override).
...@@ -121,7 +122,7 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler, ...@@ -121,7 +122,7 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler,
void DisplayGaiaLoginWithErrorMessage(const string16& error_message, void DisplayGaiaLoginWithErrorMessage(const string16& error_message,
bool fatal_error); bool fatal_error);
// Instead of siging in, prepare requirements for showing the advanced // Instead of signing in, prepare requirements for showing the advanced
// configuration dialog. // configuration dialog.
void PrepareConfigDialog(); void PrepareConfigDialog();
......
...@@ -3814,8 +3814,6 @@ ...@@ -3814,8 +3814,6 @@
'browser/ui/webui/options2/search_engine_manager_handler2.h', 'browser/ui/webui/options2/search_engine_manager_handler2.h',
'browser/ui/webui/options2/startup_pages_handler2.cc', 'browser/ui/webui/options2/startup_pages_handler2.cc',
'browser/ui/webui/options2/startup_pages_handler2.h', 'browser/ui/webui/options2/startup_pages_handler2.h',
'browser/ui/webui/options2/stop_syncing_handler.cc',
'browser/ui/webui/options2/stop_syncing_handler.h',
'browser/ui/webui/options2/web_intents_settings_handler2.cc', 'browser/ui/webui/options2/web_intents_settings_handler2.cc',
'browser/ui/webui/options2/web_intents_settings_handler2.h', 'browser/ui/webui/options2/web_intents_settings_handler2.h',
'browser/ui/webui/plugins_ui.cc', 'browser/ui/webui/plugins_ui.cc',
......
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