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 UI_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ | 5 #ifndef UI_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ |
6 #define UI_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ | 6 #define UI_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // 3. Generates a notification when VPN is disconnected not as a result of | 38 // 3. Generates a notification when VPN is disconnected not as a result of |
39 // user's action. | 39 // user's action. |
40 class UI_CHROMEOS_EXPORT NetworkStateNotifier | 40 class UI_CHROMEOS_EXPORT NetworkStateNotifier |
41 : public chromeos::NetworkConnectionObserver, | 41 : public chromeos::NetworkConnectionObserver, |
42 public chromeos::NetworkStateHandlerObserver { | 42 public chromeos::NetworkStateHandlerObserver { |
43 public: | 43 public: |
44 explicit NetworkStateNotifier(NetworkConnect* network_connect); | 44 explicit NetworkStateNotifier(NetworkConnect* network_connect); |
45 ~NetworkStateNotifier() override; | 45 ~NetworkStateNotifier() override; |
46 | 46 |
47 // NetworkConnectionObserver | 47 // NetworkConnectionObserver |
| 48 void ConnectToNetworkRequested(const std::string& service_path) override; |
| 49 void ConnectSucceeded(const std::string& service_path) override; |
48 void ConnectFailed(const std::string& service_path, | 50 void ConnectFailed(const std::string& service_path, |
49 const std::string& error_name) override; | 51 const std::string& error_name) override; |
50 void DiconnectRequested(const std::string& service_path) override; | 52 void DiconnectRequested(const std::string& service_path) override; |
51 | 53 |
52 // NetworkStateHandlerObserver | 54 // NetworkStateHandlerObserver |
53 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; | 55 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; |
54 void NetworkConnectionStateChanged( | 56 void NetworkConnectionStateChanged( |
55 const chromeos::NetworkState* network) override; | 57 const chromeos::NetworkState* network) override; |
56 void NetworkPropertiesUpdated(const chromeos::NetworkState* network) override; | 58 void NetworkPropertiesUpdated(const chromeos::NetworkState* network) override; |
57 | 59 |
58 // Show a connection error notification. If |error_name| matches an error | 60 // Show a connection error notification. If |error_name| matches an error |
59 // defined in NetworkConnectionHandler for connect, configure, or activation | 61 // defined in NetworkConnectionHandler for connect, configure, or activation |
60 // failed, then the associated message is shown; otherwise use the last_error | 62 // failed, then the associated message is shown; otherwise use the last_error |
61 // value for the network or a Shill property if available. | 63 // value for the network or a Shill property if available. |
62 void ShowNetworkConnectError(const std::string& error_name, | 64 void ShowNetworkConnectError(const std::string& error_name, |
63 const std::string& service_path); | 65 const std::string& service_path); |
64 | 66 |
65 // Show a mobile activation error notification. | 67 // Show a mobile activation error notification. |
66 void ShowMobileActivationError(const std::string& service_path); | 68 void ShowMobileActivationError(const std::string& service_path); |
67 | 69 |
68 // Removes any existing connect notifications. | |
69 void RemoveConnectNotification(); | |
70 | |
71 static const char kNotifierNetwork[]; | 70 static const char kNotifierNetwork[]; |
72 static const char kNotifierNetworkError[]; | 71 static const char kNotifierNetworkError[]; |
73 static const char kNetworkConnectNotificationId[]; | 72 static const char kNetworkConnectNotificationId[]; |
74 static const char kNetworkActivateNotificationId[]; | 73 static const char kNetworkActivateNotificationId[]; |
75 static const char kNetworkOutOfCreditsNotificationId[]; | 74 static const char kNetworkOutOfCreditsNotificationId[]; |
76 | 75 |
77 private: | 76 private: |
78 void ConnectErrorPropertiesSucceeded( | 77 void ConnectErrorPropertiesSucceeded( |
79 const std::string& error_name, | 78 const std::string& error_name, |
80 const std::string& service_path, | 79 const std::string& service_path, |
81 const base::DictionaryValue& shill_properties); | 80 const base::DictionaryValue& shill_properties); |
82 void ConnectErrorPropertiesFailed( | 81 void ConnectErrorPropertiesFailed( |
83 const std::string& error_name, | 82 const std::string& error_name, |
84 const std::string& service_path, | 83 const std::string& service_path, |
85 const std::string& shill_connect_error, | 84 const std::string& shill_connect_error, |
86 scoped_ptr<base::DictionaryValue> shill_error_data); | 85 scoped_ptr<base::DictionaryValue> shill_error_data); |
87 void ShowConnectErrorNotification( | 86 void ShowConnectErrorNotification( |
88 const std::string& error_name, | 87 const std::string& error_name, |
89 const std::string& service_path, | 88 const std::string& service_path, |
90 const base::DictionaryValue& shill_properties); | 89 const base::DictionaryValue& shill_properties); |
91 void ShowVpnDisconnectedNotification(const chromeos::NetworkState* vpn); | 90 void ShowVpnDisconnectedNotification(const chromeos::NetworkState* vpn); |
92 | 91 |
| 92 // Removes any existing connect notifications. |
| 93 void RemoveConnectNotification(); |
| 94 |
93 // Returns true if the default network changed. | 95 // Returns true if the default network changed. |
94 bool UpdateDefaultNetwork(const chromeos::NetworkState* network); | 96 bool UpdateDefaultNetwork(const chromeos::NetworkState* network); |
95 | 97 |
96 // Helper methods to update state and check for notifications. | 98 // Helper methods to update state and check for notifications. |
97 void UpdateVpnConnectionState(const chromeos::NetworkState* vpn); | 99 void UpdateVpnConnectionState(const chromeos::NetworkState* vpn); |
98 void UpdateCellularOutOfCredits(const chromeos::NetworkState* cellular); | 100 void UpdateCellularOutOfCredits(const chromeos::NetworkState* cellular); |
99 void UpdateCellularActivating(const chromeos::NetworkState* cellular); | 101 void UpdateCellularActivating(const chromeos::NetworkState* cellular); |
100 | 102 |
101 // Invokes network_connect_->ShowNetworkSettingsForPath from a callback. | 103 // Invokes network_connect_->ShowNetworkSettingsForPath from a callback. |
102 void ShowNetworkSettingsForPath(const std::string& service_path); | 104 void ShowNetworkSettingsForPath(const std::string& service_path); |
103 | 105 |
104 NetworkConnect* network_connect_; // unowned | 106 NetworkConnect* network_connect_; // unowned |
105 std::string last_default_network_; | 107 std::string last_default_network_; |
106 bool did_show_out_of_credits_; | 108 bool did_show_out_of_credits_; |
107 base::Time out_of_credits_notify_time_; | 109 base::Time out_of_credits_notify_time_; |
108 std::set<std::string> cellular_activating_; | 110 std::set<std::string> cellular_activating_; |
109 bool need_vpn_disconnection_notify_; | 111 bool need_vpn_disconnection_notify_; |
110 base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_; | 112 base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_; |
111 | 113 |
112 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); | 114 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); |
113 }; | 115 }; |
114 | 116 |
115 } // namespace ui | 117 } // namespace ui |
116 | 118 |
117 #endif // UI_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ | 119 #endif // UI_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ |
OLD | NEW |