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

Side by Side Diff: chromeos/network/network_state.h

Issue 2819383002: [CrOS Tether] Update NetworkState to include tether properties and integrate into NetworkStateHandl… (Closed)
Patch Set: Update TODOs. Created 3 years, 8 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
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // so cache them to avoid excessively complex client code. 73 // so cache them to avoid excessively complex client code.
73 const std::string& ip_address() const { return ip_address_; } 74 const std::string& ip_address() const { return ip_address_; }
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_; }
83 // For Shill nletwork types, the connectable property is set via an update
stevenjb 2017/04/19 17:34:17 network
Kyle Horimoto 2017/04/19 19:23:29 Done.
84 // from Shill, so SetTetherNetworkConnectable() should not be called in those
85 // cases. For tether networks, the network is connectable by default, so this
86 // function should be called when the network is created.
87 void SetTetherNetworkConnectable();
stevenjb 2017/04/19 17:34:17 Generally keep complex methods separate from trivi
Kyle Horimoto 2017/04/19 19:23:29 Done.
82 bool is_captive_portal() const { return is_captive_portal_; } 88 bool is_captive_portal() const { return is_captive_portal_; }
83 int signal_strength() const { return signal_strength_; } 89 int signal_strength() const { return signal_strength_; }
90 // For Wi-Fi, WiMAX, and cellular networks, signal strength is set via updates
91 // from Shill, so SetTetherSignalStrength() should not be called in those
92 // cases. For tether networks, the signal strength is received as a message
93 // from the tether host over Bluetooth, so it must be set via
94 // SetTetherSignalStrength() since it does not come from Shill.
95 void SetTetherSignalStrength(int signal_strength);
stevenjb 2017/04/19 17:34:17 ditto
Kyle Horimoto 2017/04/19 19:23:29 Done.
84 96
85 // Wifi property accessors 97 // Wifi property accessors
86 const std::string& eap_method() const { return eap_method_; } 98 const std::string& eap_method() const { return eap_method_; }
87 const std::vector<uint8_t>& raw_ssid() const { return raw_ssid_; } 99 const std::vector<uint8_t>& raw_ssid() const { return raw_ssid_; }
88 100
89 // Cellular property accessors 101 // Cellular property accessors
90 const std::string& network_technology() const { 102 const std::string& network_technology() const {
91 return network_technology_; 103 return network_technology_;
92 } 104 }
93 const std::string& activation_type() const { return activation_type_; } 105 const std::string& activation_type() const { return activation_type_; }
94 const std::string& activation_state() const { return activation_state_; } 106 const std::string& activation_state() const { return activation_state_; }
95 const std::string& roaming() const { return roaming_; } 107 const std::string& roaming() const { return roaming_; }
96 const std::string& payment_url() const { return payment_url_; } 108 const std::string& payment_url() const { return payment_url_; }
97 bool cellular_out_of_credits() const { return cellular_out_of_credits_; } 109 bool cellular_out_of_credits() const { return cellular_out_of_credits_; }
98 110
99 // VPN property accessors 111 // VPN property accessors
100 const std::string& vpn_provider_type() const { return vpn_provider_type_; } 112 const std::string& vpn_provider_type() const { return vpn_provider_type_; }
101 const std::string& third_party_vpn_provider_extension_id() const { 113 const std::string& third_party_vpn_provider_extension_id() const {
102 return third_party_vpn_provider_extension_id_; 114 return third_party_vpn_provider_extension_id_;
103 } 115 }
104 116
117 // Tether accessors and setters.
118 int battery_percentage() const { return battery_percentage_; }
119 void SetBatteryPercentage(int battery_percentage);
stevenjb 2017/04/19 17:34:17 inline, set_battery_percentage()
Kyle Horimoto 2017/04/19 19:23:29 Done.
120 const std::string& carrier() const { return carrier_; }
121 void SetCarrier(const std::string& carrier);
stevenjb 2017/04/19 17:34:17 inline
Kyle Horimoto 2017/04/19 19:23:29 Done.
105 const std::string& tether_guid() const { return tether_guid_; } 122 const std::string& tether_guid() const { return tether_guid_; }
106 void set_tether_guid(const std::string& guid) { tether_guid_ = guid; } 123 void set_tether_guid(const std::string& guid) { tether_guid_ = guid; }
107 124
108 // Returns true if the network securty is WEP_8021x (Dynamic WEP) 125 // Returns true if the network securty is WEP_8021x (Dynamic WEP)
109 bool IsDynamicWep() const; 126 bool IsDynamicWep() const;
110 127
111 // Returns true if |connection_state_| is a connected/connecting state. 128 // Returns true if |connection_state_| is a connected/connecting state.
112 bool IsConnectedState() const; 129 bool IsConnectedState() const;
113 bool IsConnectingState() const; 130 bool IsConnectingState() const;
114 131
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 static bool StateIsConnected(const std::string& connection_state); 163 static bool StateIsConnected(const std::string& connection_state);
147 static bool StateIsConnecting(const std::string& connection_state); 164 static bool StateIsConnecting(const std::string& connection_state);
148 static bool NetworkStateIsCaptivePortal( 165 static bool NetworkStateIsCaptivePortal(
149 const base::DictionaryValue& shill_properties); 166 const base::DictionaryValue& shill_properties);
150 static bool ErrorIsValid(const std::string& error); 167 static bool ErrorIsValid(const std::string& error);
151 168
152 private: 169 private:
153 friend class MobileActivatorTest; 170 friend class MobileActivatorTest;
154 friend class NetworkStateHandler; 171 friend class NetworkStateHandler;
155 friend class NetworkChangeNotifierChromeosUpdateTest; 172 friend class NetworkChangeNotifierChromeosUpdateTest;
173 FRIEND_TEST_ALL_PREFIXES(NetworkStateTest, TetherProperties);
156 174
157 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|. 175 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|.
158 // Returns true if |name_| changes. 176 // Returns true if |name_| changes.
159 bool UpdateName(const base::DictionaryValue& properties); 177 bool UpdateName(const base::DictionaryValue& properties);
160 178
161 // Set to true if the network is a member of Manager.Services. 179 // Set to true if the network is a member of Manager.Services.
162 bool visible_ = false; 180 bool visible_ = false;
163 181
164 // Network Service properties. Avoid adding any additional properties here. 182 // Network Service properties. Avoid adding any additional properties here.
165 // Instead use NetworkConfigurationHandler::GetProperties() to asynchronously 183 // Instead use NetworkConfigurationHandler::GetProperties() to asynchronously
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 std::string activation_state_; 224 std::string activation_state_;
207 std::string roaming_; 225 std::string roaming_;
208 std::string payment_url_; 226 std::string payment_url_;
209 bool cellular_out_of_credits_ = false; 227 bool cellular_out_of_credits_ = false;
210 228
211 // VPN properties, used to construct the display name and to show the correct 229 // VPN properties, used to construct the display name and to show the correct
212 // configuration dialog. 230 // configuration dialog.
213 std::string vpn_provider_type_; 231 std::string vpn_provider_type_;
214 std::string third_party_vpn_provider_extension_id_; 232 std::string third_party_vpn_provider_extension_id_;
215 233
234 // Tether properties.
235 std::string carrier_;
236 int battery_percentage_;
237
216 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler 238 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler
217 // provides proxy configuration. crbug.com/241775 239 // provides proxy configuration. crbug.com/241775
218 base::DictionaryValue proxy_config_; 240 base::DictionaryValue proxy_config_;
219 241
220 DISALLOW_COPY_AND_ASSIGN(NetworkState); 242 DISALLOW_COPY_AND_ASSIGN(NetworkState);
221 }; 243 };
222 244
223 } // namespace chromeos 245 } // namespace chromeos
224 246
225 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ 247 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698