| 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/dbus/power_manager_client.h" | 5 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 if (pause_count_) { | 601 if (pause_count_) { |
| 602 pause_count_ = 0; | 602 pause_count_ = 0; |
| 603 discharging_ = !discharging_; | 603 discharging_ = !discharging_; |
| 604 } else { | 604 } else { |
| 605 // Pause twice (i.e. skip updating the menu), including the current | 605 // Pause twice (i.e. skip updating the menu), including the current |
| 606 // call to this function. | 606 // call to this function. |
| 607 pause_count_ = 2; | 607 pause_count_ = 2; |
| 608 return; | 608 return; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 battery_percentage_ += (discharging_ ? -1 : 1); | 611 battery_percentage_ += (discharging_ ? -5 : 5); |
| 612 battery_percentage_ = std::min(std::max(battery_percentage_, 0), 100); |
| 612 | 613 |
| 613 const int kSecondsToEmptyFullBattery(3 * 60 * 60); // 3 hours. | 614 const int kSecondsToEmptyFullBattery(3 * 60 * 60); // 3 hours. |
| 614 | 615 |
| 615 PowerSupplyStatus status; | 616 PowerSupplyStatus status; |
| 616 status.line_power_on = !discharging_; | 617 status.line_power_on = !discharging_; |
| 617 status.battery_is_present = true; | 618 status.battery_is_present = true; |
| 618 status.battery_percentage = battery_percentage_; | 619 status.battery_percentage = battery_percentage_; |
| 619 status.battery_seconds_to_empty = | 620 status.battery_seconds_to_empty = |
| 620 std::max(1, battery_percentage_ * kSecondsToEmptyFullBattery / 100); | 621 std::max(1, battery_percentage_ * kSecondsToEmptyFullBattery / 100); |
| 621 status.battery_seconds_to_full = | 622 status.battery_seconds_to_full = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 641 PowerManagerClient* PowerManagerClient::Create( | 642 PowerManagerClient* PowerManagerClient::Create( |
| 642 DBusClientImplementationType type, | 643 DBusClientImplementationType type, |
| 643 dbus::Bus* bus) { | 644 dbus::Bus* bus) { |
| 644 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 645 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 645 return new PowerManagerClientImpl(bus); | 646 return new PowerManagerClientImpl(bus); |
| 646 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 647 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 647 return new PowerManagerClientStubImpl(); | 648 return new PowerManagerClientStubImpl(); |
| 648 } | 649 } |
| 649 | 650 |
| 650 } // namespace chromeos | 651 } // namespace chromeos |
| OLD | NEW |