| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/chromeos/input_method/input_method_engine.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 class InputMethodEngineImpl | 48 class InputMethodEngineImpl |
| 49 : public InputMethodEngine, | 49 : public InputMethodEngine, |
| 50 public input_method::IBusEngineController::Observer { | 50 public input_method::IBusEngineController::Observer { |
| 51 public: | 51 public: |
| 52 InputMethodEngineImpl() | 52 InputMethodEngineImpl() |
| 53 : observer_(NULL), active_(false), next_context_id_(1), | 53 : observer_(NULL), active_(false), next_context_id_(1), |
| 54 context_id_(-1) {} | 54 context_id_(-1) {} |
| 55 | 55 |
| 56 ~InputMethodEngineImpl() { | 56 ~InputMethodEngineImpl() { |
| 57 input_method::InputMethodManager::GetInstance()->RemoveActiveIme(ibus_id_); | 57 input_method::InputMethodManager* manager = |
| 58 input_method::InputMethodManager::GetInstance(); |
| 59 manager->RemoveInputMethodExtension(ibus_id_); |
| 58 } | 60 } |
| 59 | 61 |
| 60 bool Init(InputMethodEngine::Observer* observer, | 62 bool Init(InputMethodEngine::Observer* observer, |
| 61 const char* engine_name, | 63 const char* engine_name, |
| 62 const char* extension_id, | 64 const char* extension_id, |
| 63 const char* engine_id, | 65 const char* engine_id, |
| 64 const char* description, | 66 const char* description, |
| 65 const char* language, | 67 const char* language, |
| 66 const std::vector<std::string>& layouts, | 68 const std::vector<std::string>& layouts, |
| 67 std::string* error); | 69 std::string* error); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 description, | 174 description, |
| 173 language, | 175 language, |
| 174 layout.c_str())); | 176 layout.c_str())); |
| 175 if (!connection_.get()) { | 177 if (!connection_.get()) { |
| 176 *error = "ConnectInputMethodExtension() failed."; | 178 *error = "ConnectInputMethodExtension() failed."; |
| 177 return false; | 179 return false; |
| 178 } | 180 } |
| 179 | 181 |
| 180 observer_ = observer; | 182 observer_ = observer; |
| 181 engine_id_ = engine_id; | 183 engine_id_ = engine_id; |
| 182 manager->AddActiveIme(ibus_id_, engine_name, layouts, language); | 184 manager->AddInputMethodExtension(ibus_id_, engine_name, layouts, language); |
| 183 return true; | 185 return true; |
| 184 } | 186 } |
| 185 | 187 |
| 186 bool InputMethodEngineImpl::SetComposition( | 188 bool InputMethodEngineImpl::SetComposition( |
| 187 int context_id, | 189 int context_id, |
| 188 const char* text, | 190 const char* text, |
| 189 int selection_start, | 191 int selection_start, |
| 190 int selection_end, | 192 int selection_end, |
| 191 int cursor, | 193 int cursor, |
| 192 const std::vector<SegmentInfo>& segments, | 194 const std::vector<SegmentInfo>& segments, |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 description, language, layouts, error)) { | 656 description, language, layouts, error)) { |
| 655 LOG(ERROR) << "Init() failed."; | 657 LOG(ERROR) << "Init() failed."; |
| 656 delete new_engine; | 658 delete new_engine; |
| 657 new_engine = NULL; | 659 new_engine = NULL; |
| 658 } | 660 } |
| 659 | 661 |
| 660 return new_engine; | 662 return new_engine; |
| 661 } | 663 } |
| 662 | 664 |
| 663 } // namespace chromeos | 665 } // namespace chromeos |
| OLD | NEW |