Commit b55e04f8 authored by nancy's avatar nancy Committed by Commit Bot

Convert and get the correct launch source for LaunchApp.

ChromeLauncherController::LaunchApp could be called from
AppServiceAppItem::Activate, which is not from Shelf as the launch
source, so convert and get the correct launch source from the LaunchApp
function's parameter.

BUG=1043205

Change-Id: I9ca32bc50340b861938afffadfd5c8a823d83f15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066503Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744073}
parent 31f8e515
...@@ -418,9 +418,10 @@ IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherWithParamsBrowserTest, ...@@ -418,9 +418,10 @@ IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherWithParamsBrowserTest,
// Launching non-ready ARC app creates item on shelf and spinning animation. // Launching non-ready ARC app creates item on shelf and spinning animation.
if (is_pinned()) { if (is_pinned()) {
EXPECT_EQ(ash::SHELF_ACTION_NEW_WINDOW_CREATED, EXPECT_EQ(
SelectShelfItem(shelf_id, ui::ET_MOUSE_PRESSED, ash::SHELF_ACTION_NEW_WINDOW_CREATED,
display::kInvalidDisplayId)); SelectShelfItem(shelf_id, ui::ET_MOUSE_PRESSED,
display::kInvalidDisplayId, ash::LAUNCH_FROM_SHELF));
} else { } else {
arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON, arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON,
arc::UserInteractionType::NOT_USER_INITIATED); arc::UserInteractionType::NOT_USER_INITIATED);
......
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h" #include "chrome/grit/theme_resources.h"
#include "chrome/services/app_service/public/mojom/types.mojom.h"
#include "chromeos/strings/grit/chromeos_strings.h" #include "chromeos/strings/grit/chromeos_strings.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
#include "components/arc/arc_prefs.h" #include "components/arc/arc_prefs.h"
...@@ -139,6 +140,19 @@ const extensions::Extension* GetExtension(Profile* profile, ...@@ -139,6 +140,19 @@ const extensions::Extension* GetExtension(Profile* profile,
return registry->GetInstalledExtension(extension_id); return registry->GetInstalledExtension(extension_id);
} }
apps::mojom::LaunchSource ConvertLaunchSource(ash::ShelfLaunchSource source) {
switch (source) {
case ash::LAUNCH_FROM_UNKNOWN:
return apps::mojom::LaunchSource::kUnknown;
case ash::LAUNCH_FROM_APP_LIST:
return apps::mojom::LaunchSource::kFromAppListGrid;
case ash::LAUNCH_FROM_APP_LIST_SEARCH:
return apps::mojom::LaunchSource::kFromAppListQuery;
case ash::LAUNCH_FROM_SHELF:
return apps::mojom::LaunchSource::kFromShelf;
}
}
} // namespace } // namespace
// A class to get events from ChromeOS when a user gets changed or added. // A class to get events from ChromeOS when a user gets changed or added.
...@@ -481,8 +495,7 @@ void ChromeLauncherController::LaunchApp(const ash::ShelfID& id, ...@@ -481,8 +495,7 @@ void ChromeLauncherController::LaunchApp(const ash::ShelfID& id,
apps::AppServiceProxy* proxy = apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_); apps::AppServiceProxyFactory::GetForProfile(profile_);
DCHECK(proxy); DCHECK(proxy);
proxy->Launch(app_id, event_flags, apps::mojom::LaunchSource::kFromShelf, proxy->Launch(app_id, event_flags, ConvertLaunchSource(source), display_id);
display_id);
} }
void ChromeLauncherController::ActivateApp(const std::string& app_id, void ChromeLauncherController::ActivateApp(const std::string& app_id,
......
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