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.
5 #ifndef CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_
6 #define CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h"
16 #include "chromeos/chromeos_export.h"
17 #include "chromeos/dbus/dbus_method_call_status.h"
18 #include "chromeos/dbus/shill_property_changed_observer.h"
19 #include "chromeos/network/network_handler.h"
20 #include "chromeos/network/network_profile.h"
23 class DictionaryValue
;
28 class NetworkProfileObserver
;
29 class NetworkStateHandler
;
31 class CHROMEOS_EXPORT NetworkProfileHandler
32 : public ShillPropertyChangedObserver
{
34 typedef std::vector
<NetworkProfile
> ProfileList
;
36 ~NetworkProfileHandler() override
;
38 void AddObserver(NetworkProfileObserver
* observer
);
39 void RemoveObserver(NetworkProfileObserver
* observer
);
41 void GetManagerPropertiesCallback(DBusMethodCallStatus call_status
,
42 const base::DictionaryValue
& properties
);
44 // ShillPropertyChangedObserver overrides
45 void OnPropertyChanged(const std::string
& name
,
46 const base::Value
& value
) override
;
48 void GetProfilePropertiesCallback(const std::string
& profile_path
,
49 const base::DictionaryValue
& properties
);
51 const NetworkProfile
* GetProfileForPath(
52 const std::string
& profile_path
) const;
53 const NetworkProfile
* GetProfileForUserhash(
54 const std::string
& userhash
) const;
56 // Returns the first profile entry with a non-empty userhash.
57 // TODO(stevenjb): Replace with GetProfileForUserhash() with the correct
59 const NetworkProfile
* GetDefaultUserProfile() const;
61 static std::string
GetSharedProfilePath();
64 friend class AutoConnectHandlerTest
;
65 friend class ClientCertResolverTest
;
66 friend class NetworkConnectionHandlerTest
;
67 friend class NetworkHandler
;
68 NetworkProfileHandler();
70 // Add ShillManagerClient property observer and request initial list.
73 void AddProfile(const NetworkProfile
& profile
);
74 void RemoveProfile(const std::string
& profile_path
);
77 ProfileList profiles_
;
79 // Contains the profile paths for which properties were requested. Once the
80 // properties are retrieved and the path is still in this set, a new profile
82 std::set
<std::string
> pending_profile_creations_
;
83 base::ObserverList
<NetworkProfileObserver
> observers_
;
85 // For Shill client callbacks
86 base::WeakPtrFactory
<NetworkProfileHandler
> weak_ptr_factory_
;
89 DISALLOW_COPY_AND_ASSIGN(NetworkProfileHandler
);
92 } // namespace chromeos
94 #endif // CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_