Commit 787953e1 authored by Leo Zhang's avatar Leo Zhang Committed by Commit Bot

Remove ime_service_connector from state.

Store connector instances inside a map of InputMethodManager then remove
the instance of ime service connector from InputMethodManager::State.

Test: Test IME service on VM (betty).
Bug: 1139328
Change-Id: I32057af4ac75fa5f3392741e87004559290f4494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2509071Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Leo Zhang <googleo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829875}
parent 500376ce
......@@ -901,14 +901,6 @@ void InputMethodManagerImpl::StateImpl::ResetInputViewUrl() {
input_view_url_overridden = false;
}
void InputMethodManagerImpl::StateImpl::ConnectMojoManager(
mojo::PendingReceiver<chromeos::ime::mojom::InputEngineManager> receiver) {
if (!ime_service_connector_) {
ime_service_connector_ = std::make_unique<ImeServiceConnector>(profile);
}
ime_service_connector_->SetupImeService(std::move(receiver));
}
// ------------------------ InputMethodManagerImpl
bool InputMethodManagerImpl::IsLoginKeyboard(
const std::string& layout) const {
......@@ -1197,7 +1189,15 @@ void InputMethodManagerImpl::ActivateInputMethodMenuItem(
void InputMethodManagerImpl::ConnectInputEngineManager(
mojo::PendingReceiver<chromeos::ime::mojom::InputEngineManager> receiver) {
DCHECK(state_);
state_->ConnectMojoManager(std::move(receiver));
ImeServiceConnectorMap::iterator iter =
ime_service_connectors_.find(state_->profile);
if (iter == ime_service_connectors_.end()) {
auto connector_ = std::make_unique<ImeServiceConnector>(state_->profile);
iter = ime_service_connectors_
.insert(std::make_pair(state_->profile, std::move(connector_)))
.first;
}
iter->second->SetupImeService(std::move(receiver));
}
bool InputMethodManagerImpl::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
......
......@@ -129,11 +129,6 @@ class InputMethodManagerImpl : public InputMethodManager,
// Reset the input view URL to the default url of the current input method.
void ResetInputViewUrl();
// Connect to an InputEngineManager instance in an IME Mojo service.
void ConnectMojoManager(
mojo::PendingReceiver<chromeos::ime::mojom::InputEngineManager>
receiver);
// ------------------------- Data members.
Profile* const profile;
......@@ -188,8 +183,6 @@ class InputMethodManagerImpl : public InputMethodManager,
InputMethodManager::UIStyle ui_style_ =
InputMethodManager::UIStyle::kNormal;
std::unique_ptr<ImeServiceConnector> ime_service_connector_;
// Do not forget to update StateImpl::InitFrom(const StateImpl& other) and
// StateImpl::Dump() when adding new data members!!!
};
......@@ -355,6 +348,12 @@ class InputMethodManagerImpl : public InputMethodManager,
using ProfileEngineMap = std::map<Profile*, EngineMap, ProfileCompare>;
ProfileEngineMap engine_map_;
// Map a profile to the IME service connector.
typedef std::
map<Profile*, std::unique_ptr<ImeServiceConnector>, ProfileCompare>
ImeServiceConnectorMap;
ImeServiceConnectorMap ime_service_connectors_;
content::NotificationRegistrar notification_registrar_;
DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl);
......
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