Commit e40da8dd authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Put KioskNextHome app in HomeScreenContainer

Renames AppListTabletModeContainer to HomeScreenContainer to reflect
that it contains the home screen (either app list or kiosk next app).

Hosts the KioskNextHome app window in this container when KioskNextShell
is enabled.

Also moves KioskNextShell tests from LoginUtilsTest to their own file.

Bug: 937549
Change-Id: Icd2a878ed67a913128058e3d5fe688b65de7c5ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1538688Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Auto-Submit: Michael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644371}
parent 321d70a0
......@@ -1156,7 +1156,7 @@ void AppListControllerImpl::UpdateLauncherContainer() {
return;
auto container_id = launcher_should_show_behind_apps
? ash::kShellWindowId_AppListTabletModeContainer
? ash::kShellWindowId_HomeScreenContainer
: ash::kShellWindowId_AppListContainer;
aura::Window* root_window = window->GetRootWindow();
......
......@@ -85,9 +85,8 @@ void AppListPresenterDelegateImpl::Init(app_list::AppListView* view,
const bool is_tablet_mode = IsTabletMode();
aura::Window* parent_window =
RootWindowController::ForWindow(root_window)
->GetContainer(is_tablet_mode
? kShellWindowId_AppListTabletModeContainer
: kShellWindowId_AppListContainer);
->GetContainer(is_tablet_mode ? kShellWindowId_HomeScreenContainer
: kShellWindowId_AppListContainer);
params.parent = parent_window;
params.initial_apps_page = current_apps_page;
params.is_tablet_mode = is_tablet_mode;
......
......@@ -1220,11 +1220,10 @@ TEST_F(AppListPresenterDelegateHomeLauncherTest, ParentWindowContainer) {
->Contains(window));
// Turn on tablet mode. The window container should be
// kShellWindowId_AppListTabletModeContainer.
// kShellWindowId_HomeScreenContainer.
EnableTabletMode(true);
EXPECT_TRUE(
root_window->GetChildById(kShellWindowId_AppListTabletModeContainer)
->Contains(window));
EXPECT_TRUE(root_window->GetChildById(kShellWindowId_HomeScreenContainer)
->Contains(window));
}
// Tests that the background opacity change for app list.
......
......@@ -85,8 +85,8 @@ std::unique_ptr<ui::LayerTreeOwner> CreateLayerForAssistantSnapshot(
aura::Window* app_list_container =
ash::Shell::GetContainer(root_window, kShellWindowId_AppListContainer);
aura::Window* app_list_tablet_mode_container = ash::Shell::GetContainer(
root_window, kShellWindowId_AppListTabletModeContainer);
aura::Window* app_list_tablet_mode_container =
ash::Shell::GetContainer(root_window, kShellWindowId_HomeScreenContainer);
// Ignore app list to prevent interfering with app list animations.
if (app_list_container)
......
......@@ -29,7 +29,7 @@ namespace {
bool MinimizeAllWindows() {
bool handled = false;
aura::Window* container = Shell::Get()->GetPrimaryRootWindow()->GetChildById(
kShellWindowId_AppListTabletModeContainer);
kShellWindowId_HomeScreenContainer);
aura::Window::Windows windows =
Shell::Get()->mru_window_tracker()->BuildWindowForCycleList();
for (auto it = windows.rbegin(); it != windows.rend(); it++) {
......
......@@ -23,7 +23,7 @@ const int32_t kActivatableShellWindowIds[] = {
kShellWindowId_AlwaysOnTopContainer,
kShellWindowId_AppListContainer,
kShellWindowId_DefaultContainer,
kShellWindowId_AppListTabletModeContainer,
kShellWindowId_HomeScreenContainer,
// Launcher and status are intentionally checked after other containers
// even though these layers are higher. The user expects their windows
......
......@@ -57,8 +57,8 @@ enum ShellWindowId {
// The container for the app list.
kShellWindowId_AppListContainer,
// The container for the app list in tablet mode.
kShellWindowId_AppListTabletModeContainer,
// The container for the home screen, e.g. the app list in tablet mode.
kShellWindowId_HomeScreenContainer,
// The container for the PIP window.
kShellWindowId_PipContainer,
......@@ -168,7 +168,7 @@ const int32_t kAllShellContainerIds[] = {
kShellWindowId_DefaultContainer,
kShellWindowId_AlwaysOnTopContainer,
kShellWindowId_AppListContainer,
kShellWindowId_AppListTabletModeContainer,
kShellWindowId_HomeScreenContainer,
kShellWindowId_ArcImeWindowParentContainer,
kShellWindowId_ArcVirtualKeyboardContainer,
kShellWindowId_ShelfContainer,
......
......@@ -863,8 +863,8 @@ void RootWindowController::CreateContainers() {
"LockScreenRelatedContainersContainer", screen_rotation_container);
aura::Window* app_list_tablet_mode_container =
CreateContainer(kShellWindowId_AppListTabletModeContainer,
"AppListTabletModeContainer", non_lock_screen_containers);
CreateContainer(kShellWindowId_HomeScreenContainer, "HomeScreenContainer",
non_lock_screen_containers);
wm::SetSnapsChildrenToPhysicalPixelBoundary(app_list_tablet_mode_container);
app_list_tablet_mode_container->SetProperty(::wm::kUsesScreenCoordinatesKey,
true);
......
......@@ -41,18 +41,6 @@
#include "components/rlz/rlz_tracker.h"
#endif
#if defined(GOOGLE_CHROME_BUILD)
#include "apps/test/app_window_waiter.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/common/extensions/extension_constants.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/window.h"
#endif
namespace chromeos {
namespace {
......@@ -97,123 +85,6 @@ class LoginUtilsTest : public OobeBaseTest {
DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest);
};
#if defined(GOOGLE_CHROME_BUILD)
class LoginUtilsKioskNextShellTest : public LoginUtilsTest {
public:
void SetUp() override {
feature_list_.InitAndEnableFeature(ash::features::kKioskNextShell);
LoginUtilsTest::SetUp();
}
void LoginAndSetKioskNextShellPref(bool kiosk_next_shell_pref_value) {
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
WaitForSigninScreen();
Login("username");
// Take some time to finish login and register user prefs.
base::RunLoop().RunUntilIdle();
// Update the now registered Kiosk Next Shell pref.
ProfileHelper::Get()
->GetProfileByUser(user_manager::UserManager::Get()->GetActiveUser())
->GetPrefs()
->SetBoolean(ash::prefs::kKioskNextShellEnabled,
kiosk_next_shell_pref_value);
}
private:
base::test::ScopedFeatureList feature_list_;
};
// This observer is used by LoginUtilsKioskNextShellTest to keep track of
// whether a Fullscreen window was launched by ash during the test run.
class FullscreenWindowEnvObserver : public aura::EnvObserver,
public aura::WindowObserver {
public:
FullscreenWindowEnvObserver() { env_observer_.Add(aura::Env::GetInstance()); }
bool did_fullscreen_window_launch() const {
return did_fullscreen_window_launch_;
}
// aura::EnvObserver:
void OnWindowInitialized(aura::Window* window) override {
window_observer_.Add(window);
}
// aura::WindowObserver:
void OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) override {
did_fullscreen_window_launch_ =
did_fullscreen_window_launch_ ||
window->GetProperty(aura::client::kShowStateKey) ==
ui::SHOW_STATE_FULLSCREEN;
}
private:
bool did_fullscreen_window_launch_ = false;
ScopedObserver<aura::Env, aura::EnvObserver> env_observer_{this};
ScopedObserver<aura::Window, aura::WindowObserver> window_observer_{this};
DISALLOW_COPY_AND_ASSIGN(FullscreenWindowEnvObserver);
};
IN_PROC_BROWSER_TEST_F(LoginUtilsKioskNextShellTest, PRE_KioskNextShellLaunch) {
LoginAndSetKioskNextShellPref(true);
}
// Checks that the Kiosk Next Home window is launched on sign-in when the
// feature is enabled and its pref allows it.
IN_PROC_BROWSER_TEST_F(LoginUtilsKioskNextShellTest, KioskNextShellLaunch) {
// Enable all component extensions.
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
WaitForSigninScreen();
FullscreenWindowEnvObserver fullscreen_observer;
Login("username");
// Wait for the app to launch before verifying it is fullscreen.
apps::AppWindowWaiter waiter(
extensions::AppWindowRegistry::Get(ProfileHelper::Get()->GetProfileByUser(
user_manager::UserManager::Get()->GetActiveUser())),
extension_misc::kKioskNextHomeAppId);
EXPECT_NE(nullptr,
waiter.WaitForShownWithTimeout(TestTimeouts::action_timeout()));
EXPECT_TRUE(fullscreen_observer.did_fullscreen_window_launch());
}
IN_PROC_BROWSER_TEST_F(LoginUtilsKioskNextShellTest,
PRE_KioskNextShellDoesntLaunchWhenPrefIsDisabled) {
LoginAndSetKioskNextShellPref(false);
}
// Checks that the Kiosk Next Home window does not launch in sign-in when
// its pref is disabled
IN_PROC_BROWSER_TEST_F(LoginUtilsKioskNextShellTest,
KioskNextShellDoesntLaunchWhenPrefIsDisabled) {
// Enable all component extensions.
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
WaitForSigninScreen();
Login("username");
// Wait for the app to launch before verifying that it didn't.
apps::AppWindowWaiter waiter(
extensions::AppWindowRegistry::Get(ProfileHelper::Get()->GetProfileByUser(
user_manager::UserManager::Get()->GetActiveUser())),
extension_misc::kKioskNextHomeAppId);
EXPECT_EQ(nullptr,
waiter.WaitForShownWithTimeout(TestTimeouts::action_timeout()));
}
#endif // defined(GOOGLE_CHROME_BUILD)
// Exercises login, like the desktopui_MashLogin Chrome OS autotest.
IN_PROC_BROWSER_TEST_F(LoginUtilsTest, MashLogin) {
// Test is relevant for both SingleProcessMash and MultiProcessMash, but
......
......@@ -3,6 +3,5 @@
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(() => {
chrome.app.window.create(
'main.html', {state: 'fullscreen', resizable: false, frame: 'none'});
chrome.app.window.create('main.html', {state: 'maximized', frame: 'none'});
});
......@@ -17,7 +17,16 @@
#include "mojo/public/cpp/bindings/interface_request.h"
#include "services/service_manager/public/cpp/connector.h"
namespace {
KioskNextShellClient* g_kiosk_next_shell_client_instance = nullptr;
} // namespace
KioskNextShellClient::KioskNextShellClient() {
DCHECK(!g_kiosk_next_shell_client_instance);
g_kiosk_next_shell_client_instance = this;
ash::mojom::KioskNextShellControllerPtr kiosk_next_shell_controller;
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
......@@ -28,12 +37,21 @@ KioskNextShellClient::KioskNextShellClient() {
kiosk_next_shell_controller->SetClient(std::move(client));
}
KioskNextShellClient::~KioskNextShellClient() = default;
KioskNextShellClient::~KioskNextShellClient() {
DCHECK_EQ(this, g_kiosk_next_shell_client_instance);
g_kiosk_next_shell_client_instance = nullptr;
}
// static
KioskNextShellClient* KioskNextShellClient::Get() {
return g_kiosk_next_shell_client_instance;
}
void KioskNextShellClient::LaunchKioskNextShell(const AccountId& account_id) {
// TODO(michaelpg): Create a dummy app for non-internal builds.
#if defined(GOOGLE_CHROME_BUILD)
has_launched_ = true;
Profile* profile =
chromeos::ProfileHelper::Get()->GetProfileByAccountId(account_id);
const extensions::Extension* app =
......
......@@ -15,12 +15,20 @@ class KioskNextShellClient : public ash::mojom::KioskNextShellClient {
KioskNextShellClient();
~KioskNextShellClient() override;
// Returns the singleton KioskNextShellClient instance, if it exists.
static KioskNextShellClient* Get();
// mojom::KioskNextShellClient:
void LaunchKioskNextShell(const AccountId& account_id) override;
bool has_launched() const { return has_launched_; }
private:
mojo::Binding<ash::mojom::KioskNextShellClient> binding_{this};
// True once the KioskNextShell has been launched.
bool has_launched_ = false;
DISALLOW_COPY_AND_ASSIGN(KioskNextShellClient);
};
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "apps/test/app_window_waiter.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/screens/gaia_view.h"
#include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
#include "chrome/browser/chromeos/login/test/oobe_base_test.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/ui/ash/kiosk_next_shell_client.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/extensions/extension_constants.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
namespace chromeos {
namespace {
class KioskNextShellClientTest : public OobeBaseTest {
public:
// OobeBaseTest:
void SetUp() override {
feature_list_.InitAndEnableFeature(ash::features::kKioskNextShell);
OobeBaseTest::SetUp();
}
void Login(const std::string& username) {
WaitForSigninScreen();
content::WindowedNotificationObserver session_started_observer(
chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources());
LoginDisplayHost::default_host()
->GetOobeUI()
->GetGaiaScreenView()
->ShowSigninScreenForTest(username, "password", "[]");
// Wait for the session to start after submitting the credentials. This
// will wait until all the background requests are done.
session_started_observer.Wait();
}
void LoginAndEnableKioskNextShellPref() {
Login("username");
// Take some time to finish login and register user prefs.
base::RunLoop().RunUntilIdle();
// Update the now registered Kiosk Next Shell pref.
ProfileHelper::Get()
->GetProfileByUser(user_manager::UserManager::Get()->GetActiveUser())
->GetPrefs()
->SetBoolean(ash::prefs::kKioskNextShellEnabled, true);
}
private:
FakeGaiaMixin fake_gaia_{&mixin_host_, embedded_test_server()};
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(KioskNextShellClientTest, PRE_KioskNextShellLaunch) {
LoginAndEnableKioskNextShellPref();
}
// Checks that the Kiosk Next Home window is launched on sign-in when the
// feature is enabled and its pref allows it.
IN_PROC_BROWSER_TEST_F(KioskNextShellClientTest, KioskNextShellLaunch) {
// Enable all component extensions.
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
Login("username");
// Wait for the app to launch.
apps::AppWindowWaiter waiter(
extensions::AppWindowRegistry::Get(ProfileHelper::Get()->GetProfileByUser(
user_manager::UserManager::Get()->GetActiveUser())),
extension_misc::kKioskNextHomeAppId);
EXPECT_TRUE(waiter.WaitForShownWithTimeout(TestTimeouts::action_timeout()));
}
// Checks that the Kiosk Next Home window does not launch in sign-in when
// its pref is disabled.
IN_PROC_BROWSER_TEST_F(KioskNextShellClientTest, KioskNextShellNotLaunched) {
// Enable all component extensions.
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
Login("username");
// Wait for the app to launch before verifying that it didn't.
apps::AppWindowWaiter waiter(
extensions::AppWindowRegistry::Get(ProfileHelper::Get()->GetProfileByUser(
user_manager::UserManager::Get()->GetActiveUser())),
extension_misc::kKioskNextHomeAppId);
EXPECT_FALSE(waiter.WaitForShownWithTimeout(TestTimeouts::action_timeout()));
}
// Variant of KioskNextShellClientTest that disables Mash in order to test the
// Ash container of the Chrome app window.
// TODO(crbug.com/945704): Once we can identify the app window's container with
// SingleProcessMash enabled, remove this test class and add the container check
// to the KioskNextShellLaunch test.
class KioskNextShellClientMashDisabledTest : public KioskNextShellClientTest {
public:
// KioskNextShellClientTest:
void SetUp() override {
feature_list_.InitAndDisableFeature(features::kSingleProcessMash);
KioskNextShellClientTest::SetUp();
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(KioskNextShellClientMashDisabledTest,
PRE_KioskNextShellLaunch) {
LoginAndEnableKioskNextShellPref();
}
// Checks that the Kiosk Next Home window is launched on sign-in when the
// feature is enabled and its pref allows it.
IN_PROC_BROWSER_TEST_F(KioskNextShellClientMashDisabledTest,
KioskNextShellLaunch) {
// Enable all component extensions.
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
Login("username");
// Wait for the app to launch.
apps::AppWindowWaiter waiter(
extensions::AppWindowRegistry::Get(ProfileHelper::Get()->GetProfileByUser(
user_manager::UserManager::Get()->GetActiveUser())),
extension_misc::kKioskNextHomeAppId);
extensions::AppWindow* app_window =
waiter.WaitForShownWithTimeout(TestTimeouts::action_timeout());
ASSERT_TRUE(app_window);
// Verify the window is in the Home Screen container.
EXPECT_EQ(app_window->GetNativeWindow()->parent(),
app_window->GetNativeWindow()->GetRootWindow()->GetChildById(
ash::kShellWindowId_HomeScreenContainer));
}
} // namespace
} // namespace chromeos
......@@ -26,10 +26,12 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/kiosk_next_shell_client.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h"
#include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
#include "chrome/common/extensions/extension_constants.h"
#include "components/session_manager/core/session_manager.h"
#include "extensions/common/constants.h"
#include "services/ws/public/cpp/property_type_converters.h"
......@@ -71,6 +73,13 @@ bool IsLoginFeedbackModalDialog(const AppWindow* app_window) {
state == SessionState::LOGIN_SECONDARY;
}
// Return true if |app_window| is a Kiosk Next Home app in a KioskNext session.
bool IsKioskNextHomeWindow(const AppWindow* app_window) {
return KioskNextShellClient::Get() &&
KioskNextShellClient::Get()->has_launched() &&
app_window->extension_id() == extension_misc::kKioskNextHomeAppId;
}
} // namespace
ChromeNativeAppWindowViewsAuraAsh::ChromeNativeAppWindowViewsAuraAsh()
......@@ -143,6 +152,8 @@ void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit(
container_id = ash::kShellWindowId_ImeWindowParentContainer;
else if (create_params.show_on_lock_screen)
container_id = ash::kShellWindowId_LockActionHandlerContainer;
else if (IsKioskNextHomeWindow(app_window()))
container_id = ash::kShellWindowId_HomeScreenContainer;
if (container_id.has_value()) {
ash_util::SetupWidgetInitParamsForContainer(init_params, *container_id);
......
......@@ -2025,6 +2025,9 @@ test("browser_tests") {
sources += [
# The screen this test is checking exists in official build only.
"../browser/chromeos/login/sync_consent_interactive_ui_test.cc",
# The KioskNext app is available in Chrome-branded builds only.
"../browser/ui/ash/kiosk_next_shell_client_browsertest.cc",
]
}
sources -= [
......
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