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