| OLD | NEW |
| 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/system/audio/audio_controller.h" | 8 #include "ash/system/audio/audio_controller.h" |
| 9 #include "ash/system/brightness/brightness_controller.h" | 9 #include "ash/system/brightness/brightness_controller.h" |
| 10 #include "ash/system/power/power_status_controller.h" |
| 10 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/system/tray/system_tray_delegate.h" | 12 #include "ash/system/tray/system_tray_delegate.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "chrome/browser/chromeos/audio/audio_handler.h" | 14 #include "chrome/browser/chromeos/audio/audio_handler.h" |
| 14 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 15 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 15 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 16 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 16 #include "chrome/browser/chromeos/login/user.h" | 17 #include "chrome/browser/chromeos/login/user.h" |
| 17 #include "chrome/browser/chromeos/login/user_manager.h" | 18 #include "chrome/browser/chromeos/login/user_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 20 | 21 |
| 21 namespace chromeos { | 22 namespace chromeos { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 class SystemTrayDelegate : public ash::SystemTrayDelegate, | 26 class SystemTrayDelegate : public ash::SystemTrayDelegate, |
| 26 public AudioHandler::VolumeObserver, | 27 public AudioHandler::VolumeObserver, |
| 27 public PowerManagerClient::Observer { | 28 public PowerManagerClient::Observer { |
| 28 public: | 29 public: |
| 29 explicit SystemTrayDelegate(ash::SystemTray* tray) : tray_(tray) { | 30 explicit SystemTrayDelegate(ash::SystemTray* tray) : tray_(tray) { |
| 30 AudioHandler::GetInstance()->AddVolumeObserver(this); | 31 AudioHandler::GetInstance()->AddVolumeObserver(this); |
| 31 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 32 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 33 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( |
| 34 PowerManagerClient::UPDATE_USER); |
| 32 } | 35 } |
| 33 | 36 |
| 34 virtual ~SystemTrayDelegate() { | 37 virtual ~SystemTrayDelegate() { |
| 35 AudioHandler::GetInstance()->RemoveVolumeObserver(this); | 38 AudioHandler::GetInstance()->RemoveVolumeObserver(this); |
| 36 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 39 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 37 } | 40 } |
| 38 | 41 |
| 39 // Overridden from ash::SystemTrayDelegate. | 42 // Overridden from ash::SystemTrayDelegate. |
| 40 virtual const std::string GetUserDisplayName() OVERRIDE { | 43 virtual const std::string GetUserDisplayName() OVERRIDE { |
| 41 return UserManager::Get()->logged_in_user().GetDisplayName(); | 44 return UserManager::Get()->logged_in_user().GetDisplayName(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ash::Shell::GetInstance()->audio_controller()-> | 98 ash::Shell::GetInstance()->audio_controller()-> |
| 96 OnVolumeChanged(level); | 99 OnVolumeChanged(level); |
| 97 } | 100 } |
| 98 | 101 |
| 99 // Overridden from PowerManagerClient::Observer. | 102 // Overridden from PowerManagerClient::Observer. |
| 100 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE { | 103 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE { |
| 101 ash::Shell::GetInstance()->brightness_controller()-> | 104 ash::Shell::GetInstance()->brightness_controller()-> |
| 102 OnBrightnessChanged(level / 100.f, user_initiated); | 105 OnBrightnessChanged(level / 100.f, user_initiated); |
| 103 } | 106 } |
| 104 | 107 |
| 108 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE { |
| 109 ash::Shell::GetInstance()->power_status_controller()-> |
| 110 OnPowerStatusChanged(power_status); |
| 111 } |
| 112 |
| 105 // TODO(sad): Override more from PowerManagerClient::Observer here (e.g. | 113 // TODO(sad): Override more from PowerManagerClient::Observer here (e.g. |
| 106 // PowerChanged, PowerButtonStateChanged etc.). | 114 // PowerButtonStateChanged etc.). |
| 107 | 115 |
| 108 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 116 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
| 109 }; | 117 }; |
| 110 | 118 |
| 111 } // namespace | 119 } // namespace |
| 112 | 120 |
| 113 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 121 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
| 114 return new chromeos::SystemTrayDelegate(tray); | 122 return new chromeos::SystemTrayDelegate(tray); |
| 115 } | 123 } |
| 116 | 124 |
| 117 } // namespace chromeos | 125 } // namespace chromeos |
| OLD | NEW |