Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: chromeos/audio/audio_devices_pref_handler_impl.cc

Issue 2270693005: Fix the corner case for new audio device is not selected as active if it is plugged in for the firs… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chromeos/audio/audio_devices_pref_handler_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/audio_devices_pref_handler_impl.cc
diff --git a/chromeos/audio/audio_devices_pref_handler_impl.cc b/chromeos/audio/audio_devices_pref_handler_impl.cc
index 5171e40d85e7ef7a7e6633f7eff9ace647fbce94..3a25f56c7d8d9cceb79578a4d25893971d17a335 100644
--- a/chromeos/audio/audio_devices_pref_handler_impl.cc
+++ b/chromeos/audio/audio_devices_pref_handler_impl.cc
@@ -24,6 +24,10 @@ namespace {
const int kPrefMuteOff = 0;
const int kPrefMuteOn = 1;
+// Prefs keys.
+const char kActiveKey[] = "active";
+const char kActivateByUserKey[] = "activate_by_user";
+
// Gets the device id string for storing audio preference. The format of
// device string is a string consisting of 2 parts.
// |integer from lower 32 bit of device id| :
@@ -89,9 +93,9 @@ void AudioDevicesPrefHandlerImpl::SetDeviceActive(const AudioDevice& device,
bool active,
bool activate_by_user) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- dict->SetBoolean("active", active);
+ dict->SetBoolean(kActiveKey, active);
if (active)
- dict->SetBoolean("activate_by_user", activate_by_user);
+ dict->SetBoolean(kActivateByUserKey, activate_by_user);
device_state_settings_->Set(GetDeviceIdString(device), std::move(dict));
SaveDevicesStatePref();
@@ -109,12 +113,12 @@ bool AudioDevicesPrefHandlerImpl::GetDeviceActive(const AudioDevice& device,
LOG(ERROR) << "Could not get device state for device:" << device.ToString();
return false;
}
- if (!dict->GetBoolean("active", active)) {
+ if (!dict->GetBoolean(kActiveKey, active)) {
LOG(ERROR) << "Could not get active value for device:" << device.ToString();
return false;
}
- if (*active && !dict->GetBoolean("activate_by_user", activate_by_user)) {
+ if (*active && !dict->GetBoolean(kActivateByUserKey, activate_by_user)) {
LOG(ERROR) << "Could not get activate_by_user value for previously "
"active device:"
<< device.ToString();
« no previous file with comments | « no previous file | chromeos/audio/audio_devices_pref_handler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698