Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1048)

Unified Diff: chrome/browser/chromeos/power/low_battery_observer.cc

Issue 10947046: Eliminate kAshNotifyDisabled and SystemNotification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/power/low_battery_observer.h ('k') | chrome/browser/chromeos/profile_startup.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/power/low_battery_observer.cc
diff --git a/chrome/browser/chromeos/power/low_battery_observer.cc b/chrome/browser/chromeos/power/low_battery_observer.cc
deleted file mode 100644
index 2fe0333d04be2c71f4fab3bb9c11a8b71bf100b3..0000000000000000000000000000000000000000
--- a/chrome/browser/chromeos/power/low_battery_observer.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2011 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 "chrome/browser/chromeos/power/low_battery_observer.h"
-
-#include "base/utf_string_conversions.h"
-#include "chrome/common/time_format.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace chromeos {
-
-LowBatteryObserver::LowBatteryObserver(Profile* profile)
- : notification_(profile, "battery.chromeos",
- IDR_NOTIFICATION_LOW_BATTERY,
- l10n_util::GetStringUTF16(IDS_LOW_BATTERY_TITLE)),
- remaining_(0) {}
-
-LowBatteryObserver::~LowBatteryObserver() {
- Hide();
-}
-
-void LowBatteryObserver::PowerChanged(const PowerSupplyStatus& power_status) {
- // Notification will show when remaining number of minutes is <= limit_min.
- const base::TimeDelta limit_min = base::TimeDelta::FromMinutes(15);
- // Notification will hide when remaining number of minutes is > limit_max.
- const base::TimeDelta limit_max = base::TimeDelta::FromMinutes(30);
- // Notification will be forced visible if hidden by user when time remaining
- // <= critical.
- const base::TimeDelta critical = base::TimeDelta::FromMinutes(5);
-
- base::TimeDelta remaining =
- base::TimeDelta::FromSeconds(power_status.battery_seconds_to_empty);
-
- // To simplify the logic - we handle the case of calculating the remaining
- // time as if we were on line power.
- // remaining time of zero means still calculating, this is denoted by
- // base::TimeDelta().
- bool line_power = power_status.line_power_on ||
- remaining == base::TimeDelta();
-
- // The urgent flag is used to re-notify the user if the power level
- // goes critical. We only want to do this once even if the time remaining
- // goes back up (so long as it doesn't go above limit_max.
- bool urgent = !line_power &&
- (notification_.urgent() || remaining <= critical);
-
- // This is a simple state machine with two states and three edges:
- // States: visible_, !visible_
- // Edges: hide: is visible_ to !visible_ triggered if we transition
- // to line_power, we're calculating our time remaining,
- // or our time remaining has climbed higher than
- // limit_max (either by reduced user an undetected transition
- // to/from line_power).
- // update: is visible_ to _visible triggered when we didn't hide
- // and the minutes remaining changed from what's shown.
- // show: is !visible_ to visible_ triggered when we're on battery,
- // we know the remaining time, and that time is less than limit.
-
- if (notification_.visible()) {
- if (line_power || remaining > limit_max) {
- Hide();
- } else if (remaining.InMinutes() != remaining_) {
- Show(remaining, urgent);
- }
- } else {
- if (!line_power && remaining <= limit_min) {
- Show(remaining, urgent);
- }
- }
-}
-
-void LowBatteryObserver::Show(base::TimeDelta remaining, bool urgent) {
- notification_.Show(l10n_util::GetStringFUTF16(IDS_LOW_BATTERY_MESSAGE,
- TimeFormat::TimeRemaining(remaining)), urgent, true);
- remaining_ = remaining.InMinutes();
-}
-
-void LowBatteryObserver::Hide() {
- notification_.Hide();
-}
-
-} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/power/low_battery_observer.h ('k') | chrome/browser/chromeos/profile_startup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698