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

Side by Side Diff: chrome/browser/chromeos/status/power_menu_button.cc

Issue 8438064: Separate StatusAreaView from StatusAreaViewChromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fixes + fixup Delegate Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/status/power_menu_button.h" 5 #include "chrome/browser/chromeos/status/power_menu_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/chromeos/cros/cros_library.h" 14 #include "chrome/browser/chromeos/cros/cros_library.h"
15 #include "chrome/browser/chromeos/view_ids.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/canvas_skia.h" 21 #include "ui/gfx/canvas_skia.h"
21 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
22 #include "views/controls/menu/menu_item_view.h" 23 #include "views/controls/menu/menu_item_view.h"
23 #include "views/controls/menu/menu_runner.h" 24 #include "views/controls/menu/menu_runner.h"
24 #include "views/controls/menu/submenu_view.h" 25 #include "views/controls/menu/submenu_view.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 238
238 private: 239 private:
239 PowerMenuButton* menu_button_; 240 PowerMenuButton* menu_button_;
240 gfx::Font percentage_font_; 241 gfx::Font percentage_font_;
241 gfx::Font estimate_font_; 242 gfx::Font estimate_font_;
242 }; 243 };
243 244
244 //////////////////////////////////////////////////////////////////////////////// 245 ////////////////////////////////////////////////////////////////////////////////
245 // PowerMenuButton 246 // PowerMenuButton
246 247
247 PowerMenuButton::PowerMenuButton(StatusAreaHost* host) 248 PowerMenuButton::PowerMenuButton(StatusAreaButton::Delegate* delegate)
248 : StatusAreaButton(host, this), 249 : StatusAreaButton(delegate, this),
249 battery_is_present_(false), 250 battery_is_present_(false),
250 line_power_on_(false), 251 line_power_on_(false),
251 battery_percentage_(0.0), 252 battery_percentage_(0.0),
252 battery_index_(-1), 253 battery_index_(-1),
253 battery_time_to_full_(TimeDelta::FromMicroseconds(kInitialMS)), 254 battery_time_to_full_(TimeDelta::FromMicroseconds(kInitialMS)),
254 battery_time_to_empty_(TimeDelta::FromMicroseconds(kInitialMS)), 255 battery_time_to_empty_(TimeDelta::FromMicroseconds(kInitialMS)),
255 status_(NULL) { 256 status_(NULL) {
257 set_id(VIEW_ID_STATUS_BUTTON_POWER);
256 UpdateIconAndLabelInfo(); 258 UpdateIconAndLabelInfo();
257 CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this); 259 CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this);
258 } 260 }
259 261
260 PowerMenuButton::~PowerMenuButton() { 262 PowerMenuButton::~PowerMenuButton() {
261 CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this); 263 CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this);
262 } 264 }
263 265
264 // PowerMenuButton, views::MenuDelegate implementation: 266 // PowerMenuButton, views::MenuDelegate implementation:
265 267
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // If previous is 0, then it either was never set (initial condition) 417 // If previous is 0, then it either was never set (initial condition)
416 // or got down to 0. 418 // or got down to 0.
417 if (*previous == TimeDelta::FromMicroseconds(kInitialMS) || 419 if (*previous == TimeDelta::FromMicroseconds(kInitialMS) ||
418 diff < kMinDiff || 420 diff < kMinDiff ||
419 diff > kMaxDiff) { 421 diff > kMaxDiff) {
420 *previous = current; 422 *previous = current;
421 } 423 }
422 } 424 }
423 425
424 } // namespace chromeos 426 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698