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

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 10825264: Consolidate volume control code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and VolumeControlDelegate only accesible via SystemTrayDelegate. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chromeos/system/ash_system_tray_delegate.h" 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/system/audio/audio_observer.h" 9 #include "ash/system/audio/audio_observer.h"
10 #include "ash/system/bluetooth/bluetooth_observer.h" 10 #include "ash/system/bluetooth/bluetooth_observer.h"
11 #include "ash/system/brightness/brightness_observer.h" 11 #include "ash/system/brightness/brightness_observer.h"
12 #include "ash/system/date/clock_observer.h" 12 #include "ash/system/date/clock_observer.h"
13 #include "ash/system/drive/drive_observer.h" 13 #include "ash/system/drive/drive_observer.h"
14 #include "ash/system/ime/ime_observer.h" 14 #include "ash/system/ime/ime_observer.h"
15 #include "ash/system/network/network_observer.h" 15 #include "ash/system/network/network_observer.h"
16 #include "ash/system/power/power_status_observer.h" 16 #include "ash/system/power/power_status_observer.h"
17 #include "ash/system/status_area_widget.h" 17 #include "ash/system/status_area_widget.h"
18 #include "ash/system/tray_accessibility.h" 18 #include "ash/system/tray_accessibility.h"
19 #include "ash/system/tray_caps_lock.h" 19 #include "ash/system/tray_caps_lock.h"
20 #include "ash/system/tray/system_tray_delegate.h" 20 #include "ash/system/tray/system_tray_delegate.h"
21 #include "ash/system/tray/system_tray.h" 21 #include "ash/system/tray/system_tray.h"
22 #include "ash/system/user/update_observer.h" 22 #include "ash/system/user/update_observer.h"
23 #include "ash/system/user/user_observer.h" 23 #include "ash/system/user/user_observer.h"
24 #include "ash/volume_control_delegate.h"
24 #include "base/bind_helpers.h" 25 #include "base/bind_helpers.h"
25 #include "base/callback.h" 26 #include "base/callback.h"
26 #include "base/chromeos/chromeos_version.h" 27 #include "base/chromeos/chromeos_version.h"
27 #include "base/logging.h" 28 #include "base/logging.h"
28 #include "base/memory/weak_ptr.h" 29 #include "base/memory/weak_ptr.h"
29 #include "base/utf_string_conversions.h" 30 #include "base/utf_string_conversions.h"
30 #include "chrome/browser/browser_process.h" 31 #include "chrome/browser/browser_process.h"
31 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 32 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
32 #include "chrome/browser/chromeos/audio/audio_handler.h" 33 #include "chrome/browser/chromeos/audio/audio_handler.h"
33 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" 34 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
(...skipping 15 matching lines...) Expand all
49 #include "chrome/browser/chromeos/login/user_manager.h" 50 #include "chrome/browser/chromeos/login/user_manager.h"
50 #include "chrome/browser/chromeos/mobile_config.h" 51 #include "chrome/browser/chromeos/mobile_config.h"
51 #include "chrome/browser/chromeos/status/data_promo_notification.h" 52 #include "chrome/browser/chromeos/status/data_promo_notification.h"
52 #include "chrome/browser/chromeos/status/network_menu.h" 53 #include "chrome/browser/chromeos/status/network_menu.h"
53 #include "chrome/browser/chromeos/status/network_menu_icon.h" 54 #include "chrome/browser/chromeos/status/network_menu_icon.h"
54 #include "chrome/browser/chromeos/system_key_event_listener.h" 55 #include "chrome/browser/chromeos/system_key_event_listener.h"
55 #include "chrome/browser/chromeos/system/timezone_settings.h" 56 #include "chrome/browser/chromeos/system/timezone_settings.h"
56 #include "chrome/browser/lifetime/application_lifetime.h" 57 #include "chrome/browser/lifetime/application_lifetime.h"
57 #include "chrome/browser/prefs/pref_service.h" 58 #include "chrome/browser/prefs/pref_service.h"
58 #include "chrome/browser/profiles/profile_manager.h" 59 #include "chrome/browser/profiles/profile_manager.h"
60 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
59 #include "chrome/browser/ui/browser_finder.h" 61 #include "chrome/browser/ui/browser_finder.h"
60 #include "chrome/browser/ui/browser.h" 62 #include "chrome/browser/ui/browser.h"
61 #include "chrome/browser/ui/chrome_pages.h" 63 #include "chrome/browser/ui/chrome_pages.h"
62 #include "chrome/browser/ui/singleton_tabs.h" 64 #include "chrome/browser/ui/singleton_tabs.h"
63 #include "chrome/browser/upgrade_detector.h" 65 #include "chrome/browser/upgrade_detector.h"
64 #include "chrome/common/chrome_notification_types.h" 66 #include "chrome/common/chrome_notification_types.h"
65 #include "chrome/common/pref_names.h" 67 #include "chrome/common/pref_names.h"
66 #include "chrome/common/url_constants.h" 68 #include "chrome/common/url_constants.h"
67 #include "chromeos/dbus/dbus_thread_manager.h" 69 #include "chromeos/dbus/dbus_thread_manager.h"
68 #include "chromeos/dbus/power_manager_client.h" 70 #include "chromeos/dbus/power_manager_client.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 new base::WeakPtrFactory<SystemTrayDelegate>(this))), 166 new base::WeakPtrFactory<SystemTrayDelegate>(this))),
165 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( 167 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
166 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 168 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
167 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( 169 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST(
168 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 170 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
169 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), 171 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))),
170 clock_type_(base::k24HourClock), 172 clock_type_(base::k24HourClock),
171 search_key_mapped_to_(input_method::kSearchKey), 173 search_key_mapped_to_(input_method::kSearchKey),
172 screen_locked_(false), 174 screen_locked_(false),
173 connected_network_state_(STATE_UNKNOWN), 175 connected_network_state_(STATE_UNKNOWN),
174 data_promo_notification_(new DataPromoNotification()) { 176 data_promo_notification_(new DataPromoNotification()),
177 volume_control_delegate_(ALLOW_THIS_IN_INITIALIZER_LIST(
178 new VolumeController)) {
175 AudioHandler::GetInstance()->AddVolumeObserver(this); 179 AudioHandler::GetInstance()->AddVolumeObserver(this);
176 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); 180 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
177 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( 181 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(
178 PowerManagerClient::UPDATE_INITIAL); 182 PowerManagerClient::UPDATE_INITIAL);
179 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 183 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
180 184
181 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 185 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
182 crosnet->AddNetworkManagerObserver(this); 186 crosnet->AddNetworkManagerObserver(this);
183 OnNetworkManagerChanged(crosnet); 187 OnNetworkManagerChanged(crosnet);
184 crosnet->AddCellularDataPlanObserver(this); 188 crosnet->AddCellularDataPlanObserver(this);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 content::RecordAction( 334 content::RecordAction(
331 content::UserMetricsAction("OpenLanguageOptionsDialog")); 335 content::UserMetricsAction("OpenLanguageOptionsDialog"));
332 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), 336 chrome::ShowSettingsSubPage(GetAppropriateBrowser(),
333 chrome::kLanguageOptionsSubPage); 337 chrome::kLanguageOptionsSubPage);
334 } 338 }
335 339
336 virtual void ShowHelp() OVERRIDE { 340 virtual void ShowHelp() OVERRIDE {
337 chrome::ShowHelp(GetAppropriateBrowser(), chrome::HELP_SOURCE_MENU); 341 chrome::ShowHelp(GetAppropriateBrowser(), chrome::HELP_SOURCE_MENU);
338 } 342 }
339 343
340 virtual bool IsAudioMuted() const OVERRIDE {
341 return AudioHandler::GetInstance()->IsMuted();
342 }
343
344 virtual void SetAudioMuted(bool muted) OVERRIDE {
345 return AudioHandler::GetInstance()->SetMuted(muted);
346 }
347
348 virtual float GetVolumeLevel() const OVERRIDE {
349 return AudioHandler::GetInstance()->GetVolumePercent() / 100.f;
350 }
351
352 virtual void SetVolumeLevel(float level) OVERRIDE {
353 AudioHandler::GetInstance()->SetVolumePercent(level * 100.f);
354 }
355
356 virtual bool IsCapsLockOn() const OVERRIDE { 344 virtual bool IsCapsLockOn() const OVERRIDE {
357 input_method::InputMethodManager* ime_manager = 345 input_method::InputMethodManager* ime_manager =
358 input_method::InputMethodManager::GetInstance(); 346 input_method::InputMethodManager::GetInstance();
359 return ime_manager->GetXKeyboard()->CapsLockIsEnabled(); 347 return ime_manager->GetXKeyboard()->CapsLockIsEnabled();
360 } 348 }
361 349
362 virtual void SetCapsLockEnabled(bool enabled) OVERRIDE { 350 virtual void SetCapsLockEnabled(bool enabled) OVERRIDE {
363 input_method::InputMethodManager* ime_manager = 351 input_method::InputMethodManager* ime_manager =
364 input_method::InputMethodManager::GetInstance(); 352 input_method::InputMethodManager::GetInstance();
365 return ime_manager->GetXKeyboard()->SetCapsLockEnabled(enabled); 353 return ime_manager->GetXKeyboard()->SetCapsLockEnabled(enabled);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 702
715 virtual void ShowCellularURL(const std::string& url) OVERRIDE { 703 virtual void ShowCellularURL(const std::string& url) OVERRIDE {
716 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(url)); 704 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(url));
717 } 705 }
718 706
719 virtual void ChangeProxySettings() OVERRIDE { 707 virtual void ChangeProxySettings() OVERRIDE {
720 CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE); 708 CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE);
721 BaseLoginDisplayHost::default_host()->OpenProxySettings(); 709 BaseLoginDisplayHost::default_host()->OpenProxySettings();
722 } 710 }
723 711
712 virtual ash::VolumeControlDelegate* volume_control_delegate() const OVERRIDE {
713 return volume_control_delegate_.get();
714 }
715
716 virtual void SetVolumeControlDelegate(
sadrul 2012/08/14 18:12:52 SetVolumeControlDelegate doesn't seem to be used a
jennyz 2012/08/14 18:15:30 Yes, this is only used for testing.
717 scoped_ptr<ash::VolumeControlDelegate> delegate) OVERRIDE {
718 volume_control_delegate_.swap(delegate);
719 }
724 private: 720 private:
725 // Returns the last active browser. If there is no such browser, creates a new 721 // Returns the last active browser. If there is no such browser, creates a new
726 // browser window with an empty tab and returns it. 722 // browser window with an empty tab and returns it.
727 Browser* GetAppropriateBrowser() { 723 Browser* GetAppropriateBrowser() {
728 return browser::FindOrCreateTabbedBrowser( 724 return browser::FindOrCreateTabbedBrowser(
729 ProfileManager::GetDefaultProfileOrOffTheRecord()); 725 ProfileManager::GetDefaultProfileOrOffTheRecord());
730 } 726 }
731 727
732 void SetProfile(Profile* profile) { 728 void SetProfile(Profile* profile) {
733 pref_registrar_.reset(new PrefChangeRegistrar); 729 pref_registrar_.reset(new PrefChangeRegistrar);
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 bool screen_locked_; 1239 bool screen_locked_;
1244 ConnectionState connected_network_state_; 1240 ConnectionState connected_network_state_;
1245 std::string connected_network_path_; 1241 std::string connected_network_path_;
1246 1242
1247 scoped_refptr<BluetoothAdapter> bluetooth_adapter_; 1243 scoped_refptr<BluetoothAdapter> bluetooth_adapter_;
1248 1244
1249 BooleanPrefMember accessibility_enabled_; 1245 BooleanPrefMember accessibility_enabled_;
1250 1246
1251 scoped_ptr<DataPromoNotification> data_promo_notification_; 1247 scoped_ptr<DataPromoNotification> data_promo_notification_;
1252 1248
1249 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_;
1250
1253 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1251 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1254 }; 1252 };
1255 1253
1256 } // namespace 1254 } // namespace
1257 1255
1258 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { 1256 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) {
1259 return new chromeos::SystemTrayDelegate(tray); 1257 return new chromeos::SystemTrayDelegate(tray);
1260 } 1258 }
1261 1259
1262 } // namespace chromeos 1260 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698