OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/base/ime/chromeos/ime_bridge.h" | 5 #include "ui/base/ime/chromeos/ime_bridge.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 | 10 |
11 namespace chromeos { | 11 namespace chromeos { |
12 | 12 |
13 static IMEBridge* g_ime_bridge = NULL; | 13 static IMEBridge* g_ime_bridge = NULL; |
14 | 14 |
15 // An implementation of IMEBridge. | 15 // An implementation of IMEBridge. |
16 class IMEBridgeImpl : public IMEBridge { | 16 class IMEBridgeImpl : public IMEBridge { |
17 public: | 17 public: |
18 IMEBridgeImpl() | 18 IMEBridgeImpl() |
19 : input_context_handler_(NULL), | 19 : input_context_handler_(NULL), |
20 engine_handler_(NULL), | 20 engine_handler_(NULL), |
21 candidate_window_handler_(NULL), | 21 candidate_window_handler_(NULL), |
22 current_text_input_(ui::TEXT_INPUT_TYPE_NONE) { | 22 current_text_input_(ui::TEXT_INPUT_TYPE_NONE) { |
23 } | 23 } |
24 | 24 |
25 virtual ~IMEBridgeImpl() { | 25 ~IMEBridgeImpl() override {} |
26 } | |
27 | 26 |
28 // IMEBridge override. | 27 // IMEBridge override. |
29 virtual IMEInputContextHandlerInterface* | 28 IMEInputContextHandlerInterface* GetInputContextHandler() const override { |
30 GetInputContextHandler() const override { | |
31 return input_context_handler_; | 29 return input_context_handler_; |
32 } | 30 } |
33 | 31 |
34 // IMEBridge override. | 32 // IMEBridge override. |
35 virtual void SetInputContextHandler( | 33 void SetInputContextHandler( |
36 IMEInputContextHandlerInterface* handler) override { | 34 IMEInputContextHandlerInterface* handler) override { |
37 input_context_handler_ = handler; | 35 input_context_handler_ = handler; |
38 } | 36 } |
39 | 37 |
40 // IMEBridge override. | 38 // IMEBridge override. |
41 virtual void SetCurrentEngineHandler( | 39 void SetCurrentEngineHandler(IMEEngineHandlerInterface* handler) override { |
42 IMEEngineHandlerInterface* handler) override { | |
43 engine_handler_ = handler; | 40 engine_handler_ = handler; |
44 } | 41 } |
45 | 42 |
46 // IMEBridge override. | 43 // IMEBridge override. |
47 virtual IMEEngineHandlerInterface* GetCurrentEngineHandler() const override { | 44 IMEEngineHandlerInterface* GetCurrentEngineHandler() const override { |
48 return engine_handler_; | 45 return engine_handler_; |
49 } | 46 } |
50 | 47 |
51 // IMEBridge override. | 48 // IMEBridge override. |
52 virtual IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() const | 49 IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() |
53 override { | 50 const override { |
54 return candidate_window_handler_; | 51 return candidate_window_handler_; |
55 } | 52 } |
56 | 53 |
57 // IMEBridge override. | 54 // IMEBridge override. |
58 virtual void SetCandidateWindowHandler( | 55 void SetCandidateWindowHandler( |
59 IMECandidateWindowHandlerInterface* handler) override { | 56 IMECandidateWindowHandlerInterface* handler) override { |
60 candidate_window_handler_ = handler; | 57 candidate_window_handler_ = handler; |
61 } | 58 } |
62 | 59 |
63 // IMEBridge override. | 60 // IMEBridge override. |
64 virtual void SetCurrentTextInputType(ui::TextInputType input_type) override { | 61 void SetCurrentTextInputType(ui::TextInputType input_type) override { |
65 current_text_input_ = input_type; | 62 current_text_input_ = input_type; |
66 } | 63 } |
67 | 64 |
68 // IMEBridge override. | 65 // IMEBridge override. |
69 virtual ui::TextInputType GetCurrentTextInputType() const override { | 66 ui::TextInputType GetCurrentTextInputType() const override { |
70 return current_text_input_; | 67 return current_text_input_; |
71 } | 68 } |
72 | 69 |
73 private: | 70 private: |
74 IMEInputContextHandlerInterface* input_context_handler_; | 71 IMEInputContextHandlerInterface* input_context_handler_; |
75 IMEEngineHandlerInterface* engine_handler_; | 72 IMEEngineHandlerInterface* engine_handler_; |
76 IMECandidateWindowHandlerInterface* candidate_window_handler_; | 73 IMECandidateWindowHandlerInterface* candidate_window_handler_; |
77 ui::TextInputType current_text_input_; | 74 ui::TextInputType current_text_input_; |
78 | 75 |
79 DISALLOW_COPY_AND_ASSIGN(IMEBridgeImpl); | 76 DISALLOW_COPY_AND_ASSIGN(IMEBridgeImpl); |
(...skipping 18 matching lines...) Expand all Loading... |
98 delete g_ime_bridge; | 95 delete g_ime_bridge; |
99 g_ime_bridge = NULL; | 96 g_ime_bridge = NULL; |
100 } | 97 } |
101 | 98 |
102 // static. | 99 // static. |
103 IMEBridge* IMEBridge::Get() { | 100 IMEBridge* IMEBridge::Get() { |
104 return g_ime_bridge; | 101 return g_ime_bridge; |
105 } | 102 } |
106 | 103 |
107 } // namespace chromeos | 104 } // namespace chromeos |
OLD | NEW |