summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 21:10:29 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 21:10:29 +0000
commit9232738f3f237d64e15fe17f9830b516652f5c86 (patch)
treee8e64d72bdab3ff5a33c57c674f72105fcddf771 /chrome
parenta081aebba3483e4605cff0e81b917b69b0f49fe3 (diff)
downloadchromium_src-9232738f3f237d64e15fe17f9830b516652f5c86.zip
chromium_src-9232738f3f237d64e15fe17f9830b516652f5c86.tar.gz
chromium_src-9232738f3f237d64e15fe17f9830b516652f5c86.tar.bz2
Get rid of the SpeechRecognitionPreferences interface. It only had one method, and we can roll that into SpeechRecognitionDelegate instead to simplify things. This also allows us to get rid of ChromeSpeechRecognitionPreferences.
R=tommi@chromium.org Review URL: https://codereview.chromium.org/18487007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc4
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc5
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h2
-rw-r--r--chrome/browser/profiles/profile.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.cc10
-rw-r--r--chrome/browser/profiles/profile_impl.h6
-rw-r--r--chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc15
-rw-r--r--chrome/browser/speech/chrome_speech_recognition_manager_delegate.h1
-rw-r--r--chrome/browser/speech/chrome_speech_recognition_preferences.cc219
-rw-r--r--chrome/browser/speech/chrome_speech_recognition_preferences.h124
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc11
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/test/base/testing_profile.cc10
-rw-r--r--chrome/test/base/testing_profile.h2
14 files changed, 23 insertions, 392 deletions
diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
index e5ca157..06426c2 100644
--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
@@ -83,7 +83,6 @@
#include "chrome/browser/signin/about_signin_internals_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
-#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
#include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -176,9 +175,6 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() {
#if defined(OS_CHROMEOS)
chromeos::NetworkingPrivateEventRouterFactory::GetInstance();
#endif
-#if defined(ENABLE_INPUT_SPEECH)
- ChromeSpeechRecognitionPreferences::InitializeFactory();
-#endif
#if defined(ENABLE_PRINTING)
CloudPrintProxyServiceFactory::GetInstance();
#endif
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 592ed84..64064a7 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -321,11 +321,6 @@ content::GeolocationPermissionContext*
return ChromeGeolocationPermissionContextFactory::GetForProfile(this);
}
-content::SpeechRecognitionPreferences*
- OffTheRecordProfileImpl::GetSpeechRecognitionPreferences() {
- return profile_->GetSpeechRecognitionPreferences();
-}
-
quota::SpecialStoragePolicy*
OffTheRecordProfileImpl::GetSpecialStoragePolicy() {
return GetExtensionSpecialStoragePolicy();
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index f6053e1..9f6ed29 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -101,8 +101,6 @@ class OffTheRecordProfileImpl : public Profile {
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
virtual content::GeolocationPermissionContext*
GetGeolocationPermissionContext() OVERRIDE;
- virtual content::SpeechRecognitionPreferences*
- GetSpeechRecognitionPreferences() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
private:
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index d060484..0f86688 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -111,6 +111,10 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
prefs::kDefaultApps,
"install",
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ registry->RegisterBooleanPref(
+ prefs::kSpeechRecognitionFilterProfanities,
+ true,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#if defined(OS_CHROMEOS)
// TODO(dilmah): For OS_CHROMEOS we maintain kApplicationLocale in both
// local state and user's profile. For other platforms we maintain
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index aa86bf0..7123d16 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -67,7 +67,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/sessions/session_service_factory.h"
-#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
#include "chrome/browser/user_style_sheet_watcher.h"
@@ -903,15 +902,6 @@ content::GeolocationPermissionContext*
return ChromeGeolocationPermissionContextFactory::GetForProfile(this);
}
-content::SpeechRecognitionPreferences*
-ProfileImpl::GetSpeechRecognitionPreferences() {
-#if defined(ENABLE_INPUT_SPEECH)
- return ChromeSpeechRecognitionPreferences::GetForProfile(this).get();
-#else
- return NULL;
-#endif
-}
-
DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() {
return DownloadServiceFactory::GetForProfile(this)->
GetDownloadManagerDelegate();
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 59e125c..a8ece65 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -37,10 +37,6 @@ namespace base {
class SequencedTaskRunner;
}
-namespace content {
-class SpeechRecognitionPreferences;
-}
-
namespace extensions {
class ExtensionSystem;
}
@@ -81,8 +77,6 @@ class ProfileImpl : public Profile {
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
virtual content::GeolocationPermissionContext*
GetGeolocationPermissionContext() OVERRIDE;
- virtual content::SpeechRecognitionPreferences*
- GetSpeechRecognitionPreferences() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
// Profile implementation:
diff --git a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
index 24e74ef..0d4bb39 100644
--- a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
+++ b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -343,8 +342,7 @@ void ChromeSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id);
// Make sure that initiators (extensions/web pages) properly set the
- // |render_process_id| field, which is needed later to retrieve the
- // ChromeSpeechRecognitionPreferences associated to their profile.
+ // |render_process_id| field, which is needed later to retrieve the profile.
DCHECK_NE(context.render_process_id, 0);
// Check that the render view type is appropriate, and whether or not we
@@ -362,6 +360,17 @@ ChromeSpeechRecognitionManagerDelegate::GetEventListener() {
return this;
}
+bool ChromeSpeechRecognitionManagerDelegate::FilterProfanities(
+ int render_process_id) {
+ content::RenderProcessHost* rph =
+ content::RenderProcessHost::FromID(render_process_id);
+ if (!rph) // Guard against race conditions on RPH lifetime.
+ return true;
+
+ return Profile::FromBrowserContext(rph->GetBrowserContext())->GetPrefs()->
+ GetBoolean(prefs::kSpeechRecognitionFilterProfanities);
+}
+
void ChromeSpeechRecognitionManagerDelegate::CheckRenderViewType(
base::Callback<void(bool ask_user, bool is_allowed)> callback,
int render_process_id,
diff --git a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h
index 7cd5a77..1d33a71 100644
--- a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h
+++ b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h
@@ -45,6 +45,7 @@ class ChromeSpeechRecognitionManagerDelegate
int session_id,
base::Callback<void(bool ask_user, bool is_allowed)> callback) OVERRIDE;
virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE;
+ virtual bool FilterProfanities(int render_process_id) OVERRIDE;
// Callback called by |tab_watcher_| on the IO thread to signal tab closure.
virtual void TabClosedCallback(int render_process_id, int render_view_id);
diff --git a/chrome/browser/speech/chrome_speech_recognition_preferences.cc b/chrome/browser/speech/chrome_speech_recognition_preferences.cc
deleted file mode 100644
index dea478a..0000000
--- a/chrome/browser/speech/chrome_speech_recognition_preferences.cc
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
-
-#include "base/bind.h"
-#include "base/prefs/pref_service.h"
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/pref_names.h"
-#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
-#include "components/user_prefs/pref_registry_syncable.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_details.h"
-
-using base::ListValue;
-using content::BrowserThread;
-
-namespace {
-const bool kDefaultFilterProfanities = true;
-const bool kDefaultShownSecurityNotification = false;
-}
-
-ChromeSpeechRecognitionPreferences::Factory*
-ChromeSpeechRecognitionPreferences::Factory::GetInstance() {
- return Singleton<ChromeSpeechRecognitionPreferences::Factory>::get();
-}
-
-void ChromeSpeechRecognitionPreferences::InitializeFactory() {
- ChromeSpeechRecognitionPreferences::Factory::GetInstance();
-}
-
-scoped_refptr<ChromeSpeechRecognitionPreferences>
-ChromeSpeechRecognitionPreferences::Factory::GetForProfile(Profile* profile) {
- DCHECK(profile);
- // GetServiceForBrowserContext will let us instantiate a new (if not already
- // cached for the profile) Service through BuildServiceInstanceFor method.
- ChromeSpeechRecognitionPreferences::Service* service =
- static_cast<ChromeSpeechRecognitionPreferences::Service*>(
- GetServiceForBrowserContext(profile, true));
-
- if (!service) {
- // Incognito won't have this service.
- return NULL;
- }
-
- return service->GetPreferences();
-}
-
-ChromeSpeechRecognitionPreferences::Factory::Factory()
- : BrowserContextKeyedServiceFactory(
- "ChromeSpeechRecognitionPreferences",
- BrowserContextDependencyManager::GetInstance()) {
-}
-
-ChromeSpeechRecognitionPreferences::Factory::~Factory() {
-}
-
-BrowserContextKeyedService*
-ChromeSpeechRecognitionPreferences::Factory::BuildServiceInstanceFor(
- content::BrowserContext* profile) const {
- DCHECK(profile);
- return new ChromeSpeechRecognitionPreferences::Service(
- static_cast<Profile*>(profile));
-}
-
-void ChromeSpeechRecognitionPreferences::Factory::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* prefs) {
- prefs->RegisterBooleanPref(
- prefs::kSpeechRecognitionFilterProfanities,
- kDefaultFilterProfanities,
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-
- prefs->RegisterListPref(
- prefs::kSpeechRecognitionTrayNotificationShownContexts,
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-}
-
-bool ChromeSpeechRecognitionPreferences::Factory::
-ServiceIsNULLWhileTesting() const {
- return true;
-}
-
-bool ChromeSpeechRecognitionPreferences::Factory::
-ServiceIsCreatedWithBrowserContext() const {
- return false;
-}
-
-ChromeSpeechRecognitionPreferences::Service::Service(
- Profile* profile)
- : preferences_(new ChromeSpeechRecognitionPreferences(profile)) {
-}
-
-ChromeSpeechRecognitionPreferences::Service::~Service() {
-}
-
-void ChromeSpeechRecognitionPreferences::Service::Shutdown() {
- DCHECK(preferences_.get());
- preferences_->DetachFromProfile();
-}
-
-scoped_refptr<ChromeSpeechRecognitionPreferences>
-ChromeSpeechRecognitionPreferences::Service::GetPreferences() const {
- return preferences_;
-}
-
-scoped_refptr<ChromeSpeechRecognitionPreferences>
-ChromeSpeechRecognitionPreferences::GetForProfile(Profile* profile) {
- scoped_refptr<ChromeSpeechRecognitionPreferences> ret;
- if (profile) {
- // Note that when in incognito, GetForProfile will return NULL.
- // We catch that case below and return the default preferences.
- ret = Factory::GetInstance()->GetForProfile(profile);
- }
-
- if (!ret.get()) {
- // Create a detached preferences object if no profile is provided.
- ret = new ChromeSpeechRecognitionPreferences(NULL);
- }
-
- return ret;
-}
-
-ChromeSpeechRecognitionPreferences::ChromeSpeechRecognitionPreferences(
- Profile* profile)
- : profile_(profile),
- pref_change_registrar_(new PrefChangeRegistrar()),
- filter_profanities_(kDefaultFilterProfanities),
- notifications_shown_(new ListValue()) {
- if (!profile_)
- return;
-
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- pref_change_registrar_->Init(profile_->GetPrefs());
-
- ReloadFilterProfanities();
- pref_change_registrar_->Add(
- prefs::kSpeechRecognitionFilterProfanities,
- base::Bind(&ChromeSpeechRecognitionPreferences::ReloadFilterProfanities,
- base::Unretained(this)));
-
- ReloadNotificationsShown();
- pref_change_registrar_->Add(
- prefs::kSpeechRecognitionTrayNotificationShownContexts,
- base::Bind(&ChromeSpeechRecognitionPreferences::ReloadNotificationsShown,
- base::Unretained(this)));
-}
-
-ChromeSpeechRecognitionPreferences::~ChromeSpeechRecognitionPreferences() {
-}
-
-void ChromeSpeechRecognitionPreferences::DetachFromProfile() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(profile_);
- pref_change_registrar_.reset();
- profile_ = NULL;
-}
-
-bool ChromeSpeechRecognitionPreferences::FilterProfanities() const {
- base::AutoLock read_lock(preferences_lock_);
- return filter_profanities_;
-}
-
-void ChromeSpeechRecognitionPreferences::SetFilterProfanities(
- bool filter_profanities) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- {
- base::AutoLock write_lock(preferences_lock_);
- filter_profanities_ = filter_profanities;
- }
- if (profile_) {
- profile_->GetPrefs()->SetBoolean(prefs::kSpeechRecognitionFilterProfanities,
- filter_profanities);
- }
-}
-
-void ChromeSpeechRecognitionPreferences::ToggleFilterProfanities() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- SetFilterProfanities(!FilterProfanities());
-}
-
-bool ChromeSpeechRecognitionPreferences::ShouldShowSecurityNotification(
- const std::string& context_name) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(notifications_shown_.get());
- scoped_ptr<base::StringValue> match_name(
- base::Value::CreateStringValue(context_name));
- return notifications_shown_->Find(*match_name) == notifications_shown_->end();
-}
-
-void ChromeSpeechRecognitionPreferences::SetHasShownSecurityNotification(
- const std::string& context_name) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(notifications_shown_.get());
- notifications_shown_->AppendIfNotPresent(
- base::Value::CreateStringValue(context_name));
- if (profile_) {
- profile_->GetPrefs()->Set(
- prefs::kSpeechRecognitionTrayNotificationShownContexts,
- *notifications_shown_);
- }
-}
-
-void ChromeSpeechRecognitionPreferences::ReloadFilterProfanities() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- base::AutoLock write_lock(preferences_lock_);
- filter_profanities_ = profile_->GetPrefs()->GetBoolean(
- prefs::kSpeechRecognitionFilterProfanities);
-}
-
-void ChromeSpeechRecognitionPreferences::ReloadNotificationsShown() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- base::AutoLock write_lock(preferences_lock_);
- const base::ListValue* pref_list = profile_->GetPrefs()->GetList(
- prefs::kSpeechRecognitionTrayNotificationShownContexts);
- notifications_shown_.reset(pref_list->DeepCopy());
-}
diff --git a/chrome/browser/speech/chrome_speech_recognition_preferences.h b/chrome/browser/speech/chrome_speech_recognition_preferences.h
deleted file mode 100644
index 17640be..0000000
--- a/chrome/browser/speech/chrome_speech_recognition_preferences.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
-#define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/singleton.h"
-#include "base/prefs/pref_change_registrar.h"
-#include "base/synchronization/lock.h"
-#include "base/threading/non_thread_safe.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
-#include "content/public/browser/speech_recognition_preferences.h"
-
-class PrefService;
-class Profile;
-
-namespace base {
-class ListValue;
-}
-
-// Utility class that handles persistent storage of speech recognition
-// preferences. Instances of this class must be obtained exclusively through the
-// method ChromeSpeechRecognitionPreferences::GetForProfile(...), so that
-// preferences are handled within the Profile (if not NULL). The internal
-// factory class also handles ownership and lifetime of the
-// ChromeSpeechRecognitionPreferences instances (through the inner Service
-// class), allowing them to be used in a detached mode (no persistent storage)
-// even when a Profile is not available (or has been shutdown).
-
-class ChromeSpeechRecognitionPreferences
- : public content::SpeechRecognitionPreferences {
- public:
- static void InitializeFactory();
- static scoped_refptr<ChromeSpeechRecognitionPreferences> GetForProfile(
- Profile* profile);
-
- // content::SpeechRecognitionPreferences implementation.
- // Called by both Content (on IO thread) and Chrome (on UI thread).
- virtual bool FilterProfanities() const OVERRIDE;
-
- // Called only by Chrome (on UI thread).
- void SetFilterProfanities(bool filter_profanities);
- void ToggleFilterProfanities();
- bool ShouldShowSecurityNotification(const std::string& context_name) const;
- void SetHasShownSecurityNotification(const std::string& context_name);
-
- private:
- // The two classes below are needed to handle storage of speech recognition
- // preferences in profile preferences, according to the Chromium Profile
- // Architecture document entitled "The New Way:
- // BrowserContextKeyedServiceFactory".
-
- // Singleton that manages instantiation of ChromeSpeechRecognitionPreferences
- // handling its association with Profiles.
- class Factory : public BrowserContextKeyedServiceFactory {
- public:
- static Factory* GetInstance();
- scoped_refptr<ChromeSpeechRecognitionPreferences> GetForProfile(
- Profile* profile);
-
- private:
- friend struct DefaultSingletonTraits<Factory>;
-
- Factory();
- virtual ~Factory();
-
- // BrowserContextKeyedServiceFactory methods:
- virtual BrowserContextKeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const OVERRIDE;
- virtual void RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
- virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
- virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(Factory);
- };
-
- // This wrapper handles the binding between ChromeSpeechRecognitionPreferences
- // instances (which can have a longer lifetime, since they are refcounted) and
- // BrowserContextKeyedService (which lifetime depends on the Profile service).
- // Upon profile shutdown, the ChromeSpeechRecognitionPreferences instance is
- // detached from profile, meaning that after that point its clients can still
- // use it, but preferences will no longer be kept in sync with the profile.
- class Service : public BrowserContextKeyedService {
- public:
- explicit Service(Profile* profile);
- virtual ~Service();
-
- // BrowserContextKeyedService implementation.
- virtual void Shutdown() OVERRIDE;
-
- scoped_refptr<ChromeSpeechRecognitionPreferences> GetPreferences() const;
-
- private:
- scoped_refptr<ChromeSpeechRecognitionPreferences> preferences_;
-
- DISALLOW_COPY_AND_ASSIGN(Service);
- };
-
- explicit ChromeSpeechRecognitionPreferences(Profile* profile);
- virtual ~ChromeSpeechRecognitionPreferences();
-
- void DetachFromProfile();
- void ReloadFilterProfanities();
- void ReloadNotificationsShown();
-
- Profile* profile_; // NULL when detached.
- scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
- bool filter_profanities_;
- scoped_ptr<base::ListValue> notifications_shown_;
-
- // Lock used to ensure exclusive access to preference variables that are
- // accessed by both threads (note: mutable is required to keep getters const).
- mutable base::Lock preferences_lock_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences);
-};
-
-#endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index a82feff..9ed8090 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -44,7 +44,6 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
#include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/tab_contents/retargeting_details.h"
@@ -1450,8 +1449,8 @@ bool RenderViewContextMenu::IsCommandIdChecked(int id) const {
#if defined(ENABLE_INPUT_SPEECH)
// Check box for menu item 'Block offensive words'.
if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) {
- return ChromeSpeechRecognitionPreferences::GetForProfile(profile_)->
- FilterProfanities();
+ return profile_->GetPrefs()->GetBoolean(
+ prefs::kSpeechRecognitionFilterProfanities);
}
#endif
@@ -1889,8 +1888,10 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
#if defined(ENABLE_INPUT_SPEECH)
case IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES: {
- ChromeSpeechRecognitionPreferences::GetForProfile(profile_)->
- ToggleFilterProfanities();
+ profile_->GetPrefs()->SetBoolean(
+ prefs::kSpeechRecognitionFilterProfanities,
+ !profile_->GetPrefs()->GetBoolean(
+ prefs::kSpeechRecognitionFilterProfanities));
break;
}
#endif
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index adeed80..cf0f80e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1875,8 +1875,6 @@
'browser/speech/chrome_speech_recognition_manager_delegate.h',
'browser/speech/chrome_speech_recognition_manager_delegate_bubble_ui.cc',
'browser/speech/chrome_speech_recognition_manager_delegate_bubble_ui.h',
- 'browser/speech/chrome_speech_recognition_preferences.cc',
- 'browser/speech/chrome_speech_recognition_preferences.h',
'browser/speech/extension_api/tts_extension_api_constants.cc',
'browser/speech/extension_api/tts_extension_api_constants.h',
'browser/speech/speech_recognition_bubble.cc',
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 145804e..d521860 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -47,7 +47,6 @@
#include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
#include "chrome/browser/profiles/storage_partition_descriptor.h"
#include "chrome/browser/search_engines/template_url_fetcher_factory.h"
-#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_constants.h"
@@ -691,15 +690,6 @@ TestingProfile::GetGeolocationPermissionContext() {
return ChromeGeolocationPermissionContextFactory::GetForProfile(this);
}
-content::SpeechRecognitionPreferences*
- TestingProfile::GetSpeechRecognitionPreferences() {
-#if defined(ENABLE_INPUT_SPEECH)
- return ChromeSpeechRecognitionPreferences::GetForProfile(this).get();
-#else
- return NULL;
-#endif
-}
-
std::wstring TestingProfile::GetName() {
return std::wstring();
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 9088fbe..c8c7faa 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -190,8 +190,6 @@ class TestingProfile : public Profile {
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
virtual content::GeolocationPermissionContext*
GetGeolocationPermissionContext() OVERRIDE;
- virtual content::SpeechRecognitionPreferences*
- GetSpeechRecognitionPreferences() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual TestingProfile* AsTestingProfile() OVERRIDE;