Commit dc0018f5 authored by Nicholas Hollingum's avatar Nicholas Hollingum Committed by Commit Bot

Exo: Dont default all widgets as Arc++ apps

Since crrev.com/c/1955818 all exo widgets (i.e. windows with a title
bar, close buttons, etc) are defaulted to Arc++. This caused many
crostini windows, which previously had no association, to be considered
as Arc++ apps. This causes the Arc++ IME to steal events when there
happens to be (or ever have been) an active input field in an arc++ app
anywhere.

We move the code that sets Arc++ windows to
ClientControlledShellSurface, which Arc++ apps use.

Bug: 1069388
Change-Id: If559a68315c2dcf175023f6601bdaf8bb6de46ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306499
Commit-Queue: Nic Hollingum <hollingum@google.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798539}
parent b15579b1
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.h" #include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.h"
#include <memory>
#include <utility>
#include "ash/shell.h" #include "ash/shell.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
...@@ -16,8 +19,11 @@ ...@@ -16,8 +19,11 @@
#include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_bridge_service.h"
#include "components/arc/test/connection_holder_util.h" #include "components/arc/test/connection_holder_util.h"
#include "components/arc/test/fake_accessibility_helper_instance.h" #include "components/arc/test/fake_accessibility_helper_instance.h"
#include "components/exo/buffer.h"
#include "components/exo/client_controlled_accelerators.h"
#include "components/exo/shell_surface.h" #include "components/exo/shell_surface.h"
#include "components/exo/shell_surface_util.h" #include "components/exo/shell_surface_util.h"
#include "components/exo/surface.h"
#include "components/exo/test/exo_test_helper.h" #include "components/exo/test/exo_test_helper.h"
#include "components/exo/wm_helper.h" #include "components/exo/wm_helper.h"
#include "components/exo/wm_helper_chromeos.h" #include "components/exo/wm_helper_chromeos.h"
...@@ -29,6 +35,12 @@ ...@@ -29,6 +35,12 @@
namespace arc { namespace arc {
struct ArcTestWindow {
std::unique_ptr<exo::Buffer> buffer;
std::unique_ptr<exo::Surface> surface;
std::unique_ptr<exo::ClientControlledShellSurface> shell_surface;
};
class ArcAccessibilityHelperBridgeBrowserTest : public InProcessBrowserTest { class ArcAccessibilityHelperBridgeBrowserTest : public InProcessBrowserTest {
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
arc::SetArcAvailableCommandLineForTesting(command_line); arc::SetArcAvailableCommandLineForTesting(command_line);
...@@ -61,6 +73,25 @@ class ArcAccessibilityHelperBridgeBrowserTest : public InProcessBrowserTest { ...@@ -61,6 +73,25 @@ class ArcAccessibilityHelperBridgeBrowserTest : public InProcessBrowserTest {
} }
protected: protected:
// Create and initialize a window for this test, i.e. an Arc++-specific
// version of ExoTestHelper::CreateWindow.
ArcTestWindow MakeTestWindow(std::string name) {
ArcTestWindow ret;
exo::test::ExoTestHelper helper;
ret.surface = std::make_unique<exo::Surface>();
ret.buffer = std::make_unique<exo::Buffer>(
helper.CreateGpuMemoryBuffer(gfx::Size(640, 480)));
ret.shell_surface = helper.CreateClientControlledShellSurface(
ret.surface.get(), /*is_modal=*/false);
ret.surface->Attach(ret.buffer.get());
ret.surface->Commit();
// Forcefully set task_id for each window.
exo::SetShellApplicationId(
ret.shell_surface->GetWidget()->GetNativeWindow(), std::move(name));
return ret;
}
std::unique_ptr<FakeAccessibilityHelperInstance> std::unique_ptr<FakeAccessibilityHelperInstance>
fake_accessibility_helper_instance_; fake_accessibility_helper_instance_;
std::unique_ptr<exo::WMHelper> wm_helper_; std::unique_ptr<exo::WMHelper> wm_helper_;
...@@ -72,38 +103,21 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest, ...@@ -72,38 +103,21 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest,
fake_accessibility_helper_instance_->filter_type()); fake_accessibility_helper_instance_->filter_type());
EXPECT_FALSE(fake_accessibility_helper_instance_->explore_by_touch_enabled()); EXPECT_FALSE(fake_accessibility_helper_instance_->explore_by_touch_enabled());
exo::test::ExoTestHelper exo_test_helper; ArcTestWindow test_window_1 = MakeTestWindow("org.chromium.arc.1");
exo::test::ExoTestWindow test_window_1 = ArcTestWindow test_window_2 = MakeTestWindow("org.chromium.arc.2");
exo_test_helper.CreateWindow(640, 480, false /* is_modal */);
exo::test::ExoTestWindow test_window_2 =
exo_test_helper.CreateWindow(640, 480, false /* is_modal */);
// Forcefully set task_id to each window.
exo::SetShellApplicationId(
test_window_1.shell_surface()->GetWidget()->GetNativeWindow(),
"org.chromium.arc.1");
exo::SetShellApplicationId(
test_window_2.shell_surface()->GetWidget()->GetNativeWindow(),
"org.chromium.arc.2");
wm::ActivationClient* activation_client = wm::ActivationClient* activation_client =
ash::Shell::Get()->activation_client(); ash::Shell::Get()->activation_client();
activation_client->ActivateWindow( activation_client->ActivateWindow(
test_window_1.shell_surface()->GetWidget()->GetNativeWindow()); test_window_1.shell_surface->GetWidget()->GetNativeWindow());
ASSERT_EQ(test_window_1.shell_surface()->GetWidget()->GetNativeWindow(), ASSERT_EQ(test_window_1.shell_surface->GetWidget()->GetNativeWindow(),
activation_client->GetActiveWindow()); activation_client->GetActiveWindow());
ASSERT_FALSE( ASSERT_FALSE(
test_window_1.shell_surface() test_window_1.shell_surface->GetWidget()->GetNativeWindow()->GetProperty(
->GetWidget() aura::client::kAccessibilityTouchExplorationPassThrough));
->GetNativeWindow()
->GetProperty(
aura::client::kAccessibilityTouchExplorationPassThrough));
ASSERT_FALSE( ASSERT_FALSE(
test_window_2.shell_surface() test_window_2.shell_surface->GetWidget()->GetNativeWindow()->GetProperty(
->GetWidget() aura::client::kAccessibilityTouchExplorationPassThrough));
->GetNativeWindow()
->GetProperty(
aura::client::kAccessibilityTouchExplorationPassThrough));
chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(true); chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(true);
...@@ -113,11 +127,8 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest, ...@@ -113,11 +127,8 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest,
// Use ChromeVox by default. Touch exploration pass through is still false. // Use ChromeVox by default. Touch exploration pass through is still false.
EXPECT_FALSE( EXPECT_FALSE(
test_window_1.shell_surface() test_window_1.shell_surface->GetWidget()->GetNativeWindow()->GetProperty(
->GetWidget() aura::client::kAccessibilityTouchExplorationPassThrough));
->GetNativeWindow()
->GetProperty(
aura::client::kAccessibilityTouchExplorationPassThrough));
ArcAccessibilityHelperBridge* bridge = ArcAccessibilityHelperBridge* bridge =
ArcAccessibilityHelperBridge::GetForBrowserContext(browser()->profile()); ArcAccessibilityHelperBridge::GetForBrowserContext(browser()->profile());
...@@ -126,53 +137,38 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest, ...@@ -126,53 +137,38 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest,
// (current active window) would become true. // (current active window) would become true.
bridge->SetNativeChromeVoxArcSupport(false); bridge->SetNativeChromeVoxArcSupport(false);
EXPECT_TRUE(test_window_1.shell_surface() EXPECT_TRUE(
->GetWidget() test_window_1.shell_surface->GetWidget()->GetNativeWindow()->GetProperty(
->GetNativeWindow() aura::client::kAccessibilityTouchExplorationPassThrough));
->GetProperty(
aura::client::kAccessibilityTouchExplorationPassThrough));
// Activate test_window_2 and confirm that it still be false. // Activate test_window_2 and confirm that it still be false.
activation_client->ActivateWindow( activation_client->ActivateWindow(
test_window_2.shell_surface()->GetWidget()->GetNativeWindow()); test_window_2.shell_surface->GetWidget()->GetNativeWindow());
ASSERT_EQ(test_window_2.shell_surface()->GetWidget()->GetNativeWindow(), ASSERT_EQ(test_window_2.shell_surface->GetWidget()->GetNativeWindow(),
activation_client->GetActiveWindow()); activation_client->GetActiveWindow());
EXPECT_FALSE( EXPECT_FALSE(
test_window_2.shell_surface() test_window_2.shell_surface->GetWidget()->GetNativeWindow()->GetProperty(
->GetWidget() aura::client::kAccessibilityTouchExplorationPassThrough));
->GetNativeWindow()
->GetProperty(
aura::client::kAccessibilityTouchExplorationPassThrough));
EXPECT_TRUE(fake_accessibility_helper_instance_->explore_by_touch_enabled()); EXPECT_TRUE(fake_accessibility_helper_instance_->explore_by_touch_enabled());
} }
IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest, IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest,
RequestTreeSyncOnWindowIdChange) { RequestTreeSyncOnWindowIdChange) {
exo::test::ExoTestHelper exo_test_helper; ArcTestWindow test_window_1 = MakeTestWindow("org.chromium.arc.1");
exo::test::ExoTestWindow test_window_1 = ArcTestWindow test_window_2 = MakeTestWindow("org.chromium.arc.2");
exo_test_helper.CreateWindow(640, 480, false /* is_modal */);
exo::test::ExoTestWindow test_window_2 =
exo_test_helper.CreateWindow(640, 480, false /* is_modal */);
exo::SetShellApplicationId(
test_window_1.shell_surface()->GetWidget()->GetNativeWindow(),
"org.chromium.arc.1");
exo::SetShellApplicationId(
test_window_2.shell_surface()->GetWidget()->GetNativeWindow(),
"org.chromium.arc.2");
wm::ActivationClient* activation_client = wm::ActivationClient* activation_client =
ash::Shell::Get()->activation_client(); ash::Shell::Get()->activation_client();
activation_client->ActivateWindow( activation_client->ActivateWindow(
test_window_1.shell_surface()->GetWidget()->GetNativeWindow()); test_window_1.shell_surface->GetWidget()->GetNativeWindow());
chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(true); chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(true);
exo::SetShellClientAccessibilityId( exo::SetShellClientAccessibilityId(
test_window_1.shell_surface()->GetWidget()->GetNativeWindow(), 10); test_window_1.shell_surface->GetWidget()->GetNativeWindow(), 10);
exo::SetShellClientAccessibilityId( exo::SetShellClientAccessibilityId(
test_window_2.shell_surface()->GetWidget()->GetNativeWindow(), 20); test_window_2.shell_surface->GetWidget()->GetNativeWindow(), 20);
EXPECT_TRUE( EXPECT_TRUE(
fake_accessibility_helper_instance_->last_requested_tree_window_key() fake_accessibility_helper_instance_->last_requested_tree_window_key()
...@@ -184,7 +180,7 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest, ...@@ -184,7 +180,7 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest,
->get_window_id()); ->get_window_id());
activation_client->ActivateWindow( activation_client->ActivateWindow(
test_window_2.shell_surface()->GetWidget()->GetNativeWindow()); test_window_2.shell_surface->GetWidget()->GetNativeWindow());
EXPECT_EQ( EXPECT_EQ(
20U, fake_accessibility_helper_instance_->last_requested_tree_window_key() 20U, fake_accessibility_helper_instance_->last_requested_tree_window_key()
...@@ -192,7 +188,7 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest, ...@@ -192,7 +188,7 @@ IN_PROC_BROWSER_TEST_F(ArcAccessibilityHelperBridgeBrowserTest,
->get_window_id()); ->get_window_id());
exo::SetShellClientAccessibilityId( exo::SetShellClientAccessibilityId(
test_window_2.shell_surface()->GetWidget()->GetNativeWindow(), 21); test_window_2.shell_surface->GetWidget()->GetNativeWindow(), 21);
EXPECT_EQ( EXPECT_EQ(
21U, fake_accessibility_helper_instance_->last_requested_tree_window_key() 21U, fake_accessibility_helper_instance_->last_requested_tree_window_key()
......
...@@ -1028,6 +1028,9 @@ gfx::Rect ClientControlledShellSurface::GetShadowBounds() const { ...@@ -1028,6 +1028,9 @@ gfx::Rect ClientControlledShellSurface::GetShadowBounds() const {
void ClientControlledShellSurface::InitializeWindowState( void ClientControlledShellSurface::InitializeWindowState(
ash::WindowState* window_state) { ash::WindowState* window_state) {
// Set the relevant window properties for Arc apps.
SetArcAppType(window_state->window());
// Allow the client to request bounds that do not fill the entire work area // Allow the client to request bounds that do not fill the entire work area
// when maximized, or the entire display when fullscreen. // when maximized, or the entire display when fullscreen.
window_state->set_allow_set_bounds_direct(true); window_state->set_allow_set_bounds_direct(true);
......
...@@ -962,7 +962,6 @@ void ShellSurfaceBase::CreateShellSurfaceWidget( ...@@ -962,7 +962,6 @@ void ShellSurfaceBase::CreateShellSurfaceWidget(
SetShellApplicationId(window, application_id_); SetShellApplicationId(window, application_id_);
SetShellStartupId(window, startup_id_); SetShellStartupId(window, startup_id_);
SetShellMainSurface(window, root_surface()); SetShellMainSurface(window, root_surface());
SetArcAppType(window);
// Start tracking changes to window bounds and window state. // Start tracking changes to window bounds and window state.
window->AddObserver(this); window->AddObserver(this);
......
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