| 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/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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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* GetVolumeControlDelegate() const OVERRIDE |
| 713 { |
| 714 return volume_control_delegate_.get(); |
| 715 } |
| 716 |
| 717 virtual void SetVolumeControlDelegate( |
| 718 scoped_ptr<ash::VolumeControlDelegate> delegate) OVERRIDE { |
| 719 volume_control_delegate_.swap(delegate); |
| 720 } |
| 724 private: | 721 private: |
| 725 // Returns the last active browser. If there is no such browser, creates a new | 722 // Returns the last active browser. If there is no such browser, creates a new |
| 726 // browser window with an empty tab and returns it. | 723 // browser window with an empty tab and returns it. |
| 727 Browser* GetAppropriateBrowser() { | 724 Browser* GetAppropriateBrowser() { |
| 728 return browser::FindOrCreateTabbedBrowser( | 725 return browser::FindOrCreateTabbedBrowser( |
| 729 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 726 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| 730 } | 727 } |
| 731 | 728 |
| 732 void SetProfile(Profile* profile) { | 729 void SetProfile(Profile* profile) { |
| 733 pref_registrar_.reset(new PrefChangeRegistrar); | 730 pref_registrar_.reset(new PrefChangeRegistrar); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 bool screen_locked_; | 1240 bool screen_locked_; |
| 1244 ConnectionState connected_network_state_; | 1241 ConnectionState connected_network_state_; |
| 1245 std::string connected_network_path_; | 1242 std::string connected_network_path_; |
| 1246 | 1243 |
| 1247 scoped_refptr<BluetoothAdapter> bluetooth_adapter_; | 1244 scoped_refptr<BluetoothAdapter> bluetooth_adapter_; |
| 1248 | 1245 |
| 1249 BooleanPrefMember accessibility_enabled_; | 1246 BooleanPrefMember accessibility_enabled_; |
| 1250 | 1247 |
| 1251 scoped_ptr<DataPromoNotification> data_promo_notification_; | 1248 scoped_ptr<DataPromoNotification> data_promo_notification_; |
| 1252 | 1249 |
| 1250 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_; |
| 1251 |
| 1253 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1252 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
| 1254 }; | 1253 }; |
| 1255 | 1254 |
| 1256 } // namespace | 1255 } // namespace |
| 1257 | 1256 |
| 1258 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 1257 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
| 1259 return new chromeos::SystemTrayDelegate(tray); | 1258 return new chromeos::SystemTrayDelegate(tray); |
| 1260 } | 1259 } |
| 1261 | 1260 |
| 1262 } // namespace chromeos | 1261 } // namespace chromeos |
| OLD | NEW |