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

Side by Side Diff: ash/system/power/power_status_view.cc

Issue 10535118: Work around the crOS battery time reporting issue in ash tray battery UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/system/power/power_status_view.h" 5 #include "ash/system/power/power_status_view.h"
6 6
7 #include "ash/system/power/tray_power.h" 7 #include "ash/system/power/tray_power.h"
8 #include "ash/system/tray/tray_constants.h" 8 #include "ash/system/tray/tray_constants.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 void PowerStatusView::UpdateText() { 81 void PowerStatusView::UpdateText() {
82 view_type_ == VIEW_DEFAULT ? 82 view_type_ == VIEW_DEFAULT ?
83 UpdateTextForDefaultView() : UpdateTextForNotificationView(); 83 UpdateTextForDefaultView() : UpdateTextForNotificationView();
84 } 84 }
85 85
86 void PowerStatusView::UpdateTextForDefaultView() { 86 void PowerStatusView::UpdateTextForDefaultView() {
87 int hour = 0; 87 int hour = 0;
88 int min = 0; 88 int min = 0;
89 if (!supply_status_.is_calculating_battery_time) { 89 if (!supply_status_.is_calculating_battery_time) {
90 // TODO(jennyz): Due to crosbug.com/31633, averaged_battery_time_to_empty
91 // from PowerSupplyStatus object can contain garbage data for the first
92 // call in a crOS session. Until this bug is fixed, use
93 // supply_status_.battery_seconds_to_empty to render battery time.
94 // Change back to use averaged_battery_time_to_empty to display in UI
95 // once crosbug.com/31633 is fixed.
90 base::TimeDelta time = base::TimeDelta::FromSeconds( 96 base::TimeDelta time = base::TimeDelta::FromSeconds(
91 supply_status_.averaged_battery_time_to_empty); 97 supply_status_.battery_seconds_to_empty);
sadrul 2012/06/11 21:43:15 Interesting. Just the seconds_to_empty is garbage,
92 hour = time.InHours(); 98 hour = time.InHours();
93 min = (time - base::TimeDelta::FromHours(hour)).InMinutes(); 99 min = (time - base::TimeDelta::FromHours(hour)).InMinutes();
94 } 100 }
95 101
96 if (supply_status_.line_power_on && supply_status_.battery_is_full) { 102 if (supply_status_.line_power_on && supply_status_.battery_is_full) {
97 time_status_label_->SetText( 103 time_status_label_->SetText(
98 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 104 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
99 IDS_ASH_STATUS_TRAY_BATTERY_FULL)); 105 IDS_ASH_STATUS_TRAY_BATTERY_FULL));
100 } else { 106 } else {
101 string16 battery_percentage = l10n_util::GetStringFUTF16( 107 string16 battery_percentage = l10n_util::GetStringFUTF16(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 PreferredSizeChanged(); 184 PreferredSizeChanged();
179 } 185 }
180 186
181 gfx::Size PowerStatusView::GetPreferredSize() { 187 gfx::Size PowerStatusView::GetPreferredSize() {
182 gfx::Size size = views::View::GetPreferredSize(); 188 gfx::Size size = views::View::GetPreferredSize();
183 return gfx::Size(size.width(), kTrayPopupItemHeight); 189 return gfx::Size(size.width(), kTrayPopupItemHeight);
184 } 190 }
185 191
186 } // namespace internal 192 } // namespace internal
187 } // namespace ash 193 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698