OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ | 5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ |
6 #define CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ | 6 #define CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ |
7 | 7 |
| 8 #include <string> |
8 #include "base/bind.h" | 9 #include "base/bind.h" |
9 #include "base/callback.h" | 10 #include "base/callback.h" |
10 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
11 #include "chromeos/dbus/dbus_client_implementation_type.h" | 12 #include "chromeos/dbus/dbus_client_implementation_type.h" |
12 | 13 |
13 namespace dbus { | 14 namespace dbus { |
14 class Bus; | 15 class Bus; |
15 class ObjectPath; | 16 class ObjectPath; |
16 } // namespace dbus | 17 } // namespace dbus |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 // A class to make the actual DBus method call handling for IBusEngineFactory | 21 // A class to make the actual DBus method call handling for IBusEngineFactory |
21 // service. The exported method call is used by ibus-daemon to create engine | 22 // service. The exported method call is used by ibus-daemon to create engine |
22 // service if the extension IME is enabled. | 23 // service if the extension IME is enabled. |
23 class CHROMEOS_EXPORT IBusEngineFactoryService { | 24 class CHROMEOS_EXPORT IBusEngineFactoryService { |
24 public: | 25 public: |
25 // The CreateEngine message accepts |engine_id| which identifies the engine | 26 typedef base::Callback<void(const dbus::ObjectPath& path)> |
26 // module(ex. "mozc"), and returns an ObjectPath. The ibus-daemon will send | 27 CreateEngineResponseSender; |
27 // dbus message to returned ObjectPath for engine processing. | 28 typedef base::Callback<void(const CreateEngineResponseSender& sender)> |
28 typedef base::Callback<dbus::ObjectPath (const std::string& engine_id)> | |
29 CreateEngineHandler; | 29 CreateEngineHandler; |
30 | 30 |
31 virtual ~IBusEngineFactoryService(); | 31 virtual ~IBusEngineFactoryService(); |
32 | 32 |
33 // Sets CreateEngine method call handler. | 33 // Sets CreateEngine method call handler for |engine_id|. If ibus-daemon calls |
| 34 // CreateEngine message with |engine_id|, the |create_engine_handler| will be |
| 35 // called. |
34 virtual void SetCreateEngineHandler( | 36 virtual void SetCreateEngineHandler( |
| 37 const std::string& engine_id, |
35 const CreateEngineHandler& create_engine_handler) = 0; | 38 const CreateEngineHandler& create_engine_handler) = 0; |
36 | 39 |
37 // Unsets CreateEngine method call handler. | 40 // Unsets CreateEngine method call handler for |engine_id|. |
38 virtual void UnsetCreateEngineHandler() = 0; | 41 virtual void UnsetCreateEngineHandler(const std::string& engine_id) = 0; |
39 | 42 |
40 // Factory function, creates a new instance and returns ownership. | 43 // Factory function, creates a new instance and returns ownership. |
41 // For normal usage, accesses the sigleton via DBusThreadManager::Get(). | 44 // For normal usage, accesses the sigleton via DBusThreadManager::Get(). |
42 static CHROMEOS_EXPORT IBusEngineFactoryService* Create( | 45 static CHROMEOS_EXPORT IBusEngineFactoryService* Create( |
43 dbus::Bus* bus, | 46 dbus::Bus* bus, |
44 DBusClientImplementationType type); | 47 DBusClientImplementationType type); |
45 | 48 |
46 protected: | 49 protected: |
47 // Create() should be used instead. | 50 // Create() should be used instead. |
48 IBusEngineFactoryService(); | 51 IBusEngineFactoryService(); |
49 | 52 |
50 private: | 53 private: |
51 DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryService); | 54 DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryService); |
52 }; | 55 }; |
53 | 56 |
54 } // namespace chromeos | 57 } // namespace chromeos |
55 | 58 |
56 #endif // CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ | 59 #endif // CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ |
OLD | NEW |