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. 4 5 #ifndef CHROMEOS_NETWORK_FAVORITE_STATE_H_ 6 #define CHROMEOS_NETWORK_FAVORITE_STATE_H_ 7 8 #include "chromeos/network/managed_state.h" 9 #include "chromeos/network/network_ui_data.h" 10 #include "chromeos/network/onc/onc_constants.h" 11 12 namespace chromeos { 13 14 // A simple class to provide essential information for Services created 15 // by Shill corresponding to Profile Entries (i.e. 'preferred' or 'favorite' 16 // networks). 17 // Note: NetworkStateHandler will store an entry for each member of 18 // Manager.ServiceCompleteList, even for visible entries that are not 19 // favorites. This is necessary to avoid unnecessarily re-requesting entries, 20 // and to limit the code complexity. The is_favorite() accessor is used to skip 21 // entries that are not actually favorites. 22 class CHROMEOS_EXPORT FavoriteState : public ManagedState { 23 public: 24 explicit FavoriteState(const std::string& path); 25 virtual ~FavoriteState(); 26 27 // ManagedState overrides 28 virtual bool PropertyChanged(const std::string& key, 29 const base::Value& value) OVERRIDE; 30 31 // Accessors 32 const std::string& profile_path() const { return profile_path_; } 33 bool is_favorite() const { return !profile_path_.empty(); } 34 const NetworkUIData& ui_data() const { return ui_data_; } 35 36 // Returns true if the ONC source is a device or user policy. 37 bool IsManaged() const; 38 39 // Returns true if the network properties are stored in a user profile. 40 bool IsPrivate() const; 41 42 private: 43 std::string profile_path_; 44 NetworkUIData ui_data_; 45 46 DISALLOW_COPY_AND_ASSIGN(FavoriteState); 47 }; 48 49 } // namespace chromeos 50 51 #endif // CHROMEOS_NETWORK_FAVORITE_STATE_H_ 52