diff options
-rw-r--r-- | chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc | 13 | ||||
-rw-r--r-- | chrome/browser/chromeos/audio/audio_pref_handler_impl.cc | 109 | ||||
-rw-r--r-- | chrome/browser/chromeos/audio/audio_pref_handler_impl.h | 59 | ||||
-rw-r--r-- | chrome/browser/prefs/browser_prefs.cc | 2 | ||||
-rw-r--r-- | chrome/chrome_browser_chromeos.gypi | 2 | ||||
-rw-r--r-- | chromeos/audio/audio_pref_handler.h | 61 | ||||
-rw-r--r-- | chromeos/chromeos.gyp | 1 |
7 files changed, 10 insertions, 237 deletions
diff --git a/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc b/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc index fcd602a..a027e41 100644 --- a/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc +++ b/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc @@ -175,9 +175,16 @@ void AudioDevicesPrefHandlerImpl::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterDictionaryPref(prefs::kAudioDevicesVolumePercent); registry->RegisterDictionaryPref(prefs::kAudioDevicesMute); - // TODO(jennyz,rkc): Move the rest of the preferences registered by - // AudioPrefHandlerImpl::RegisterPrefs here once we remove the old audio - // handler code. + // Register the prefs backing the audio muting policies. + registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true); + // This pref has moved to the media subsystem but we should verify it is there + // before we use it. + registry->RegisterBooleanPref(::prefs::kAudioCaptureAllowed, true); + + // Register the legacy audio prefs for migration. + registry->RegisterDoublePref(prefs::kAudioVolumePercent, + kDefaultVolumeGainPercent); + registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff); } // static diff --git a/chrome/browser/chromeos/audio/audio_pref_handler_impl.cc b/chrome/browser/chromeos/audio/audio_pref_handler_impl.cc deleted file mode 100644 index 2cc885e..0000000 --- a/chrome/browser/chromeos/audio/audio_pref_handler_impl.cc +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 2013 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/chromeos/audio/audio_pref_handler_impl.h" - -#include <algorithm> -#include <cmath> - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/logging.h" -#include "base/prefs/pref_registry_simple.h" -#include "base/prefs/pref_service.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/common/pref_names.h" - -using std::max; -using std::min; - -namespace chromeos { - -namespace { - -// Default value for the volume pref, as a percent in the range [0.0, 100.0]. -const double kDefaultVolumePercent = 75.0; - -// Values used for muted preference. -const int kPrefMuteOff = 0; -const int kPrefMuteOn = 1; - -} // namespace - -double AudioPrefHandlerImpl::GetOutputVolumeValue() { - return local_state_->GetDouble(prefs::kAudioVolumePercent); -} - -void AudioPrefHandlerImpl::SetOutputVolumeValue(double volume_percent) { - local_state_->SetDouble(prefs::kAudioVolumePercent, volume_percent); -} - -bool AudioPrefHandlerImpl::GetOutputMuteValue() { - return (local_state_->GetInteger(prefs::kAudioMute) == kPrefMuteOn); -} - -void AudioPrefHandlerImpl::SetOutputMuteValue(bool mute) { - local_state_->SetInteger(prefs::kAudioMute, - mute ? kPrefMuteOn : kPrefMuteOff); -} - -bool AudioPrefHandlerImpl::GetAudioCaptureAllowedValue() { - return local_state_->GetBoolean(::prefs::kAudioCaptureAllowed); -} - -bool AudioPrefHandlerImpl::GetAudioOutputAllowedValue() { - return local_state_->GetBoolean(prefs::kAudioOutputAllowed); -} - -void AudioPrefHandlerImpl::AddAudioPrefObserver( - AudioPrefObserver* observer) { - observers_.AddObserver(observer); -} - -void AudioPrefHandlerImpl::RemoveAudioPrefObserver( - AudioPrefObserver* observer) { - observers_.RemoveObserver(observer); -} - -AudioPrefHandlerImpl::AudioPrefHandlerImpl(PrefService* local_state) - : local_state_(local_state) { - InitializePrefObservers(); -} - -AudioPrefHandlerImpl::~AudioPrefHandlerImpl() { -}; - -void AudioPrefHandlerImpl::InitializePrefObservers() { - pref_change_registrar_.Init(local_state_); - base::Closure callback = - base::Bind(&AudioPrefHandlerImpl::NotifyAudioPolicyChange, - base::Unretained(this)); - pref_change_registrar_.Add(prefs::kAudioOutputAllowed, callback); - pref_change_registrar_.Add(::prefs::kAudioCaptureAllowed, callback); -} - -void AudioPrefHandlerImpl::NotifyAudioPolicyChange() { - FOR_EACH_OBSERVER(AudioPrefObserver, - observers_, - OnAudioPolicyPrefChanged()); -} - -// static -void AudioPrefHandlerImpl::RegisterPrefs(PrefRegistrySimple* registry) { - registry->RegisterDoublePref(prefs::kAudioVolumePercent, - kDefaultVolumePercent); - registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff); - // Register the prefs backing the audio muting policies. - registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true); - // This pref has moved to the media subsystem but we should verify it is there - // before we use it. - registry->RegisterBooleanPref(::prefs::kAudioCaptureAllowed, true); -} - -// static -AudioPrefHandler* AudioPrefHandler::Create(PrefService* local_state) { - return new AudioPrefHandlerImpl(local_state); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/audio/audio_pref_handler_impl.h b/chrome/browser/chromeos/audio/audio_pref_handler_impl.h deleted file mode 100644 index 47f8da0..0000000 --- a/chrome/browser/chromeos/audio/audio_pref_handler_impl.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2013 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_CHROMEOS_AUDIO_AUDIO_PREF_HANDLER_IMPL_H_ -#define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_PREF_HANDLER_IMPL_H_ - -#include "base/observer_list.h" -#include "base/prefs/pref_change_registrar.h" -#include "chromeos/audio/audio_pref_handler.h" - -class PrefRegistrySimple; -class PrefService; - -namespace chromeos { - -// TODO(jennyz,rkc): This class will be removed once we remove the old Audio -// Handler code. -// Class which implements AudioPrefHandler interface and register audio -// preferences as well. -class AudioPrefHandlerImpl : public AudioPrefHandler { - public: - explicit AudioPrefHandlerImpl(PrefService* local_state); - - // Overriden from AudioPreHandler. - virtual double GetOutputVolumeValue() OVERRIDE; - virtual void SetOutputVolumeValue(double volume_percent) OVERRIDE; - virtual bool GetOutputMuteValue() OVERRIDE; - virtual void SetOutputMuteValue(bool mute_on) OVERRIDE; - virtual bool GetAudioCaptureAllowedValue() OVERRIDE; - virtual bool GetAudioOutputAllowedValue() OVERRIDE; - virtual void AddAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE; - virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE; - - // Registers volume and mute preferences. - static void RegisterPrefs(PrefRegistrySimple* registry); - - protected: - virtual ~AudioPrefHandlerImpl(); - - private: - // Initializes the observers for the policy prefs. - void InitializePrefObservers(); - - // Notifies the AudioPrefObserver for audio policy pref changes. - void NotifyAudioPolicyChange(); - - PrefService* local_state_; // not owned - - PrefChangeRegistrar pref_change_registrar_; - - ObserverList<AudioPrefObserver> observers_; - - DISALLOW_COPY_AND_ASSIGN(AudioPrefHandlerImpl); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_PREF_HANDLER_IMPL_H_ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index da3ed8c..a7a936b 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -123,7 +123,6 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h" -#include "chrome/browser/chromeos/audio/audio_pref_handler_impl.h" #include "chrome/browser/chromeos/customization_document.h" #include "chrome/browser/chromeos/display/display_preferences.h" #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" @@ -249,7 +248,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) { #if defined(OS_CHROMEOS) chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry); - chromeos::AudioPrefHandlerImpl::RegisterPrefs(registry); chromeos::DataPromoNotification::RegisterPrefs(registry); chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry); chromeos::device_settings_cache::RegisterPrefs(registry); diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 6944e066..3469ee2 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -143,8 +143,6 @@ 'browser/chromeos/attestation/attestation_policy_observer.h', 'browser/chromeos/audio/audio_devices_pref_handler_impl.cc', 'browser/chromeos/audio/audio_devices_pref_handler_impl.h', - 'browser/chromeos/audio/audio_pref_handler_impl.cc', - 'browser/chromeos/audio/audio_pref_handler_impl.h', 'browser/chromeos/background/ash_user_wallpaper_delegate.cc', 'browser/chromeos/background/ash_user_wallpaper_delegate.h', 'browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc', diff --git a/chromeos/audio/audio_pref_handler.h b/chromeos/audio/audio_pref_handler.h deleted file mode 100644 index 89e4b7b..0000000 --- a/chromeos/audio/audio_pref_handler.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2013 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 CHROMEOS_AUDIO_AUDIO_PREF_HANDLER_H_ -#define CHROMEOS_AUDIO_AUDIO_PREF_HANDLER_H_ - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "chromeos/audio/audio_pref_observer.h" -#include "chromeos/chromeos_export.h" - -class PrefRegistrySimple; - -namespace chromeos { - -// TODO(jennyz,rkc): This class will be removed once we remove the old Audio -// Handler code. -// Interface that handles audio preference related work, reads and writes -// audio preferences, and notifies AudioPrefObserver for audio preference -// changes. -class CHROMEOS_EXPORT AudioPrefHandler - : public base::RefCountedThreadSafe<AudioPrefHandler> { - public: - // Gets the audio output volume value from prefs. - virtual double GetOutputVolumeValue() = 0; - - // Sets the output audio volume value to prefs. - virtual void SetOutputVolumeValue(double volume_percent) = 0; - - // Reads the audio output mute value from prefs. - virtual bool GetOutputMuteValue() = 0; - - // Sets the audio output mute value to prefs. - virtual void SetOutputMuteValue(bool mute_on) = 0; - - // Reads the audio capture allowed value from prefs. - virtual bool GetAudioCaptureAllowedValue() = 0; - - // Sets the audio output allowed value from prefs. - virtual bool GetAudioOutputAllowedValue() = 0; - - // Adds an audio preference observer. - virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0; - - // Removes an audio preference observer. - virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0; - - // Creates the instance. - static AudioPrefHandler* Create(PrefService* local_state); - - protected: - virtual ~AudioPrefHandler() {} - - private: - friend class base::RefCountedThreadSafe<AudioPrefHandler>; -}; - -} // namespace chromeos - -#endif // CHROMEOS_AUDIO_AUDIO_PREF_HANDLER_H_ diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 4522321..6ae7624 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -37,7 +37,6 @@ 'audio/audio_device.h', 'audio/audio_devices_pref_handler.h', 'audio/audio_pref_observer.h', - 'audio/audio_pref_handler.h', 'audio/cras_audio_handler.cc', 'audio/cras_audio_handler.h', 'audio/audio_devices_pref_handler_stub.cc', |