connection_factory.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/services/ime/connection_factory.h"
  5. #include <utility>
  6. namespace ash {
  7. namespace ime {
  8. ConnectionFactory::ConnectionFactory(
  9. mojo::PendingReceiver<mojom::ConnectionFactory> pending_receiver)
  10. : receiver_(this, std::move(pending_receiver)) {}
  11. ConnectionFactory::~ConnectionFactory() = default;
  12. void ConnectionFactory::ConnectToInputMethod(
  13. const std::string& ime_spec,
  14. mojo::PendingAssociatedReceiver<mojom::InputMethod> pending_input_method,
  15. mojo::PendingAssociatedRemote<mojom::InputMethodHost>
  16. pending_input_method_host,
  17. mojom::InputMethodSettingsPtr settings,
  18. ConnectToInputMethodCallback callback) {
  19. // `settings` is unused because Rule-Based IMEs do not have settings.
  20. rule_based_engine_ =
  21. RuleBasedEngine::Create(ime_spec, std::move(pending_input_method),
  22. std::move(pending_input_method_host));
  23. std::move(callback).Run(/*bound=*/true);
  24. }
  25. bool ConnectionFactory::IsConnected() {
  26. return rule_based_engine_ && rule_based_engine_->IsConnected();
  27. }
  28. } // namespace ime
  29. } // namespace ash