| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 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_NETWORK_PROFILE_HANDLER_H_ |
| 6 #define CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" |
| 15 #include "chromeos/chromeos_export.h" |
| 16 #include "chromeos/dbus/dbus_method_call_status.h" |
| 17 #include "chromeos/dbus/shill_property_changed_observer.h" |
| 18 #include "chromeos/network/network_profile.h" |
| 19 |
| 20 namespace base { |
| 21 class DictionaryValue; |
| 22 } |
| 23 |
| 24 namespace chromeos { |
| 25 |
| 26 class NetworkProfileObserver; |
| 27 |
| 28 class CHROMEOS_EXPORT NetworkProfileHandler |
| 29 : public ShillPropertyChangedObserver { |
| 30 public: |
| 31 typedef std::vector<NetworkProfile> ProfileList; |
| 32 |
| 33 // Initializes the singleton and registers it for DBus events. |
| 34 static NetworkProfileHandler* Initialize(); |
| 35 |
| 36 // Returns if the singleton is initialized. |
| 37 static bool IsInitialized(); |
| 38 |
| 39 // Unregisters the singleton from DBus events and destroys it. |
| 40 static void Shutdown(); |
| 41 |
| 42 // Initialize() must be called before this. |
| 43 static NetworkProfileHandler* Get(); |
| 44 |
| 45 void AddObserver(NetworkProfileObserver* observer); |
| 46 void RemoveObserver(NetworkProfileObserver* observer); |
| 47 |
| 48 void RequestInitialProfileList(); |
| 49 void GetManagerPropertiesCallback(DBusMethodCallStatus call_status, |
| 50 const base::DictionaryValue& properties); |
| 51 |
| 52 // ShillPropertyChangedObserver overrides |
| 53 virtual void OnPropertyChanged(const std::string& name, |
| 54 const base::Value& value) OVERRIDE; |
| 55 |
| 56 void GetProfilePropertiesCallback(const std::string& profile_path, |
| 57 const base::DictionaryValue& properties); |
| 58 |
| 59 const NetworkProfile* GetProfileForPath( |
| 60 const std::string& profile_path) const; |
| 61 const NetworkProfile* GetProfileForUserhash( |
| 62 const std::string& userhash) const; |
| 63 |
| 64 protected: |
| 65 // We make the de-/constructor protected to prevent their usage except in |
| 66 // tests by deriving a stub (see NetworkProfileHandlerStub). Outside of tests, |
| 67 // the singleton should be retrieved with the static Get() function. |
| 68 NetworkProfileHandler(); |
| 69 virtual ~NetworkProfileHandler(); |
| 70 |
| 71 void AddProfile(const NetworkProfile& profile); |
| 72 void RemoveProfile(const std::string& profile_path); |
| 73 |
| 74 private: |
| 75 ProfileList profiles_; |
| 76 ObserverList<NetworkProfileObserver> observers_; |
| 77 |
| 78 protected: |
| 79 // For Shill client callbacks |
| 80 base::WeakPtrFactory<NetworkProfileHandler> weak_ptr_factory_; |
| 81 |
| 82 private: |
| 83 DISALLOW_COPY_AND_ASSIGN(NetworkProfileHandler); |
| 84 }; |
| 85 |
| 86 } // namespace chromeos |
| 87 |
| 88 #endif // CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_ |
| OLD | NEW |