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/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class SystemTrayDelegate : public ash::SystemTrayDelegate, | 25 class SystemTrayDelegate : public ash::SystemTrayDelegate, |
26 public AudioHandler::VolumeObserver, | 26 public AudioHandler::VolumeObserver, |
27 public PowerManagerClient::Observer { | 27 public PowerManagerClient::Observer { |
28 public: | 28 public: |
29 explicit SystemTrayDelegate(ash::SystemTray* tray) : tray_(tray) { | 29 explicit SystemTrayDelegate(ash::SystemTray* tray) : tray_(tray) { |
30 AudioHandler::GetInstance()->AddVolumeObserver(this); | 30 AudioHandler::GetInstance()->AddVolumeObserver(this); |
31 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 31 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
32 } | 32 } |
33 | 33 |
34 virtual ~SystemTrayDelegate() { | 34 virtual ~SystemTrayDelegate() { |
35 AudioHandler::GetInstance()->RemoveVolumeObserver(this); | 35 AudioHandler* audiohandler = AudioHandler::GetInstance(); |
| 36 if (audiohandler) |
| 37 audiohandler->RemoveVolumeObserver(this); |
36 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 38 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
37 } | 39 } |
38 | 40 |
39 // Overridden from ash::SystemTrayDelegate. | 41 // Overridden from ash::SystemTrayDelegate. |
40 virtual const std::string GetUserDisplayName() OVERRIDE { | 42 virtual const std::string GetUserDisplayName() OVERRIDE { |
41 return UserManager::Get()->logged_in_user().GetDisplayName(); | 43 return UserManager::Get()->logged_in_user().GetDisplayName(); |
42 } | 44 } |
43 | 45 |
44 virtual const std::string GetUserEmail() OVERRIDE { | 46 virtual const std::string GetUserEmail() OVERRIDE { |
45 return UserManager::Get()->logged_in_user().email(); | 47 return UserManager::Get()->logged_in_user().email(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 110 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
109 }; | 111 }; |
110 | 112 |
111 } // namespace | 113 } // namespace |
112 | 114 |
113 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 115 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
114 return new chromeos::SystemTrayDelegate(tray); | 116 return new chromeos::SystemTrayDelegate(tray); |
115 } | 117 } |
116 | 118 |
117 } // namespace chromeos | 119 } // namespace chromeos |
OLD | NEW |