| OLD | NEW |
| (Empty) |
| 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 #include "chromeos/dbus/ibus/ibus_client.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/callback.h" | |
| 9 #include "chromeos/dbus/ibus/ibus_constants.h" | |
| 10 #include "chromeos/dbus/ibus/ibus_component.h" | |
| 11 #include "chromeos/dbus/ibus/ibus_engine_service.h" | |
| 12 #include "chromeos/ime/ibus_bridge.h" | |
| 13 #include "dbus/bus.h" | |
| 14 #include "dbus/message.h" | |
| 15 #include "dbus/object_path.h" | |
| 16 #include "dbus/object_proxy.h" | |
| 17 | |
| 18 namespace chromeos { | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 // An implementation of IBusClient without ibus-daemon interaction. | |
| 23 // Currently this class is used only on linux desktop. | |
| 24 // TODO(nona): Use this on ChromeOS device once crbug.com/171351 is fixed. | |
| 25 class IBusClientDaemonlessImpl : public IBusClient { | |
| 26 public: | |
| 27 IBusClientDaemonlessImpl() {} | |
| 28 virtual ~IBusClientDaemonlessImpl() {} | |
| 29 | |
| 30 virtual void CreateInputContext( | |
| 31 const std::string& client_name, | |
| 32 const CreateInputContextCallback & callback, | |
| 33 const ErrorCallback& error_callback) OVERRIDE { | |
| 34 // TODO(nona): Remove this function once ibus-daemon is gone. | |
| 35 // We don't have to do anything for this function except for calling | |
| 36 // |callback| as the success of this function. The original spec of ibus | |
| 37 // supports multiple input contexts, but there is only one input context in | |
| 38 // Chrome OS. That is all IME events will be came from same input context | |
| 39 // and all engine action shuold be forwarded to same input context. | |
| 40 dbus::ObjectPath path("dummpy path"); | |
| 41 callback.Run(path); | |
| 42 } | |
| 43 | |
| 44 virtual void RegisterComponent( | |
| 45 const IBusComponent& ibus_component, | |
| 46 const RegisterComponentCallback& callback, | |
| 47 const ErrorCallback& error_callback) OVERRIDE { | |
| 48 // TODO(nona): Remove this function once ibus-daemon is gone. | |
| 49 // The information about engine is stored in chromeos::InputMethodManager so | |
| 50 // IBusBridge doesn't do anything except for calling |callback| as success | |
| 51 // of this function. | |
| 52 callback.Run(); | |
| 53 } | |
| 54 | |
| 55 virtual void SetGlobalEngine(const std::string& engine_name, | |
| 56 const ErrorCallback& error_callback) OVERRIDE { | |
| 57 IBusEngineHandlerInterface* previous_engine = | |
| 58 IBusBridge::Get()->GetEngineHandler(); | |
| 59 if (previous_engine) | |
| 60 previous_engine->Disable(); | |
| 61 IBusBridge::Get()->CreateEngine(engine_name); | |
| 62 IBusEngineHandlerInterface* next_engine = | |
| 63 IBusBridge::Get()->GetEngineHandler(); | |
| 64 IBusBridge::Get()->SetEngineHandler(next_engine); | |
| 65 if (next_engine) | |
| 66 next_engine->Enable(); | |
| 67 } | |
| 68 | |
| 69 virtual void Exit(ExitOption option, | |
| 70 const ErrorCallback& error_callback) OVERRIDE { | |
| 71 // Exit is not supported on daemon-less implementation. | |
| 72 } | |
| 73 | |
| 74 private: | |
| 75 DISALLOW_COPY_AND_ASSIGN(IBusClientDaemonlessImpl); | |
| 76 }; | |
| 77 | |
| 78 } // namespace | |
| 79 | |
| 80 /////////////////////////////////////////////////////////////////////////////// | |
| 81 // IBusClient | |
| 82 | |
| 83 IBusClient::IBusClient() {} | |
| 84 | |
| 85 IBusClient::~IBusClient() {} | |
| 86 | |
| 87 // static | |
| 88 IBusClient* IBusClient::Create() { | |
| 89 return new IBusClientDaemonlessImpl(); | |
| 90 } | |
| 91 | |
| 92 } // namespace chromeos | |
| OLD | NEW |