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

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

Issue 21046008: Convert all connect code to use NetworkHandler instead of NetworkLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore check VPN PassphraseRequred Created 7 years, 4 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 | Annotate | Revision Log
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chromeos/network/managed_state.h" 12 #include "chromeos/network/managed_state.h"
13 #include "chromeos/network/network_ui_data.h"
13 #include "chromeos/network/onc/onc_constants.h" 14 #include "chromeos/network/onc/onc_constants.h"
14 15
15 namespace chromeos { 16 namespace chromeos {
16 17
17 // Simple class to provide network state information about a network service. 18 // Simple class to provide network state information about a network service.
18 // This class should always be passed as a const* and should never be held 19 // This class should always be passed as a const* and should never be held
19 // on to. Store network_state->path() (defined in ManagedState) instead and 20 // on to. Store network_state->path() (defined in ManagedState) instead and
20 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for 21 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for
21 // the network. 22 // the network.
22 class CHROMEOS_EXPORT NetworkState : public ManagedState { 23 class CHROMEOS_EXPORT NetworkState : public ManagedState {
(...skipping 20 matching lines...) Expand all
43 const std::string& device_path() const { return device_path_; } 44 const std::string& device_path() const { return device_path_; }
44 const std::string& guid() const { return guid_; } 45 const std::string& guid() const { return guid_; }
45 const std::string& connection_state() const { return connection_state_; } 46 const std::string& connection_state() const { return connection_state_; }
46 const std::string& profile_path() const { return profile_path_; } 47 const std::string& profile_path() const { return profile_path_; }
47 const std::string& error() const { return error_; } 48 const std::string& error() const { return error_; }
48 const std::string& error_details() const { return error_details_; } 49 const std::string& error_details() const { return error_details_; }
49 bool auto_connect() const { return auto_connect_; } 50 bool auto_connect() const { return auto_connect_; }
50 bool favorite() const { return favorite_; } 51 bool favorite() const { return favorite_; }
51 int priority() const { return priority_; } 52 int priority() const { return priority_; }
52 const base::DictionaryValue& proxy_config() const { return proxy_config_; } 53 const base::DictionaryValue& proxy_config() const { return proxy_config_; }
53 onc::ONCSource onc_source() const { return onc_source_; } 54 const NetworkUIData& ui_data() const { return ui_data_; }
54 // IPConfig Properties 55 // IPConfig Properties
55 const std::string& ip_address() const { return ip_address_; } 56 const std::string& ip_address() const { return ip_address_; }
56 const std::string& gateway() const { return gateway_; } 57 const std::string& gateway() const { return gateway_; }
57 const std::vector<std::string>& dns_servers() const { return dns_servers_; } 58 const std::vector<std::string>& dns_servers() const { return dns_servers_; }
58 const int prefix_length() const { return prefix_length_; } 59 const int prefix_length() const { return prefix_length_; }
59 // Wireless property accessors 60 // Wireless property accessors
60 int signal_strength() const { return signal_strength_; } 61 int signal_strength() const { return signal_strength_; }
61 bool connectable() const { return connectable_; } 62 bool connectable() const { return connectable_; }
62 // Cellular property accessors 63 // Cellular property accessors
63 const std::string& network_technology() const { 64 const std::string& network_technology() const {
(...skipping 27 matching lines...) Expand all
91 std::string GetNetmask() const; 92 std::string GetNetmask() const;
92 93
93 // Helpers (used e.g. when a state is cached) 94 // Helpers (used e.g. when a state is cached)
94 static bool StateIsConnected(const std::string& connection_state); 95 static bool StateIsConnected(const std::string& connection_state);
95 static bool StateIsConnecting(const std::string& connection_state); 96 static bool StateIsConnecting(const std::string& connection_state);
96 97
97 // Helper to return a full prefixed version of an IPConfig property 98 // Helper to return a full prefixed version of an IPConfig property
98 // key. 99 // key.
99 static std::string IPConfigProperty(const char* key); 100 static std::string IPConfigProperty(const char* key);
100 101
101 // Sets |out| to the ONCSource specified by the UIData property |value|. 102 // Sets |out| to the UIData sepcified by |value|. Returns true successfully
102 // Returns true if the source was successfully parsed. 103 // parsed.
103 static bool GetOncSource(const base::Value& value, onc::ONCSource* out); 104 static bool GetUIDataFromValue(const base::Value& value, NetworkUIData* out);
104 105
105 private: 106 private:
106 friend class NetworkStateHandler; 107 friend class NetworkStateHandler;
107 friend class NetworkChangeNotifierChromeosUpdateTest; 108 friend class NetworkChangeNotifierChromeosUpdateTest;
108 109
109 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|. 110 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|.
110 // Returns true if |name_| changes. 111 // Returns true if |name_| changes.
111 bool UpdateName(const base::DictionaryValue& properties); 112 bool UpdateName(const base::DictionaryValue& properties);
112 113
113 // TODO(gauravsh): Audit the list of properties that we are caching. We should 114 // TODO(gauravsh): Audit the list of properties that we are caching. We should
114 // only be doing this for commonly accessed properties. crbug.com/252553 115 // only be doing this for commonly accessed properties. crbug.com/252553
115 // Common Network Service properties 116 // Common Network Service properties
116 std::string security_; 117 std::string security_;
117 std::string device_path_; 118 std::string device_path_;
118 std::string guid_; 119 std::string guid_;
119 std::string connection_state_; 120 std::string connection_state_;
120 std::string profile_path_; 121 std::string profile_path_;
121 std::string error_; 122 std::string error_;
122 std::string error_details_; 123 std::string error_details_;
123 bool auto_connect_; 124 bool auto_connect_;
124 bool favorite_; 125 bool favorite_;
125 int priority_; 126 int priority_;
126 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler 127 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler
127 // provides proxy configuration. crbug/241775 128 // provides proxy configuration. crbug/241775
128 base::DictionaryValue proxy_config_; 129 base::DictionaryValue proxy_config_;
129 onc::ONCSource onc_source_; 130 NetworkUIData ui_data_;
130 // IPConfig properties. 131 // IPConfig properties.
131 // Note: These do not correspond to actual Shill.Service properties 132 // Note: These do not correspond to actual Shill.Service properties
132 // but are derived from the service's corresponding IPConfig object. 133 // but are derived from the service's corresponding IPConfig object.
133 std::string ip_address_; 134 std::string ip_address_;
134 std::string gateway_; 135 std::string gateway_;
135 std::vector<std::string> dns_servers_; 136 std::vector<std::string> dns_servers_;
136 int prefix_length_; 137 int prefix_length_;
137 // Wireless properties 138 // Wireless properties
138 int signal_strength_; 139 int signal_strength_;
139 bool connectable_; 140 bool connectable_;
140 // Cellular properties 141 // Cellular properties
141 std::string network_technology_; 142 std::string network_technology_;
142 std::string activation_state_; 143 std::string activation_state_;
143 std::string roaming_; 144 std::string roaming_;
144 bool activate_over_non_cellular_networks_; 145 bool activate_over_non_cellular_networks_;
145 bool cellular_out_of_credits_; 146 bool cellular_out_of_credits_;
146 // Cellular payment portal properties. 147 // Cellular payment portal properties.
147 std::string usage_url_; 148 std::string usage_url_;
148 std::string payment_url_; 149 std::string payment_url_;
149 std::string post_method_; 150 std::string post_method_;
150 std::string post_data_; 151 std::string post_data_;
151 152
152 DISALLOW_COPY_AND_ASSIGN(NetworkState); 153 DISALLOW_COPY_AND_ASSIGN(NetworkState);
153 }; 154 };
154 155
155 } // namespace chromeos 156 } // namespace chromeos
156 157
157 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ 158 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698