| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/menus/menu_model.h" |
| 12 #include "chrome/browser/chromeos/options/network_config_view.h" | 13 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 13 #include "gfx/native_widget_types.h" | 14 #include "gfx/native_widget_types.h" |
| 14 #include "views/controls/menu/menu_2.h" | |
| 15 #include "views/controls/menu/view_menu_delegate.h" | 15 #include "views/controls/menu/view_menu_delegate.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 class Canvas; | 19 class Canvas; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace views { |
| 23 class Menu2; |
| 24 } |
| 25 |
| 22 namespace chromeos { | 26 namespace chromeos { |
| 23 | 27 |
| 24 // Menu for network menu button in the status area/welcome screen. | 28 // Menu for network menu button in the status area/welcome screen. |
| 25 // This class will populating the menu with the list of networks. | 29 // This class will populating the menu with the list of networks. |
| 26 // It will also handle connecting to another wifi/cellular network. | 30 // It will also handle connecting to another wifi/cellular network. |
| 27 // | 31 // |
| 28 // The network menu looks like this: | 32 // The network menu looks like this: |
| 29 // | 33 // |
| 30 // <icon> Ethernet | 34 // <icon> Ethernet |
| 31 // <icon> Wifi Network A | 35 // <icon> Wifi Network A |
| 32 // <icon> Wifi Network B | 36 // <icon> Wifi Network B |
| 33 // <icon> Wifi Network C | 37 // <icon> Wifi Network C |
| 34 // <icon> Cellular Network A | 38 // <icon> Cellular Network A |
| 35 // <icon> Cellular Network B | 39 // <icon> Cellular Network B |
| 36 // <icon> Cellular Network C | 40 // <icon> Cellular Network C |
| 37 // <icon> Other... | 41 // <icon> Other... |
| 38 // -------------------------------- | 42 // -------------------------------- |
| 39 // Disable Wifi | 43 // Disable Wifi |
| 40 // Disable Celluar | 44 // Disable Celluar |
| 41 // -------------------------------- | 45 // -------------------------------- |
| 42 // <IP Address> | 46 // <IP Address> |
| 43 // Network settings... | 47 // Network settings... |
| 44 // | 48 // |
| 45 // <icon> will show the strength of the wifi/cellular networks. | 49 // <icon> will show the strength of the wifi/cellular networks. |
| 46 // The label will be BOLD if the network is currently connected. | 50 // The label will be BOLD if the network is currently connected. |
| 47 class NetworkMenu : public views::ViewMenuDelegate, | 51 class NetworkMenu : public views::ViewMenuDelegate, |
| 48 public menus::MenuModel { | 52 public menus::MenuModel { |
| 49 public: | 53 public: |
| 54 struct NetworkInfo { |
| 55 NetworkInfo() : need_passphrase(false), remembered(true) {} |
| 56 // "ethernet" | "wifi" | "cellular" | "other". |
| 57 std::string network_type; |
| 58 // "connected" | "connecting" | "disconnected" | "error". |
| 59 std::string status; |
| 60 // status message or error message, empty if unknown status. |
| 61 std::string message; |
| 62 // IP address (if network is active, empty otherwise) |
| 63 std::string ip_address; |
| 64 // true if the network requires a passphrase. |
| 65 bool need_passphrase; |
| 66 // true if the network is currently remembered. |
| 67 bool remembered; |
| 68 }; |
| 69 |
| 50 NetworkMenu(); | 70 NetworkMenu(); |
| 51 virtual ~NetworkMenu(); | 71 virtual ~NetworkMenu(); |
| 52 | 72 |
| 73 // Retrieves network info for the DOMUI NetworkMenu (NetworkMenuUI). |
| 74 // |index| is the index in menu_items_, set when the menu is built. |
| 75 bool GetNetworkAt(int index, NetworkInfo* info) const; |
| 76 |
| 53 // menus::MenuModel implementation. | 77 // menus::MenuModel implementation. |
| 54 virtual bool HasIcons() const { return true; } | 78 virtual bool HasIcons() const { return true; } |
| 55 virtual int GetItemCount() const; | 79 virtual int GetItemCount() const; |
| 56 virtual menus::MenuModel::ItemType GetTypeAt(int index) const; | 80 virtual menus::MenuModel::ItemType GetTypeAt(int index) const; |
| 57 virtual int GetCommandIdAt(int index) const { return index; } | 81 virtual int GetCommandIdAt(int index) const { return index; } |
| 58 virtual string16 GetLabelAt(int index) const; | 82 virtual string16 GetLabelAt(int index) const; |
| 59 virtual bool IsLabelDynamicAt(int index) const { return true; } | 83 virtual bool IsLabelDynamicAt(int index) const { return true; } |
| 60 virtual const gfx::Font* GetLabelFontAt(int index) const; | 84 virtual const gfx::Font* GetLabelFontAt(int index) const; |
| 61 virtual bool GetAcceleratorAt(int index, | 85 virtual bool GetAcceleratorAt(int index, |
| 62 menus::Accelerator* accelerator) const { return false; } | 86 menus::Accelerator* accelerator) const { return false; } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Set to true if we are currently refreshing the menu. | 167 // Set to true if we are currently refreshing the menu. |
| 144 bool refreshing_menu_; | 168 bool refreshing_menu_; |
| 145 | 169 |
| 146 // The number of wifi strength images. | 170 // The number of wifi strength images. |
| 147 static const int kNumWifiImages; | 171 static const int kNumWifiImages; |
| 148 | 172 |
| 149 // Our menu items. | 173 // Our menu items. |
| 150 MenuItemVector menu_items_; | 174 MenuItemVector menu_items_; |
| 151 | 175 |
| 152 // The network menu. | 176 // The network menu. |
| 153 views::Menu2 network_menu_; | 177 scoped_ptr<views::Menu2> network_menu_; |
| 154 | 178 |
| 155 // Holds minimum width or -1 if it wasn't set up. | 179 // Holds minimum width or -1 if it wasn't set up. |
| 156 int min_width_; | 180 int min_width_; |
| 157 | 181 |
| 158 DISALLOW_COPY_AND_ASSIGN(NetworkMenu); | 182 DISALLOW_COPY_AND_ASSIGN(NetworkMenu); |
| 159 }; | 183 }; |
| 160 | 184 |
| 161 } // namespace chromeos | 185 } // namespace chromeos |
| 162 | 186 |
| 163 #endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ | 187 #endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ |
| OLD | NEW |