summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/ibus/ibus_engine_factory_service.h
blob: 248b64a83d0e080cef36baafecd57271db1686a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_
#define CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_

#include <string>
#include "base/bind.h"
#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"

namespace dbus {
class Bus;
class ObjectPath;
}  // namespace dbus

namespace chromeos {

// A class to make the actual DBus method call handling for IBusEngineFactory
// service. The exported method call is used by ibus-daemon to create engine
// service if the extension IME is enabled.
class CHROMEOS_EXPORT IBusEngineFactoryService {
 public:
  typedef base::Callback<void(const dbus::ObjectPath& path)>
      CreateEngineResponseSender;
  typedef base::Callback<void(const CreateEngineResponseSender& sender)>
      CreateEngineHandler;

  virtual ~IBusEngineFactoryService();

  // Sets CreateEngine method call handler for |engine_id|. If ibus-daemon calls
  // CreateEngine message with |engine_id|, the |create_engine_handler| will be
  // called.
  virtual void SetCreateEngineHandler(
      const std::string& engine_id,
      const CreateEngineHandler& create_engine_handler) = 0;

  // Unsets CreateEngine method call handler for |engine_id|.
  virtual void UnsetCreateEngineHandler(const std::string& engine_id) = 0;

  // Generates object path which is unique among all EngineServices.
  virtual dbus::ObjectPath GenerateUniqueObjectPath() = 0;

  // Factory function, creates a new instance and returns ownership.
  // For normal usage, accesses the singleton via DBusThreadManager::Get().
  static CHROMEOS_EXPORT IBusEngineFactoryService* Create(
      dbus::Bus* bus,
      DBusClientImplementationType type);

 protected:
  // Create() should be used instead.
  IBusEngineFactoryService();

 private:
  DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryService);
};

}  // namespace chromeos

#endif  // CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_