Commit 73c3c21a authored by Tim Zheng's avatar Tim Zheng Committed by Commit Bot

Launch Crostini app on the launcher display.

When a Crostini app is started by clicking on the launcher item, this
change makes the app windows start in the same display as the launcher.

BUG=chromium:843001
TEST=Manual test on an eve device.

Change-Id: Id3b65d71148d1e4107d8f9bddd31b2a27df6a58b
Reviewed-on: https://chromium-review.googlesource.com/1089880Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarStefan Kuhne <skuhne@chromium.org>
Commit-Queue: Tim Zheng <timzheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565391}
parent 0a85ddf2
......@@ -104,7 +104,8 @@ void AppListControllerDelegateImpl::ActivateApp(
}
ChromeLauncherController::instance()->ActivateApp(
extension->id(), AppListSourceToLaunchSource(source), event_flags);
extension->id(), AppListSourceToLaunchSource(source), event_flags,
display::kInvalidDisplayId);
if (!IsHomeLauncherEnabledInTabletMode())
DismissView();
......
......@@ -48,7 +48,8 @@ const char* CrostiniAppItem::GetItemType() const {
void CrostiniAppItem::Activate(int event_flags) {
ChromeLauncherController::instance()->ActivateApp(
id(), ash::LAUNCH_FROM_APP_LIST, event_flags);
id(), ash::LAUNCH_FROM_APP_LIST, event_flags,
GetController()->GetAppListDisplayId());
// Launching Crostini apps can take a few seconds if the container is not
// currently running. We show a spinner in the shelf but it looks nicer to
......
......@@ -32,7 +32,8 @@ CrostiniAppResult::~CrostiniAppResult() = default;
void CrostiniAppResult::Open(int event_flags) {
ChromeLauncherController::instance()->ActivateApp(
id(), ash::LAUNCH_FROM_APP_LIST_SEARCH, event_flags);
id(), ash::LAUNCH_FROM_APP_LIST_SEARCH, event_flags,
controller()->GetAppListDisplayId());
// Manually dismiss the app list as it can take several seconds for apps to
// launch.
......
......@@ -90,9 +90,9 @@ namespace {
// Calls ItemSelected with |source|, default arguments, and no callback.
void SelectItemWithSource(ash::ShelfItemDelegate* delegate,
ash::ShelfLaunchSource source) {
delegate->ItemSelected(nullptr, display::kInvalidDisplayId, source,
base::DoNothing());
ash::ShelfLaunchSource source,
int64_t display_id) {
delegate->ItemSelected(nullptr, display_id, source, base::DoNothing());
}
// Returns true if the given |item| has a pinned shelf item type.
......@@ -409,12 +409,13 @@ void ChromeLauncherController::LaunchApp(const ash::ShelfID& id,
void ChromeLauncherController::ActivateApp(const std::string& app_id,
ash::ShelfLaunchSource source,
int event_flags) {
int event_flags,
int64_t display_id) {
// If there is an existing delegate for this app, select it.
const ash::ShelfID shelf_id(app_id);
ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(shelf_id);
if (delegate) {
SelectItemWithSource(delegate, source);
SelectItemWithSource(delegate, source, display_id);
return;
}
......@@ -422,9 +423,9 @@ void ChromeLauncherController::ActivateApp(const std::string& app_id,
std::unique_ptr<AppShortcutLauncherItemController> item_delegate =
AppShortcutLauncherItemController::Create(shelf_id);
if (!item_delegate->GetRunningApplications().empty())
SelectItemWithSource(item_delegate.get(), source);
SelectItemWithSource(item_delegate.get(), source, display_id);
else
LaunchApp(shelf_id, source, event_flags, display::kInvalidDisplayId);
LaunchApp(shelf_id, source, event_flags, display_id);
}
void ChromeLauncherController::SetLauncherItemImage(
......
......@@ -134,7 +134,8 @@ class ChromeLauncherController
// Used by the app-list, and by pinned-app shelf items.
void ActivateApp(const std::string& app_id,
ash::ShelfLaunchSource source,
int event_flags);
int event_flags,
int64_t display_id);
// Set the image for a specific shelf item (e.g. when set by the app).
void SetLauncherItemImage(const ash::ShelfID& shelf_id,
......
......@@ -976,9 +976,11 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateApp) {
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("app1"));
controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0);
controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0,
display::kInvalidDisplayId);
EXPECT_EQ(++tab_count, tab_strip->count());
controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0);
controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0,
display::kInvalidDisplayId);
EXPECT_EQ(tab_count, tab_strip->count());
}
......@@ -1852,8 +1854,10 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, TabbedHostedAndBookmarkApps) {
shelf_model()->ItemByID(bookmark_app_shelf_id)->status);
// Now use the launcher controller to activate the apps.
controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0,
display::kInvalidDisplayId);
controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0,
display::kInvalidDisplayId);
// There should be no new browsers or tabs as both apps were already open.
EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
......@@ -1903,8 +1907,10 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, WindowedHostedAndBookmarkApps) {
shelf_model()->ItemByID(bookmark_app_shelf_id)->status);
// Now use the launcher controller to activate the apps.
controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0,
display::kInvalidDisplayId);
controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0,
display::kInvalidDisplayId);
// There should be two new browsers.
EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile()));
......
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