| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_AREA_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_AREA_VIEW_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_AREA_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_AREA_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "third_party/cros/chromeos_cros_api.h" | |
| 10 #include "third_party/cros/chromeos_power.h" | |
| 11 #include "views/controls/menu/simple_menu_model.h" | 9 #include "views/controls/menu/simple_menu_model.h" |
| 12 #include "views/controls/menu/view_menu_delegate.h" | 10 #include "views/controls/menu/view_menu_delegate.h" |
| 13 #include "views/view.h" | 11 #include "views/view.h" |
| 14 | 12 |
| 15 class Browser; | 13 class Browser; |
| 14 class ClockMenuButton; |
| 16 class NetworkMenuButton; | 15 class NetworkMenuButton; |
| 16 class PowerMenuButton; |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class MenuButton; | 19 class MenuButton; |
| 20 class ImageView; | |
| 21 } | 20 } |
| 22 | 21 |
| 23 // This class is used to wrap the small informative widgets in the upper-right | 22 // This class is used to wrap the small informative widgets in the upper-right |
| 24 // of the window title bar. It is used on ChromeOS only. | 23 // of the window title bar. It is used on ChromeOS only. |
| 25 class StatusAreaView : public views::View, | 24 class StatusAreaView : public views::View, |
| 26 public views::SimpleMenuModel::Delegate, | 25 public views::SimpleMenuModel::Delegate, |
| 27 public views::ViewMenuDelegate { | 26 public views::ViewMenuDelegate { |
| 28 public: | 27 public: |
| 29 enum OpenTabsMode { | 28 enum OpenTabsMode { |
| 30 OPEN_TABS_ON_LEFT = 1, | 29 OPEN_TABS_ON_LEFT = 1, |
| 31 OPEN_TABS_CLOBBER, | 30 OPEN_TABS_CLOBBER, |
| 32 OPEN_TABS_ON_RIGHT | 31 OPEN_TABS_ON_RIGHT |
| 33 }; | 32 }; |
| 34 | 33 |
| 35 explicit StatusAreaView(Browser* browser); | 34 explicit StatusAreaView(Browser* browser); |
| 36 virtual ~StatusAreaView(); | 35 virtual ~StatusAreaView() {} |
| 37 | 36 |
| 38 void Init(); | 37 void Init(); |
| 39 | 38 |
| 40 // views::View* overrides. | 39 // views::View* overrides. |
| 41 virtual gfx::Size GetPreferredSize(); | 40 virtual gfx::Size GetPreferredSize(); |
| 42 virtual void Layout(); | 41 virtual void Layout(); |
| 43 virtual void Paint(gfx::Canvas* canvas); | 42 virtual void Paint(gfx::Canvas* canvas); |
| 44 | 43 |
| 45 static OpenTabsMode GetOpenTabsMode(); | 44 static OpenTabsMode GetOpenTabsMode(); |
| 46 static void SetOpenTabsMode(OpenTabsMode mode); | 45 static void SetOpenTabsMode(OpenTabsMode mode); |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 void CreateAppMenu(); | 48 void CreateAppMenu(); |
| 50 | 49 |
| 51 // views::SimpleMenuModel::Delegate implementation. | 50 // views::SimpleMenuModel::Delegate implementation. |
| 52 virtual bool IsCommandIdChecked(int command_id) const; | 51 virtual bool IsCommandIdChecked(int command_id) const; |
| 53 virtual bool IsCommandIdEnabled(int command_id) const; | 52 virtual bool IsCommandIdEnabled(int command_id) const; |
| 54 virtual bool GetAcceleratorForCommandId(int command_id, | 53 virtual bool GetAcceleratorForCommandId(int command_id, |
| 55 views::Accelerator* accelerator); | 54 views::Accelerator* accelerator); |
| 56 virtual void ExecuteCommand(int command_id); | 55 virtual void ExecuteCommand(int command_id); |
| 57 | 56 |
| 58 // views::ViewMenuDelegate implementation. | 57 // views::ViewMenuDelegate implementation. |
| 59 virtual void RunMenu(views::View* source, const gfx::Point& pt, | 58 virtual void RunMenu(views::View* source, const gfx::Point& pt, |
| 60 gfx::NativeView hwnd); | 59 gfx::NativeView hwnd); |
| 61 // Called whenever the battery status changes. | |
| 62 void PowerStatusChanged(const chromeos::PowerStatus& status); | |
| 63 | |
| 64 static void LoadCrosLibrary(); | |
| 65 // Called whenever the battery status changes. Dispatches to | |
| 66 // PowerStatusChanged() instance method. | |
| 67 static void PowerStatusChangedHandler( | |
| 68 void* object, const chromeos::PowerStatus& status); | |
| 69 | 60 |
| 70 // The browser window that owns us. | 61 // The browser window that owns us. |
| 71 Browser* browser_; | 62 Browser* browser_; |
| 72 | 63 |
| 64 ClockMenuButton* clock_view_; |
| 73 NetworkMenuButton* network_view_; | 65 NetworkMenuButton* network_view_; |
| 74 views::ImageView* battery_view_; | 66 PowerMenuButton* battery_view_; |
| 75 views::MenuButton* menu_view_; | 67 views::MenuButton* menu_view_; |
| 76 | 68 |
| 77 scoped_ptr<views::SimpleMenuModel> app_menu_contents_; | 69 scoped_ptr<views::SimpleMenuModel> app_menu_contents_; |
| 78 scoped_ptr<views::SimpleMenuModel> options_menu_contents_; | 70 scoped_ptr<views::SimpleMenuModel> options_menu_contents_; |
| 79 scoped_ptr<views::Menu2> app_menu_menu_; | 71 scoped_ptr<views::Menu2> app_menu_menu_; |
| 80 // A reference to the battery power api, to allow callbacks when the | |
| 81 // battery status changes. | |
| 82 chromeos::PowerStatusConnection power_status_connection_; | |
| 83 | 72 |
| 84 static OpenTabsMode open_tabs_mode_; | 73 static OpenTabsMode open_tabs_mode_; |
| 85 // True if the library was loaded. | |
| 86 static bool cros_library_loaded_; | |
| 87 // True if there was an error loading the cros shared object. | |
| 88 static bool cros_library_error_; | |
| 89 | 74 |
| 90 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); | 75 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); |
| 91 }; | 76 }; |
| 92 | 77 |
| 93 #endif // CHROME_BROWSER_CHROMEOS_STATUS_AREA_VIEW_H_ | 78 #endif // CHROME_BROWSER_CHROMEOS_STATUS_AREA_VIEW_H_ |
| OLD | NEW |