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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | |
12 #include "chrome/browser/chromeos/options/network_config_view.h" | 13 #include "chrome/browser/chromeos/options/network_config_view.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
14 #include "ui/base/models/simple_menu_model.h" | 15 #include "ui/base/models/menu_model.h" |
15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "views/controls/button/menu_button.h" | |
18 #include "views/controls/menu/menu_delegate.h" | |
16 #include "views/controls/menu/view_menu_delegate.h" | 19 #include "views/controls/menu/view_menu_delegate.h" |
17 | 20 |
18 namespace gfx { | 21 namespace gfx { |
19 class Canvas; | 22 class Canvas; |
20 } | 23 } |
21 | 24 |
22 namespace views { | |
23 class Menu2; | |
24 } | |
25 | |
26 namespace chromeos { | 25 namespace chromeos { |
27 | 26 |
28 // Menu for network menu button in the status area/welcome screen. | 27 // Menu for network menu button in the status area/welcome screen. |
29 // This class will populating the menu with the list of networks. | 28 // This class will populating the menu with the list of networks. |
30 // It will also handle connecting to another wifi/cellular network. | 29 // It will also handle connecting to another wifi/cellular network. |
31 // | 30 // |
32 // The network menu looks like this: | 31 // The network menu looks like this: |
33 // | 32 // |
34 // <icon> Ethernet | 33 // <icon> Ethernet |
35 // <icon> Wifi Network A | 34 // <icon> Wifi Network A |
36 // <icon> Wifi Network B | 35 // <icon> Wifi Network B |
37 // <icon> Wifi Network C | 36 // <icon> Wifi Network C |
38 // <icon> Cellular Network A | 37 // <icon> Cellular Network A |
39 // <icon> Cellular Network B | 38 // <icon> Cellular Network B |
40 // <icon> Cellular Network C | 39 // <icon> Cellular Network C |
41 // <icon> Other... | 40 // <icon> Other... |
42 // -------------------------------- | 41 // -------------------------------- |
43 // Disable Wifi | 42 // Disable Wifi |
44 // Disable Celluar | 43 // Disable Celluar |
45 // -------------------------------- | 44 // -------------------------------- |
46 // <IP Address> | 45 // <IP Address> |
47 // Network settings... | 46 // Network settings... |
48 // | 47 // |
49 // <icon> will show the strength of the wifi/cellular networks. | 48 // <icon> will show the strength of the wifi/cellular networks. |
50 // The label will be BOLD if the network is currently connected. | 49 // The label will be BOLD if the network is currently connected. |
51 class NetworkMenu : public views::ViewMenuDelegate, | 50 class NetworkMenu : public views::MenuDelegate, |
52 public ui::MenuModel { | 51 public views::ViewMenuDelegate { |
53 public: | 52 public: |
54 struct NetworkInfo { | 53 struct NetworkInfo { |
55 NetworkInfo() : | 54 NetworkInfo() : |
56 need_passphrase(false), remembered(true), auto_connect(true) {} | 55 need_passphrase(false), remembered(true), auto_connect(true) {} |
57 // "ethernet" | "wifi" | "cellular" | "other". | 56 // "ethernet" | "wifi" | "cellular" | "other". |
58 std::string network_type; | 57 std::string network_type; |
59 // "connected" | "connecting" | "disconnected" | "error". | 58 // "connected" | "connecting" | "disconnected" | "error". |
60 std::string status; | 59 std::string status; |
61 // status message or error message, empty if unknown status. | 60 // status message or error message, empty if unknown status. |
62 std::string message; | 61 std::string message; |
(...skipping 13 matching lines...) Expand all Loading... | |
76 virtual ~NetworkMenu(); | 75 virtual ~NetworkMenu(); |
77 | 76 |
78 // Connect or reconnect to the network at |index|. | 77 // Connect or reconnect to the network at |index|. |
79 // If remember >= 0, set the favorite state of the network. | 78 // If remember >= 0, set the favorite state of the network. |
80 // Returns true if a connect occurred (e.g. menu should be closed). | 79 // Returns true if a connect occurred (e.g. menu should be closed). |
81 bool ConnectToNetworkAt(int index, | 80 bool ConnectToNetworkAt(int index, |
82 const std::string& passphrase, | 81 const std::string& passphrase, |
83 const std::string& ssid, | 82 const std::string& ssid, |
84 int remember) const; | 83 int remember) const; |
85 | 84 |
86 // ui::MenuModel implementation. | 85 // views::MenuDelegate implementation |
87 virtual bool HasIcons() const { return true; } | 86 virtual std::wstring GetLabel(int id) const OVERRIDE; |
88 virtual int GetItemCount() const; | 87 virtual const gfx::Font* GetLabelFont(int id) const OVERRIDE; |
89 virtual ui::MenuModel::ItemType GetTypeAt(int index) const; | 88 virtual bool IsItemChecked(int id) const OVERRIDE; |
90 virtual int GetCommandIdAt(int index) const { return index; } | 89 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
91 virtual string16 GetLabelAt(int index) const; | 90 virtual void ExecuteCommand(int id) OVERRIDE; |
92 virtual bool IsItemDynamicAt(int index) const { return true; } | |
93 virtual const gfx::Font* GetLabelFontAt(int index) const; | |
94 virtual bool GetAcceleratorAt(int index, | |
95 ui::Accelerator* accelerator) const { return false; } | |
96 virtual bool IsItemCheckedAt(int index) const; | |
97 virtual int GetGroupIdAt(int index) const { return 0; } | |
98 virtual bool GetIconAt(int index, SkBitmap* icon); | |
99 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const { | |
100 return NULL; | |
101 } | |
102 virtual bool IsEnabledAt(int index) const; | |
103 virtual ui::MenuModel* GetSubmenuModelAt(int index) const { return NULL; } | |
104 virtual void HighlightChangedTo(int index) {} | |
105 virtual void ActivatedAt(int index); | |
106 virtual void MenuWillShow() {} | |
107 virtual void SetMenuModelDelegate(ui::MenuModelDelegate* delegate) {} | |
108 | 91 |
109 void SetFirstLevelMenuWidth(int width); | 92 void SetFirstLevelMenuWidth(int width); |
110 | 93 |
111 // Cancels the active menu. | 94 // Cancels the active menu. |
112 void CancelMenu(); | 95 void CancelMenu(); |
113 | 96 |
114 // The following methods returns pointer to a shared instance of the SkBitmap. | 97 // The following methods returns pointer to a shared instance of the SkBitmap. |
115 // This shared bitmap is owned by the resource bundle and should not be freed. | 98 // This shared bitmap is owned by the resource bundle and should not be freed. |
116 | 99 |
117 // Returns the Icon for a network strength for a WifiNetwork |wifi|. | 100 // Returns the Icon for a network strength for a WifiNetwork |wifi|. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 // This method will convert the |icon| bitmap to the correct size for display. | 133 // This method will convert the |icon| bitmap to the correct size for display. |
151 // |icon| must be non-NULL. | 134 // |icon| must be non-NULL. |
152 // If one of the |bottom_right_badge| or |top_left_badge| icons are not NULL, | 135 // If one of the |bottom_right_badge| or |top_left_badge| icons are not NULL, |
153 // they will be drawn on top of the icon. | 136 // they will be drawn on top of the icon. |
154 static SkBitmap IconForDisplay(const SkBitmap* icon, | 137 static SkBitmap IconForDisplay(const SkBitmap* icon, |
155 const SkBitmap* bottom_right_badge, | 138 const SkBitmap* bottom_right_badge, |
156 const SkBitmap* top_left_badge); | 139 const SkBitmap* top_left_badge); |
157 | 140 |
158 protected: | 141 protected: |
159 virtual bool IsBrowserMode() const = 0; | 142 virtual bool IsBrowserMode() const = 0; |
143 virtual views::MenuButton* GetMenuButton() = 0; | |
oshima
2011/04/15 17:40:12
where are we using this?
rhashimoto
2011/04/15 21:20:27
NetworkMenu is a superclass for NetworkMenuButton
| |
160 virtual gfx::NativeWindow GetNativeWindow() const = 0; | 144 virtual gfx::NativeWindow GetNativeWindow() const = 0; |
161 virtual void OpenButtonOptions() = 0; | 145 virtual void OpenButtonOptions() = 0; |
162 virtual bool ShouldOpenButtonOptions() const = 0; | 146 virtual bool ShouldOpenButtonOptions() const = 0; |
163 | 147 |
164 // Notify subclasses that connection to |network| was initiated. | 148 // Notify subclasses that connection to |network| was initiated. |
165 virtual void OnConnectNetwork(const Network* network, | 149 virtual void OnConnectNetwork(const Network* network, |
166 SkBitmap selected_icon_) {} | 150 SkBitmap selected_icon_) {} |
167 // Update the menu (e.g. when the network list or status has changed). | 151 // Update the menu (e.g. when the network list or status has changed). |
168 void UpdateMenu(); | 152 void UpdateMenu(); |
169 | 153 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 // The number of animating images for network connecting. | 220 // The number of animating images for network connecting. |
237 static const int kNumAnimatingImages; | 221 static const int kNumAnimatingImages; |
238 // Animation images. These are created lazily. | 222 // Animation images. These are created lazily. |
239 static SkBitmap kAnimatingImages[]; | 223 static SkBitmap kAnimatingImages[]; |
240 static SkBitmap kAnimatingImagesBlack[]; | 224 static SkBitmap kAnimatingImagesBlack[]; |
241 | 225 |
242 // Our menu items. | 226 // Our menu items. |
243 MenuItemVector menu_items_; | 227 MenuItemVector menu_items_; |
244 | 228 |
245 // The network menu. | 229 // The network menu. |
246 scoped_ptr<views::Menu2> network_menu_; | 230 scoped_ptr<views::MenuItemView> network_menu_; |
247 | 231 |
248 // Holds minimum width or -1 if it wasn't set up. | 232 // Holds minimum width or -1 if it wasn't set up. |
249 int min_width_; | 233 int min_width_; |
250 | 234 |
251 // If true, call into the settings UI for network configuration dialogs. | 235 // If true, call into the settings UI for network configuration dialogs. |
252 bool use_settings_ui_; | 236 bool use_settings_ui_; |
253 | 237 |
254 DISALLOW_COPY_AND_ASSIGN(NetworkMenu); | 238 DISALLOW_COPY_AND_ASSIGN(NetworkMenu); |
255 }; | 239 }; |
256 | 240 |
257 } // namespace chromeos | 241 } // namespace chromeos |
258 | 242 |
259 #endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ | 243 #endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ |
OLD | NEW |