Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / dbus / shill_profile_client.h
blob885151f892a877b497c217e248f62d84acb8a6dd
1 // Copyright (c) 2012 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_DBUS_SHILL_PROFILE_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
14 #include "chromeos/dbus/shill_client_helper.h"
16 namespace base {
18 class Value;
19 class DictionaryValue;
21 } // namespace base
23 namespace dbus {
25 class ObjectPath;
27 } // namespace dbus
29 namespace chromeos {
31 class ShillPropertyChangedObserver;
33 // ShillProfileClient is used to communicate with the Shill Profile
34 // service. All methods should be called from the origin thread which
35 // initializes the DBusThreadManager instance.
36 class CHROMEOS_EXPORT ShillProfileClient : public DBusClient {
37 public:
38 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
39 typedef ShillClientHelper::DictionaryValueCallbackWithoutStatus
40 DictionaryValueCallbackWithoutStatus;
41 typedef ShillClientHelper::ErrorCallback ErrorCallback;
43 // Interface for setting up services for testing. Accessed through
44 // GetTestInterface(), only implemented in the stub implementation.
45 // TODO(stevenjb): remove dependencies on entry_path -> service_path
46 // mappings in some of the TestInterface implementations.
47 class TestInterface {
48 public:
49 virtual void AddProfile(const std::string& profile_path,
50 const std::string& userhash) = 0;
52 // Adds an entry to the profile only. |entry_path| corresponds to a
53 // 'service_path' and a corresponding entry will be added to
54 // ShillManagerClient ServiceCompleteList. No checking or updating of
55 // ShillServiceClient is performed.
56 virtual void AddEntry(const std::string& profile_path,
57 const std::string& entry_path,
58 const base::DictionaryValue& properties) = 0;
60 // Adds a service to the profile, copying properties from the
61 // ShillServiceClient entry matching |service_path|. Returns false if no
62 // Service entry exists or if a Profile entry already exists. Also sets
63 // the Profile property of the service in ShillServiceClient.
64 virtual bool AddService(const std::string& profile_path,
65 const std::string& service_path) = 0;
67 // Copies properties from the ShillServiceClient entry matching
68 // |service_path| to the profile entry matching |profile_path|. Returns
69 // false if no Service entry exits or if no Profile entry exists.
70 virtual bool UpdateService(const std::string& profile_path,
71 const std::string& service_path) = 0;
73 // Sets |profiles| to the current list of profile paths.
74 virtual void GetProfilePaths(std::vector<std::string>* profiles) = 0;
76 // Sets |properties| to the entry for |service_path|, sets |profile_path|
77 // to the path of the profile with the entry, and returns true if the
78 // service exists in any profile.
79 virtual bool GetService(const std::string& service_path,
80 std::string* profile_path,
81 base::DictionaryValue* properties) = 0;
83 // Remove all profile entries.
84 virtual void ClearProfiles() = 0;
86 protected:
87 virtual ~TestInterface() {}
90 ~ShillProfileClient() override;
92 // Factory function, creates a new instance which is owned by the caller.
93 // For normal usage, access the singleton via DBusThreadManager::Get().
94 static ShillProfileClient* Create();
96 // Returns the shared profile path.
97 static std::string GetSharedProfilePath();
99 // Adds a property changed |observer| for the profile at |profile_path|.
100 virtual void AddPropertyChangedObserver(
101 const dbus::ObjectPath& profile_path,
102 ShillPropertyChangedObserver* observer) = 0;
104 // Removes a property changed |observer| for the profile at |profile_path|.
105 virtual void RemovePropertyChangedObserver(
106 const dbus::ObjectPath& profile_path,
107 ShillPropertyChangedObserver* observer) = 0;
109 // Calls GetProperties method.
110 // |callback| is called after the method call succeeds.
111 virtual void GetProperties(
112 const dbus::ObjectPath& profile_path,
113 const DictionaryValueCallbackWithoutStatus& callback,
114 const ErrorCallback& error_callback) = 0;
116 // Calls GetEntry method.
117 // |callback| is called after the method call succeeds.
118 virtual void GetEntry(const dbus::ObjectPath& profile_path,
119 const std::string& entry_path,
120 const DictionaryValueCallbackWithoutStatus& callback,
121 const ErrorCallback& error_callback) = 0;
123 // Calls DeleteEntry method.
124 // |callback| is called after the method call succeeds.
125 virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
126 const std::string& entry_path,
127 const base::Closure& callback,
128 const ErrorCallback& error_callback) = 0;
130 // Returns an interface for testing (stub only), or returns NULL.
131 virtual TestInterface* GetTestInterface() = 0;
133 protected:
134 friend class ShillProfileClientTest;
136 // Create() should be used instead.
137 ShillProfileClient();
139 private:
140 DISALLOW_COPY_AND_ASSIGN(ShillProfileClient);
143 } // namespace chromeos
145 #endif // CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_