| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/webui/options2/stop_syncing_handler2.h" | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/bind.h" | |
| 9 #include "base/utf_string_conversions.h" | |
| 10 #include "base/values.h" | |
| 11 #include "chrome/browser/google/google_util.h" | |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "chrome/browser/profiles/profile_manager.h" | |
| 14 #include "chrome/browser/sync/profile_sync_service.h" | |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 16 #include "chrome/common/url_constants.h" | |
| 17 #include "content/public/browser/web_ui.h" | |
| 18 #include "grit/chromium_strings.h" | |
| 19 #include "grit/generated_resources.h" | |
| 20 #include "ui/base/l10n/l10n_util.h" | |
| 21 | |
| 22 namespace options2 { | |
| 23 | |
| 24 StopSyncingHandler::StopSyncingHandler() { | |
| 25 } | |
| 26 | |
| 27 StopSyncingHandler::~StopSyncingHandler() { | |
| 28 } | |
| 29 | |
| 30 void StopSyncingHandler::GetLocalizedValues( | |
| 31 DictionaryValue* localized_strings) { | |
| 32 DCHECK(localized_strings); | |
| 33 localized_strings->SetString("stopSyncingExplanation", | |
| 34 l10n_util::GetStringFUTF16( | |
| 35 IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL, | |
| 36 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 37 ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam( | |
| 38 chrome::kSyncGoogleDashboardURL)))); | |
| 39 localized_strings->SetString("stopSyncingTitle", | |
| 40 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE)); | |
| 41 localized_strings->SetString("stopSyncingConfirm", | |
| 42 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL)); | |
| 43 } | |
| 44 | |
| 45 void StopSyncingHandler::RegisterMessages() { | |
| 46 web_ui()->RegisterMessageCallback("stopSyncing", | |
| 47 base::Bind(&StopSyncingHandler::StopSyncing, base::Unretained(this))); | |
| 48 } | |
| 49 | |
| 50 void StopSyncingHandler::StopSyncing(const ListValue* args){ | |
| 51 ProfileSyncService* service(ProfileSyncServiceFactory:: | |
| 52 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | |
| 53 if (service != NULL && ProfileSyncService::IsSyncEnabled()) { | |
| 54 service->DisableForUser(); | |
| 55 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 } // namespace options2 | |
| OLD | NEW |