diff options
author | chocobo@google.com <chocobo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 01:33:21 +0000 |
---|---|---|
committer | chocobo@google.com <chocobo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 01:33:21 +0000 |
commit | 7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01 (patch) | |
tree | 045a49a9bd5eb156517d391ff44d46a20f947a91 /chrome/browser/chromeos/network_menu_button.h | |
parent | 13555c122fbc9ec2a6c1a4cbace288ec7892be6e (diff) | |
download | chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.zip chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.tar.gz chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.tar.bz2 |
Refactor cros library code into central location and have the UI elements observe changes.
- implemented power menu button showing remaining battery info.
- implemented clock menu button showing detailed clock info.
- also implemented monitoring of network status change.
- don't show highlighted state for these menu buttons
BUG=23923
TEST=none
Review URL: http://codereview.chromium.org/251099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/network_menu_button.h')
-rw-r--r-- | chrome/browser/chromeos/network_menu_button.h | 78 |
1 files changed, 11 insertions, 67 deletions
diff --git a/chrome/browser/chromeos/network_menu_button.h b/chrome/browser/chromeos/network_menu_button.h index 6b0a0ef..6f6fe38 100644 --- a/chrome/browser/chromeos/network_menu_button.h +++ b/chrome/browser/chromeos/network_menu_button.h @@ -6,38 +6,16 @@ #define CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_ #include <string> -#include <vector> #include "base/timer.h" +#include "chrome/browser/chromeos/cros_network_library.h" #include "chrome/browser/chromeos/password_dialog_view.h" -#include "third_party/cros/chromeos_network.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "views/controls/button/menu_button.h" #include "views/controls/menu/menu_2.h" #include "views/controls/menu/view_menu_delegate.h" class Browser; - -struct WifiNetwork { - WifiNetwork() : encrypted(false), strength(0) { } - WifiNetwork(const std::string& ssid, bool encrypted, - chromeos::EncryptionType encryption, int strength) - : ssid(ssid), - encrypted(encrypted), - encryption(encryption), - strength(strength) { } - - // WifiNetworks are sorted by ssids. - bool operator< (const WifiNetwork& other) const { - return ssid < other.ssid; - } - - std::string ssid; - bool encrypted; - chromeos::EncryptionType encryption; - int strength; -}; -typedef std::vector<WifiNetwork> WifiNetworkVector; +class SkBitmap; // The network menu button in the status area. // This class will handle getting the wifi networks and populating the menu. @@ -46,10 +24,11 @@ typedef std::vector<WifiNetwork> WifiNetworkVector; class NetworkMenuButton : public views::MenuButton, public views::ViewMenuDelegate, public views::Menu2Model, - public PasswordDialogDelegate { + public PasswordDialogDelegate, + public CrosNetworkLibrary::Observer { public: - NetworkMenuButton(Browser* browser, bool cros_library_loaded); - virtual ~NetworkMenuButton() {} + explicit NetworkMenuButton(Browser* browser); + virtual ~NetworkMenuButton(); // views::Menu2Model implementation. virtual bool HasIcons() const { return false; } @@ -74,28 +53,14 @@ class NetworkMenuButton : public views::MenuButton, virtual bool OnPasswordDialogAccept(const std::string& ssid, const string16& password); + // CrosNetworkLibrary::Observer implementation. + virtual void NetworkChanged(CrosNetworkLibrary* obj); + private: // views::ViewMenuDelegate implementation. virtual void RunMenu(views::View* source, const gfx::Point& pt, gfx::NativeView hwnd); - // Gets the WifiNetwork for the given ssid in the list of wifi networks. - // Returns whether or not WifiNetwork was found. - bool GetWifiNetwork(const WifiNetworkVector& networks, - const std::string& ssid, - WifiNetwork* network); - - // Helper method to add a wifi network to the model. - void AddWifiNetwork(const std::string& ssid, bool encrypted, - chromeos::EncryptionType encryption, int strength); - - // Refreshes the networks model using real data. - void RefreshNetworks(); - - // Connect to the specified wireless network with password. - // Returns whether or not connection was successful. - bool ConnectToWifiNetwork(const std::string& ssid, const string16& password); - // Start animating the icon to show that we are connecting to a network. void StartConnectingAnimation(); @@ -105,38 +70,17 @@ class NetworkMenuButton : public views::MenuButton, // Update the icon to either the connecting, connected, or disconnected icon. void UpdateIcon(); - // Whether or not the cros shared library loaded successfully or not. - bool cros_library_loaded_; - // Set to true if we are currently refreshing the menu. bool refreshing_menu_; // The number of wifi strength images. static const int kNumWifiImages; - // Wifi strength images. - static SkBitmap* wifi_images_[]; - - // Wired image. - static SkBitmap* wired_image_; - - // Disconnected image. - static SkBitmap* disconnected_image_; - - // Whether or not ethernet is connected. - bool ethernet_connected_; - - // The currently connected wifi network ssid. - std::string current_ssid_; - - // The wifi netowrk ssid we are attempting to connect to. - std::string connecting_ssid_; - // A list of wifi networks. WifiNetworkVector wifi_networks_; - // A list of wifi networks that we are currently showing in the menu. - WifiNetworkVector wifi_networks_in_menu_; + // The activated wifi network. + WifiNetwork activated_wifi_network_; // The network menu. views::Menu2 network_menu_; |