Commit 4952ed4b authored by Danan S's avatar Danan S Committed by Commit Bot

Add enum ash::ShelfLaunchSource::LAUNCH_FROM_SHELF

This enum is used when launching apps from the Shelf instead of the
currently used ash::ShelfLaunchSource::LAUNCH_FROM_UNKNOWN.

This not only makes the source of the app launch more clear, but
it helps make the behavior of code that examines the app launch
source clearer.

Bug: 900261
Change-Id: I8e7d8bdf5122621bf177cb1acb429445ed97a9c7
Reviewed-on: https://chromium-review.googlesource.com/c/1460106
Commit-Queue: Danan S <danan@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630518}
parent bfeff654
...@@ -160,6 +160,8 @@ struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { ...@@ -160,6 +160,8 @@ struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> {
return ash::mojom::ShelfLaunchSource::APP_LIST; return ash::mojom::ShelfLaunchSource::APP_LIST;
case ash::LAUNCH_FROM_APP_LIST_SEARCH: case ash::LAUNCH_FROM_APP_LIST_SEARCH:
return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH; return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH;
case ash::LAUNCH_FROM_SHELF:
return ash::mojom::ShelfLaunchSource::SHELF;
} }
NOTREACHED(); NOTREACHED();
return ash::mojom::ShelfLaunchSource::UNKNOWN; return ash::mojom::ShelfLaunchSource::UNKNOWN;
...@@ -177,6 +179,9 @@ struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { ...@@ -177,6 +179,9 @@ struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> {
case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH: case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH:
*out = ash::LAUNCH_FROM_APP_LIST_SEARCH; *out = ash::LAUNCH_FROM_APP_LIST_SEARCH;
return true; return true;
case ash::mojom::ShelfLaunchSource::SHELF:
*out = ash::LAUNCH_FROM_SHELF;
return true;
} }
NOTREACHED(); NOTREACHED();
return false; return false;
......
...@@ -78,7 +78,7 @@ enum ShelfBackgroundType { ...@@ -78,7 +78,7 @@ enum ShelfBackgroundType {
// Source of the launch or activation request, for tracking. // Source of the launch or activation request, for tracking.
enum ShelfLaunchSource { enum ShelfLaunchSource {
// The item was launched from an unknown source (ie. not the app list). // The item was launched from an unknown source.
LAUNCH_FROM_UNKNOWN, LAUNCH_FROM_UNKNOWN,
// The item was launched from a generic app list view. // The item was launched from a generic app list view.
...@@ -86,6 +86,9 @@ enum ShelfLaunchSource { ...@@ -86,6 +86,9 @@ enum ShelfLaunchSource {
// The item was launched from an app list search view. // The item was launched from an app list search view.
LAUNCH_FROM_APP_LIST_SEARCH, LAUNCH_FROM_APP_LIST_SEARCH,
// The item was launched from the shelf itself.
LAUNCH_FROM_SHELF,
}; };
// The actions that may be performed when a shelf item is selected. // The actions that may be performed when a shelf item is selected.
......
...@@ -46,9 +46,10 @@ enum ShelfItemType { ...@@ -46,9 +46,10 @@ enum ShelfItemType {
// Source of the launch or activation request, for tracking. // Source of the launch or activation request, for tracking.
// These values match ash::ShelfLaunchSource. // These values match ash::ShelfLaunchSource.
enum ShelfLaunchSource { enum ShelfLaunchSource {
UNKNOWN, // The item was launched from outside the app list. UNKNOWN, // The item was launched from elsewhere.
APP_LIST, // The item was launched from a generic app list view. APP_LIST, // The item was launched from a generic app list view.
APP_LIST_SEARCH, // The item was launched from an app list search view. APP_LIST_SEARCH, // The item was launched from an app list search view.
SHELF, // The item was launched from the shelf.
}; };
// The Shelf controller allows clients (eg. Chrome) to control the ash shelf. // The Shelf controller allows clients (eg. Chrome) to control the ash shelf.
......
...@@ -51,7 +51,7 @@ TEST_F(AppListShelfItemDelegateTest, OnlyMinimizeCycleListWindows) { ...@@ -51,7 +51,7 @@ TEST_F(AppListShelfItemDelegateTest, OnlyMinimizeCycleListWindows) {
ui::EventType::ET_MOUSE_PRESSED, ui::VKEY_UNKNOWN, ui::EF_NONE); ui::EventType::ET_MOUSE_PRESSED, ui::VKEY_UNKNOWN, ui::EF_NONE);
delegate()->ItemSelected( delegate()->ItemSelected(
std::move(test_event), GetPrimaryDisplay().id(), std::move(test_event), GetPrimaryDisplay().id(),
ShelfLaunchSource::LAUNCH_FROM_UNKNOWN, ShelfLaunchSource::LAUNCH_FROM_SHELF,
base::BindOnce( base::BindOnce(
[](ash::ShelfAction, base::Optional<ash::MenuItemList>) {})); [](ash::ShelfAction, base::Optional<ash::MenuItemList>) {}));
ASSERT_TRUE(wm::GetWindowState(w1.get())->IsMinimized()); ASSERT_TRUE(wm::GetWindowState(w1.get())->IsMinimized());
......
...@@ -106,7 +106,7 @@ void Shelf::ActivateShelfItemOnDisplay(int item_index, int64_t display_id) { ...@@ -106,7 +106,7 @@ void Shelf::ActivateShelfItemOnDisplay(int item_index, int64_t display_id) {
ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id);
std::unique_ptr<ui::Event> event = std::make_unique<ui::KeyEvent>( std::unique_ptr<ui::Event> event = std::make_unique<ui::KeyEvent>(
ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE); ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE);
item_delegate->ItemSelected(std::move(event), display_id, LAUNCH_FROM_UNKNOWN, item_delegate->ItemSelected(std::move(event), display_id, LAUNCH_FROM_SHELF,
base::DoNothing()); base::DoNothing());
} }
......
...@@ -684,7 +684,7 @@ void ShelfView::ButtonPressed(views::Button* sender, ...@@ -684,7 +684,7 @@ void ShelfView::ButtonPressed(views::Button* sender,
// Notify the item of its selection; handle the result in AfterItemSelected. // Notify the item of its selection; handle the result in AfterItemSelected.
item_awaiting_response_ = item.id; item_awaiting_response_ = item.id;
model_->GetShelfItemDelegate(item.id)->ItemSelected( model_->GetShelfItemDelegate(item.id)->ItemSelected(
ui::Event::Clone(event), GetDisplayIdForView(this), LAUNCH_FROM_UNKNOWN, ui::Event::Clone(event), GetDisplayIdForView(this), LAUNCH_FROM_SHELF,
base::BindOnce(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(), base::BindOnce(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(),
item, sender, base::Passed(ui::Event::Clone(event)), item, sender, base::Passed(ui::Event::Clone(event)),
ink_drop)); ink_drop));
......
...@@ -93,7 +93,7 @@ void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) { ...@@ -93,7 +93,7 @@ void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) {
case ash::MENU_OPEN_NEW: case ash::MENU_OPEN_NEW:
// Use a copy of the id to avoid crashes, as this menu's owner will be // Use a copy of the id to avoid crashes, as this menu's owner will be
// destroyed if LaunchApp replaces the ShelfItemDelegate instance. // destroyed if LaunchApp replaces the ShelfItemDelegate instance.
controller_->LaunchApp(ash::ShelfID(item_.id), ash::LAUNCH_FROM_UNKNOWN, controller_->LaunchApp(ash::ShelfID(item_.id), ash::LAUNCH_FROM_SHELF,
ui::EF_NONE, display_id_); ui::EF_NONE, display_id_);
break; break;
case ash::MENU_CLOSE: case ash::MENU_CLOSE:
......
...@@ -249,7 +249,8 @@ void LauncherControllerHelper::LaunchApp(const ash::ShelfID& id, ...@@ -249,7 +249,8 @@ void LauncherControllerHelper::LaunchApp(const ash::ShelfID& id,
AppLaunchParams params = CreateAppLaunchParamsWithEventFlags( AppLaunchParams params = CreateAppLaunchParamsWithEventFlags(
profile_, extension, event_flags, extensions::SOURCE_APP_LAUNCHER, profile_, extension, event_flags, extensions::SOURCE_APP_LAUNCHER,
display_id); display_id);
if (source != ash::LAUNCH_FROM_UNKNOWN && if ((source == ash::LAUNCH_FROM_APP_LIST ||
source == ash::LAUNCH_FROM_APP_LIST_SEARCH) &&
app_id == extensions::kWebStoreAppId) { app_id == extensions::kWebStoreAppId) {
// Get the corresponding source string. // Get the corresponding source string.
std::string source_value = GetSourceFromAppListSource(source); std::string source_value = GetSourceFromAppListSource(source);
......
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