OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/remote_input_method_win.h" | 5 #include "ui/base/ime/remote_input_method_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/metro.h" | 10 #include "base/win/metro.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 if (event->is_char()) { | 194 if (event->is_char()) { |
195 if (text_input_client_) { | 195 if (text_input_client_) { |
196 text_input_client_->InsertChar( | 196 text_input_client_->InsertChar( |
197 event->GetCharacter(), | 197 event->GetCharacter(), |
198 ui::GetModifiersFromKeyState()); | 198 ui::GetModifiersFromKeyState()); |
199 } | 199 } |
200 event->StopPropagation(); | 200 event->StopPropagation(); |
201 return; | 201 return; |
202 } | 202 } |
203 if (delegate_) | 203 if (delegate_) { |
204 ignore_result(delegate_->DispatchKeyEventPostIME(event)); | 204 ignore_result(delegate_->DispatchKeyEventPostIME(event)); |
| 205 if (text_input_client_ && pending_char_events_.size()) { |
| 206 for (size_t i = 0; i < pending_char_events_.size(); ++i) { |
| 207 text_input_client_->InsertChar( |
| 208 pending_char_events_[i], event->flags()); |
| 209 } |
| 210 event->StopPropagation(); |
| 211 } |
| 212 } |
| 213 pending_char_events_.clear(); |
205 } | 214 } |
206 | 215 |
207 void OnTextInputTypeChanged(const TextInputClient* client) override { | 216 void OnTextInputTypeChanged(const TextInputClient* client) override { |
208 if (!text_input_client_ || text_input_client_ != client) | 217 if (!text_input_client_ || text_input_client_ != client) |
209 return; | 218 return; |
210 std::vector<int32> prev_input_scopes; | 219 std::vector<int32> prev_input_scopes; |
211 std::swap(input_scopes_, prev_input_scopes); | 220 std::swap(input_scopes_, prev_input_scopes); |
212 input_scopes_ = GetInputScopesAsInt(client->GetTextInputType(), | 221 input_scopes_ = GetInputScopesAsInt(client->GetTextInputType(), |
213 client->GetTextInputMode()); | 222 client->GetTextInputMode()); |
214 if (input_scopes_ != prev_input_scopes && remote_delegate_) { | 223 if (input_scopes_ != prev_input_scopes && remote_delegate_) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // According to the comment in text_input_client.h, | 328 // According to the comment in text_input_client.h, |
320 // TextInputClient::InsertText should never be called when the | 329 // TextInputClient::InsertText should never be called when the |
321 // text input type is TEXT_INPUT_TYPE_NONE. | 330 // text input type is TEXT_INPUT_TYPE_NONE. |
322 for (size_t i = 0; i < text.size(); ++i) | 331 for (size_t i = 0; i < text.size(); ++i) |
323 text_input_client_->InsertChar(text[i], 0); | 332 text_input_client_->InsertChar(text[i], 0); |
324 return; | 333 return; |
325 } | 334 } |
326 text_input_client_->InsertText(text); | 335 text_input_client_->InsertText(text); |
327 } | 336 } |
328 | 337 |
| 338 void OnCharForNextKeyEvent(base::char16 ch) override { |
| 339 pending_char_events_.push_back(ch); |
| 340 } |
| 341 |
329 bool CanSendRemoteNotification( | 342 bool CanSendRemoteNotification( |
330 const TextInputClient* text_input_client) const { | 343 const TextInputClient* text_input_client) const { |
331 return text_input_client_ && | 344 return text_input_client_ && |
332 text_input_client_ == text_input_client && | 345 text_input_client_ == text_input_client && |
333 remote_delegate_; | 346 remote_delegate_; |
334 } | 347 } |
335 | 348 |
336 base::ObserverList<InputMethodObserver> observer_list_; | 349 base::ObserverList<InputMethodObserver> observer_list_; |
337 | 350 |
338 internal::InputMethodDelegate* delegate_; | 351 internal::InputMethodDelegate* delegate_; |
339 internal::RemoteInputMethodDelegateWin* remote_delegate_; | 352 internal::RemoteInputMethodDelegateWin* remote_delegate_; |
340 | 353 |
341 TextInputClient* text_input_client_; | 354 TextInputClient* text_input_client_; |
342 std::vector<int32> input_scopes_; | 355 std::vector<int32> input_scopes_; |
343 std::vector<gfx::Rect> composition_character_bounds_; | 356 std::vector<gfx::Rect> composition_character_bounds_; |
344 bool is_candidate_popup_open_; | 357 bool is_candidate_popup_open_; |
345 bool is_ime_; | 358 bool is_ime_; |
346 LANGID langid_; | 359 LANGID langid_; |
| 360 std::vector<base::char16> pending_char_events_; |
347 | 361 |
348 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); | 362 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); |
349 }; | 363 }; |
350 | 364 |
351 } // namespace | 365 } // namespace |
352 | 366 |
353 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget) { | 367 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget) { |
354 // If the remote input method is already registered then don't do it again. | 368 // If the remote input method is already registered then don't do it again. |
355 if (ui::g_public_interface_ && ui::g_private_interface_) | 369 if (ui::g_public_interface_ && ui::g_private_interface_) |
356 return false; | 370 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
374 return make_scoped_ptr(new RemoteInputMethodWin(delegate)); | 388 return make_scoped_ptr(new RemoteInputMethodWin(delegate)); |
375 } | 389 } |
376 | 390 |
377 // static | 391 // static |
378 RemoteInputMethodPrivateWin* RemoteInputMethodPrivateWin::Get( | 392 RemoteInputMethodPrivateWin* RemoteInputMethodPrivateWin::Get( |
379 InputMethod* input_method) { | 393 InputMethod* input_method) { |
380 return GetPrivate(input_method); | 394 return GetPrivate(input_method); |
381 } | 395 } |
382 | 396 |
383 } // namespace ui | 397 } // namespace ui |
OLD | NEW |