Use a repeating callback for AppStreamLauncherItem's pressed callback.
PressedCallback will become move-only when it supports OnceCallbacks.
Since AppStreamLauncherItem wants to use the same callback for the
button and label, and it doesn't care about the `ui::Event`, just pass a
RepeatingClosure through to be shared instead.
Bug: 1326449
Change-Id: Ic019752bf19047eddd1145378b13f89b1128e920
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5078790
Reviewed-by: Pu Shi <pushi@google.com>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1232238}
diff --git a/ash/system/phonehub/app_stream_launcher_item.cc b/ash/system/phonehub/app_stream_launcher_item.cc
index 9ebeb1ee..941ec65 100644
--- a/ash/system/phonehub/app_stream_launcher_item.cc
+++ b/ash/system/phonehub/app_stream_launcher_item.cc
@@ -4,7 +4,10 @@
#include "ash/system/phonehub/app_stream_launcher_item.h"
+#include <utility>
+
#include "ash/strings/grit/ash_strings.h"
+#include "base/functional/callback.h"
#include "base/hash/hash.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
@@ -68,7 +71,7 @@
} // namespace
AppStreamLauncherItem::AppStreamLauncherItem(
- views::ImageButton::PressedCallback callback,
+ base::RepeatingClosure callback,
const phonehub::Notification::AppMetadata& app_metadata) {
SetPreferredSize(kEcheAppItemSize);
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
@@ -107,8 +110,8 @@
recent_app_button_->SetTooltipText(accessible_name);
recent_app_button_->SetEnabled(enabled);
- label_ = AddChildView(
- std::make_unique<AppNameLabel>(callback, app_metadata.visible_app_name));
+ label_ = AddChildView(std::make_unique<AppNameLabel>(
+ std::move(callback), app_metadata.visible_app_name));
label_->SetEnabled(enabled);
label_->SetAccessibleName(accessible_name);
label_->SetTooltipText(accessible_name);
diff --git a/ash/system/phonehub/app_stream_launcher_item.h b/ash/system/phonehub/app_stream_launcher_item.h
index 791c82a5..3559e59 100644
--- a/ash/system/phonehub/app_stream_launcher_item.h
+++ b/ash/system/phonehub/app_stream_launcher_item.h
@@ -7,6 +7,7 @@
#include "ash/ash_export.h"
#include "ash/system/phonehub/phone_hub_recent_app_button.h"
+#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "chromeos/ash/components/phonehub/notification.h"
#include "ui/base/metadata/metadata_header_macros.h"
@@ -25,7 +26,7 @@
public:
AppStreamLauncherItem(
- views::ImageButton::PressedCallback callback,
+ base::RepeatingClosure callback,
const phonehub::Notification::AppMetadata& app_metadata);
~AppStreamLauncherItem() override;
diff --git a/ash/system/phonehub/app_stream_launcher_view.cc b/ash/system/phonehub/app_stream_launcher_view.cc
index e33816c7..863b4c1 100644
--- a/ash/system/phonehub/app_stream_launcher_view.cc
+++ b/ash/system/phonehub/app_stream_launcher_view.cc
@@ -191,8 +191,7 @@
}
void AppStreamLauncherView::AppIconActivated(
- phonehub::Notification::AppMetadata app,
- const ui::Event& event) {
+ phonehub::Notification::AppMetadata app) {
auto* interaction_handler_ =
phone_hub_manager_->GetRecentAppsInteractionHandler();
if (!interaction_handler_)
diff --git a/ash/system/phonehub/app_stream_launcher_view.h b/ash/system/phonehub/app_stream_launcher_view.h
index 67756b3e..0f7e3d4 100644
--- a/ash/system/phonehub/app_stream_launcher_view.h
+++ b/ash/system/phonehub/app_stream_launcher_view.h
@@ -68,8 +68,7 @@
views::Button::PressedCallback callback,
const gfx::VectorIcon& icon,
int message_id);
- void AppIconActivated(phonehub::Notification::AppMetadata app,
- const ui::Event& event);
+ void AppIconActivated(phonehub::Notification::AppMetadata app);
// Update the UI based on the information in the data model.
void UpdateFromDataModel();