Commit 5d576e9a authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Reland: Fix text input on ARC++ Kiosk apps.

The original CL is crrev.com/c/1291289. It was reverted due to crash.
Please see crbug.com/903671.

We changed IsInArcAppWindow() to use the window property,
aura::client::kAppType, but it's not set for ARC++ Kiosk apps' window.
It makes text input on ARC++ Kiosk apps stop working.
This CL adds a temporary workaround for this situation. Ideally,
IsArcAppWindow() in arc_util.cc should handle windows of ARC++ Kiosk app
correctly.

Bug: 891825, 903671
Test: Can type text on Wikipedia kiosk app.
Change-Id: I3e6457ee3dc5f3fdcca35a7acbb007325697ddbd
Reviewed-on: https://chromium-review.googlesource.com/c/1339779Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609551}
parent d80abf59
......@@ -13,6 +13,7 @@
#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/shell_surface.h"
#include "components/exo/wm_helper.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
......@@ -31,6 +32,9 @@ namespace arc {
namespace {
// TODO(yhanada): Remove this once IsArcAppWindow is fixed for ARC++ Kiosk app.
constexpr char kArcAppIdPrefix[] = "org.chromium.arc";
base::Optional<double> g_override_default_device_scale_factor;
double GetDefaultDeviceScaleFactor() {
......@@ -49,9 +53,26 @@ class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
~ArcWindowDelegateImpl() override = default;
bool IsInArcAppWindow(const aura::Window* window) const override {
if (!exo::WMHelper::GetInstance())
return false;
aura::Window* active = exo::WMHelper::GetInstance()->GetActiveWindow();
for (; window; window = window->parent()) {
if (IsArcAppWindow(window))
return true;
// IsArcAppWindow returns false for a window of ARC++ Kiosk app, so we
// have to check application id of the active window to cover that case.
// TODO(yhanada): Make IsArcAppWindow support a window of ARC++ Kiosk.
// Specifically, a window of ARC++ Kiosk should have ash::AppType::ARC_APP
// property. Please see implementation of IsArcAppWindow().
if (window == active) {
const std::string* app_id = exo::ShellSurface::GetApplicationId(window);
if (IsArcKioskMode() && app_id &&
base::StartsWith(*app_id, kArcAppIdPrefix,
base::CompareCase::SENSITIVE)) {
return true;
}
}
}
return false;
}
......
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