network_profile_handler.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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_handler.h" 19#include "chromeos/network/network_profile.h" 20 21namespace base { 22class DictionaryValue; 23} 24 25namespace chromeos { 26 27class NetworkProfileObserver; 28 29class CHROMEOS_EXPORT NetworkProfileHandler 30 : public ShillPropertyChangedObserver { 31 public: 32 typedef std::vector<NetworkProfile> ProfileList; 33 34 virtual ~NetworkProfileHandler(); 35 36 void AddObserver(NetworkProfileObserver* observer); 37 void RemoveObserver(NetworkProfileObserver* observer); 38 39 void GetManagerPropertiesCallback(DBusMethodCallStatus call_status, 40 const base::DictionaryValue& properties); 41 42 // ShillPropertyChangedObserver overrides 43 virtual void OnPropertyChanged(const std::string& name, 44 const base::Value& value) OVERRIDE; 45 46 void GetProfilePropertiesCallback(const std::string& profile_path, 47 const base::DictionaryValue& properties); 48 49 const NetworkProfile* GetProfileForPath( 50 const std::string& profile_path) const; 51 const NetworkProfile* GetProfileForUserhash( 52 const std::string& userhash) const; 53 54 protected: 55 friend class NetworkHandler; 56 NetworkProfileHandler(); 57 58 void AddProfile(const NetworkProfile& profile); 59 void RemoveProfile(const std::string& profile_path); 60 61 private: 62 ProfileList profiles_; 63 ObserverList<NetworkProfileObserver> observers_; 64 65 protected: 66 // For Shill client callbacks 67 base::WeakPtrFactory<NetworkProfileHandler> weak_ptr_factory_; 68 69 private: 70 DISALLOW_COPY_AND_ASSIGN(NetworkProfileHandler); 71}; 72 73} // namespace chromeos 74 75#endif // CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_ 76