OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_H | 5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_H |
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_H | 6 #define ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_H |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "ash/system/chromeos/network/network_icon.h" | 10 #include "ash/system/chromeos/network/network_icon.h" |
11 #include "ash/system/chromeos/network/network_observer.h" | 11 #include "ash/system/chromeos/network/network_observer.h" |
| 12 #include "ash/system/chromeos/network/tray_network_state_observer.h" |
12 #include "ash/system/tray/system_tray_item.h" | 13 #include "ash/system/tray/system_tray_item.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/time.h" | 15 #include "base/time.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 class NetworkState; | 18 class NetworkState; |
18 } | 19 } |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 namespace internal { | 22 namespace internal { |
22 | 23 |
23 class TrayNetworkStateObserver; | 24 class TrayNetworkStateObserver; |
24 | 25 |
25 namespace tray { | 26 namespace tray { |
26 class NetworkDefaultView; | 27 class NetworkDefaultView; |
27 class NetworkDetailedView; | 28 class NetworkDetailedView; |
28 class NetworkMessages; | 29 class NetworkMessages; |
29 class NetworkMessageView; | 30 class NetworkMessageView; |
30 class NetworkNotificationView; | 31 class NetworkNotificationView; |
31 class NetworkTrayView; | 32 class NetworkTrayView; |
32 } | 33 } |
33 | 34 |
34 class TrayNetwork : public SystemTrayItem, | 35 class TrayNetwork : public SystemTrayItem, |
35 public NetworkObserver { | 36 public NetworkObserver, |
| 37 public TrayNetworkStateObserver::Delegate { |
36 public: | 38 public: |
37 explicit TrayNetwork(SystemTray* system_tray); | 39 explicit TrayNetwork(SystemTray* system_tray); |
38 virtual ~TrayNetwork(); | 40 virtual ~TrayNetwork(); |
39 | 41 |
40 tray::NetworkDetailedView* detailed() { return detailed_; } | 42 tray::NetworkDetailedView* detailed() { return detailed_; } |
41 void set_request_wifi_view(bool b) { request_wifi_view_ = b; } | 43 void set_request_wifi_view(bool b) { request_wifi_view_ = b; } |
42 | 44 |
43 // Overridden from SystemTrayItem. | 45 // SystemTrayItem |
44 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; | 46 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; |
45 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; | 47 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; |
46 virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE; | 48 virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE; |
47 virtual views::View* CreateNotificationView( | 49 virtual views::View* CreateNotificationView( |
48 user::LoginStatus status) OVERRIDE; | 50 user::LoginStatus status) OVERRIDE; |
49 virtual void DestroyTrayView() OVERRIDE; | 51 virtual void DestroyTrayView() OVERRIDE; |
50 virtual void DestroyDefaultView() OVERRIDE; | 52 virtual void DestroyDefaultView() OVERRIDE; |
51 virtual void DestroyDetailedView() OVERRIDE; | 53 virtual void DestroyDetailedView() OVERRIDE; |
52 virtual void DestroyNotificationView() OVERRIDE; | 54 virtual void DestroyNotificationView() OVERRIDE; |
53 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; | 55 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; |
54 virtual void UpdateAfterShelfAlignmentChange( | 56 virtual void UpdateAfterShelfAlignmentChange( |
55 ShelfAlignment alignment) OVERRIDE; | 57 ShelfAlignment alignment) OVERRIDE; |
56 | 58 |
57 // Overridden from NetworkObserver. | 59 // NetworkObserver |
58 virtual void OnNetworkRefresh(const NetworkIconInfo& info) OVERRIDE; | 60 virtual void OnNetworkRefresh(const NetworkIconInfo& info) OVERRIDE; |
59 virtual void SetNetworkMessage(NetworkTrayDelegate* delegate, | 61 virtual void SetNetworkMessage(NetworkTrayDelegate* delegate, |
60 MessageType message_type, | 62 MessageType message_type, |
61 NetworkType network_type, | 63 NetworkType network_type, |
62 const string16& title, | 64 const string16& title, |
63 const string16& message, | 65 const string16& message, |
64 const std::vector<string16>& links) OVERRIDE; | 66 const std::vector<string16>& links) OVERRIDE; |
65 virtual void ClearNetworkMessage(MessageType message_type) OVERRIDE; | 67 virtual void ClearNetworkMessage(MessageType message_type) OVERRIDE; |
66 virtual void OnWillToggleWifi() OVERRIDE; | 68 virtual void OnWillToggleWifi() OVERRIDE; |
67 | 69 |
68 // Called when the network for the tray icon may have been updated. | 70 // TrayNetworkStateObserver::Delegate |
69 void TrayNetworkUpdated(); | 71 virtual void NetworkStateChanged(bool list_changed) OVERRIDE; |
70 | 72 virtual void NetworkServiceChanged( |
71 // Called when the properties for |network| may have been updated. | 73 const chromeos::NetworkState* network) OVERRIDE; |
72 void NetworkServiceChanged(const chromeos::NetworkState* network); | |
73 | |
74 // Request a network connection (called from detailed view). | |
75 void ConnectToNetwork(const std::string& service_path); | |
76 | |
77 // Returns true if a user initiated connection to |network| occured. | |
78 bool HasConnectingNetwork(const std::string& service_path); | |
79 | 74 |
80 // Gets the correct icon and label for |icon_type|. | 75 // Gets the correct icon and label for |icon_type|. |
81 void GetNetworkStateHandlerImageAndLabel(network_icon::IconType icon_type, | 76 void GetNetworkStateHandlerImageAndLabel(network_icon::IconType icon_type, |
82 gfx::ImageSkia* image, | 77 gfx::ImageSkia* image, |
83 string16* label); | 78 string16* label); |
84 | 79 |
85 // Updates and returns the appropriate message id if a network technology | |
86 // (i.e. cellular) is uninitialized. | |
87 int GetUninitializedMsg(); | |
88 | |
89 private: | 80 private: |
90 friend class tray::NetworkMessageView; | 81 friend class tray::NetworkMessageView; |
91 friend class tray::NetworkNotificationView; | 82 friend class tray::NetworkNotificationView; |
92 | 83 |
93 void LinkClicked(MessageType message_type, int link_id); | 84 void LinkClicked(MessageType message_type, int link_id); |
94 | 85 |
95 const tray::NetworkMessages* messages() const { return messages_.get(); } | 86 const tray::NetworkMessages* messages() const { return messages_.get(); } |
96 | 87 |
97 tray::NetworkTrayView* tray_; | 88 tray::NetworkTrayView* tray_; |
98 tray::NetworkDefaultView* default_; | 89 tray::NetworkDefaultView* default_; |
99 tray::NetworkDetailedView* detailed_; | 90 tray::NetworkDetailedView* detailed_; |
100 tray::NetworkNotificationView* notification_; | 91 tray::NetworkNotificationView* notification_; |
101 scoped_ptr<tray::NetworkMessages> messages_; | 92 scoped_ptr<tray::NetworkMessages> messages_; |
102 bool request_wifi_view_; | 93 bool request_wifi_view_; |
103 scoped_ptr<TrayNetworkStateObserver> network_state_observer_; | 94 scoped_ptr<TrayNetworkStateObserver> network_state_observer_; |
104 std::set<std::string> connecting_networks_; | |
105 base::Time uninitialized_state_time_; | |
106 int uninitialized_msg_; | |
107 | 95 |
108 DISALLOW_COPY_AND_ASSIGN(TrayNetwork); | 96 DISALLOW_COPY_AND_ASSIGN(TrayNetwork); |
109 }; | 97 }; |
110 | 98 |
111 } // namespace internal | 99 } // namespace internal |
112 } // namespace ash | 100 } // namespace ash |
113 | 101 |
114 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_H | 102 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_H |
OLD | NEW |