This source file includes following definitions.
- candidate_window_handler_
- GetInputContextHandler
- SetInputContextHandler
- SetEngineHandler
- GetEngineHandler
- SetCurrentEngineHandler
- SetCurrentEngineHandlerById
- GetCurrentEngineHandler
- GetCandidateWindowHandler
- SetCandidateWindowHandler
- Initialize
- Shutdown
- Get
#include "ui/base/ime/chromeos/ime_bridge.h"
#include <map>
#include "base/logging.h"
#include "base/memory/singleton.h"
namespace chromeos {
static IMEBridge* g_ime_bridge = NULL;
class IMEBridgeImpl : public IMEBridge {
public:
IMEBridgeImpl()
: input_context_handler_(NULL),
engine_handler_(NULL),
candidate_window_handler_(NULL) {
}
virtual ~IMEBridgeImpl() {
}
virtual IMEInputContextHandlerInterface*
GetInputContextHandler() const OVERRIDE {
return input_context_handler_;
}
virtual void SetInputContextHandler(
IMEInputContextHandlerInterface* handler) OVERRIDE {
input_context_handler_ = handler;
}
virtual void SetEngineHandler(
const std::string& engine_id,
IMEEngineHandlerInterface* handler) OVERRIDE {
DCHECK(!engine_id.empty());
DCHECK(handler);
engine_handler_map_[engine_id] = handler;
}
virtual IMEEngineHandlerInterface* GetEngineHandler(
const std::string& engine_id) OVERRIDE {
if (engine_id.empty() ||
engine_handler_map_.find(engine_id) == engine_handler_map_.end()) {
return NULL;
}
return engine_handler_map_[engine_id];
}
virtual void SetCurrentEngineHandler(
IMEEngineHandlerInterface* handler) OVERRIDE {
engine_handler_ = handler;
}
virtual IMEEngineHandlerInterface* SetCurrentEngineHandlerById(
const std::string& engine_id) OVERRIDE {
std::map<std::string, IMEEngineHandlerInterface*>::const_iterator itor =
engine_handler_map_.find(engine_id);
if (itor == engine_handler_map_.end()) {
engine_handler_ = NULL;
return NULL;
}
engine_handler_ = engine_handler_map_[engine_id];
return engine_handler_;
}
virtual IMEEngineHandlerInterface* GetCurrentEngineHandler() const OVERRIDE {
return engine_handler_;
}
virtual IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() const
OVERRIDE {
return candidate_window_handler_;
}
virtual void SetCandidateWindowHandler(
IMECandidateWindowHandlerInterface* handler) OVERRIDE {
candidate_window_handler_ = handler;
}
private:
IMEInputContextHandlerInterface* input_context_handler_;
IMEEngineHandlerInterface* engine_handler_;
IMECandidateWindowHandlerInterface* candidate_window_handler_;
std::map<std::string, IMEEngineHandlerInterface*> engine_handler_map_;
DISALLOW_COPY_AND_ASSIGN(IMEBridgeImpl);
};
IMEBridge::IMEBridge() {
}
IMEBridge::~IMEBridge() {
}
void IMEBridge::Initialize() {
if (!g_ime_bridge)
g_ime_bridge = new IMEBridgeImpl();
}
void IMEBridge::Shutdown() {
delete g_ime_bridge;
g_ime_bridge = NULL;
}
IMEBridge* IMEBridge::Get() {
return g_ime_bridge;
}
}