summaryrefslogtreecommitdiff
path: root/chromium/components/arc/ime
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/arc/ime')
-rw-r--r--chromium/components/arc/ime/arc_ime_service.cc31
-rw-r--r--chromium/components/arc/ime/arc_ime_service.h22
-rw-r--r--chromium/components/arc/ime/arc_ime_service_unittest.cc18
3 files changed, 47 insertions, 24 deletions
diff --git a/chromium/components/arc/ime/arc_ime_service.cc b/chromium/components/arc/ime/arc_ime_service.cc
index 7913a6baa35..4718428b020 100644
--- a/chromium/components/arc/ime/arc_ime_service.cc
+++ b/chromium/components/arc/ime/arc_ime_service.cc
@@ -7,14 +7,17 @@
#include <utility>
#include "ash/keyboard/ui/keyboard_ui_controller.h"
+#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chromeos/constants/chromeos_features.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/arc/arc_util.h"
#include "components/arc/ime/arc_ime_bridge_impl.h"
#include "components/exo/wm_helper.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
@@ -45,11 +48,12 @@ double GetDefaultDeviceScaleFactor() {
class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
public:
explicit ArcWindowDelegateImpl(ArcImeService* ime_service)
- : ime_service_(ime_service) {}
+ : ime_service_(ime_service) {}
~ArcWindowDelegateImpl() override = default;
bool IsInArcAppWindow(const aura::Window* window) const override {
+ // WMHelper is not craeted in browser_tests.
if (!exo::WMHelper::HasInstance())
return false;
aura::Window* active = exo::WMHelper::GetInstance()->GetActiveWindow();
@@ -71,7 +75,7 @@ class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
}
void RegisterFocusObserver() override {
- // WMHelper is not created in tests.
+ // WMHelper is not craeted in browser_tests.
if (!exo::WMHelper::HasInstance())
return;
exo::WMHelper::GetInstance()->AddFocusObserver(ime_service_);
@@ -93,7 +97,7 @@ class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
}
bool IsImeBlocked(aura::Window* window) const override {
- // WMHelper is not created in tests.
+ // WMHelper is not craeted in browser_tests.
if (!exo::WMHelper::HasInstance())
return false;
return exo::WMHelper::GetInstance()->IsImeBlocked(window);
@@ -137,8 +141,15 @@ ArcImeService* ArcImeService::GetForBrowserContext(
ArcImeService::ArcImeService(content::BrowserContext* context,
ArcBridgeService* bridge_service)
+ : ArcImeService(context,
+ bridge_service,
+ std::make_unique<ArcWindowDelegateImpl>(this)) {}
+
+ArcImeService::ArcImeService(content::BrowserContext* context,
+ ArcBridgeService* bridge_service,
+ std::unique_ptr<ArcWindowDelegate> delegate)
: ime_bridge_(new ArcImeBridgeImpl(this, bridge_service)),
- arc_window_delegate_(new ArcWindowDelegateImpl(this)),
+ arc_window_delegate_(std::move(delegate)),
ime_type_(ui::TEXT_INPUT_TYPE_NONE),
ime_flags_(ui::TEXT_INPUT_FLAG_NONE),
is_personalized_learning_allowed_(false),
@@ -174,11 +185,6 @@ void ArcImeService::SetImeBridgeForTesting(
ime_bridge_ = std::move(test_ime_bridge);
}
-void ArcImeService::SetArcWindowDelegateForTesting(
- std::unique_ptr<ArcWindowDelegate> delegate) {
- arc_window_delegate_ = std::move(delegate);
-}
-
ui::InputMethod* ArcImeService::GetInputMethod() {
return arc_window_delegate_->GetInputMethodForWindow(focused_arc_window_);
}
@@ -606,6 +612,13 @@ bool ArcImeService::SetCompositionFromExistingText(
return false;
}
+bool ArcImeService::SetAutocorrectRange(const base::string16& autocorrect_text,
+ const gfx::Range& range) {
+ // TODO(https:://crbug.com/1091088): Implement this method.
+ NOTIMPLEMENTED_LOG_ONCE();
+ return false;
+}
+
// static
void ArcImeService::SetOverrideDefaultDeviceScaleFactorForTesting(
base::Optional<double> scale_factor) {
diff --git a/chromium/components/arc/ime/arc_ime_service.h b/chromium/components/arc/ime/arc_ime_service.h
index bc12839d20c..4a48b317eb9 100644
--- a/chromium/components/arc/ime/arc_ime_service.h
+++ b/chromium/components/arc/ime/arc_ime_service.h
@@ -49,10 +49,6 @@ class ArcImeService : public KeyedService,
// or nullptr if the browser |context| is not allowed to use ARC.
static ArcImeService* GetForBrowserContext(content::BrowserContext* context);
- ArcImeService(content::BrowserContext* context,
- ArcBridgeService* bridge_service);
- ~ArcImeService() override;
-
class ArcWindowDelegate {
public:
virtual ~ArcWindowDelegate() = default;
@@ -67,13 +63,14 @@ class ArcImeService : public KeyedService,
virtual bool IsImeBlocked(aura::Window* window) const = 0;
};
+ ArcImeService(content::BrowserContext* context,
+ ArcBridgeService* bridge_service);
+
+ ~ArcImeService() override;
+
// Injects the custom IPC bridge object for testing purpose only.
void SetImeBridgeForTesting(std::unique_ptr<ArcImeBridge> test_ime_bridge);
- // Injects the custom delegate for ARC windows, for testing purpose only.
- void SetArcWindowDelegateForTesting(
- std::unique_ptr<ArcWindowDelegate> delegate);
-
// Overridden from aura::EnvObserver:
void OnWindowInitialized(aura::Window* new_window) override;
@@ -149,6 +146,8 @@ class ArcImeService : public KeyedService,
bool SetCompositionFromExistingText(
const gfx::Range& range,
const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) override;
+ bool SetAutocorrectRange(const base::string16& autocorrect_text,
+ const gfx::Range& range) override;
// Normally, the default device scale factor is used to convert from DPI to
// physical pixels. This method provides a way to override it for testing.
@@ -156,6 +155,13 @@ class ArcImeService : public KeyedService,
base::Optional<double> scale_factor);
private:
+ friend class ArcImeServiceTest;
+
+ // Injects the custom delegate for ARC windows, for testing purpose only.
+ ArcImeService(content::BrowserContext* context,
+ ArcBridgeService* bridge_service,
+ std::unique_ptr<ArcWindowDelegate> delegate);
+
ui::InputMethod* GetInputMethod();
// Detaches from the IME associated with the |old_window|, and attaches to the
diff --git a/chromium/components/arc/ime/arc_ime_service_unittest.cc b/chromium/components/arc/ime/arc_ime_service_unittest.cc
index f38b5efd768..2b0f0ac4ff9 100644
--- a/chromium/components/arc/ime/arc_ime_service_unittest.cc
+++ b/chromium/components/arc/ime/arc_ime_service_unittest.cc
@@ -12,6 +12,8 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
+#include "chromeos/constants/chromeos_features.h"
#include "components/arc/mojom/ime.mojom.h"
#include "components/arc/session/arc_bridge_service.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -207,16 +209,17 @@ class ArcImeServiceTest : public testing::Test {
private:
void SetUp() override {
arc_bridge_service_ = std::make_unique<ArcBridgeService>();
- instance_ =
- std::make_unique<ArcImeService>(nullptr, arc_bridge_service_.get());
- fake_arc_ime_bridge_ = new FakeArcImeBridge();
- instance_->SetImeBridgeForTesting(base::WrapUnique(fake_arc_ime_bridge_));
fake_input_method_ = std::make_unique<FakeInputMethod>();
+ auto delegate =
+ std::make_unique<FakeArcWindowDelegate>(fake_input_method_.get());
+ fake_window_delegate_ = delegate.get();
+
+ instance_ = base::WrapUnique(new ArcImeService(
+ nullptr, arc_bridge_service_.get(), std::move(delegate)));
+ fake_arc_ime_bridge_ = new FakeArcImeBridge();
+ instance_->SetImeBridgeForTesting(base::WrapUnique(fake_arc_ime_bridge_));
- fake_window_delegate_ = new FakeArcWindowDelegate(fake_input_method_.get());
- instance_->SetArcWindowDelegateForTesting(
- base::WrapUnique(fake_window_delegate_));
arc_win_ = fake_window_delegate_->CreateFakeArcWindow();
}
@@ -226,6 +229,7 @@ class ArcImeServiceTest : public testing::Test {
fake_window_delegate_ = nullptr;
fake_arc_ime_bridge_ = nullptr;
instance_.reset();
+ fake_input_method_.reset();
arc_bridge_service_.reset();
}
};