OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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_NETWORK_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "app/throb_animation.h" | 10 #include "app/throb_animation.h" |
11 #include "base/timer.h" | 11 #include "base/timer.h" |
12 #include "chrome/browser/chromeos/cros_network_library.h" | 12 #include "chrome/browser/chromeos/cros_network_library.h" |
13 #include "chrome/browser/chromeos/password_dialog_view.h" | 13 #include "chrome/browser/chromeos/password_dialog_view.h" |
14 #include "chrome/browser/chromeos/status_area_button.h" | 14 #include "chrome/browser/chromeos/status_area_button.h" |
15 #include "views/controls/menu/menu_2.h" | 15 #include "views/controls/menu/menu_2.h" |
16 #include "views/controls/menu/view_menu_delegate.h" | 16 #include "views/controls/menu/view_menu_delegate.h" |
17 | 17 |
18 class Browser; | 18 class Browser; |
19 class SkBitmap; | 19 class SkBitmap; |
20 | 20 |
| 21 namespace gfx { |
| 22 class Canvas; |
| 23 } |
| 24 |
21 // The network menu button in the status area. | 25 // The network menu button in the status area. |
22 // This class will handle getting the wifi networks and populating the menu. | 26 // This class will handle getting the wifi networks and populating the menu. |
23 // It will also handle the status icon changing and connecting to another | 27 // It will also handle the status icon changing and connecting to another |
24 // wifi network. | 28 // wifi network. |
25 class NetworkMenuButton : public StatusAreaButton, | 29 class NetworkMenuButton : public StatusAreaButton, |
26 public views::ViewMenuDelegate, | 30 public views::ViewMenuDelegate, |
27 public views::Menu2Model, | 31 public views::Menu2Model, |
28 public PasswordDialogDelegate, | 32 public PasswordDialogDelegate, |
29 public CrosNetworkLibrary::Observer { | 33 public CrosNetworkLibrary::Observer { |
30 public: | 34 public: |
(...skipping 21 matching lines...) Expand all Loading... |
52 // PasswordDialogDelegate implementation. | 56 // PasswordDialogDelegate implementation. |
53 virtual bool OnPasswordDialogCancel() { return true; } | 57 virtual bool OnPasswordDialogCancel() { return true; } |
54 virtual bool OnPasswordDialogAccept(const std::string& ssid, | 58 virtual bool OnPasswordDialogAccept(const std::string& ssid, |
55 const string16& password); | 59 const string16& password); |
56 | 60 |
57 // AnimationDelegate implementation. | 61 // AnimationDelegate implementation. |
58 virtual void AnimationProgressed(const Animation* animation); | 62 virtual void AnimationProgressed(const Animation* animation); |
59 | 63 |
60 // CrosNetworkLibrary::Observer implementation. | 64 // CrosNetworkLibrary::Observer implementation. |
61 virtual void NetworkChanged(CrosNetworkLibrary* obj); | 65 virtual void NetworkChanged(CrosNetworkLibrary* obj); |
| 66 virtual void NetworkTraffic(CrosNetworkLibrary* cros, |
| 67 int traffic_type); |
| 68 |
| 69 protected: |
| 70 // StatusAreaButton implementation. |
| 71 virtual void DrawIcon(gfx::Canvas* canvas); |
62 | 72 |
63 private: | 73 private: |
64 // views::ViewMenuDelegate implementation. | 74 // views::ViewMenuDelegate implementation. |
65 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 75 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
66 | 76 |
67 // Update the icon to either the connecting, connected, or disconnected icon. | |
68 void UpdateIcon(); | |
69 | |
70 // Set to true if we are currently refreshing the menu. | 77 // Set to true if we are currently refreshing the menu. |
71 bool refreshing_menu_; | 78 bool refreshing_menu_; |
72 | 79 |
73 // The number of wifi strength images. | 80 // The number of wifi strength images. |
74 static const int kNumWifiImages; | 81 static const int kNumWifiImages; |
75 | 82 |
| 83 // The minimum opacity of the wifi bars. |
| 84 static const int kMinOpacity; |
| 85 |
| 86 // The maximum opacity of the wifi bars. |
| 87 static const int kMaxOpacity; |
| 88 |
76 // A list of wifi networks. | 89 // A list of wifi networks. |
77 WifiNetworkVector wifi_networks_; | 90 WifiNetworkVector wifi_networks_; |
78 | 91 |
79 // The activated wifi network. | 92 // The activated wifi network. |
80 WifiNetwork activated_wifi_network_; | 93 WifiNetwork activated_wifi_network_; |
81 | 94 |
82 // The network menu. | 95 // The network menu. |
83 views::Menu2 network_menu_; | 96 views::Menu2 network_menu_; |
84 | 97 |
85 // Our parent window | 98 // Our parent window |
86 gfx::NativeWindow browser_window_; | 99 gfx::NativeWindow browser_window_; |
87 | 100 |
88 // The throb animation that does the wifi connecting animation. | 101 // The throb animation that does the wifi connecting animation. |
89 ThrobAnimation animation_; | 102 ThrobAnimation animation_connecting_; |
90 | 103 |
91 // The duration of the wifi connecting icon throbbing in milliseconds. | 104 // The throb animation that does the downloading animation. |
| 105 ThrobAnimation animation_downloading_; |
| 106 |
| 107 // The throb animation that does the uploading animation. |
| 108 ThrobAnimation animation_uploading_; |
| 109 |
| 110 // The duration of the icon throbbing in milliseconds. |
92 static const int kThrobDuration; | 111 static const int kThrobDuration; |
93 | 112 |
94 DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton); | 113 DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton); |
95 }; | 114 }; |
96 | 115 |
97 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_ | 116 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_MENU_BUTTON_H_ |
OLD | NEW |