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

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

Issue 289383004: Merge FavoriteState into NetworkState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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
« no previous file with comments | « chromeos/network/network_sms_handler_unittest.cc ('k') | chromeos/network/network_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/network/managed_state.h" 12 #include "chromeos/network/managed_state.h"
12 #include "chromeos/network/network_ui_data.h" 13 #include "chromeos/network/network_ui_data.h"
13 #include "components/onc/onc_constants.h" 14 #include "components/onc/onc_constants.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace base { 17 namespace base {
17 class DictionaryValue; 18 class DictionaryValue;
18 class Value; 19 class Value;
19 } 20 }
20 21
21 namespace chromeos { 22 namespace chromeos {
22 23
23 // Simple class to provide network state information about a network service. 24 // Simple class to provide network state information about a network service.
24 // This class should always be passed as a const* and should never be held 25 // This class should always be passed as a const* and should never be held
25 // on to. Store network_state->path() (defined in ManagedState) instead and 26 // on to. Store network_state->path() (defined in ManagedState) instead and
26 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for 27 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for
27 // the network. 28 // the network.
29 //
30 // Note: NetworkStateHandler will store an entry for each member of
31 // Manager.ServiceCompleteList. The visible() method indicates whether the
32 // network is visible, and the IsInProfile() method indicates whether the
33 // network is saved in a profile.
28 class CHROMEOS_EXPORT NetworkState : public ManagedState { 34 class CHROMEOS_EXPORT NetworkState : public ManagedState {
29 public: 35 public:
30 explicit NetworkState(const std::string& path); 36 explicit NetworkState(const std::string& path);
31 virtual ~NetworkState(); 37 virtual ~NetworkState();
32 38
33 // ManagedState overrides 39 // ManagedState overrides
34 // If you change this method, update GetProperties too. 40 // If you change this method, update GetProperties too.
35 virtual bool PropertyChanged(const std::string& key, 41 virtual bool PropertyChanged(const std::string& key,
36 const base::Value& value) OVERRIDE; 42 const base::Value& value) OVERRIDE;
37 virtual bool InitialPropertiesReceived( 43 virtual bool InitialPropertiesReceived(
38 const base::DictionaryValue& properties) OVERRIDE; 44 const base::DictionaryValue& properties) OVERRIDE;
39 virtual void GetStateProperties( 45 virtual void GetStateProperties(
40 base::DictionaryValue* dictionary) const OVERRIDE; 46 base::DictionaryValue* dictionary) const OVERRIDE;
41 47
42 void IPConfigPropertiesChanged(const base::DictionaryValue& properties); 48 void IPConfigPropertiesChanged(const base::DictionaryValue& properties);
43 49
44 // Returns true, if the network requires a service activation. 50 // Returns true, if the network requires a service activation.
45 bool RequiresActivation() const; 51 bool RequiresActivation() const;
46 52
47 // Accessors 53 // Accessors
54 bool visible() const { return visible_; }
48 const std::string& security() const { return security_; } 55 const std::string& security() const { return security_; }
49 const std::string& device_path() const { return device_path_; } 56 const std::string& device_path() const { return device_path_; }
50 const std::string& guid() const { return guid_; } 57 const std::string& guid() const { return guid_; }
51 const std::string& connection_state() const { return connection_state_; }
52 const std::string& profile_path() const { return profile_path_; } 58 const std::string& profile_path() const { return profile_path_; }
53 const std::string& error() const { return error_; } 59 const std::string& error() const { return error_; }
54 const std::string& last_error() const { return last_error_; } 60 const std::string& last_error() const { return last_error_; }
55 void clear_last_error() { last_error_.clear(); } 61 void clear_last_error() { last_error_.clear(); }
56 62
63 // Returns |connection_state_| if visible, kStateDisconnect otherwise.
64 std::string connection_state() const;
65
57 const NetworkUIData& ui_data() const { return ui_data_; } 66 const NetworkUIData& ui_data() const { return ui_data_; }
67 const base::DictionaryValue& proxy_config() const { return proxy_config_; }
58 68
59 // IPConfig Properties. These require an extra call to ShillIPConfigClient, 69 // IPConfig Properties. These require an extra call to ShillIPConfigClient,
60 // so cache them to avoid excessively complex client code. 70 // so cache them to avoid excessively complex client code.
61 const std::string& ip_address() const { return ip_address_; } 71 const std::string& ip_address() const { return ip_address_; }
62 const std::string& gateway() const { return gateway_; } 72 const std::string& gateway() const { return gateway_; }
63 const std::vector<std::string>& dns_servers() const { return dns_servers_; } 73 const std::vector<std::string>& dns_servers() const { return dns_servers_; }
64 const GURL& web_proxy_auto_discovery_url() const { 74 const GURL& web_proxy_auto_discovery_url() const {
65 return web_proxy_auto_discovery_url_; 75 return web_proxy_auto_discovery_url_;
66 } 76 }
67 77
(...skipping 15 matching lines...) Expand all
83 } 93 }
84 bool cellular_out_of_credits() const { return cellular_out_of_credits_; } 94 bool cellular_out_of_credits() const { return cellular_out_of_credits_; }
85 95
86 // Whether this network has a CACertNSS nickname set. 96 // Whether this network has a CACertNSS nickname set.
87 bool HasCACertNSS() const { return has_ca_cert_nss_; } 97 bool HasCACertNSS() const { return has_ca_cert_nss_; }
88 98
89 // Returns true if |connection_state_| is a connected/connecting state. 99 // Returns true if |connection_state_| is a connected/connecting state.
90 bool IsConnectedState() const; 100 bool IsConnectedState() const;
91 bool IsConnectingState() const; 101 bool IsConnectingState() const;
92 102
103 // Returns true if this is a network stored in a profile.
104 bool IsInProfile() const;
105
93 // Returns true if the network properties are stored in a user profile. 106 // Returns true if the network properties are stored in a user profile.
94 bool IsPrivate() const; 107 bool IsPrivate() const;
95 108
96 // Returns a comma separated string of name servers. 109 // Returns a comma separated string of name servers.
97 std::string GetDnsServersAsString() const; 110 std::string GetDnsServersAsString() const;
98 111
99 // Converts the prefix length to a netmask string. 112 // Converts the prefix length to a netmask string.
100 std::string GetNetmask() const; 113 std::string GetNetmask() const;
101 114
115 // Returns a specifier for identifying this network in the absence of a GUID.
116 // This should only be used by NetworkStateHandler for keeping track of
117 // GUIDs assigned to unsaved networks.
118 std::string GetSpecifier() const;
119
102 // Set the GUID. Called exclusively by NetworkStateHandler. 120 // Set the GUID. Called exclusively by NetworkStateHandler.
103 void SetGuid(const std::string& guid); 121 void SetGuid(const std::string& guid);
104 122
105 // Helpers (used e.g. when a state or error is cached) 123 // Helpers (used e.g. when a state or error is cached)
106 static bool StateIsConnected(const std::string& connection_state); 124 static bool StateIsConnected(const std::string& connection_state);
107 static bool StateIsConnecting(const std::string& connection_state); 125 static bool StateIsConnecting(const std::string& connection_state);
108 static bool ErrorIsValid(const std::string& error); 126 static bool ErrorIsValid(const std::string& error);
109 127
110 private: 128 private:
111 friend class MobileActivatorTest; 129 friend class MobileActivatorTest;
112 friend class NetworkStateHandler; 130 friend class NetworkStateHandler;
113 friend class NetworkChangeNotifierChromeosUpdateTest; 131 friend class NetworkChangeNotifierChromeosUpdateTest;
114 132
115 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|. 133 // Updates |name_| from WiFi.HexSSID if provided, and validates |name_|.
116 // Returns true if |name_| changes. 134 // Returns true if |name_| changes.
117 bool UpdateName(const base::DictionaryValue& properties); 135 bool UpdateName(const base::DictionaryValue& properties);
118 136
137 void set_visible(bool visible) { visible_ = visible; }
138
139 // Set to true if the network is a member of Manager.Services.
140 bool visible_;
141
119 // Network Service properties. Avoid adding any additional properties here. 142 // Network Service properties. Avoid adding any additional properties here.
120 // Instead use NetworkConfigurationHandler::GetProperties() to asynchronously 143 // Instead use NetworkConfigurationHandler::GetProperties() to asynchronously
121 // request properties from Shill. 144 // request properties from Shill.
122 std::string security_; 145 std::string security_;
123 std::string eap_method_; // Needed for WiFi EAP networks 146 std::string eap_method_; // Needed for WiFi EAP networks
124 std::string device_path_; 147 std::string device_path_;
125 std::string guid_; 148 std::string guid_;
126 std::string connection_state_; 149 std::string connection_state_;
127 std::string profile_path_; 150 std::string profile_path_;
128 bool connectable_; 151 bool connectable_;
(...skipping 26 matching lines...) Expand all
155 std::string network_technology_; 178 std::string network_technology_;
156 std::string activation_state_; 179 std::string activation_state_;
157 std::string roaming_; 180 std::string roaming_;
158 bool activate_over_non_cellular_networks_; 181 bool activate_over_non_cellular_networks_;
159 bool cellular_out_of_credits_; 182 bool cellular_out_of_credits_;
160 183
161 // Whether a deprecated CaCertNSS property of this network is set. Required 184 // Whether a deprecated CaCertNSS property of this network is set. Required
162 // for migration to PEM. 185 // for migration to PEM.
163 bool has_ca_cert_nss_; 186 bool has_ca_cert_nss_;
164 187
188 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler
189 // provides proxy configuration. crbug.com/241775
190 base::DictionaryValue proxy_config_;
191
165 DISALLOW_COPY_AND_ASSIGN(NetworkState); 192 DISALLOW_COPY_AND_ASSIGN(NetworkState);
166 }; 193 };
167 194
168 } // namespace chromeos 195 } // namespace chromeos
169 196
170 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ 197 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_
OLDNEW
« no previous file with comments | « chromeos/network/network_sms_handler_unittest.cc ('k') | chromeos/network/network_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698