| OLD | NEW |
| 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" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 //////////////////////////////////////////////////////////////////////////////// | 309 //////////////////////////////////////////////////////////////////////////////// |
| 310 // PowerMenuButton, views::View implementation: | 310 // PowerMenuButton, views::View implementation: |
| 311 void PowerMenuButton::OnLocaleChanged() { | 311 void PowerMenuButton::OnLocaleChanged() { |
| 312 UpdateIconAndLabelInfo(); | 312 UpdateIconAndLabelInfo(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 //////////////////////////////////////////////////////////////////////////////// | 315 //////////////////////////////////////////////////////////////////////////////// |
| 316 // PowerMenuButton, views::ViewMenuDelegate implementation: | 316 // PowerMenuButton, views::ViewMenuDelegate implementation: |
| 317 | 317 |
| 318 void PowerMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { | 318 void PowerMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { |
| 319 // Explicitly query the power status. |
| 320 if (CrosLibrary::Get()->EnsureLoaded()) |
| 321 CrosLibrary::Get()->GetPowerLibrary()->RequestStatusUpdate(); |
| 322 |
| 319 views::MenuItemView* menu = new views::MenuItemView(this); | 323 views::MenuItemView* menu = new views::MenuItemView(this); |
| 320 // MenuRunner takes ownership of |menu|. | 324 // MenuRunner takes ownership of |menu|. |
| 321 menu_runner_.reset(new views::MenuRunner(menu)); | 325 menu_runner_.reset(new views::MenuRunner(menu)); |
| 322 views::MenuItemView* submenu = menu->AppendMenuItem( | 326 views::MenuItemView* submenu = menu->AppendMenuItem( |
| 323 POWER_BATTERY_PERCENTAGE_ITEM, | 327 POWER_BATTERY_PERCENTAGE_ITEM, |
| 324 std::wstring(), | 328 std::wstring(), |
| 325 views::MenuItemView::NORMAL); | 329 views::MenuItemView::NORMAL); |
| 326 status_ = new StatusView(this); | 330 status_ = new StatusView(this); |
| 327 submenu->AddChildView(status_); | 331 submenu->AddChildView(status_); |
| 328 menu->CreateSubmenu()->set_resize_open_menu(true); | 332 menu->CreateSubmenu()->set_resize_open_menu(true); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // If previous is 0, then it either was never set (initial condition) | 418 // If previous is 0, then it either was never set (initial condition) |
| 415 // or got down to 0. | 419 // or got down to 0. |
| 416 if (*previous == TimeDelta::FromMicroseconds(kInitialMS) || | 420 if (*previous == TimeDelta::FromMicroseconds(kInitialMS) || |
| 417 diff < kMinDiff || | 421 diff < kMinDiff || |
| 418 diff > kMaxDiff) { | 422 diff > kMaxDiff) { |
| 419 *previous = current; | 423 *previous = current; |
| 420 } | 424 } |
| 421 } | 425 } |
| 422 | 426 |
| 423 } // namespace chromeos | 427 } // namespace chromeos |
| OLD | NEW |