scanner: Adjust placeholder Scanner action notifications and toasts.

Since the Scanner action feedback mechanism isn't ready yet, temporarily
remove the "action complete" toast for actions other than "copy text".

Also adjust the placeholder strings on the notifications and toasts to
special case the "copy text" action.

Bug: b:382182688
Change-Id: I009d347ca5fdde2df54dbeda4a11c5a928c7bb42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6109880
Commit-Queue: Michelle Chen <michellegc@google.com>
Reviewed-by: Chuong Ho <hdchuong@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1399963}
diff --git a/ash/scanner/scanner_action_view_model.cc b/ash/scanner/scanner_action_view_model.cc
index 82b34bae..2e52928 100644
--- a/ash/scanner/scanner_action_view_model.cc
+++ b/ash/scanner/scanner_action_view_model.cc
@@ -252,6 +252,11 @@
   }
 }
 
+manta::proto::ScannerAction::ActionCase ScannerActionViewModel::GetActionCase()
+    const {
+  return unpopulated_action_.action_case();
+}
+
 void ScannerActionViewModel::ExecuteAction(
     ScannerCommandCallback action_finished_callback) const {
   unpopulated_action_.PopulateToVariant(base::BindOnce(
diff --git a/ash/scanner/scanner_action_view_model.h b/ash/scanner/scanner_action_view_model.h
index e48fcbb..c6e7c87 100644
--- a/ash/scanner/scanner_action_view_model.h
+++ b/ash/scanner/scanner_action_view_model.h
@@ -12,6 +12,7 @@
 #include "ash/scanner/scanner_unpopulated_action.h"
 #include "base/functional/callback_helpers.h"
 #include "base/memory/weak_ptr.h"
+#include "components/manta/proto/scanner.pb.h"
 
 namespace gfx {
 struct VectorIcon;
@@ -38,6 +39,7 @@
   // This may crash if this action has been previously moved.
   std::u16string GetText() const;
   const gfx::VectorIcon& GetIcon() const;
+  manta::proto::ScannerAction::ActionCase GetActionCase() const;
 
   // Executes this action, running the provided callback with a success value
   // when the execution finishes.
diff --git a/ash/scanner/scanner_controller.cc b/ash/scanner/scanner_controller.cc
index a04bbdbd..926303e 100644
--- a/ash/scanner/scanner_controller.cc
+++ b/ash/scanner/scanner_controller.cc
@@ -21,6 +21,7 @@
 #include "base/memory/ref_counted_memory.h"
 #include "base/memory/scoped_refptr.h"
 #include "components/account_id/account_id.h"
+#include "components/manta/proto/scanner.pb.h"
 #include "ui/message_center/message_center.h"
 #include "ui/message_center/public/cpp/notification.h"
 #include "ui/message_center/public/cpp/notifier_id.h"
@@ -37,7 +38,8 @@
 
 // Shows an action progress notification. Note that this will remove the
 // previous action notification if there is one.
-void ShowActionProgressNotification() {
+void ShowActionProgressNotification(
+    manta::proto::ScannerAction::ActionCase action_case) {
   message_center::RichNotificationData optional_fields;
   // Show an infinite loading progress bar.
   optional_fields.progress = -1;
@@ -48,10 +50,11 @@
                                      /*by_user=*/false);
   // TODO: crbug.com/375967525 - Finalize the action notification strings and
   // icon.
-  constexpr char16_t kPlaceholderActionProgressTitle[] = u"Creating...";
   message_center->AddNotification(CreateSystemNotificationPtr(
       message_center::NOTIFICATION_TYPE_PROGRESS, kScannerActionNotificationId,
-      kPlaceholderActionProgressTitle,
+      action_case == manta::proto::ScannerAction::kCopyToClipboard
+          ? u"Copying text..."
+          : u"Creating...",
       /*message=*/u"",
       /*display_source=*/u"", GURL(),
       message_center::NotifierId(message_center::NotifierType::SYSTEM_COMPONENT,
@@ -62,22 +65,24 @@
 }
 
 // Should be called when an action finishes execution.
-void OnActionFinished(bool success) {
+void OnActionFinished(manta::proto::ScannerAction::ActionCase action_case,
+                      bool success) {
   // Remove the action progress notification.
   message_center::MessageCenter::Get()->RemoveNotification(
       kScannerActionNotificationId,
       /*by_user=*/false);
 
   if (success) {
-    // TODO: crbug.com/382182688 - The action success text should depend on the
-    // type of action executed.
-    constexpr char16_t kPlaceholderActionSuccessText[] = u"Action Finished";
-    // TODO: crbug.com/383925780 - Add feedback mechanism to the toast.
-    ToastManager::Get()->Show(ToastData(kScannerActionSuccessToastId,
-                                        ToastCatalogName::kScannerActionSuccess,
-                                        kPlaceholderActionSuccessText));
+    // TODO: crbug.com/375967525 - Finalize the action toast string.
+    if (action_case == manta::proto::ScannerAction::kCopyToClipboard) {
+      ToastManager::Get()->Show(ToastData(
+          kScannerActionSuccessToastId, ToastCatalogName::kScannerActionSuccess,
+          u"Text copied to clipboard"));
+    }
+    // TODO: crbug.com/383925780 - We should also show a toast for other action
+    // cases once the feedback mechanism is ready.
   } else {
-    // TODO: crbug.com/378582420 - The action failure text should depend on the
+    // TODO: crbug.com/383926250 - The action failure text should depend on the
     // type of action attempted.
     constexpr char16_t kPlaceholderActionFailureText[] = u"Action Failed";
     ToastManager::Get()->Show(ToastData(kScannerActionFailureToastId,
@@ -147,8 +152,10 @@
 
 void ScannerController::ExecuteAction(
     const ScannerActionViewModel& scanner_action) {
-  scanner_action.ExecuteAction(base::BindOnce(&OnActionFinished));
-  ShowActionProgressNotification();
+  const manta::proto::ScannerAction::ActionCase action_case =
+      scanner_action.GetActionCase();
+  scanner_action.ExecuteAction(base::BindOnce(&OnActionFinished, action_case));
+  ShowActionProgressNotification(action_case);
 }
 
 bool ScannerController::HasActiveSessionForTesting() const {
diff --git a/ash/scanner/scanner_controller_unittest.cc b/ash/scanner/scanner_controller_unittest.cc
index c112ff9..7d99b24c 100644
--- a/ash/scanner/scanner_controller_unittest.cc
+++ b/ash/scanner/scanner_controller_unittest.cc
@@ -172,8 +172,10 @@
   ASSERT_TRUE(scanner_controller);
   EXPECT_TRUE(scanner_controller->StartNewSession());
   manta::proto::ScannerOutput output;
-  output.add_objects()->add_actions()->mutable_new_event()->set_title(
-      "Event title");
+  output.add_objects()
+      ->add_actions()
+      ->mutable_copy_to_clipboard()
+      ->set_html_text("<b>Hello</b>");
   FakeScannerProfileScopedDelegate& fake_profile_scoped_delegate =
       *GetFakeScannerProfileScopedDelegate(*scanner_controller);
   // Mock a successful action.