| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/input_method/input_method_engine_base.h" | 5 #include "chrome/browser/ui/input_method/input_method_engine_base.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #undef FocusIn | 9 #undef FocusIn |
| 10 #undef FocusOut | 10 #undef FocusOut |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 InputMethodEngineBase::InputMethodEngineBase() | 154 InputMethodEngineBase::InputMethodEngineBase() |
| 155 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 155 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 156 context_id_(0), | 156 context_id_(0), |
| 157 next_context_id_(1), | 157 next_context_id_(1), |
| 158 composition_text_(new ui::CompositionText()), | 158 composition_text_(new ui::CompositionText()), |
| 159 composition_cursor_(0), | 159 composition_cursor_(0), |
| 160 sent_key_event_(nullptr), | 160 sent_key_event_(nullptr), |
| 161 profile_(nullptr), | 161 profile_(nullptr), |
| 162 next_request_id_(1), | 162 next_request_id_(1), |
| 163 composition_changed_(false), |
| 163 text_(""), | 164 text_(""), |
| 165 commit_text_changed_(false), |
| 164 handling_key_event_(false) {} | 166 handling_key_event_(false) {} |
| 165 | 167 |
| 166 InputMethodEngineBase::~InputMethodEngineBase() {} | 168 InputMethodEngineBase::~InputMethodEngineBase() {} |
| 167 | 169 |
| 168 void InputMethodEngineBase::Initialize( | 170 void InputMethodEngineBase::Initialize( |
| 169 std::unique_ptr<InputMethodEngineBase::Observer> observer, | 171 std::unique_ptr<InputMethodEngineBase::Observer> observer, |
| 170 const char* extension_id, | 172 const char* extension_id, |
| 171 Profile* profile) { | 173 Profile* profile) { |
| 172 DCHECK(observer) << "Observer must not be null."; | 174 DCHECK(observer) << "Observer must not be null."; |
| 173 | 175 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 383 } |
| 382 | 384 |
| 383 void InputMethodEngineBase::KeyEventHandled(const std::string& extension_id, | 385 void InputMethodEngineBase::KeyEventHandled(const std::string& extension_id, |
| 384 const std::string& request_id, | 386 const std::string& request_id, |
| 385 bool handled) { | 387 bool handled) { |
| 386 handling_key_event_ = false; | 388 handling_key_event_ = false; |
| 387 // When finish handling key event, take care of the unprocessed commitText | 389 // When finish handling key event, take care of the unprocessed commitText |
| 388 // and setComposition calls. | 390 // and setComposition calls. |
| 389 ui::IMEInputContextHandlerInterface* input_context = | 391 ui::IMEInputContextHandlerInterface* input_context = |
| 390 ui::IMEBridge::Get()->GetInputContextHandler(); | 392 ui::IMEBridge::Get()->GetInputContextHandler(); |
| 391 if (!text_.empty()) { | 393 if (commit_text_changed_) { |
| 392 if (input_context) { | 394 if (input_context) { |
| 393 input_context->CommitText(text_); | 395 input_context->CommitText(text_); |
| 394 } | 396 } |
| 395 text_ = ""; | 397 text_ = ""; |
| 398 commit_text_changed_ = false; |
| 396 } | 399 } |
| 397 | 400 |
| 398 if (!composition_.text.empty()) { | 401 if (composition_changed_) { |
| 399 if (input_context) { | 402 if (input_context) { |
| 400 input_context->UpdateCompositionText( | 403 input_context->UpdateCompositionText( |
| 401 composition_, composition_.selection.start(), true); | 404 composition_, composition_.selection.start(), true); |
| 402 } | 405 } |
| 403 composition_.Clear(); | 406 composition_.Clear(); |
| 407 composition_changed_ = false; |
| 404 } | 408 } |
| 405 | 409 |
| 406 RequestMap::iterator request = request_map_.find(request_id); | 410 RequestMap::iterator request = request_map_.find(request_id); |
| 407 if (request == request_map_.end()) { | 411 if (request == request_map_.end()) { |
| 408 LOG(ERROR) << "Request ID not found: " << request_id; | 412 LOG(ERROR) << "Request ID not found: " << request_id; |
| 409 return; | 413 return; |
| 410 } | 414 } |
| 411 | 415 |
| 412 request->second.second.Run(handled); | 416 request->second.second.Run(handled); |
| 413 request_map_.erase(request); | 417 request_map_.erase(request); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 ui::EventTimeForNow()); | 455 ui::EventTimeForNow()); |
| 452 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_, | 456 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_, |
| 453 &ui_event); | 457 &ui_event); |
| 454 if (!SendKeyEvent(&ui_event, event.code)) | 458 if (!SendKeyEvent(&ui_event, event.code)) |
| 455 return false; | 459 return false; |
| 456 } | 460 } |
| 457 return true; | 461 return true; |
| 458 } | 462 } |
| 459 | 463 |
| 460 } // namespace input_method | 464 } // namespace input_method |
| OLD | NEW |