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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_NETWORK_NETWORK_UI_DATA_H_
6 #define CHROMEOS_NETWORK_NETWORK_UI_DATA_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chromeos/chromeos_export.h"
13 #include "components/onc/onc_constants.h"
16 class DictionaryValue
;
21 // Helper for accessing and setting values in the network's UI data dictionary.
22 // Accessing values is done via static members that take the network as an
23 // argument. In order to fill a UI data dictionary, construct an instance, set
24 // up your data members, and call FillDictionary(). For example, if you have a
27 // NetworkUIData ui_data;
28 // ui_data.FillDictionary(network->ui_data());
29 class CHROMEOS_EXPORT NetworkUIData
{
32 NetworkUIData(const NetworkUIData
& other
);
33 NetworkUIData
& operator=(const NetworkUIData
& other
);
34 explicit NetworkUIData(const base::DictionaryValue
& dict
);
37 ::onc::ONCSource
onc_source() const { return onc_source_
; }
39 const base::DictionaryValue
* user_settings() const {
40 return user_settings_
.get();
42 void set_user_settings(scoped_ptr
<base::DictionaryValue
> dict
);
44 // Returns |onc_source_| as a string, one of kONCSource*.
45 std::string
GetONCSourceAsString() const;
47 // Fills in |dict| with the currently configured values. This will write the
48 // keys appropriate for Network::ui_data() as defined below (kKeyXXX).
49 void FillDictionary(base::DictionaryValue
* dict
) const;
51 // Creates a NetworkUIData object from |onc_source|. This function is used to
52 // create the "UIData" property of the Shill configuration.
53 static scoped_ptr
<NetworkUIData
> CreateFromONC(::onc::ONCSource onc_source
);
55 // Key for storing source of the ONC network.
56 static const char kKeyONCSource
[];
58 // Key for storing the user settings.
59 static const char kKeyUserSettings
[];
61 // Values for kKeyONCSource
62 static const char kONCSourceUserImport
[];
63 static const char kONCSourceDevicePolicy
[];
64 static const char kONCSourceUserPolicy
[];
67 ::onc::ONCSource onc_source_
;
68 scoped_ptr
<base::DictionaryValue
> user_settings_
;
71 } // namespace chromeos
73 #endif // CHROMEOS_NETWORK_NETWORK_UI_DATA_H_