Index: chrome/browser/chromeos/cros/network_library.h |
diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h |
index 2eef83dbb92c285e5d013345cf0419db2cb54396..3aa1f8f87b3fa97ddfc44a4114de6835b058d3f1 100644 |
--- a/chrome/browser/chromeos/cros/network_library.h |
+++ b/chrome/browser/chromeos/cros/network_library.h |
@@ -26,6 +26,7 @@ class Value; |
namespace chromeos { |
+class Network; |
class NetworkDeviceParser; |
class NetworkParser; |
@@ -363,6 +364,38 @@ struct CellularApn { |
}; |
typedef std::vector<CellularApn> CellularApnList; |
+// Holds meta information for a network property: Whether the property is under |
+// policy control, if it is user-editable, and whether the policy-provided |
+// default value, if applicable. |
+class NetworkPropertyUIData { |
+ public: |
+ // Enum values indicating the entity controlling the property. |
+ enum Controller { |
+ // Property is managed by policy. |
+ CONTROLLER_POLICY, |
+ // The user controls the policy. |
+ CONTROLLER_USER, |
+ }; |
+ |
+ // Initializes an empty object. |
+ NetworkPropertyUIData(); |
+ |
+ // Updates the object from the network-level UI data. |property_key| may be |
+ // null, in which case the there'll be no default value and |controller| will |
+ // be set to CONTROLLER_POLICY iff the network is managed. |
+ void UpdateFromNetwork(const Network* network, const char* property_key); |
+ |
+ Controller controller() const { return controller_; } |
+ const base::Value* default_value() const { return default_value_.get(); } |
+ bool editable() const { return controller() != CONTROLLER_POLICY; } |
+ |
+ private: |
+ Controller controller_; |
+ scoped_ptr<base::Value> default_value_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NetworkPropertyUIData); |
+}; |
stevenjb
2011/11/29 07:23:19
I think this would be better in its own file. netw
Mattias Nissler (ping if slow)
2011/11/29 14:48:50
Done.
|
+ |
// Cellular network is considered low data when less than 60 minues. |
static const int kCellularDataLowSecs = 60 * 60; |
@@ -384,6 +417,16 @@ const int kPriorityPreferred = 1; |
// Source of the ONC network. This is an integer according to enum ONCSource. |
extern const char kUIDataKeyONCSource[]; |
+extern const char kUIDataKeyProperties[]; |
+extern const char kUIDataKeyPropertiesController[]; |
+extern const char kUIDataKeyPropertiesControllerPolicy[]; |
+extern const char kUIDataKeyPropertiesControllerUser[]; |
+extern const char kUIDataKeyPropertiesDefaultValue[]; |
+ |
+// Names of the properties stored in the dictionary under |
+// kUIDataKeyPropertiesController. |
+extern const char kUIDataPropertyAutoConnect[]; |
+extern const char kUIDataPropertyPreferred[]; |
// Contains data related to the flimflam.Device interface, |
// e.g. ethernet, wifi, cellular. |
@@ -634,6 +677,7 @@ class Network { |
int priority_order() const { return priority_order_; } |
const std::string& proxy_config() const { return proxy_config_; } |
+ |
const DictionaryValue* ui_data() const { return &ui_data_; } |
DictionaryValue* ui_data() { return &ui_data_; } |
@@ -661,6 +705,12 @@ class Network { |
// Copy any credentials from a remembered network that are unset in |this|. |
virtual void CopyCredentialsFromRemembered(Network* remembered); |
+ // Accessors returning policy management state information. |
+ bool IsManagedByPolicy() const; |
+ void GetUIDataForPreferred(NetworkPropertyUIData* ui_data) const; |
+ void GetUIDataForAutoConnect(NetworkPropertyUIData* ui_data) const; |
+ void GetUIDataForIPConfig(NetworkPropertyUIData* ui_data) const; |
stevenjb
2011/11/29 07:23:19
These last three seem unnecessary. Why not just ca
Mattias Nissler (ping if slow)
2011/11/29 14:48:50
Obsolete in the new version.
|
+ |
// Static helper functions. |
static bool IsConnectedState(ConnectionState state) { |
return (state == STATE_READY || |
@@ -716,6 +766,10 @@ class Network { |
const std::string& str, |
std::string* dest); |
+ // Check whether a property is configured by policy and should thus not be |
+ // editable by the user. |
+ bool IsManaged(const char* prop); |
stevenjb
2011/11/29 07:23:19
This appears to be unimplemented?
Mattias Nissler (ping if slow)
2011/11/29 14:48:50
Good catch, this is a leftover. Removed.
|
+ |
void set_unique_id(const std::string& unique_id) { unique_id_ = unique_id; } |
private: |