OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_recognition_preferences.h" | 5 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ChromeSpeechRecognitionPreferences::~ChromeSpeechRecognitionPreferences() { | 134 ChromeSpeechRecognitionPreferences::~ChromeSpeechRecognitionPreferences() { |
135 } | 135 } |
136 | 136 |
137 void ChromeSpeechRecognitionPreferences::DetachFromProfile() { | 137 void ChromeSpeechRecognitionPreferences::DetachFromProfile() { |
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
139 DCHECK(profile_); | 139 DCHECK(profile_); |
140 pref_change_registrar_.reset(); | 140 pref_change_registrar_.reset(); |
141 profile_ = NULL; | 141 profile_ = NULL; |
142 } | 142 } |
143 | 143 |
144 void ChromeSpeechRecognitionPreferences::Observe( | 144 void ChromeSpeechRecognitionPreferences::OnPreferenceChanged( |
145 int type, | 145 PrefServiceBase* service, |
146 const content::NotificationSource& source, | 146 const std::string& pref_name) { |
147 const content::NotificationDetails& details) { | |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED); | 148 ReloadPreference(pref_name); |
150 std::string* pref_name = content::Details<std::string>(details).ptr(); | |
151 ReloadPreference(*pref_name); | |
152 } | 149 } |
153 | 150 |
154 bool ChromeSpeechRecognitionPreferences::FilterProfanities() const { | 151 bool ChromeSpeechRecognitionPreferences::FilterProfanities() const { |
155 base::AutoLock read_lock(preferences_lock_); | 152 base::AutoLock read_lock(preferences_lock_); |
156 return filter_profanities_; | 153 return filter_profanities_; |
157 } | 154 } |
158 | 155 |
159 void ChromeSpeechRecognitionPreferences::SetFilterProfanities( | 156 void ChromeSpeechRecognitionPreferences::SetFilterProfanities( |
160 bool filter_profanities) { | 157 bool filter_profanities) { |
161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (key == prefs::kSpeechRecognitionFilterProfanities) { | 202 if (key == prefs::kSpeechRecognitionFilterProfanities) { |
206 filter_profanities_ = | 203 filter_profanities_ = |
207 pref_service->GetBoolean(prefs::kSpeechRecognitionFilterProfanities); | 204 pref_service->GetBoolean(prefs::kSpeechRecognitionFilterProfanities); |
208 } else if (key == prefs::kSpeechRecognitionTrayNotificationShownContexts) { | 205 } else if (key == prefs::kSpeechRecognitionTrayNotificationShownContexts) { |
209 const base::ListValue* pref_list = profile_->GetPrefs()->GetList( | 206 const base::ListValue* pref_list = profile_->GetPrefs()->GetList( |
210 prefs::kSpeechRecognitionTrayNotificationShownContexts); | 207 prefs::kSpeechRecognitionTrayNotificationShownContexts); |
211 DCHECK(pref_list); | 208 DCHECK(pref_list); |
212 notifications_shown_.reset(pref_list->DeepCopy()); | 209 notifications_shown_.reset(pref_list->DeepCopy()); |
213 } | 210 } |
214 } | 211 } |
OLD | NEW |