OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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/dom_ui/stop_syncing_handler.h" |
| 6 |
| 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" |
| 9 #include "base/values.h" |
| 10 #include "base/callback.h" |
| 11 #include "grit/chromium_strings.h" |
| 12 #include "grit/generated_resources.h" |
| 13 #include "chrome/browser/sync/profile_sync_service.h" |
| 14 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/profile_manager.h" |
| 16 |
| 17 StopSyncingHandler::StopSyncingHandler() { |
| 18 } |
| 19 |
| 20 StopSyncingHandler::~StopSyncingHandler() { |
| 21 } |
| 22 |
| 23 void StopSyncingHandler::GetLocalizedValues( |
| 24 DictionaryValue* localized_strings) { |
| 25 DCHECK(localized_strings); |
| 26 localized_strings->SetString(L"stop_syncing_explanation", |
| 27 l10n_util::GetStringF(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL, |
| 28 l10n_util::GetString(IDS_PRODUCT_NAME))); |
| 29 localized_strings->SetString(L"stop_syncing_title", |
| 30 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE)); |
| 31 localized_strings->SetString(L"stop_syncing_confirm", |
| 32 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL)); |
| 33 } |
| 34 |
| 35 void StopSyncingHandler::RegisterMessages() { |
| 36 DCHECK(dom_ui_); |
| 37 dom_ui_->RegisterMessageCallback("stopSyncing", |
| 38 NewCallback(this, &StopSyncingHandler::StopSyncing)); |
| 39 } |
| 40 |
| 41 void StopSyncingHandler::StopSyncing(const Value* value){ |
| 42 DCHECK(dom_ui_); |
| 43 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); |
| 44 if(service != NULL && ProfileSyncService::IsSyncEnabled()) { |
| 45 service->DisableForUser(); |
| 46 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
| 47 } |
| 48 } |
OLD | NEW |