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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 if (!engine) { | 363 if (!engine) { |
364 return RespondNow( | 364 return RespondNow( |
365 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); | 365 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); |
366 } | 366 } |
367 | 367 |
368 std::unique_ptr<ClearComposition::Params> parent_params( | 368 std::unique_ptr<ClearComposition::Params> parent_params( |
369 ClearComposition::Params::Create(*args_)); | 369 ClearComposition::Params::Create(*args_)); |
370 const ClearComposition::Params::Parameters& params = | 370 const ClearComposition::Params::Parameters& params = |
371 parent_params->parameters; | 371 parent_params->parameters; |
372 | 372 |
373 return RespondNow(OneArgument(base::MakeUnique<base::FundamentalValue>( | 373 std::string error; |
374 engine->ClearComposition(params.context_id, &error_)))); | 374 bool success = engine->ClearComposition(params.context_id, &error); |
375 SetError(error); | |
lazyboy
2016/09/30 01:16:04
if (!success) SetError(), unless I'm missing somet
Devlin
2016/09/30 18:29:09
In this CL, I was trying to keep things as close t
lazyboy
2016/09/30 20:43:32
The only implementation (non-mock) of ClearComposi
Devlin
2016/10/01 01:03:39
Acknowledged.
| |
376 return RespondNow( | |
377 OneArgument(base::MakeUnique<base::FundamentalValue>(success))); | |
375 } | 378 } |
376 | 379 |
377 bool InputImeHideInputViewFunction::RunAsync() { | 380 bool InputImeHideInputViewFunction::RunAsync() { |
378 InputMethodEngine* engine = GetActiveEngine( | 381 InputMethodEngine* engine = GetActiveEngine( |
379 Profile::FromBrowserContext(browser_context()), extension_id()); | 382 Profile::FromBrowserContext(browser_context()), extension_id()); |
380 if (!engine) { | 383 if (!engine) { |
381 return true; | 384 return true; |
382 } | 385 } |
383 engine->HideInputView(); | 386 engine->HideInputView(); |
384 return true; | 387 return true; |
(...skipping 12 matching lines...) Expand all Loading... | |
397 event_router ? event_router->GetEngine(extension_id(), params.engine_id) | 400 event_router ? event_router->GetEngine(extension_id(), params.engine_id) |
398 : nullptr; | 401 : nullptr; |
399 if (!engine) { | 402 if (!engine) { |
400 return RespondNow( | 403 return RespondNow( |
401 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); | 404 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); |
402 } | 405 } |
403 | 406 |
404 const SetCandidateWindowProperties::Params::Parameters::Properties& | 407 const SetCandidateWindowProperties::Params::Parameters::Properties& |
405 properties = params.properties; | 408 properties = params.properties; |
406 | 409 |
410 std::string error; | |
407 if (properties.visible && | 411 if (properties.visible && |
408 !engine->SetCandidateWindowVisible(*properties.visible, &error_)) { | 412 !engine->SetCandidateWindowVisible(*properties.visible, &error)) { |
413 SetError(error); | |
409 return RespondNow( | 414 return RespondNow( |
410 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); | 415 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); |
411 } | 416 } |
412 | 417 |
413 InputMethodEngine::CandidateWindowProperty properties_out = | 418 InputMethodEngine::CandidateWindowProperty properties_out = |
414 engine->GetCandidateWindowProperty(); | 419 engine->GetCandidateWindowProperty(); |
415 bool modified = false; | 420 bool modified = false; |
416 | 421 |
417 if (properties.cursor_visible) { | 422 if (properties.cursor_visible) { |
418 properties_out.is_cursor_visible = *properties.cursor_visible; | 423 properties_out.is_cursor_visible = *properties.cursor_visible; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 if (candidate_in.label) | 482 if (candidate_in.label) |
478 candidates_out.back().label = *candidate_in.label; | 483 candidates_out.back().label = *candidate_in.label; |
479 if (candidate_in.annotation) | 484 if (candidate_in.annotation) |
480 candidates_out.back().annotation = *candidate_in.annotation; | 485 candidates_out.back().annotation = *candidate_in.annotation; |
481 if (candidate_in.usage) { | 486 if (candidate_in.usage) { |
482 candidates_out.back().usage.title = candidate_in.usage->title; | 487 candidates_out.back().usage.title = candidate_in.usage->title; |
483 candidates_out.back().usage.body = candidate_in.usage->body; | 488 candidates_out.back().usage.body = candidate_in.usage->body; |
484 } | 489 } |
485 } | 490 } |
486 | 491 |
487 return RespondNow(OneArgument(base::MakeUnique<base::FundamentalValue>( | 492 std::string error; |
488 engine->SetCandidates(params.context_id, candidates_out, &error_)))); | 493 bool success = |
494 engine->SetCandidates(params.context_id, candidates_out, &error); | |
495 SetError(error); | |
lazyboy
2016/09/30 01:16:04
Same here and in other places.
Unless we implicitl
Devlin
2016/09/30 18:29:09
Done.
| |
496 return RespondNow( | |
497 OneArgument(base::MakeUnique<base::FundamentalValue>(success))); | |
489 } | 498 } |
490 | 499 |
491 ExtensionFunction::ResponseAction InputImeSetCursorPositionFunction::Run() { | 500 ExtensionFunction::ResponseAction InputImeSetCursorPositionFunction::Run() { |
492 InputMethodEngine* engine = GetActiveEngine( | 501 InputMethodEngine* engine = GetActiveEngine( |
493 Profile::FromBrowserContext(browser_context()), extension_id()); | 502 Profile::FromBrowserContext(browser_context()), extension_id()); |
494 if (!engine) { | 503 if (!engine) { |
495 return RespondNow( | 504 return RespondNow( |
496 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); | 505 OneArgument(base::MakeUnique<base::FundamentalValue>(false))); |
497 } | 506 } |
498 | 507 |
499 std::unique_ptr<SetCursorPosition::Params> parent_params( | 508 std::unique_ptr<SetCursorPosition::Params> parent_params( |
500 SetCursorPosition::Params::Create(*args_)); | 509 SetCursorPosition::Params::Create(*args_)); |
501 const SetCursorPosition::Params::Parameters& params = | 510 const SetCursorPosition::Params::Parameters& params = |
502 parent_params->parameters; | 511 parent_params->parameters; |
503 | 512 |
504 return RespondNow(OneArgument( | 513 std::string error; |
505 base::MakeUnique<base::FundamentalValue>(engine->SetCursorPosition( | 514 bool success = |
506 params.context_id, params.candidate_id, &error_)))); | 515 engine->SetCursorPosition(params.context_id, params.candidate_id, &error); |
516 SetError(error); | |
517 return RespondNow( | |
518 OneArgument(base::MakeUnique<base::FundamentalValue>(success))); | |
507 } | 519 } |
508 | 520 |
509 ExtensionFunction::ResponseAction InputImeSetMenuItemsFunction::Run() { | 521 ExtensionFunction::ResponseAction InputImeSetMenuItemsFunction::Run() { |
510 std::unique_ptr<SetMenuItems::Params> parent_params( | 522 std::unique_ptr<SetMenuItems::Params> parent_params( |
511 SetMenuItems::Params::Create(*args_)); | 523 SetMenuItems::Params::Create(*args_)); |
512 const SetMenuItems::Params::Parameters& params = | 524 const SetMenuItems::Params::Parameters& params = |
513 parent_params->parameters; | 525 parent_params->parameters; |
514 | 526 |
515 InputImeEventRouter* event_router = | 527 InputImeEventRouter* event_router = |
516 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); | 528 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 parent_params->parameters; | 575 parent_params->parameters; |
564 | 576 |
565 InputImeEventRouter* event_router = | 577 InputImeEventRouter* event_router = |
566 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); | 578 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); |
567 InputMethodEngine* engine = | 579 InputMethodEngine* engine = |
568 event_router ? event_router->GetEngine(extension_id(), params.engine_id) | 580 event_router ? event_router->GetEngine(extension_id(), params.engine_id) |
569 : nullptr; | 581 : nullptr; |
570 if (!engine) | 582 if (!engine) |
571 return RespondNow(Error(kErrorEngineNotAvailable)); | 583 return RespondNow(Error(kErrorEngineNotAvailable)); |
572 | 584 |
585 std::string error; | |
573 engine->DeleteSurroundingText(params.context_id, params.offset, params.length, | 586 engine->DeleteSurroundingText(params.context_id, params.offset, params.length, |
574 &error_); | 587 &error); |
588 SetError(error); | |
575 return RespondNow(NoArguments()); | 589 return RespondNow(NoArguments()); |
576 } | 590 } |
577 | 591 |
578 ExtensionFunction::ResponseAction | 592 ExtensionFunction::ResponseAction |
579 InputMethodPrivateNotifyImeMenuItemActivatedFunction::Run() { | 593 InputMethodPrivateNotifyImeMenuItemActivatedFunction::Run() { |
580 chromeos::input_method::InputMethodDescriptor current_input_method = | 594 chromeos::input_method::InputMethodDescriptor current_input_method = |
581 chromeos::input_method::InputMethodManager::Get() | 595 chromeos::input_method::InputMethodManager::Get() |
582 ->GetActiveIMEState() | 596 ->GetActiveIMEState() |
583 ->GetCurrentInputMethod(); | 597 ->GetCurrentInputMethod(); |
584 std::string active_extension_id = | 598 std::string active_extension_id = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 return; | 641 return; |
628 InputMethodEngine* engine = | 642 InputMethodEngine* engine = |
629 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), | 643 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), |
630 details.extension_id); | 644 details.extension_id); |
631 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 645 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
632 if (engine) | 646 if (engine) |
633 engine->Enable(engine->GetActiveComponentId()); | 647 engine->Enable(engine->GetActiveComponentId()); |
634 } | 648 } |
635 | 649 |
636 } // namespace extensions | 650 } // namespace extensions |
OLD | NEW |