Commit 9b8061fe authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Use application id in NotificationSurface to distinguish surfaces of ARC notifications.

Bug: 829383, 834027
Test: IME works on ARC++ apps and notifications from ARC++ apps.
Change-Id: I98d7cb43845c668ad0afb273c623b49abf08f595
Reviewed-on: https://chromium-review.googlesource.com/1051433Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565075}
parent 6d9fec40
......@@ -180,7 +180,7 @@ bool IsArcOptInVerificationDisabled() {
chromeos::switches::kDisableArcOptInVerification);
}
bool IsArcAppWindow(aura::Window* window) {
bool IsArcAppWindow(const aura::Window* window) {
if (!window)
return false;
return window->GetProperty(aura::client::kAppType) ==
......
......@@ -95,7 +95,7 @@ bool IsArcOptInVerificationDisabled();
// Returns true if the |window|'s aura::client::kAppType is ARC_APP. When
// |window| is nullptr, returns false.
bool IsArcAppWindow(aura::Window* window);
bool IsArcAppWindow(const aura::Window* window);
// Returns true if data clean up is requested for each ARC start.
bool IsArcDataCleanupOnStartRequested();
......
......@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.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/shell_surface.h"
#include "components/exo/surface.h"
......@@ -28,7 +29,8 @@ namespace arc {
namespace {
constexpr char kArcAppIdPrefix[] = "org.chromium.arc";
constexpr char kArcNotificationAppId[] =
"org.chromium.arc.ArcNotificationService";
base::Optional<double> g_override_default_device_scale_factor;
......@@ -59,15 +61,19 @@ class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
aura::Window* active = exo::WMHelper::GetInstance()->GetActiveWindow();
if (!active || !active->Contains(window))
return false;
if (IsArcNotificationWindow(window, active))
// If the ARC app is focused, the active window should be ARC app window.
if (IsArcAppWindow(active))
return true;
// Need to get an application id from the active window because only
// ShellSurface window has the application id.
const std::string* app_id = exo::ShellSurface::GetApplicationId(active);
return app_id && base::StartsWith(*app_id, kArcAppIdPrefix,
base::CompareCase::SENSITIVE);
// If the ARC notification is focused, the active window is not ARC app
// window. Find an app id set to the window and check if it is the ARC
// notification app id.
for (; window && window != active; window = window->parent()) {
const std::string* app_id = exo::ShellSurface::GetApplicationId(window);
if (app_id)
return *app_id == kArcNotificationAppId;
}
return false;
}
void RegisterFocusObserver() override {
......@@ -91,20 +97,6 @@ class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
}
private:
bool IsArcNotificationWindow(const aura::Window* window,
const aura::Window* active) const {
DCHECK(IsExoWindow(window));
// TODO(yhanada): Should set an application id for NotificationSurface
// to kArcAppIdPrefix, then we can eliminate this method.
// https://crbug.com/834027
for (const aura::Window* parent = window; parent != active;
parent = parent->parent()) {
if (parent->GetName() == "ExoNotificationSurface")
return true;
}
return false;
}
ArcImeService* const ime_service_;
DISALLOW_COPY_AND_ASSIGN(ArcWindowDelegateImpl);
......
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