OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/input_ime/input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "extensions/common/manifest_handlers/background_info.h" | 21 #include "extensions/common/manifest_handlers/background_info.h" |
22 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" | 22 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" |
23 #include "ui/base/ime/chromeos/extension_ime_util.h" | 23 #include "ui/base/ime/chromeos/extension_ime_util.h" |
24 #include "ui/base/ime/chromeos/input_method_manager.h" | 24 #include "ui/base/ime/chromeos/input_method_manager.h" |
25 #include "ui/base/ime/ime_engine_handler_interface.h" | 25 #include "ui/base/ime/ime_engine_handler_interface.h" |
26 | 26 |
27 namespace input_ime = extensions::api::input_ime; | 27 namespace input_ime = extensions::api::input_ime; |
28 namespace DeleteSurroundingText = | 28 namespace DeleteSurroundingText = |
29 extensions::api::input_ime::DeleteSurroundingText; | 29 extensions::api::input_ime::DeleteSurroundingText; |
30 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; | 30 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; |
31 namespace SendKeyEvents = extensions::api::input_ime::SendKeyEvents; | |
32 namespace HideInputView = extensions::api::input_ime::HideInputView; | 31 namespace HideInputView = extensions::api::input_ime::HideInputView; |
33 namespace SetMenuItems = extensions::api::input_ime::SetMenuItems; | 32 namespace SetMenuItems = extensions::api::input_ime::SetMenuItems; |
34 namespace SetCursorPosition = extensions::api::input_ime::SetCursorPosition; | 33 namespace SetCursorPosition = extensions::api::input_ime::SetCursorPosition; |
35 namespace SetCandidates = extensions::api::input_ime::SetCandidates; | 34 namespace SetCandidates = extensions::api::input_ime::SetCandidates; |
36 namespace SetCandidateWindowProperties = | 35 namespace SetCandidateWindowProperties = |
37 extensions::api::input_ime::SetCandidateWindowProperties; | 36 extensions::api::input_ime::SetCandidateWindowProperties; |
38 namespace ClearComposition = extensions::api::input_ime::ClearComposition; | 37 namespace ClearComposition = extensions::api::input_ime::ClearComposition; |
39 namespace OnCompositionBoundsChanged = | 38 namespace OnCompositionBoundsChanged = |
40 extensions::api::input_method_private::OnCompositionBoundsChanged; | 39 extensions::api::input_method_private::OnCompositionBoundsChanged; |
41 namespace NotifyImeMenuItemActivated = | 40 namespace NotifyImeMenuItemActivated = |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 bool InputImeHideInputViewFunction::RunAsync() { | 370 bool InputImeHideInputViewFunction::RunAsync() { |
372 InputMethodEngine* engine = GetActiveEngine( | 371 InputMethodEngine* engine = GetActiveEngine( |
373 Profile::FromBrowserContext(browser_context()), extension_id()); | 372 Profile::FromBrowserContext(browser_context()), extension_id()); |
374 if (!engine) { | 373 if (!engine) { |
375 return true; | 374 return true; |
376 } | 375 } |
377 engine->HideInputView(); | 376 engine->HideInputView(); |
378 return true; | 377 return true; |
379 } | 378 } |
380 | 379 |
381 bool InputImeSendKeyEventsFunction::RunAsync() { | |
382 scoped_ptr<SendKeyEvents::Params> parent_params( | |
383 SendKeyEvents::Params::Create(*args_)); | |
384 const SendKeyEvents::Params::Parameters& params = | |
385 parent_params->parameters; | |
386 InputMethodEngine* engine = GetActiveEngine( | |
387 Profile::FromBrowserContext(browser_context()), extension_id()); | |
388 if (!engine) { | |
389 error_ = kErrorEngineNotAvailable; | |
390 return false; | |
391 } | |
392 | |
393 const std::vector<linked_ptr<input_ime::KeyboardEvent> >& key_data = | |
394 params.key_data; | |
395 std::vector<InputMethodEngineBase::KeyboardEvent> key_data_out; | |
396 | |
397 for (size_t i = 0; i < key_data.size(); ++i) { | |
398 InputMethodEngineBase::KeyboardEvent event; | |
399 event.type = input_ime::ToString(key_data[i]->type); | |
400 event.key = key_data[i]->key; | |
401 event.code = key_data[i]->code; | |
402 event.key_code = key_data[i]->key_code.get() ? *(key_data[i]->key_code) : 0; | |
403 if (key_data[i]->alt_key) | |
404 event.alt_key = *(key_data[i]->alt_key); | |
405 if (key_data[i]->ctrl_key) | |
406 event.ctrl_key = *(key_data[i]->ctrl_key); | |
407 if (key_data[i]->shift_key) | |
408 event.shift_key = *(key_data[i]->shift_key); | |
409 if (key_data[i]->caps_lock) | |
410 event.caps_lock = *(key_data[i]->caps_lock); | |
411 key_data_out.push_back(event); | |
412 } | |
413 | |
414 engine->SendKeyEvents(params.context_id, key_data_out); | |
415 return true; | |
416 } | |
417 | |
418 bool InputImeSetCandidateWindowPropertiesFunction::RunSync() { | 380 bool InputImeSetCandidateWindowPropertiesFunction::RunSync() { |
419 scoped_ptr<SetCandidateWindowProperties::Params> parent_params( | 381 scoped_ptr<SetCandidateWindowProperties::Params> parent_params( |
420 SetCandidateWindowProperties::Params::Create(*args_)); | 382 SetCandidateWindowProperties::Params::Create(*args_)); |
421 const SetCandidateWindowProperties::Params::Parameters& | 383 const SetCandidateWindowProperties::Params::Parameters& |
422 params = parent_params->parameters; | 384 params = parent_params->parameters; |
423 | 385 |
424 InputImeEventRouter* event_router = | 386 InputImeEventRouter* event_router = |
425 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); | 387 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); |
426 InputMethodEngine* engine = | 388 InputMethodEngine* engine = |
427 event_router ? event_router->GetEngine(extension_id(), params.engine_id) | 389 event_router ? event_router->GetEngine(extension_id(), params.engine_id) |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 return; | 626 return; |
665 InputMethodEngine* engine = | 627 InputMethodEngine* engine = |
666 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), | 628 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), |
667 details.extension_id); | 629 details.extension_id); |
668 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 630 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
669 if (engine) | 631 if (engine) |
670 engine->Enable(engine->GetActiveComponentId()); | 632 engine->Enable(engine->GetActiveComponentId()); |
671 } | 633 } |
672 | 634 |
673 } // namespace extensions | 635 } // namespace extensions |
OLD | NEW |