Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / network / shill_property_util.h
blobcc9da9c24377dbe0f6e1ba028d8cca709c4c7f73
1 // Copyright 2013 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_SHILL_PROPERTY_UTIL_H_
6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "chromeos/chromeos_export.h"
13 namespace base {
14 class DictionaryValue;
15 class Value;
18 namespace chromeos {
20 class NetworkUIData;
22 namespace shill_property_util {
24 // Sets the |ssid| in |properties|.
25 CHROMEOS_EXPORT void SetSSID(const std::string ssid,
26 base::DictionaryValue* properties);
28 // Returns the SSID from |properties| in UTF-8 encoding. If |verbose_logging| is
29 // true, detailed DEBUG log events will be added to the device event log. If
30 // |unknown_encoding| != nullptr, it is set to whether the SSID is of unknown
31 // encoding.
32 CHROMEOS_EXPORT std::string GetSSIDFromProperties(
33 const base::DictionaryValue& properties,
34 bool verbose_logging,
35 bool* unknown_encoding);
37 // Returns the GUID (if available), SSID, or Name from |properties|. Only used
38 // for logging and debugging.
39 CHROMEOS_EXPORT std::string GetNetworkIdFromProperties(
40 const base::DictionaryValue& properties);
42 // Returns the name for the network represented by the Shill |properties|. For
43 // WiFi it refers to the HexSSID.
44 CHROMEOS_EXPORT std::string GetNameFromProperties(
45 const std::string& service_path,
46 const base::DictionaryValue& properties);
48 // Returns the UIData specified by |value|. Returns NULL if the value cannot be
49 // parsed.
50 scoped_ptr<NetworkUIData> GetUIDataFromValue(const base::Value& value);
52 // Returns the NetworkUIData parsed from the UIData property of
53 // |shill_dictionary|. If parsing fails or the field doesn't exist, returns
54 // NULL.
55 scoped_ptr<NetworkUIData> GetUIDataFromProperties(
56 const base::DictionaryValue& shill_dictionary);
58 // Sets the UIData property in |shill_dictionary| to the serialization of
59 // |ui_data|.
60 void SetUIData(const NetworkUIData& ui_data,
61 base::DictionaryValue* shill_dictionary);
63 // Copy configuration properties required by Shill to identify a network in the
64 // format that Shill expects on writes.
65 // Only WiFi, VPN, Ethernet and EthernetEAP are supported. Wimax and Cellular
66 // are not supported.
67 // If |properties_read_from_shill| is true, it is assumed that
68 // |service_properties| has the format that Shill exposes on reads, as opposed
69 // to property dictionaries which are sent to Shill. Returns true only if all
70 // required properties could be copied.
71 bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
72 const bool properties_read_from_shill,
73 base::DictionaryValue* dest);
75 // Compares the identifying configuration properties of |new_properties| and
76 // |old_properties|, returns true if they are identical. |new_properties| must
77 // have the form that Shill expects on writes. |old_properties| must have the
78 // form that Shill exposes on reads. See also CopyIdentifyingProperties. Only
79 // WiFi, VPN, Ethernet and EthernetEAP are supported. Wimax and Cellular are not
80 // supported.
81 bool DoIdentifyingPropertiesMatch(
82 const base::DictionaryValue& new_properties,
83 const base::DictionaryValue& old_properties);
85 // Returns false if |key| is something that should not be logged either
86 // because it is sensitive or noisy. Note: this is not necessarily
87 // comprehensive, do not use it for anything genuinely sensitive (user logs
88 // should always be treated as sensitive data, but sometimes they end up
89 // attached to public issues so this helps prevent accidents, but it should not
90 // be relied upon).
91 bool IsLoggableShillProperty(const std::string& key);
93 // Parses |value| (which should be a Dictionary). Returns true and sets
94 // |home_provider_id| if |value| was succesfully parsed.
95 bool GetHomeProviderFromProperty(const base::Value& value,
96 std::string* home_provider_id);
98 } // namespace shill_property_util
100 } // namespace chromeos
102 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_