OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/options/stop_syncing_handler.h" | 5 #include "chrome/browser/ui/webui/options/stop_syncing_handler.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
16 | 17 |
17 StopSyncingHandler::StopSyncingHandler() { | 18 StopSyncingHandler::StopSyncingHandler() { |
18 } | 19 } |
19 | 20 |
20 StopSyncingHandler::~StopSyncingHandler() { | 21 StopSyncingHandler::~StopSyncingHandler() { |
21 } | 22 } |
22 | 23 |
23 void StopSyncingHandler::GetLocalizedValues( | 24 void StopSyncingHandler::GetLocalizedValues( |
24 DictionaryValue* localized_strings) { | 25 DictionaryValue* localized_strings) { |
25 DCHECK(localized_strings); | 26 DCHECK(localized_strings); |
26 localized_strings->SetString("stopSyncingExplanation", | 27 localized_strings->SetString("stopSyncingExplanation", |
27 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL)); | 28 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL)); |
28 localized_strings->SetString("stopSyncingTitle", | 29 localized_strings->SetString("stopSyncingTitle", |
29 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE)); | 30 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE)); |
30 localized_strings->SetString("stopSyncingConfirm", | 31 localized_strings->SetString("stopSyncingConfirm", |
31 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL)); | 32 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL)); |
32 } | 33 } |
33 | 34 |
34 void StopSyncingHandler::RegisterMessages() { | 35 void StopSyncingHandler::RegisterMessages() { |
35 DCHECK(web_ui_); | 36 DCHECK(web_ui_); |
36 web_ui_->RegisterMessageCallback("stopSyncing", | 37 web_ui_->RegisterMessageCallback("stopSyncing", |
37 NewCallback(this, &StopSyncingHandler::StopSyncing)); | 38 NewCallback(this, &StopSyncingHandler::StopSyncing)); |
38 } | 39 } |
39 | 40 |
40 void StopSyncingHandler::StopSyncing(const ListValue* args){ | 41 void StopSyncingHandler::StopSyncing(const ListValue* args){ |
41 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService(); | 42 Profile* profile = |
| 43 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()); |
| 44 ProfileSyncService* service = profile->GetProfileSyncService(); |
42 if (service != NULL && ProfileSyncService::IsSyncEnabled()) { | 45 if (service != NULL && ProfileSyncService::IsSyncEnabled()) { |
43 service->DisableForUser(); | 46 service->DisableForUser(); |
44 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); | 47 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
45 } | 48 } |
46 } | 49 } |
OLD | NEW |