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

Side by Side Diff: chrome/browser/chromeos/cros/network_property_ui_data.h

Issue 14846004: Migrate ProxyConfigServiceImpl to NetworkStateHandler and NetworkProfileHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 7 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 CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chromeos/network/onc/onc_constants.h"
12 13
13 namespace base { 14 namespace base {
14 class DictionaryValue; 15 class DictionaryValue;
15 class Value; 16 class Value;
16 } 17 }
17 18
18 namespace chromeos { 19 namespace chromeos {
19 20
20 class NetworkUIData;
21
22 // Holds meta information for a network property: Whether the property is under 21 // Holds meta information for a network property: Whether the property is under
23 // policy control, if it is user-editable, and whether the policy-provided 22 // policy control, if it is user-editable, and whether the policy-provided
24 // default value, if applicable. 23 // default value, if applicable.
25 class NetworkPropertyUIData { 24 class NetworkPropertyUIData {
26 public: 25 public:
27 // Enum values indicating the entity controlling the property. 26 // Enum values indicating the entity controlling the property.
28 enum Controller { 27 enum Controller {
29 // Property is managed by policy. 28 // Property is managed by policy.
30 CONTROLLER_POLICY, 29 CONTROLLER_POLICY,
31 // The user controls the policy. 30 // The user controls the policy.
32 CONTROLLER_USER, 31 CONTROLLER_USER,
33 }; 32 };
34 33
35 // Initializes the object with CONTROLLER_USER and no default value. 34 // Initializes the object with CONTROLLER_USER and no default value.
36 NetworkPropertyUIData(); 35 NetworkPropertyUIData();
37 ~NetworkPropertyUIData(); 36 ~NetworkPropertyUIData();
38 37
39 // Initializes the object by calling Reset() with the provided ui_data. 38 // Initializes the object by calling Reset() with the provided ui_data.
40 explicit NetworkPropertyUIData(const NetworkUIData& ui_data); 39 explicit NetworkPropertyUIData(onc::ONCSource onc_source);
41
42 // Resets the property to the controller specified by the given |ui_data| and
43 // clears the default value.
44 void Reset(const NetworkUIData& ui_data);
45 40
46 // Update the property object from dictionary, reading the key given by 41 // Update the property object from dictionary, reading the key given by
47 // |property_key|. 42 // |property_key|.
48 void ParseOncProperty(const NetworkUIData& ui_data, 43 void ParseOncProperty(onc::ONCSource onc_source,
49 const base::DictionaryValue* onc, 44 const base::DictionaryValue* onc,
50 const std::string& property_key); 45 const std::string& property_key);
51 46
52 const base::Value* default_value() const { return default_value_.get(); } 47 const base::Value* default_value() const { return default_value_.get(); }
53 bool managed() const { return controller_ == CONTROLLER_POLICY; } 48 bool managed() const {
49 return (onc_source_ == onc::ONC_SOURCE_DEVICE_POLICY ||
50 onc_source_ == onc::ONC_SOURCE_USER_POLICY);
51 }
54 bool recommended() const { 52 bool recommended() const {
55 return controller_ == CONTROLLER_USER && default_value_.get(); 53 return !managed() && default_value_.get();
56 } 54 }
57 bool editable() const { return controller_ == CONTROLLER_USER; } 55 bool editable() const { return !managed(); }
58 56
59 private: 57 private:
60 Controller controller_; 58 // Resets the property to the controller specified by the given |ui_data| and
59 // clears the default value.
60 void Reset(onc::ONCSource onc_source);
61
62 onc::ONCSource onc_source_;
61 scoped_ptr<base::Value> default_value_; 63 scoped_ptr<base::Value> default_value_;
62 64
63 static const char kKeyController[];
64 static const char kKeyDefaultValue[];
65
66 // So it can access the kKeyXYZ constants.
67 friend class NetworkUIDataTest;
68
69 DISALLOW_COPY_AND_ASSIGN(NetworkPropertyUIData); 65 DISALLOW_COPY_AND_ASSIGN(NetworkPropertyUIData);
70 }; 66 };
71 67
72 } // namespace chromeos 68 } // namespace chromeos
73 69
74 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_ 70 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698