Commit e05251ec authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Add arc::mojom::InputMethodManager{Host, Instance} interfaces.

This CL adds input_method_manager.mojom file and stub implementation
for InputMethodManagerHost interface.
input_method_manager.mojom file defines the bridge interface
between Chrome OS's InputMethodManager and Android's InputMethodManager.

Bug: 845079
Test: unit_tests
Change-Id: I3d5a25c7774a1258fc0e1494fc351571327a89dd
Reviewed-on: https://chromium-review.googlesource.com/1065560
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarKazuhiro Inaba <kinaba@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560961}
parent 300f4dfb
......@@ -394,6 +394,8 @@ source_set("chromeos") {
"arc/fileapi/file_stream_forwarder.h",
"arc/icon_decode_request.cc",
"arc/icon_decode_request.h",
"arc/input_method_manager/arc_input_method_manager_bridge.cc",
"arc/input_method_manager/arc_input_method_manager_bridge.h",
"arc/intent_helper/arc_external_protocol_dialog.cc",
"arc/intent_helper/arc_external_protocol_dialog.h",
"arc/intent_helper/arc_navigation_throttle.cc",
......@@ -1867,6 +1869,7 @@ source_set("unit_tests") {
"arc/fileapi/arc_file_system_operation_runner_unittest.cc",
"arc/fileapi/chrome_content_provider_url_util_unittest.cc",
"arc/fileapi/file_stream_forwarder_unittest.cc",
"arc/input_method_manager/arc_input_method_manager_bridge_unittest.cc",
"arc/intent_helper/arc_external_protocol_dialog_unittest.cc",
"arc/intent_helper/arc_navigation_throttle_unittest.cc",
"arc/intent_helper/arc_settings_service_unittest.cc",
......
......@@ -21,6 +21,7 @@
#include "chrome/browser/chromeos/arc/enterprise/arc_enterprise_reporting_service.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_bridge.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_mounter.h"
#include "chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_bridge.h"
#include "chrome/browser/chromeos/arc/intent_helper/arc_settings_service.h"
#include "chrome/browser/chromeos/arc/kiosk/arc_kiosk_bridge.h"
#include "chrome/browser/chromeos/arc/notification/arc_boot_error_notification.h"
......@@ -149,6 +150,7 @@ void ArcServiceLauncher::OnPrimaryUserProfilePrepared(Profile* profile) {
ArcFileSystemBridge::GetForBrowserContext(profile);
ArcFileSystemMounter::GetForBrowserContext(profile);
ArcImeService::GetForBrowserContext(profile);
ArcInputMethodManagerBridge::GetForBrowserContext(profile);
ArcIntentHelperBridge::GetForBrowserContext(profile);
ArcKioskBridge::GetForBrowserContext(profile);
ArcLockScreenBridge::GetForBrowserContext(profile);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_bridge.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
namespace arc {
namespace {
// Singleton factory for ArcInputMethodManagerBridge
class ArcInputMethodManagerBridgeFactory
: public internal::ArcBrowserContextKeyedServiceFactoryBase<
ArcInputMethodManagerBridge,
ArcInputMethodManagerBridgeFactory> {
public:
// Factory name used by ArcBrowserContextKeyedServiceFactoryBase
static constexpr const char* kName = "ArcInputMethodManagerBridgeFactory";
static ArcInputMethodManagerBridgeFactory* GetInstance() {
return base::Singleton<ArcInputMethodManagerBridgeFactory>::get();
}
private:
friend base::DefaultSingletonTraits<ArcInputMethodManagerBridgeFactory>;
ArcInputMethodManagerBridgeFactory() = default;
~ArcInputMethodManagerBridgeFactory() override = default;
};
} // anonymous namespace
// static
ArcInputMethodManagerBridge* ArcInputMethodManagerBridge::GetForBrowserContext(
content::BrowserContext* context) {
return ArcInputMethodManagerBridgeFactory::GetForBrowserContext(context);
}
// static
ArcInputMethodManagerBridge*
ArcInputMethodManagerBridge::GetForBrowserContextForTesting(
content::BrowserContext* context) {
return ArcInputMethodManagerBridgeFactory::GetForBrowserContextForTesting(
context);
}
ArcInputMethodManagerBridge::ArcInputMethodManagerBridge(
content::BrowserContext* context,
ArcBridgeService* bridge_service)
: bridge_service_(bridge_service) {
bridge_service_->input_method_manager()->SetHost(this);
}
ArcInputMethodManagerBridge::~ArcInputMethodManagerBridge() {
bridge_service_->input_method_manager()->SetHost(nullptr);
}
void ArcInputMethodManagerBridge::OnActiveImeChanged(
const std::string& ime_id) {
// Please see https://crbug.com/845079.
NOTIMPLEMENTED();
}
void ArcInputMethodManagerBridge::OnImeInfoChanged(
std::vector<mojom::ImeInfoPtr> ime_infos) {
// Please see https://crbug.com/845079.
NOTIMPLEMENTED();
}
} // namespace arc
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ARC_INPUT_METHOD_MANAGER_ARC_INPUT_METHOD_MANAGER_BRIDGE_H_
#define CHROME_BROWSER_CHROMEOS_ARC_INPUT_METHOD_MANAGER_ARC_INPUT_METHOD_MANAGER_BRIDGE_H_
#include <string>
#include "base/macros.h"
#include "components/arc/common/input_method_manager.mojom.h"
#include "components/keyed_service/core/keyed_service.h"
namespace content {
class BrowserContext;
} // namespace content
namespace arc {
class ArcBridgeService;
class ArcInputMethodManagerBridge : public KeyedService,
public mojom::InputMethodManagerHost {
public:
// Returns the instance for the given BrowserContext, or nullptr if the
// browser |context| is not allowed to use ARC.
static ArcInputMethodManagerBridge* GetForBrowserContext(
content::BrowserContext* context);
static ArcInputMethodManagerBridge* GetForBrowserContextForTesting(
content::BrowserContext* context);
ArcInputMethodManagerBridge(content::BrowserContext* context,
ArcBridgeService* bridge_service);
~ArcInputMethodManagerBridge() override;
// mojom::InputMethodManagerHost overrides:
void OnActiveImeChanged(const std::string& ime_id) override;
void OnImeInfoChanged(std::vector<mojom::ImeInfoPtr> ime_infos) override;
private:
ArcBridgeService* const bridge_service_; // Owned by ArcServiceManager
DISALLOW_COPY_AND_ASSIGN(ArcInputMethodManagerBridge);
};
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_INPUT_METHOD_MANAGER_ARC_INPUT_METHOD_MANAGER_BRIDGE_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_bridge.h"
#include <memory>
#include "base/macros.h"
#include "components/arc/arc_service_manager.h"
#include "components/arc/test/test_browser_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace arc {
namespace {
class ArcInputMethodManagerBridgeTest : public testing::Test {
protected:
ArcInputMethodManagerBridgeTest()
: arc_service_manager_(std::make_unique<ArcServiceManager>()),
context_(std::make_unique<TestBrowserContext>()),
service_(ArcInputMethodManagerBridge::GetForBrowserContextForTesting(
context_.get())) {}
~ArcInputMethodManagerBridgeTest() override { service_->Shutdown(); }
ArcInputMethodManagerBridge* service() { return service_; }
private:
content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<ArcServiceManager> arc_service_manager_;
std::unique_ptr<TestBrowserContext> context_;
ArcInputMethodManagerBridge* const service_;
DISALLOW_COPY_AND_ASSIGN(ArcInputMethodManagerBridgeTest);
};
} // anonymous namespace
TEST_F(ArcInputMethodManagerBridgeTest, ConstructAndDestruct) {
// These two method are not implemented yet.
ASSERT_TRUE(service() != nullptr);
service()->OnActiveImeChanged("");
service()->OnImeInfoChanged({});
SUCCEED();
}
} // namespace arc
......@@ -110,6 +110,12 @@ void ArcBridgeHostImpl::OnImeInstanceReady(mojom::ImeInstancePtr ime_ptr) {
OnInstanceReady(arc_bridge_service_->ime(), std::move(ime_ptr));
}
void ArcBridgeHostImpl::OnInputMethodManagerInstanceReady(
mojom::InputMethodManagerInstancePtr input_method_manager_ptr) {
OnInstanceReady(arc_bridge_service_->input_method_manager(),
std::move(input_method_manager_ptr));
}
void ArcBridgeHostImpl::OnIntentHelperInstanceReady(
mojom::IntentHelperInstancePtr intent_helper_ptr) {
OnInstanceReady(arc_bridge_service_->intent_helper(),
......
......@@ -60,6 +60,8 @@ class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
void OnFileSystemInstanceReady(
mojom::FileSystemInstancePtr file_system_ptr) override;
void OnImeInstanceReady(mojom::ImeInstancePtr ime_ptr) override;
void OnInputMethodManagerInstanceReady(
mojom::InputMethodManagerInstancePtr input_method_manager_ptr) override;
void OnIntentHelperInstanceReady(
mojom::IntentHelperInstancePtr intent_helper_ptr) override;
void OnKioskInstanceReady(mojom::KioskInstancePtr kiosk_ptr) override;
......
......@@ -40,6 +40,8 @@ class FileSystemHost;
class FileSystemInstance;
class ImeHost;
class ImeInstance;
class InputMethodManagerHost;
class InputMethodManagerInstance;
class IntentHelperHost;
class IntentHelperInstance;
class KioskHost;
......@@ -144,6 +146,11 @@ class ArcBridgeService {
return &file_system_;
}
ConnectionHolder<mojom::ImeInstance, mojom::ImeHost>* ime() { return &ime_; }
ConnectionHolder<mojom::InputMethodManagerInstance,
mojom::InputMethodManagerHost>*
input_method_manager() {
return &input_method_manager_;
}
ConnectionHolder<mojom::IntentHelperInstance, mojom::IntentHelperHost>*
intent_helper() {
return &intent_helper_;
......@@ -244,6 +251,9 @@ class ArcBridgeService {
ConnectionHolder<mojom::FileSystemInstance, mojom::FileSystemHost>
file_system_;
ConnectionHolder<mojom::ImeInstance, mojom::ImeHost> ime_;
ConnectionHolder<mojom::InputMethodManagerInstance,
mojom::InputMethodManagerHost>
input_method_manager_;
ConnectionHolder<mojom::IntentHelperInstance, mojom::IntentHelperHost>
intent_helper_;
ConnectionHolder<mojom::KioskInstance, mojom::KioskHost> kiosk_;
......
......@@ -26,6 +26,7 @@ if (is_chromeos) {
"enterprise_reporting.mojom",
"file_system.mojom",
"ime.mojom",
"input_method_manager.mojom",
"intent_helper.mojom",
"kiosk.mojom",
"lock_screen.mojom",
......
......@@ -18,6 +18,7 @@ import "components/arc/common/crash_collector.mojom";
import "components/arc/common/enterprise_reporting.mojom";
import "components/arc/common/file_system.mojom";
import "components/arc/common/ime.mojom";
import "components/arc/common/input_method_manager.mojom";
import "components/arc/common/intent_helper.mojom";
import "components/arc/common/kiosk.mojom";
import "components/arc/common/lock_screen.mojom";
......@@ -45,9 +46,9 @@ import "components/arc/common/volume_mounter.mojom";
import "components/arc/common/wake_lock.mojom";
import "components/arc/common/wallpaper.mojom";
// Next MinVersion: 38
// Next MinVersion: 39
// Deprecated method IDs: 101, 105
// Next method ID: 143
// Next method ID: 144
interface ArcBridgeHost {
// Keep the entries alphabetical. In order to do so without breaking
// compatibility with the ARC instance, explicitly assign each interface a
......@@ -102,6 +103,10 @@ interface ArcBridgeHost {
// Notifies Chrome that the ImeInstance interface is ready.
[MinVersion=3] OnImeInstanceReady@110(ImeInstance instance_ptr);
// Notifies Chrome that the InputMethodManagerInstance interface is ready.
[MinVersion=38] OnInputMethodManagerInstanceReady@143(
InputMethodManagerInstance instance_ptr);
// Notifies Chrome that the IntentHelperInstance interface is ready.
[MinVersion=4] OnIntentHelperInstanceReady@111(
IntentHelperInstance instance_ptr);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module arc.mojom;
// Represents the information of an Android IME.
struct ImeInfo {
// The unique ID for the Android IME. Corresponds to InputMethodInfo.getId().
string ime_id;
// The user-displayed label for the IME. Corresponds to
// InputMethodInfo.loadLabel().
string display_name;
// Whether the IME is enabled or not. It's equivalent to whether the IME is
// in ENABLED_INPUT_METHODS settings.
bool enabled;
// intent: URL to open the settings activity of the IME.
string settings_url;
};
// This interface is called by container when Android's InputMethodManager state
// is changed.
// In Android container, ArcInputMethodService IME is pre-installed to bridge
// Chrome OS's IME to Android apps. The bridge is defined in ime.mojom.
//
// Next method ID: 2
interface InputMethodManagerHost {
// Notifies Chrome that active IME in Android is changed.
OnActiveImeChanged@0(string ime_id);
// Notifies Chrome of information of installed IMEs in Android.
// The passed list doesn't contain information of our bridge IME,
// ArcInputMethodService.
OnImeInfoChanged@1(array<ImeInfo> ime_infos);
};
// This interface provides methods to control Android's InputMethodManager.
//
// Next method ID: 3
interface InputMethodManagerInstance {
// Establishes full-duplex communication with the host.
Init@0(InputMethodManagerHost host_ptr) => ();
// Enables/Disables an IME in Android. Calling this method will add/remove
// the specified IME to/from ENABLED_INPUT_METHODS settings.
EnableIme@1(string ime_id, bool enable) => (bool success);
// Switches active IME in Android.
SwitchImeTo@2(string ime_id) => (bool success);
};
......@@ -49,6 +49,9 @@ void FakeArcBridgeHost::OnFileSystemInstanceReady(
void FakeArcBridgeHost::OnImeInstanceReady(mojom::ImeInstancePtr ime_ptr) {}
void FakeArcBridgeHost::OnInputMethodManagerInstanceReady(
mojom::InputMethodManagerInstancePtr input_method_manager_ptr) {}
void FakeArcBridgeHost::OnIntentHelperInstanceReady(
mojom::IntentHelperInstancePtr intent_helper_ptr) {}
......
......@@ -40,6 +40,8 @@ class FakeArcBridgeHost : public mojom::ArcBridgeHost {
void OnFileSystemInstanceReady(
mojom::FileSystemInstancePtr file_system_ptr) override;
void OnImeInstanceReady(mojom::ImeInstancePtr ime_ptr) override;
void OnInputMethodManagerInstanceReady(
mojom::InputMethodManagerInstancePtr input_method_manager_ptr) override;
void OnIntentHelperInstanceReady(
mojom::IntentHelperInstancePtr intent_helper_ptr) override;
void OnKioskInstanceReady(mojom::KioskInstancePtr kiosk_ptr) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment