card unmasking prompt - Change expiration date spinners to text inputs, as per mocks.
[chromium-blink-merge.git] / chromeos / network / network_profile_handler.h
blob1de54f2a1c947d081e81fe738af015a8240ef9f2
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_
8 #include <set>
9 #include <string>
10 #include <vector>
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"
22 namespace base {
23 class DictionaryValue;
26 namespace chromeos {
28 class NetworkProfileObserver;
29 class NetworkStateHandler;
31 class CHROMEOS_EXPORT NetworkProfileHandler
32 : public ShillPropertyChangedObserver {
33 public:
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
58 // userhash.
59 const NetworkProfile* GetDefaultUserProfile() const;
61 static std::string GetSharedProfilePath();
63 protected:
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.
71 void Init();
73 void AddProfile(const NetworkProfile& profile);
74 void RemoveProfile(const std::string& profile_path);
76 private:
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
81 // object is created.
82 std::set<std::string> pending_profile_creations_;
83 ObserverList<NetworkProfileObserver> observers_;
85 // For Shill client callbacks
86 base::WeakPtrFactory<NetworkProfileHandler> weak_ptr_factory_;
88 private:
89 DISALLOW_COPY_AND_ASSIGN(NetworkProfileHandler);
92 } // namespace chromeos
94 #endif // CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_