diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 05:40:38 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 05:40:38 +0000 |
commit | 1d28ca09c3479a817dc5f71117b6e9e99feffa3d (patch) | |
tree | e96b8267f556cfaf0641a3919e38ac05c1edf228 /ash/system | |
parent | e49d8431d44a678c9bfc2bf698759637637cc30a (diff) | |
download | chromium_src-1d28ca09c3479a817dc5f71117b6e9e99feffa3d.zip chromium_src-1d28ca09c3479a817dc5f71117b6e9e99feffa3d.tar.gz chromium_src-1d28ca09c3479a817dc5f71117b6e9e99feffa3d.tar.bz2 |
Move TrayPower related code frome ash/system/power to ash/system/chromeos/power. This helps:
1. Remove the duplicated PowerSupplyStatus from ash/system/power.
2. Remove PowerStatusObserver from ash/system/power.
3. Remove power supply status related state, apis and observer from ash_system_tray_delegate.cc.
Not done yet:
There are still other PowerManagerClient calls in ash_system_tray_delegate.cc, which are used by other code. We may be able to move them into the new PowerManagerHandler, which will further downsize ash_system_tray_delegate. This could be done in another cl.
BUG=190299
TBR=sky
Review URL: https://chromiumcodereview.appspot.com/14691011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
17 files changed, 87 insertions, 246 deletions
diff --git a/ash/system/power/power_status_view.cc b/ash/system/chromeos/power/power_status_view.cc index 7566d1c..9aa461c 100644 --- a/ash/system/power/power_status_view.cc +++ b/ash/system/chromeos/power/power_status_view.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/system/power/power_status_view.h" +#include "ash/system/chromeos/power/power_status_view.h" #include "ash/shell.h" #include "ash/shell_delegate.h" -#include "ash/system/power/tray_power.h" +#include "ash/system/chromeos/power/tray_power.h" #include "ash/system/tray/fixed_sized_image_view.h" #include "ash/system/tray/tray_constants.h" #include "base/strings/string_number_conversions.h" @@ -59,7 +59,8 @@ PowerStatusView::PowerStatusView(ViewType view_type, Update(); } -void PowerStatusView::UpdatePowerStatus(const PowerSupplyStatus& status) { +void PowerStatusView::UpdatePowerStatus( + const chromeos::PowerSupplyStatus& status) { supply_status_ = status; // Sanitize. if (supply_status_.battery_is_full) diff --git a/ash/system/power/power_status_view.h b/ash/system/chromeos/power/power_status_view.h index 4454e5c..421ce40 100644 --- a/ash/system/power/power_status_view.h +++ b/ash/system/chromeos/power/power_status_view.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_SYSTEM_POWER_POWER_STATUS_VIEW_H_ -#define ASH_SYSTEM_POWER_POWER_STATUS_VIEW_H_ +#ifndef ASH_SYSTEM_CHROMEOS_POWER_POWER_STATUS_VIEW_H_ +#define ASH_SYSTEM_CHROMEOS_POWER_POWER_STATUS_VIEW_H_ -#include "ash/system/power/power_supply_status.h" +#include "chromeos/dbus/power_supply_status.h" #include "ui/views/view.h" namespace views { @@ -26,7 +26,7 @@ class PowerStatusView : public views::View { PowerStatusView(ViewType view_type, bool default_view_right_align); virtual ~PowerStatusView() {} - void UpdatePowerStatus(const PowerSupplyStatus& status); + void UpdatePowerStatus(const chromeos::PowerSupplyStatus& status); const base::string16& accessible_name() const { return accessible_name_; } // Overridden from views::View. @@ -76,7 +76,7 @@ class PowerStatusView : public views::View { ViewType view_type_; - PowerSupplyStatus supply_status_; + chromeos::PowerSupplyStatus supply_status_; base::string16 accessible_name_; @@ -86,4 +86,4 @@ class PowerStatusView : public views::View { } // namespace internal } // namespace ash -#endif // ASH_SYSTEM_POWER_POWER_STATUS_VIEW_H_ +#endif // ASH_SYSTEM_CHROMEOS_POWER_POWER_STATUS_VIEW_H_ diff --git a/ash/system/power/tray_power.cc b/ash/system/chromeos/power/tray_power.cc index 5ec9e3b..64f33f2 100644 --- a/ash/system/power/tray_power.cc +++ b/ash/system/chromeos/power/tray_power.cc @@ -2,15 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/system/power/tray_power.h" +#include "ash/system/chromeos/power/tray_power.h" #include "ash/ash_switches.h" #include "ash/shell.h" +#include "ash/shell_delegate.h" +#include "ash/system/chromeos/power/power_status_view.h" #include "ash/system/date/date_view.h" -#include "ash/system/power/power_status_view.h" -#include "ash/system/power/power_supply_status.h" -#include "ash/system/tray/system_tray_delegate.h" -#include "ash/system/tray/system_tray_notifier.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_notification_view.h" #include "ash/system/tray/tray_utils.h" @@ -18,6 +16,7 @@ #include "base/stringprintf.h" #include "base/strings/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "chromeos/dbus/power_supply_status.h" #include "grit/ash_resources.h" #include "grit/ash_strings.h" #include "third_party/icu/public/i18n/unicode/fieldpos.h" @@ -39,6 +38,9 @@ #include "ui/views/view.h" #include "ui/views/widget/widget.h" +using chromeos::PowerManagerHandler; +using chromeos::PowerSupplyStatus; + namespace ash { namespace internal { @@ -104,7 +106,8 @@ class PowerTrayView : public views::ImageView { state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; } - void UpdatePowerStatus(const PowerSupplyStatus& status, bool battery_alert) { + void UpdatePowerStatus(const PowerSupplyStatus& status, + bool battery_alert) { supply_status_ = status; // Sanitize. if (supply_status_.battery_is_full) @@ -203,24 +206,27 @@ TrayPower::TrayPower(SystemTray* system_tray) power_tray_(NULL), notification_view_(NULL), notification_state_(NOTIFICATION_NONE) { - Shell::GetInstance()->system_tray_notifier()->AddPowerStatusObserver(this); + PowerManagerHandler::Get()->AddObserver(this); } TrayPower::~TrayPower() { - Shell::GetInstance()->system_tray_notifier()->RemovePowerStatusObserver(this); + if (PowerManagerHandler::IsInitialized()) + PowerManagerHandler::Get()->RemoveObserver(this); } // static bool TrayPower::IsBatteryChargingUnreliable( - const PowerSupplyStatus& supply_status) { + const chromeos::PowerSupplyStatus& supply_status) { return supply_status.battery_state == - PowerSupplyStatus::NEITHER_CHARGING_NOR_DISCHARGING || - supply_status.battery_state == PowerSupplyStatus::CONNECTED_TO_USB; + PowerSupplyStatus::NEITHER_CHARGING_NOR_DISCHARGING || + supply_status.battery_state == + PowerSupplyStatus::CONNECTED_TO_USB; } // static -int TrayPower::GetBatteryImageIndex(const PowerSupplyStatus& supply_status) { +int TrayPower::GetBatteryImageIndex( + const chromeos::PowerSupplyStatus& supply_status) { int image_index = 0; if (supply_status.battery_percentage >= 100) { image_index = kNumPowerImages - 1; @@ -235,7 +241,8 @@ int TrayPower::GetBatteryImageIndex(const PowerSupplyStatus& supply_status) { } // static -int TrayPower::GetBatteryImageOffset(const PowerSupplyStatus& supply_status) { +int TrayPower::GetBatteryImageOffset( + const chromeos::PowerSupplyStatus& supply_status) { if (IsBatteryChargingUnreliable(supply_status) || !supply_status.line_power_on) return 0; @@ -267,7 +274,7 @@ gfx::ImageSkia TrayPower::GetBatteryImage(int image_index, // static base::string16 TrayPower::GetAccessibleNameString( - const PowerSupplyStatus& supply_status) { + const chromeos::PowerSupplyStatus& supply_status) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); if (supply_status.line_power_on && supply_status.battery_is_full) { return rb.GetLocalizedString( @@ -335,7 +342,7 @@ views::View* TrayPower::CreateTrayView(user::LoginStatus status) { // there is a battery or not. So always create this, and adjust visibility as // necessary. PowerSupplyStatus power_status = - ash::Shell::GetInstance()->system_tray_delegate()->GetPowerSupplyStatus(); + PowerManagerHandler::Get()->GetPowerSupplyStatus(); CHECK(power_tray_ == NULL); power_tray_ = new tray::PowerTrayView(); power_tray_->UpdatePowerStatus(power_status, false); @@ -344,14 +351,14 @@ views::View* TrayPower::CreateTrayView(user::LoginStatus status) { views::View* TrayPower::CreateDefaultView(user::LoginStatus status) { // Make sure icon status is up-to-date. (Also triggers stub activation). - ash::Shell::GetInstance()->system_tray_delegate()->RequestStatusUpdate(); + RequestStatusUpdate(); return NULL; } views::View* TrayPower::CreateNotificationView(user::LoginStatus status) { CHECK(notification_view_ == NULL); PowerSupplyStatus power_status = - ash::Shell::GetInstance()->system_tray_delegate()->GetPowerSupplyStatus(); + PowerManagerHandler::Get()->GetPowerSupplyStatus(); if (!power_status.battery_is_present) return NULL; @@ -379,7 +386,8 @@ void TrayPower::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { SetTrayImageItemBorder(power_tray_, alignment); } -void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { +void TrayPower::OnPowerStatusChanged( + const chromeos::PowerSupplyStatus& status) { bool battery_alert = UpdateNotificationState(status); if (power_tray_) power_tray_->UpdatePowerStatus(status, battery_alert); @@ -392,7 +400,12 @@ void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { HideNotificationView(); } -bool TrayPower::UpdateNotificationState(const PowerSupplyStatus& status) { +void TrayPower::RequestStatusUpdate() const { + PowerManagerHandler::Get()->RequestStatusUpdate(); +} + +bool TrayPower::UpdateNotificationState( + const chromeos::PowerSupplyStatus& status) { if (!status.battery_is_present || status.is_calculating_battery_time || status.battery_state == PowerSupplyStatus::CHARGING) { diff --git a/ash/system/power/tray_power.h b/ash/system/chromeos/power/tray_power.h index 19eaf63..db33f35 100644 --- a/ash/system/power/tray_power.h +++ b/ash/system/chromeos/power/tray_power.h @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_SYSTEM_POWER_TRAY_POWER_H_ -#define ASH_SYSTEM_POWER_TRAY_POWER_H_ +#ifndef ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ +#define ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ -#include "ash/system/power/power_status_observer.h" #include "ash/system/tray/system_tray_item.h" +#include "chromeos/power/power_manager_handler.h" class SkBitmap; @@ -28,7 +28,7 @@ enum IconSet { }; class TrayPower : public SystemTrayItem, - public PowerStatusObserver { + public chromeos::PowerManagerHandler::Observer { public: explicit TrayPower(SystemTray* system_tray); virtual ~TrayPower(); @@ -39,16 +39,18 @@ class TrayPower : public SystemTrayItem, // charger power and power consumption, i.e usage. In this case we // do not want to show either a charging or discharging state. static bool IsBatteryChargingUnreliable( - const PowerSupplyStatus& supply_status); + const chromeos::PowerSupplyStatus& supply_status); // Gets the icon index in the battery icon array image based on // |supply_status|. If |supply_status| is uncertain about the power state, // returns -1. - static int GetBatteryImageIndex(const PowerSupplyStatus& supply_status); + static int GetBatteryImageIndex( + const chromeos::PowerSupplyStatus& supply_status); // Gets the horizontal offset in the battery icon array image based on // |supply_status|. - static int GetBatteryImageOffset(const PowerSupplyStatus& supply_status); + static int GetBatteryImageOffset( + const chromeos::PowerSupplyStatus& supply_status); // Looks up the actual icon in the icon array image for |image_index|. static gfx::ImageSkia GetBatteryImage(int image_index, @@ -58,7 +60,7 @@ class TrayPower : public SystemTrayItem, // Gets the battery accessible string for |supply_status|. static base::string16 GetAccessibleNameString( - const PowerSupplyStatus& supply_status); + const chromeos::PowerSupplyStatus& supply_status); // Gets rounded battery percentage for |battery_percentage|. static int GetRoundedBatteryPercentage(double battery_percentage); @@ -82,11 +84,15 @@ class TrayPower : public SystemTrayItem, virtual void UpdateAfterShelfAlignmentChange( ShelfAlignment alignment) OVERRIDE; - // Overridden from PowerStatusObserver. - virtual void OnPowerStatusChanged(const PowerSupplyStatus& status) OVERRIDE; + // Overridden from chromeos::PowerManagerHandler::Observer. + virtual void OnPowerStatusChanged( + const chromeos::PowerSupplyStatus& status) OVERRIDE; + + // Requests a power status update. + void RequestStatusUpdate() const; // Sets |notification_state_|. Returns true if a notification should be shown. - bool UpdateNotificationState(const PowerSupplyStatus& status); + bool UpdateNotificationState(const chromeos::PowerSupplyStatus& status); bool UpdateNotificationStateForRemainingTime(int remaining_seconds); bool UpdateNotificationStateForRemainingPercentage( double remaining_percentage); @@ -101,4 +107,4 @@ class TrayPower : public SystemTrayItem, } // namespace internal } // namespace ash -#endif // ASH_SYSTEM_POWER_TRAY_POWER_H_ +#endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ diff --git a/ash/system/settings/tray_settings.cc b/ash/system/chromeos/settings/tray_settings.cc index a142ae0..0f16819 100644 --- a/ash/system/settings/tray_settings.cc +++ b/ash/system/chromeos/settings/tray_settings.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/system/settings/tray_settings.h" +#include "ash/system/chromeos/settings/tray_settings.h" #include "ash/shell.h" -#include "ash/system/power/power_status_view.h" +#include "ash/system/chromeos/power/power_status_view.h" #include "ash/system/tray/actionable_view.h" #include "ash/system/tray/fixed_sized_image_view.h" #include "ash/system/tray/system_tray_delegate.h" -#include "ash/system/tray/system_tray_notifier.h" #include "ash/system/tray/tray_constants.h" #include "base/logging.h" #include "base/utf_string_conversions.h" +#include "chromeos/dbus/power_manager_client.h" #include "grit/ash_resources.h" #include "grit/ash_strings.h" #include "third_party/skia/include/core/SkColor.h" @@ -58,8 +58,8 @@ class SettingsDefaultView : public ActionableView { power_view_right_align = true; } - PowerSupplyStatus power_status = ash::Shell::GetInstance()-> - system_tray_delegate()->GetPowerSupplyStatus(); + chromeos::PowerSupplyStatus power_status = + chromeos::PowerManagerHandler::Get()->GetPowerSupplyStatus(); if (power_status.battery_is_present) { power_status_view_ = new ash::internal::PowerStatusView( ash::internal::PowerStatusView::VIEW_DEFAULT, power_view_right_align); @@ -70,7 +70,7 @@ class SettingsDefaultView : public ActionableView { virtual ~SettingsDefaultView() {} - void UpdatePowerStatus(const PowerSupplyStatus& status) { + void UpdatePowerStatus(const chromeos::PowerSupplyStatus& status) { if (!power_status_view_) return; power_status_view_->UpdatePowerStatus(status); @@ -125,11 +125,12 @@ class SettingsDefaultView : public ActionableView { TraySettings::TraySettings(SystemTray* system_tray) : SystemTrayItem(system_tray), default_view_(NULL) { - Shell::GetInstance()->system_tray_notifier()->AddPowerStatusObserver(this); + chromeos::PowerManagerHandler::Get()->AddObserver(this); } TraySettings::~TraySettings() { - Shell::GetInstance()->system_tray_notifier()->RemovePowerStatusObserver(this); + if (chromeos::PowerManagerHandler::IsInitialized()) + chromeos::PowerManagerHandler::Get()->RemoveObserver(this); } views::View* TraySettings::CreateTrayView(user::LoginStatus status) { @@ -138,8 +139,9 @@ views::View* TraySettings::CreateTrayView(user::LoginStatus status) { views::View* TraySettings::CreateDefaultView(user::LoginStatus status) { if ((status == user::LOGGED_IN_NONE || status == user::LOGGED_IN_LOCKED) && - (!ash::Shell::GetInstance()->system_tray_delegate()-> - GetPowerSupplyStatus().battery_is_present)) + (chromeos::PowerManagerHandler::IsInitialized() && + !chromeos::PowerManagerHandler::Get()-> + GetPowerSupplyStatus().battery_is_present)) return NULL; CHECK(default_view_ == NULL); @@ -165,8 +167,8 @@ void TraySettings::DestroyDetailedView() { void TraySettings::UpdateAfterLoginStatusChange(user::LoginStatus status) { } -// Overridden from PowerStatusObserver. -void TraySettings::OnPowerStatusChanged(const PowerSupplyStatus& status) { +void TraySettings::OnPowerStatusChanged( + const chromeos::PowerSupplyStatus& status) { if (default_view_) default_view_->UpdatePowerStatus(status); } diff --git a/ash/system/settings/tray_settings.h b/ash/system/chromeos/settings/tray_settings.h index ed9c015..c0dc9db 100644 --- a/ash/system/settings/tray_settings.h +++ b/ash/system/chromeos/settings/tray_settings.h @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_SYSTEM_SETTINGS_TRAY_SETTINGS_H_ -#define ASH_SYSTEM_SETTINGS_TRAY_SETTINGS_H_ +#ifndef ASH_SYSTEM_CHROMEOS_SETTINGS_TRAY_SETTINGS_H_ +#define ASH_SYSTEM_CHROMEOS_SETTINGS_TRAY_SETTINGS_H_ -#include "ash/system/power/power_status_observer.h" #include "ash/system/tray/system_tray_item.h" +#include "chromeos/power/power_manager_handler.h" namespace ash { namespace internal { @@ -16,7 +16,7 @@ class SettingsDefaultView; } class TraySettings : public SystemTrayItem, - public PowerStatusObserver { + public chromeos::PowerManagerHandler::Observer { public: explicit TraySettings(SystemTray* system_tray); virtual ~TraySettings(); @@ -31,8 +31,9 @@ class TraySettings : public SystemTrayItem, virtual void DestroyDetailedView() OVERRIDE; virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; - // Overridden from PowerStatusObserver. - virtual void OnPowerStatusChanged(const PowerSupplyStatus& status) OVERRIDE; + // Overridden from chromeos::PowerManagerHandler::Observer. + virtual void OnPowerStatusChanged( + const chromeos::PowerSupplyStatus& status) OVERRIDE; tray::SettingsDefaultView* default_view_; @@ -42,4 +43,4 @@ class TraySettings : public SystemTrayItem, } // namespace internal } // namespace ash -#endif // ASH_SYSTEM_SETTINGS_TRAY_SETTINGS_H_ +#endif // ASH_SYSTEM_CHROMEOS_SETTINGS_TRAY_SETTINGS_H_ diff --git a/ash/system/power/DEPS b/ash/system/power/DEPS deleted file mode 100644 index 69b8167..0000000 --- a/ash/system/power/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - # TODO(stevenjb): Move this code to src/ash/system/chromeos, crbug.com/154842 - "+chromeos/dbus/power_supply_status.h", -] diff --git a/ash/system/power/power_status_observer.h b/ash/system/power/power_status_observer.h deleted file mode 100644 index 3a4b1b4..0000000 --- a/ash/system/power/power_status_observer.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SYSTEM_POWER_POWER_STATUS_OBSERVER_H_ -#define ASH_SYSTEM_POWER_POWER_STATUS_OBSERVER_H_ - -#include "ash/system/power/power_supply_status.h" - -namespace ash { - -class PowerStatusObserver { - public: - virtual ~PowerStatusObserver() {} - - virtual void OnPowerStatusChanged(const PowerSupplyStatus& status) = 0; -}; - -}; - -#endif // ASH_SYSTEM_POWER_POWER_STATUS_OBSERVER_H_ diff --git a/ash/system/power/power_supply_status.cc b/ash/system/power/power_supply_status.cc deleted file mode 100644 index fef327b..0000000 --- a/ash/system/power/power_supply_status.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/system/power/power_supply_status.h" - -#include "base/format_macros.h" -#include "base/stringprintf.h" - -namespace ash { - -#if !defined(OS_CHROMEOS) -PowerSupplyStatus::PowerSupplyStatus() - : line_power_on(false), - battery_is_present(false), - battery_is_full(false), - battery_seconds_to_empty(0), - battery_seconds_to_full(0), - battery_percentage(0), - is_calculating_battery_time(false), - battery_state(CHARGING) {} - -std::string PowerSupplyStatus::ToString() const { - std::string result; - base::StringAppendF(&result, - "line_power_on = %s ", - line_power_on ? "true" : "false"); - base::StringAppendF(&result, - "battery_is_present = %s ", - battery_is_present ? "true" : "false"); - base::StringAppendF(&result, - "battery_is_full = %s ", - battery_is_full ? "true" : "false"); - base::StringAppendF(&result, - "battery_percentage = %f ", - battery_percentage); - base::StringAppendF(&result, - "battery_seconds_to_empty = %"PRId64" ", - battery_seconds_to_empty); - base::StringAppendF(&result, - "battery_seconds_to_full = %"PRId64" ", - battery_seconds_to_full); - base::StringAppendF(&result, - "is_calculating_battery_time = %s ", - is_calculating_battery_time ? "true" : "false"); - base::StringAppendF(&result, - "battery_state = %d ", - battery_state); - return result; -} -#endif // !defined(OS_CHROMEOS) - -} // namespace ash diff --git a/ash/system/power/power_supply_status.h b/ash/system/power/power_supply_status.h deleted file mode 100644 index fd25643..0000000 --- a/ash/system/power/power_supply_status.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SYSTEM_POWER_POWER_SUPPLY_STATUS_H_ -#define ASH_SYSTEM_POWER_POWER_SUPPLY_STATUS_H_ - -#include <string> - -#include "ash/ash_export.h" -#include "base/basictypes.h" - -#if defined(OS_CHROMEOS) -#include "chromeos/dbus/power_supply_status.h" -#endif - -namespace ash { - -#if defined(OS_CHROMEOS) -typedef chromeos::PowerSupplyStatus PowerSupplyStatus; -#else -// Define local struct when not building for Chrome OS. -struct ASH_EXPORT PowerSupplyStatus { - enum BatteryState { - // Line power is connected and the battery is full or being charged. - CHARGING = 0, - - // Line power is disconnected. - DISCHARGING = 1, - - // Line power is connected and the battery isn't full, but it also - // isn't charging (or discharging). This can occur if the EC believes - // that the battery isn't authentic and chooses to run directly off - // line power. - NEITHER_CHARGING_NOR_DISCHARGING = 2, - - // A USB power source (DCP, CDP, or ACA) is connected. The battery may - // be charging or discharging depending on the negotiated current. - CONNECTED_TO_USB = 3, - }; - - bool line_power_on; - - bool battery_is_present; - bool battery_is_full; - - // Time in seconds until the battery is empty or full, 0 for unknown. - int64 battery_seconds_to_empty; - int64 battery_seconds_to_full; - - double battery_percentage; - - bool is_calculating_battery_time; - - BatteryState battery_state; - - PowerSupplyStatus(); - std::string ToString() const; -}; -#endif // defined(OS_CHROMEOS) - -} // namespace ash - -#endif // ASH_SYSTEM_POWER_POWER_SUPPLY_STATUS_H_ diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index ce3a81a..8dc0fa4 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -17,10 +17,7 @@ #include "ash/system/locale/tray_locale.h" #include "ash/system/logout_button/tray_logout_button.h" #include "ash/system/monitor/tray_monitor.h" -#include "ash/system/power/power_supply_status.h" -#include "ash/system/power/tray_power.h" #include "ash/system/session_length_limit/tray_session_length_limit.h" -#include "ash/system/settings/tray_settings.h" #include "ash/system/status_area_widget.h" #include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_item.h" @@ -56,7 +53,9 @@ #include "ash/system/chromeos/network/tray_network.h" #include "ash/system/chromeos/network/tray_sms.h" #include "ash/system/chromeos/network/tray_vpn.h" +#include "ash/system/chromeos/power/tray_power.h" #include "ash/system/chromeos/screen_capture/tray_screen_capture.h" +#include "ash/system/chromeos/settings/tray_settings.h" #include "ash/system/chromeos/tray_display.h" #endif @@ -148,7 +147,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { AddTrayItem(new internal::TrayIME(this)); tray_accessibility_ = new internal::TrayAccessibility(this); AddTrayItem(tray_accessibility_); -#if !defined(OS_WIN) +#if defined(OS_CHROMEOS) AddTrayItem(new internal::TrayPower(this)); #endif #if defined(OS_CHROMEOS) @@ -170,7 +169,9 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { AddTrayItem(new internal::TrayBrightness(this)); AddTrayItem(new internal::TrayCapsLock(this)); #endif +#if defined(OS_CHROMEOS) AddTrayItem(new internal::TraySettings(this)); +#endif AddTrayItem(new internal::TrayUpdate(this)); AddTrayItem(new internal::TrayDate(this)); diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index 0f91367..48875fd 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -6,7 +6,6 @@ #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ #include "ash/ash_export.h" -#include "ash/system/power/power_supply_status.h" #include "ash/system/tray/system_tray_bubble.h" #include "ash/system/tray/tray_background_view.h" #include "ash/system/user/login_status.h" @@ -32,7 +31,6 @@ class DriveObserver; class IMEObserver; class LocaleObserver; class LogoutButtonObserver; -class PowerStatusObserver; class SystemTrayDelegate; class UpdateObserver; class UserObserver; diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index ee0409e..162920a 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -9,7 +9,6 @@ #include <vector> #include "ash/ash_export.h" -#include "ash/system/power/power_supply_status.h" #include "ash/system/user/login_status.h" #include "base/files/file_path.h" #include "base/i18n/time_formatting.h" @@ -160,12 +159,6 @@ class SystemTrayDelegate { // Returns the desired hour clock type. virtual base::HourClockType GetHourClockType() const = 0; - // Gets the current power supply status. - virtual PowerSupplyStatus GetPowerSupplyStatus() const = 0; - - // Requests a status update. - virtual void RequestStatusUpdate() const = 0; - // Shows settings. virtual void ShowSettings() = 0; diff --git a/ash/system/tray/system_tray_notifier.cc b/ash/system/tray/system_tray_notifier.cc index a6a9d98..20f7eed 100644 --- a/ash/system/tray/system_tray_notifier.cc +++ b/ash/system/tray/system_tray_notifier.cc @@ -89,16 +89,6 @@ void SystemTrayNotifier::RemoveLogoutButtonObserver( logout_button_observers_.RemoveObserver(observer); } -void SystemTrayNotifier::AddPowerStatusObserver( - PowerStatusObserver* observer) { - power_status_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemovePowerStatusObserver( - PowerStatusObserver* observer) { - power_status_observers_.RemoveObserver(observer); -} - void SystemTrayNotifier::AddSessionLengthLimitObserver( SessionLengthLimitObserver* observer) { session_length_limit_observers_.AddObserver(observer); @@ -263,13 +253,6 @@ void SystemTrayNotifier::NotifyLocaleChanged( OnLocaleChanged(delegate, cur_locale, from_locale, to_locale)); } -void SystemTrayNotifier::NotifyPowerStatusChanged( - const PowerSupplyStatus& power_status) { - FOR_EACH_OBSERVER(PowerStatusObserver, - power_status_observers_, - OnPowerStatusChanged(power_status)); -} - void SystemTrayNotifier::NotifySessionStartTimeChanged() { FOR_EACH_OBSERVER(SessionLengthLimitObserver, session_length_limit_observers_, diff --git a/ash/system/tray/system_tray_notifier.h b/ash/system/tray/system_tray_notifier.h index 1f7becf..fbd9874 100644 --- a/ash/system/tray/system_tray_notifier.h +++ b/ash/system/tray/system_tray_notifier.h @@ -19,7 +19,6 @@ #include "ash/system/ime/ime_observer.h" #include "ash/system/locale/locale_observer.h" #include "ash/system/logout_button/logout_button_observer.h" -#include "ash/system/power/power_status_observer.h" #include "ash/system/session_length_limit/session_length_limit_observer.h" #include "ash/system/tray_accessibility.h" #include "ash/system/tray_caps_lock.h" @@ -68,9 +67,6 @@ public: void AddLogoutButtonObserver(LogoutButtonObserver* observer); void RemoveLogoutButtonObserver(LogoutButtonObserver* observer); - void AddPowerStatusObserver(PowerStatusObserver* observer); - void RemovePowerStatusObserver(PowerStatusObserver* observer); - void AddSessionLengthLimitObserver(SessionLengthLimitObserver* observer); void RemoveSessionLengthLimitObserver(SessionLengthLimitObserver* observer); @@ -116,7 +112,6 @@ public: const std::string& cur_locale, const std::string& from_locale, const std::string& to_locale); - void NotifyPowerStatusChanged(const PowerSupplyStatus& power_status); void NotifySessionStartTimeChanged(); void NotifySessionLengthLimitChanged(); void NotifyUpdateRecommended(UpdateObserver::UpdateSeverity severity); @@ -151,7 +146,6 @@ public: ObserverList<IMEObserver> ime_observers_; ObserverList<LocaleObserver> locale_observers_; ObserverList<LogoutButtonObserver> logout_button_observers_; - ObserverList<PowerStatusObserver> power_status_observers_; ObserverList<SessionLengthLimitObserver> session_length_limit_observers_; ObserverList<UpdateObserver> update_observers_; ObserverList<UserObserver> user_observers_; diff --git a/ash/system/tray/test_system_tray_delegate.cc b/ash/system/tray/test_system_tray_delegate.cc index 8299249..ddfe092 100644 --- a/ash/system/tray/test_system_tray_delegate.cc +++ b/ash/system/tray/test_system_tray_delegate.cc @@ -139,13 +139,6 @@ base::HourClockType TestSystemTrayDelegate::GetHourClockType() const { return base::k24HourClock; } -PowerSupplyStatus TestSystemTrayDelegate::GetPowerSupplyStatus() const { - return PowerSupplyStatus(); -} - -void TestSystemTrayDelegate::RequestStatusUpdate() const { -} - void TestSystemTrayDelegate::ShowSettings() { } diff --git a/ash/system/tray/test_system_tray_delegate.h b/ash/system/tray/test_system_tray_delegate.h index 8f5f5c3..b349277 100644 --- a/ash/system/tray/test_system_tray_delegate.h +++ b/ash/system/tray/test_system_tray_delegate.h @@ -40,8 +40,6 @@ class TestSystemTrayDelegate : public SystemTrayDelegate { virtual const base::string16 GetLocallyManagedUserMessage() const OVERRIDE; virtual bool SystemShouldUpgrade() const OVERRIDE; virtual base::HourClockType GetHourClockType() const OVERRIDE; - virtual PowerSupplyStatus GetPowerSupplyStatus() const OVERRIDE; - virtual void RequestStatusUpdate() const OVERRIDE; virtual void ShowSettings() OVERRIDE; virtual void ShowDateSettings() OVERRIDE; virtual void ShowNetworkSettings() OVERRIDE; |