Revert "[M120 Migration]Fix for crash during chrome exit"
[platform/framework/web/chromium-efl.git] / ash / multi_device_setup / multi_device_notification_presenter.cc
index acd45f1..6d57fe0 100644 (file)
@@ -7,6 +7,7 @@
 #include <memory>
 #include <utility>
 
+#include "ash/constants/ash_features.h"
 #include "ash/constants/notifier_catalogs.h"
 #include "ash/public/cpp/notification_utils.h"
 #include "ash/public/cpp/system_tray_client.h"
@@ -97,8 +98,17 @@ MultiDeviceNotificationPresenter::~MultiDeviceNotificationPresenter() {
 }
 
 void MultiDeviceNotificationPresenter::OnPotentialHostExistsForNewUser() {
-  std::u16string title = l10n_util::GetStringUTF16(
-      IDS_ASH_MULTI_DEVICE_SETUP_NEW_USER_POTENTIAL_HOST_EXISTS_TITLE);
+  int title_message_id =
+      IDS_ASH_MULTI_DEVICE_SETUP_NEW_USER_POTENTIAL_HOST_EXISTS_TITLE;
+  if (features::IsPhoneHubOnboardingNotifierRevampEnabled() &&
+      !features::kPhoneHubOnboardingNotifierUseNudge.Get()) {
+    title_message_id =
+        features::kPhoneHubNotifierTextGroup.Get() ==
+                features::PhoneHubNotifierTextGroup::kNotifierTextGroupA
+            ? IDS_ASH_MULTI_DEVICE_SETUP_NOTIFIER_TEXT_WITH_PHONE_HUB
+            : IDS_ASH_MULTI_DEVICE_SETUP_NOTIFIER_TEXT_WITHOUT_PHONE_HUB;
+  }
+  std::u16string title = l10n_util::GetStringUTF16(title_message_id);
   std::u16string message = l10n_util::GetStringFUTF16(
       IDS_ASH_MULTI_DEVICE_SETUP_NEW_USER_POTENTIAL_HOST_EXISTS_MESSAGE,
       ui::GetChromeOSDeviceName());
@@ -167,6 +177,11 @@ void MultiDeviceNotificationPresenter::RemoveMultiDeviceSetupNotification() {
                                       /* by_user */ false);
 }
 
+void MultiDeviceNotificationPresenter::UpdateIsSetupNotificationInteracted(
+    bool is_setup_notification_interacted) {
+  is_setup_notification_interacted_ = is_setup_notification_interacted;
+}
+
 void MultiDeviceNotificationPresenter::OnUserSessionAdded(
     const AccountId& account_id) {
   ObserveMultiDeviceSetupIfPossible();
@@ -240,6 +255,16 @@ void MultiDeviceNotificationPresenter::OnNotificationClicked(
   switch (notification_status_) {
     case Status::kNewUserNotificationVisible:
       Shell::Get()->system_tray_model()->client()->ShowMultiDeviceSetup();
+      // If user has not interacted with Phone Hub icon when the notification is
+      // visible, log MultiDeviceSetup.NotificationInteracted event when
+      // notification is clicked.
+      if (!is_setup_notification_interacted_) {
+        base::UmaHistogramCounts100("MultiDeviceSetup.NotificationInteracted",
+                                    1);
+      } else {
+        // Restore the value when the notification is clicked.
+        UpdateIsSetupNotificationInteracted(false);
+      }
       break;
     case Status::kExistingUserHostSwitchedNotificationVisible:
       // Clicks on the 'host switched' and 'Chromebook added' notifications have