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/speech/chrome_speech_input_preferences.h" | 5 #include "chrome/browser/speech/chrome_speech_input_preferences.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
11 | 11 |
12 ChromeSpeechInputPreferences::ChromeSpeechInputPreferences( | 12 ChromeSpeechInputPreferences::ChromeSpeechInputPreferences( |
13 PrefService* pref_service) | 13 PrefService* pref_service) { |
14 : censor_results_( | 14 // Migrate the old profanity filtering key to the new one. |
Satish
2011/10/07 20:09:26
may be simpler to leave the name of the preference
Leandro GraciĆ” Gil
2011/10/07 23:22:09
Agreed. I'll leave a comment to make sure the old
| |
15 pref_service->GetBoolean(prefs::kSpeechInputCensorResults)) { | 15 if (pref_service->HasPrefPath(prefs::kSpeechInputCensorResultsDeprecated)) { |
16 bool filter = pref_service->GetBoolean( | |
17 prefs::kSpeechInputCensorResultsDeprecated); | |
18 pref_service->ClearPref(prefs::kSpeechInputCensorResultsDeprecated); | |
19 pref_service->SetBoolean(prefs::kSpeechInputFilterProfanities, filter); | |
20 filter_profanities_ = filter; | |
21 } else { | |
22 filter_profanities_ = pref_service->GetBoolean( | |
23 prefs::kSpeechInputFilterProfanities); | |
24 } | |
16 } | 25 } |
17 | 26 |
18 ChromeSpeechInputPreferences::~ChromeSpeechInputPreferences() { | 27 ChromeSpeechInputPreferences::~ChromeSpeechInputPreferences() { |
19 } | 28 } |
20 | 29 |
21 bool ChromeSpeechInputPreferences::censor_results() const { | 30 bool ChromeSpeechInputPreferences::filter_profanities() const { |
22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
23 return censor_results_; | 32 return filter_profanities_; |
24 } | 33 } |
25 | 34 |
26 void ChromeSpeechInputPreferences::set_censor_results(bool censor_results) { | 35 void ChromeSpeechInputPreferences::set_filter_profanities( |
36 bool filter_profanities) { | |
27 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 37 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
28 BrowserThread::PostTask( | 38 BrowserThread::PostTask( |
29 BrowserThread::IO, FROM_HERE, | 39 BrowserThread::IO, FROM_HERE, |
30 base::Bind(&ChromeSpeechInputPreferences::set_censor_results, | 40 base::Bind(&ChromeSpeechInputPreferences::set_filter_profanities, |
31 this, censor_results)); | 41 this, filter_profanities)); |
32 return; | 42 return; |
33 } | 43 } |
34 censor_results_ = censor_results; | 44 filter_profanities_ = filter_profanities; |
35 } | 45 } |
OLD | NEW |