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 CHROMEOS_NETWORK_NETWORK_STATE_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chromeos/network/managed_state.h" | 16 #include "chromeos/network/managed_state.h" |
16 #include "components/onc/onc_constants.h" | 17 #include "components/onc/onc_constants.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 class Value; | 22 class Value; |
22 } | 23 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 const std::string& gateway() const { return gateway_; } | 75 const std::string& gateway() const { return gateway_; } |
75 const std::vector<std::string>& dns_servers() const { return dns_servers_; } | 76 const std::vector<std::string>& dns_servers() const { return dns_servers_; } |
76 const GURL& web_proxy_auto_discovery_url() const { | 77 const GURL& web_proxy_auto_discovery_url() const { |
77 return web_proxy_auto_discovery_url_; | 78 return web_proxy_auto_discovery_url_; |
78 } | 79 } |
79 | 80 |
80 // Wireless property accessors | 81 // Wireless property accessors |
81 bool connectable() const { return connectable_; } | 82 bool connectable() const { return connectable_; } |
82 bool is_captive_portal() const { return is_captive_portal_; } | 83 bool is_captive_portal() const { return is_captive_portal_; } |
83 int signal_strength() const { return signal_strength_; } | 84 int signal_strength() const { return signal_strength_; } |
85 // For Wi-Fi, WiMAX, and cellular networks, signal strength is set via updates | |
86 // from Shill, so SetSignalStrength() should not be called in those cases. For | |
Ryan Hansberry
2017/04/18 16:08:55
Do you mean to say "SetTetherSignalStrength" here?
Kyle Horimoto
2017/04/18 17:15:23
Yep, good catch. Done.
| |
87 // tether networks, the signal strength is received as a message from the | |
88 // tether host over Bluetooth, so it must be set via SetSignalStrength() | |
89 // since it does not come from Shill. | |
90 void SetTetherSignalStrength(int signal_strength); | |
84 | 91 |
85 // Wifi property accessors | 92 // Wifi property accessors |
86 const std::string& eap_method() const { return eap_method_; } | 93 const std::string& eap_method() const { return eap_method_; } |
87 const std::vector<uint8_t>& raw_ssid() const { return raw_ssid_; } | 94 const std::vector<uint8_t>& raw_ssid() const { return raw_ssid_; } |
88 | 95 |
89 // Cellular property accessors | 96 // Cellular property accessors |
90 const std::string& network_technology() const { | 97 const std::string& network_technology() const { |
91 return network_technology_; | 98 return network_technology_; |
92 } | 99 } |
93 const std::string& activation_type() const { return activation_type_; } | 100 const std::string& activation_type() const { return activation_type_; } |
94 const std::string& activation_state() const { return activation_state_; } | 101 const std::string& activation_state() const { return activation_state_; } |
95 const std::string& roaming() const { return roaming_; } | 102 const std::string& roaming() const { return roaming_; } |
96 const std::string& payment_url() const { return payment_url_; } | 103 const std::string& payment_url() const { return payment_url_; } |
97 bool cellular_out_of_credits() const { return cellular_out_of_credits_; } | 104 bool cellular_out_of_credits() const { return cellular_out_of_credits_; } |
98 | 105 |
99 // VPN property accessors | 106 // VPN property accessors |
100 const std::string& vpn_provider_type() const { return vpn_provider_type_; } | 107 const std::string& vpn_provider_type() const { return vpn_provider_type_; } |
101 const std::string& third_party_vpn_provider_extension_id() const { | 108 const std::string& third_party_vpn_provider_extension_id() const { |
102 return third_party_vpn_provider_extension_id_; | 109 return third_party_vpn_provider_extension_id_; |
103 } | 110 } |
104 | 111 |
112 // Tether accessors and setters. | |
113 int battery_percentage() const { return battery_percentage_; } | |
114 void SetBatteryPercentage(int battery_percentage); | |
115 const std::string& carrier() const { return carrier_; } | |
116 void SetCarrier(const std::string& carrier); | |
105 const std::string& tether_guid() const { return tether_guid_; } | 117 const std::string& tether_guid() const { return tether_guid_; } |
106 void set_tether_guid(const std::string& guid) { tether_guid_ = guid; } | 118 void set_tether_guid(const std::string& guid) { tether_guid_ = guid; } |
107 | 119 |
108 // Returns true if the network securty is WEP_8021x (Dynamic WEP) | 120 // Returns true if the network securty is WEP_8021x (Dynamic WEP) |
109 bool IsDynamicWep() const; | 121 bool IsDynamicWep() const; |
110 | 122 |
111 // Returns true if |connection_state_| is a connected/connecting state. | 123 // Returns true if |connection_state_| is a connected/connecting state. |
112 bool IsConnectedState() const; | 124 bool IsConnectedState() const; |
113 bool IsConnectingState() const; | 125 bool IsConnectingState() const; |
114 | 126 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 static bool StateIsConnected(const std::string& connection_state); | 158 static bool StateIsConnected(const std::string& connection_state); |
147 static bool StateIsConnecting(const std::string& connection_state); | 159 static bool StateIsConnecting(const std::string& connection_state); |
148 static bool NetworkStateIsCaptivePortal( | 160 static bool NetworkStateIsCaptivePortal( |
149 const base::DictionaryValue& shill_properties); | 161 const base::DictionaryValue& shill_properties); |
150 static bool ErrorIsValid(const std::string& error); | 162 static bool ErrorIsValid(const std::string& error); |
151 | 163 |
152 private: | 164 private: |
153 friend class MobileActivatorTest; | 165 friend class MobileActivatorTest; |
154 friend class NetworkStateHandler; | 166 friend class NetworkStateHandler; |
155 friend class NetworkChangeNotifierChromeosUpdateTest; | 167 friend class NetworkChangeNotifierChromeosUpdateTest; |
168 FRIEND_TEST_ALL_PREFIXES(NetworkStateTest, TetherProperties); | |
156 | 169 |
157 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|. | 170 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|. |
158 // Returns true if |name_| changes. | 171 // Returns true if |name_| changes. |
159 bool UpdateName(const base::DictionaryValue& properties); | 172 bool UpdateName(const base::DictionaryValue& properties); |
160 | 173 |
161 // Set to true if the network is a member of Manager.Services. | 174 // Set to true if the network is a member of Manager.Services. |
162 bool visible_ = false; | 175 bool visible_ = false; |
163 | 176 |
164 // Network Service properties. Avoid adding any additional properties here. | 177 // Network Service properties. Avoid adding any additional properties here. |
165 // Instead use NetworkConfigurationHandler::GetProperties() to asynchronously | 178 // Instead use NetworkConfigurationHandler::GetProperties() to asynchronously |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 std::string activation_state_; | 219 std::string activation_state_; |
207 std::string roaming_; | 220 std::string roaming_; |
208 std::string payment_url_; | 221 std::string payment_url_; |
209 bool cellular_out_of_credits_ = false; | 222 bool cellular_out_of_credits_ = false; |
210 | 223 |
211 // VPN properties, used to construct the display name and to show the correct | 224 // VPN properties, used to construct the display name and to show the correct |
212 // configuration dialog. | 225 // configuration dialog. |
213 std::string vpn_provider_type_; | 226 std::string vpn_provider_type_; |
214 std::string third_party_vpn_provider_extension_id_; | 227 std::string third_party_vpn_provider_extension_id_; |
215 | 228 |
229 // Tether properties. | |
230 std::string carrier_; | |
231 int battery_percentage_; | |
232 | |
216 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler | 233 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler |
217 // provides proxy configuration. crbug.com/241775 | 234 // provides proxy configuration. crbug.com/241775 |
218 base::DictionaryValue proxy_config_; | 235 base::DictionaryValue proxy_config_; |
219 | 236 |
220 DISALLOW_COPY_AND_ASSIGN(NetworkState); | 237 DISALLOW_COPY_AND_ASSIGN(NetworkState); |
221 }; | 238 }; |
222 | 239 |
223 } // namespace chromeos | 240 } // namespace chromeos |
224 | 241 |
225 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ | 242 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ |
OLD | NEW |