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

Side by Side Diff: chrome/browser/chromeos/network_menu_button.h

Issue 231014: Add wifi menu button in status bar. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/chromeos/network_menu_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_
6 #define CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_
7
8 #include <vector>
9
10 #include "chrome/browser/chromeos/password_dialog_view.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "views/controls/button/menu_button.h"
13 #include "views/controls/menu/menu_2.h"
14 #include "views/controls/menu/view_menu_delegate.h"
15
16 class Browser;
17
18 // The network menu button in the status area.
19 // This class will handle getting the wifi networks and populating the menu.
20 // It will also handle the status icon changing and connecting to another
21 // wifi network.
22 class NetworkMenuButton : public views::MenuButton,
23 public views::ViewMenuDelegate,
24 public views::Menu2Model,
25 public PasswordDialogDelegate {
26 public:
27 struct WifiNetwork {
28 WifiNetwork() { }
29 WifiNetwork(const string16& ssid, const string16& encryption, int strength)
30 : ssid(ssid),
31 encryption(encryption),
32 strength(strength) { }
33
34 string16 ssid;
35 string16 encryption;
36 int strength;
37 };
38
39 explicit NetworkMenuButton(Browser* browser);
40 virtual ~NetworkMenuButton() {}
41
42 // views::Menu2Model implementation.
43 virtual bool HasIcons() const { return false; }
44 virtual int GetItemCount() const;
45 virtual views::Menu2Model::ItemType GetTypeAt(int index) const;
46 virtual int GetCommandIdAt(int index) const;
47 virtual string16 GetLabelAt(int index) const;
48 virtual bool IsLabelDynamicAt(int index) const { return true; }
49 virtual bool GetAcceleratorAt(int index,
50 views::Accelerator* accelerator) const { return false; }
51 virtual bool IsItemCheckedAt(int index) const;
52 virtual int GetGroupIdAt(int index) const { return 0; }
53 virtual bool GetIconAt(int index, SkBitmap* icon) const { return false; }
54 virtual bool IsEnabledAt(int index) const;
55 virtual Menu2Model* GetSubmenuModelAt(int index) const { return NULL; }
56 virtual void HighlightChangedTo(int index) {}
57 virtual void ActivatedAt(int index);
58 virtual void MenuWillShow() {}
59
60 // PasswordDialogDelegate implementation.
61 virtual bool OnPasswordDialogCancel();
62 virtual bool OnPasswordDialogAccept(const string16& password);
63
64 private:
65 // views::ViewMenuDelegate implementation.
66 virtual void RunMenu(views::View* source, const gfx::Point& pt,
67 gfx::NativeView hwnd);
68
69 // Helper method to add a wifi network to the model.
70 void AddWifiNetwork(const string16& ssid, const string16& encryption,
71 int strength);
72
73 // Refreshes the wifi networks model using real data.
74 void RefreshWifiNetworks();
75
76 // Connect to the specified wireless network with password.
77 // Returns whether or not connection was successful.
78 bool ConnectToWifiNetwork(const string16& ssid, const string16& password);
79
80 // Gets the wifi image for specified wifi network.
81 SkBitmap GetWifiImage(WifiNetwork wifi_network) const;
82
83 // Set to true if we are currently refreshing the menu.
84 bool refreshing_menu_;
85
86 // The number of wifi strength images.
87 static const int kNumWifiImages;
88
89 // Wifi strength images.
90 static SkBitmap* wifi_images_[];
91
92 // Wired image.
93 static SkBitmap* wired_image_;
94
95 // Disconnected image.
96 static SkBitmap* disconnected_image_;
97
98 // The currently connected wifi network ssid.
99 string16 current_ssid_;
100
101 // The wifi netowrk ssid we are attempting to connect to.
102 string16 connecting_ssid_;
103
104 // A list of wifi networks.
105 std::vector<WifiNetwork> wifi_networks_;
106
107 // The network menu.
108 views::Menu2 network_menu_;
109
110 // The browser window that owns us.
111 Browser* browser_;
112
113 DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton);
114 };
115
116 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/chromeos/network_menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698