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

Unified Diff: chrome/browser/chromeos/status/power_menu_button.h

Issue 6811025: Change status button menu implementation from Menu2 to MenuItemView. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Mainly updates to newer coding style. Created 9 years, 8 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
Index: chrome/browser/chromeos/status/power_menu_button.h
diff --git a/chrome/browser/chromeos/status/power_menu_button.h b/chrome/browser/chromeos/status/power_menu_button.h
index 216344e40abe90f287977d46a4efb7f7ac06e2ed..782948e0c83d34b03fd05b4bfbb9545f6318b4aa 100644
--- a/chrome/browser/chromeos/status/power_menu_button.h
+++ b/chrome/browser/chromeos/status/power_menu_button.h
@@ -6,10 +6,10 @@
#define CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_
#pragma once
+#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/cros/power_library.h"
#include "chrome/browser/chromeos/status/status_area_button.h"
-#include "ui/base/models/menu_model.h"
-#include "views/controls/menu/menu_2.h"
+#include "views/controls/menu/menu_delegate.h"
#include "views/controls/menu/view_menu_delegate.h"
namespace base {
@@ -23,34 +23,16 @@ namespace chromeos {
// The power menu button in the status area.
// This class will handle getting the power status and populating the menu.
class PowerMenuButton : public StatusAreaButton,
+ public views::MenuDelegate,
public views::ViewMenuDelegate,
- public ui::MenuModel,
public PowerLibrary::Observer {
public:
PowerMenuButton();
virtual ~PowerMenuButton();
- // ui::MenuModel implementation.
- virtual bool HasIcons() const { return false; }
- virtual int GetItemCount() const;
- virtual ui::MenuModel::ItemType GetTypeAt(int index) const;
- virtual int GetCommandIdAt(int index) const { return index; }
- virtual string16 GetLabelAt(int index) const;
- virtual bool IsItemDynamicAt(int index) const { return true; }
- virtual bool GetAcceleratorAt(int index,
- ui::Accelerator* accelerator) const { return false; }
- virtual bool IsItemCheckedAt(int index) const { return false; }
- virtual int GetGroupIdAt(int index) const { return 0; }
- virtual bool GetIconAt(int index, SkBitmap* icon) { return false; }
- virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const {
- return NULL;
- }
- virtual bool IsEnabledAt(int index) const { return false; }
- virtual ui::MenuModel* GetSubmenuModelAt(int index) const { return NULL; }
- virtual void HighlightChangedTo(int index) {}
- virtual void ActivatedAt(int index) {}
- virtual void MenuWillShow() {}
- virtual void SetMenuModelDelegate(ui::MenuModelDelegate* delegate) {}
+ // views::MenuDelegate implementation
+ virtual std::wstring GetLabel(int id) const OVERRIDE;
+ virtual bool IsCommandEnabled(int id) const OVERRIDE;
// PowerLibrary::Observer implementation.
virtual void PowerChanged(PowerLibrary* obj);
@@ -68,12 +50,13 @@ class PowerMenuButton : public StatusAreaButton,
// views::ViewMenuDelegate implementation.
virtual void RunMenu(views::View* source, const gfx::Point& pt);
+ // Format strings with power status
+ string16 GetBatteryPercentageText() const;
+ string16 GetBatteryIsChargedText() const;
+
// Update the power icon and menu label info depending on the power status.
void UpdateIconAndLabelInfo();
- // The number of power images.
- static const int kNumPowerImages;
-
// Stored data gathered from CrosLibrary::PowerLibrary.
bool battery_is_present_;
bool line_power_on_;
@@ -85,9 +68,8 @@ class PowerMenuButton : public StatusAreaButton,
// The currently showing icon bitmap id.
int icon_id_;
- // The power menu. This needs to be initialized last since it calls into
- // GetLabelAt() during construction.
- views::Menu2 power_menu_;
+ // The power menu.
+ scoped_ptr<views::MenuItemView> menu_;
DISALLOW_COPY_AND_ASSIGN(PowerMenuButton);
};

Powered by Google App Engine
This is Rietveld 408576698