diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 17:24:18 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 17:24:18 +0000 |
commit | a6a7ced56b518de42dab6d3ac18de490fb494696 (patch) | |
tree | b89d63fe26927a79e9d6d07519fa1983a5466f5a /chrome/browser/chromeos/audio | |
parent | 38d455b3bc1ab2a7b9efc58d78c7ba9ec5067001 (diff) | |
download | chromium_src-a6a7ced56b518de42dab6d3ac18de490fb494696.zip chromium_src-a6a7ced56b518de42dab6d3ac18de490fb494696.tar.gz chromium_src-a6a7ced56b518de42dab6d3ac18de490fb494696.tar.bz2 |
Remove content::NotificationObserver dependency from most Prefs code.
Instead of using content::NotificationObserver, introduce specific
type-safe observer classes and update users to use them. In a very
large number of cases this was the users' only reason for being a
content::NotificationObserver and they would have a lot of
boiler-plate code such as a DCHECK on the notification type and
unpacking of the generic NotificationDetails types, so this change
removes a bunch of boilerplate and introduces more type safety.
This is part of enabling more of the Prefs code to live in
base/prefs/.
TBR=ben@chromium.org,brettw@chromium.org
BUG=155525
Review URL: https://chromiumcodereview.appspot.com/11345008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/audio')
-rw-r--r-- | chrome/browser/chromeos/audio/audio_handler.cc | 18 | ||||
-rw-r--r-- | chrome/browser/chromeos/audio/audio_handler.h | 15 |
2 files changed, 10 insertions, 23 deletions
diff --git a/chrome/browser/chromeos/audio/audio_handler.cc b/chrome/browser/chromeos/audio/audio_handler.cc index f9d9999..f78657f 100644 --- a/chrome/browser/chromeos/audio/audio_handler.cc +++ b/chrome/browser/chromeos/audio/audio_handler.cc @@ -19,7 +19,6 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/notification_service.h" using std::max; using std::min; @@ -161,18 +160,11 @@ void AudioHandler::RemoveVolumeObserver(VolumeObserver* observer) { volume_observers_.RemoveObserver(observer); } -void AudioHandler::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - if (type == chrome::NOTIFICATION_PREF_CHANGED) { - std::string* pref_name = content::Details<std::string>(details).ptr(); - if (*pref_name == prefs::kAudioOutputAllowed || - *pref_name == prefs::kAudioCaptureAllowed) { - ApplyAudioPolicy(); - } - } else { - NOTREACHED() << "Unexpected notification type : " << type; - } +void AudioHandler::OnPreferenceChanged(PrefServiceBase* service, + const std::string& pref_name) { + DCHECK(pref_name == prefs::kAudioOutputAllowed || + pref_name == prefs::kAudioCaptureAllowed); + ApplyAudioPolicy(); } AudioHandler::AudioHandler(AudioMixer* mixer) diff --git a/chrome/browser/chromeos/audio/audio_handler.h b/chrome/browser/chromeos/audio/audio_handler.h index ecb9f57a..1b77f9f 100644 --- a/chrome/browser/chromeos/audio/audio_handler.h +++ b/chrome/browser/chromeos/audio/audio_handler.h @@ -9,11 +9,8 @@ #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/prefs/public/pref_change_registrar.h" +#include "base/prefs/public/pref_observer.h" #include "base/threading/thread.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_source.h" template <typename T> struct DefaultSingletonTraits; @@ -24,7 +21,7 @@ namespace chromeos { class AudioMixer; -class AudioHandler : public content::NotificationObserver { +class AudioHandler : public PrefObserver { public: class VolumeObserver { public: @@ -76,10 +73,9 @@ class AudioHandler : public content::NotificationObserver { void AddVolumeObserver(VolumeObserver* observer); void RemoveVolumeObserver(VolumeObserver* observer); - // Overridden from content::NotificationObserver: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; + // Overridden from PrefObserver: + virtual void OnPreferenceChanged(PrefServiceBase* service, + const std::string& pref_name) OVERRIDE; private: // Defines the delete on exit Singleton traits we like. Best to have this @@ -107,7 +103,6 @@ class AudioHandler : public content::NotificationObserver { PrefService* local_state_; // not owned PrefChangeRegistrar pref_change_registrar_; - content::NotificationRegistrar registrar_; DISALLOW_COPY_AND_ASSIGN(AudioHandler); }; |