OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_FAVORITE_STATE_H_ | 5 #ifndef CHROMEOS_NETWORK_FAVORITE_STATE_H_ |
6 #define CHROMEOS_NETWORK_FAVORITE_STATE_H_ | 6 #define CHROMEOS_NETWORK_FAVORITE_STATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chromeos/network/managed_state.h" | 11 #include "chromeos/network/managed_state.h" |
12 #include "chromeos/network/network_ui_data.h" | 12 #include "chromeos/network/network_ui_data.h" |
13 #include "components/onc/onc_constants.h" | 13 #include "components/onc/onc_constants.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 // A simple class to provide essential information for Services created | 17 // A simple class to provide essential information for Services created |
18 // by Shill corresponding to Profile Entries (i.e. 'preferred' or 'favorite' | 18 // by Shill corresponding to Profile Entries (i.e. 'preferred' or 'favorite' |
19 // networks). | 19 // networks). |
20 // Note: NetworkStateHandler will store an entry for each member of | 20 // Note: NetworkStateHandler will store an entry for each member of |
21 // Manager.ServiceCompleteList, even for visible entries that are not | 21 // Manager.ServiceCompleteList, even for visible entries that are not |
22 // favorites. This is necessary to avoid unnecessarily re-requesting entries, | 22 // favorites. This is necessary to avoid unnecessarily re-requesting entries, |
23 // and to limit the code complexity. The IsFavorite() accessor is used to skip | 23 // and to limit the code complexity. The is_favorite() accessor is used to skip |
24 // entries that are not actually favorites. | 24 // entries that are not actually favorites. |
25 class CHROMEOS_EXPORT FavoriteState : public ManagedState { | 25 class CHROMEOS_EXPORT FavoriteState : public ManagedState { |
26 public: | 26 public: |
27 explicit FavoriteState(const std::string& path); | 27 explicit FavoriteState(const std::string& path); |
28 virtual ~FavoriteState(); | 28 virtual ~FavoriteState(); |
29 | 29 |
30 // ManagedState overrides | 30 // ManagedState overrides |
31 virtual bool PropertyChanged(const std::string& key, | 31 virtual bool PropertyChanged(const std::string& key, |
32 const base::Value& value) OVERRIDE; | 32 const base::Value& value) OVERRIDE; |
33 | 33 |
34 // Accessors | 34 // Accessors |
35 const std::string& profile_path() const { return profile_path_; } | 35 const std::string& profile_path() const { return profile_path_; } |
| 36 bool is_favorite() const { return !profile_path_.empty(); } |
36 const NetworkUIData& ui_data() const { return ui_data_; } | 37 const NetworkUIData& ui_data() const { return ui_data_; } |
37 const base::DictionaryValue& proxy_config() const { return proxy_config_; } | 38 const base::DictionaryValue& proxy_config() const { return proxy_config_; } |
38 const std::string& guid() const { return guid_; } | 39 const std::string& guid() const { return guid_; } |
39 const base::DictionaryValue& properties() const { return properties_; } | 40 const base::DictionaryValue& properties() const { return properties_; } |
40 | 41 |
41 // Returns true if this is a favorite stored in a profile (see note above). | |
42 bool IsFavorite() const; | |
43 | |
44 // Returns true if the network properties are stored in a user profile. | 42 // Returns true if the network properties are stored in a user profile. |
45 bool IsPrivate() const; | 43 bool IsPrivate() const; |
46 | 44 |
47 private: | 45 private: |
48 std::string profile_path_; | 46 std::string profile_path_; |
49 NetworkUIData ui_data_; | 47 NetworkUIData ui_data_; |
50 std::string guid_; | 48 std::string guid_; |
51 | 49 |
52 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler | 50 // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler |
53 // provides proxy configuration. crbug.com/241775 | 51 // provides proxy configuration. crbug.com/241775 |
54 base::DictionaryValue proxy_config_; | 52 base::DictionaryValue proxy_config_; |
55 | 53 |
56 // Keep all Favorite properties in a dictionary so that all configured | 54 // Keep all Favorite properties in a dictionary so that all configured |
57 // properties can be examined for debugging. Since the Favorite list is | 55 // properties can be examined for debugging. Since the Favorite list is |
58 // mostly fixed, the overhead should be reasonable. | 56 // mostly fixed, the overhead should be reasonable. |
59 base::DictionaryValue properties_; | 57 base::DictionaryValue properties_; |
60 | 58 |
61 DISALLOW_COPY_AND_ASSIGN(FavoriteState); | 59 DISALLOW_COPY_AND_ASSIGN(FavoriteState); |
62 }; | 60 }; |
63 | 61 |
64 } // namespace chromeos | 62 } // namespace chromeos |
65 | 63 |
66 #endif // CHROMEOS_NETWORK_FAVORITE_STATE_H_ | 64 #endif // CHROMEOS_NETWORK_FAVORITE_STATE_H_ |
OLD | NEW |