Home | History | Annotate | Download | only in ibus
      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.
      4 
      5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_
      6 #define CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_
      7 
      8 #include <string>
      9 #include "base/bind.h"
     10 #include "base/callback.h"
     11 #include "chromeos/chromeos_export.h"
     12 #include "chromeos/dbus/dbus_client_implementation_type.h"
     13 
     14 namespace dbus {
     15 class Bus;
     16 class ObjectPath;
     17 }  // namespace dbus
     18 
     19 namespace chromeos {
     20 
     21 // A class to make the actual DBus method call handling for IBusEngineFactory
     22 // service. The exported method call is used by ibus-daemon to create engine
     23 // service if the extension IME is enabled.
     24 class CHROMEOS_EXPORT IBusEngineFactoryService {
     25  public:
     26   typedef base::Callback<void(const dbus::ObjectPath& path)>
     27       CreateEngineResponseSender;
     28   typedef base::Callback<void(const CreateEngineResponseSender& sender)>
     29       CreateEngineHandler;
     30 
     31   virtual ~IBusEngineFactoryService();
     32 
     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.
     36   virtual void SetCreateEngineHandler(
     37       const std::string& engine_id,
     38       const CreateEngineHandler& create_engine_handler) = 0;
     39 
     40   // Unsets CreateEngine method call handler for |engine_id|.
     41   virtual void UnsetCreateEngineHandler(const std::string& engine_id) = 0;
     42 
     43   // Generates object path which is unique among all EngineServices.
     44   virtual dbus::ObjectPath GenerateUniqueObjectPath() = 0;
     45 
     46   // Factory function, creates a new instance and returns ownership.
     47   // For normal usage, accesses the singleton via DBusThreadManager::Get().
     48   static CHROMEOS_EXPORT IBusEngineFactoryService* Create(
     49       dbus::Bus* bus,
     50       DBusClientImplementationType type);
     51 
     52  protected:
     53   // Create() should be used instead.
     54   IBusEngineFactoryService();
     55 
     56  private:
     57   DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryService);
     58 };
     59 
     60 }  // namespace chromeos
     61 
     62 #endif  // CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_
     63