[NextBrowser][DF250404-00598] Close exit pop up when return key is pressed 87/322287/4
authoramondiguing <a.mondiguing@samsung.com>
Mon, 7 Apr 2025 08:26:59 +0000 (16:26 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 8 Apr 2025 05:48:16 +0000 (05:48 +0000)
 - Save an instance of widget in bubble view class
 - Use saved instance of widget when closing popup

Change-Id: Ie4cdb709a93eb312391f16d27f277ea3771d4db8

chrome/browser/ui/samsung/hybrid_navigation_controller.cc
chrome/browser/ui/samsung/hybrid_navigation_controller.h
chrome/browser/ui/views/samsung/exit_browser_bubble_view.cc
chrome/browser/ui/views/samsung/exit_browser_bubble_view.h
chrome/browser/ui/views/toolbar/toolbar_view.cc
chrome/browser/ui/views/toolbar/toolbar_view.h
components/samsung/public/samsung_browser_enums.h

index c1adabde0b1236710876fea55bb451609c97e732..1d49e3d8e027d80025fa8a9cb9b90b461362b87a 100644 (file)
@@ -61,7 +61,8 @@ HybridNavigationController::HybridNavigationController(Browser* browser)
       is_enter_key_released(false),
       is_popup_exists_(false),
       is_restore_popup_exists_(false),
-      is_bookamrk_popup_open_(false) {
+      is_bookamrk_popup_open_(false),
+      is_exit_popup_open_(false) {
   LOG(INFO) << "";
 }
 HybridNavigationController::~HybridNavigationController() {
@@ -374,6 +375,14 @@ bool HybridNavigationController::KeyEvent(
         }
         break;
       }
+      case samsung_browser_main::NativePopupType::EXIT: {
+        if (!keynameBack.compare(key)) {
+          browser_view_->toolbar()->CloseExitBrowserBubble();
+          LOG(INFO) << "exit popup close executed";
+          return true;
+        }
+        break;
+      }
     }
   }
 
@@ -570,6 +579,7 @@ void HybridNavigationController::BackKeyPressed() {
       } else {
         LOG(INFO) << "Tab Index not found";
       }
+
     } else {
       // show browser exit popup
       browser_view_->toolbar()->ShowExitBrowserBubble();
@@ -720,6 +730,8 @@ HybridNavigationController::GetNativePopupType() {
     return samsung_browser_main::NativePopupType::BOOKMARK;
   } else if (popup && popup->isMVOpen()) {
     return samsung_browser_main::NativePopupType::MOST_VISITED;
+  } else if (is_exit_popup_open_) {
+    return samsung_browser_main::NativePopupType::EXIT;
   }
   return samsung_browser_main::NativePopupType::NONE;
 }
index 38ae72856ff21e0a622fecdc7fca6b7d95a854a1..39cb4c0df5746ec333ae3f42eb381903af5f11b4 100644 (file)
@@ -78,6 +78,7 @@ class HybridNavigationController
   void SetPopupExists(bool val) { is_popup_exists_ = val; }
   void SetRestorePopupExists(bool val) { is_restore_popup_exists_ = val; }
   void SetBookmarkPopupOpen(bool val) { is_bookamrk_popup_open_ = val; }
+  void SetExitPopupExists(bool val) { is_exit_popup_open_ = val; }
   bool IsPopupExists() {
     return (is_popup_exists_ || is_restore_popup_exists_);
   }
@@ -127,6 +128,7 @@ class HybridNavigationController
   bool is_popup_exists_;
   bool is_restore_popup_exists_;
   bool is_bookamrk_popup_open_;
+  bool is_exit_popup_open_;
   // std::map<Tab*, HybridNavigationDriver*> tabIdToWebHandler;
 };
 }  // namespace samsung_browser_controller
index 4cd9a05c27217c7f6b16ce203838b5e554a544d3..ec3d288751f69f685d1dbdfe8c591323ce5225a9 100644 (file)
@@ -4,17 +4,38 @@
 
 #include "exit_browser_bubble_view.h"
 
+// static
+views::Widget* SamsungExitBrowserBubbleDialogView::current_instance_ = nullptr;
+
 // static
 void SamsungExitBrowserBubbleDialogView::Show(
     views::View* anchor_view,
     views::BubbleBorder::Arrow anchor_position) {
-  views::Widget* widget = BubbleDialogDelegateView::CreateBubble(
-      new SamsungExitBrowserBubbleDialogView(anchor_view, anchor_position));
-  widget->Show();
+  SamsungExitBrowserBubbleDialogView::current_instance_ =
+      BubbleDialogDelegateView::CreateBubble(
+          new SamsungExitBrowserBubbleDialogView(anchor_view, anchor_position));
+  current_instance_->Show();
 }
 
-SamsungExitBrowserBubbleDialogView::~SamsungExitBrowserBubbleDialogView() =
-    default;
+// static
+void SamsungExitBrowserBubbleDialogView::Close() {
+  LOG(INFO) << "";
+  if (current_instance_) {
+    current_instance_->Close();
+  }
+
+  current_instance_ = nullptr;
+}
+
+SamsungExitBrowserBubbleDialogView::~SamsungExitBrowserBubbleDialogView() {
+  LOG(INFO) << "";
+  auto hnc = samsung_browser_main::SamsungBrowserCore::instance()
+                 ->HybridNavigationController();
+  if (hnc) {
+    LOG(INFO) << "Setting exit popup state false";
+    hnc->SetExitPopupExists(false);
+  }
+}
 
 SamsungExitBrowserBubbleDialogView::SamsungExitBrowserBubbleDialogView(
     views::View* anchor_view,
@@ -47,7 +68,7 @@ SamsungExitBrowserBubbleDialogView::SamsungExitBrowserBubbleDialogView(
 
   SetShowCloseButton(false);
 
-  hybrid_navigation_controller->SetPopupExists(true);
+  hybrid_navigation_controller->SetExitPopupExists(true);
 
   std::u16string exit = multi_language_controller->GetUTF16String("SID_EXIT");
   std::u16string cancel =
@@ -93,7 +114,6 @@ void SamsungExitBrowserBubbleDialogView::ExitButtonPressed() {
     LOG(INFO) << "hybrid_navigation_controller is null";
     return;
   }
-  hybrid_navigation_controller->SetPopupExists(false);
   LOG(INFO) << "browser terminating";
   chrome::AttemptUserExit();
 }
@@ -111,5 +131,4 @@ void SamsungExitBrowserBubbleDialogView::CancelExitBrowserPopup() {
     LOG(INFO) << "hybrid_navigation_controller is null";
     return;
   }
-  hybrid_navigation_controller->SetPopupExists(false);
 }
\ No newline at end of file
index 9bfadf09940ac9d7270a1e433bedf5e8179b4267..fb92695a73047a42919ee7efe1df9441b3d3e3f1 100644 (file)
@@ -30,6 +30,7 @@ class SamsungExitBrowserBubbleDialogView
  public:
   static void Show(views::View* anchor_view,
                    views::BubbleBorder::Arrow anchor_position);
+  static void Close();
 
   ~SamsungExitBrowserBubbleDialogView() override;
 
@@ -39,6 +40,8 @@ class SamsungExitBrowserBubbleDialogView
       views::BubbleBorder::Arrow anchor_position);
   void ExitButtonPressed();
   void CancelExitBrowserPopup();
+
+  static views::Widget* current_instance_;
 };
 
 #endif  // CHROME_BROWSER_UI_VIEWS_SAMSUNG_EXIT_BROWSER_BUBBLE_VIEW_H_
\ No newline at end of file
index 1aaaf7536a21135c3dae4d85757e49159881e884..3b9dec1da4bca786e8233cdea75f1d943b4f953d 100644 (file)
@@ -952,6 +952,10 @@ void ToolbarView::ShowExitBrowserBubble() {
                                            views::BubbleBorder::Arrow::FLOAT);
 }
 
+void ToolbarView::CloseExitBrowserBubble() {
+  SamsungExitBrowserBubbleDialogView::Close();
+}
+
 #endif //SAMSUNG_TOOLBAR_UI
 
 ExtensionsToolbarButton* ToolbarView::GetExtensionsButton() const {
index 2a4b8bc9a04dbde66eaea56a9b9da0d10d2bbf3e..7d5c8d180989bc4303cb4367f18017330147643d 100644 (file)
@@ -158,6 +158,7 @@ class ToolbarView : public views::AccessiblePaneView,
       bool already_bookmarked,
       samsung_browser_fw_core::WatchlaterIconState watch_later_icon_state);
   void ShowExitBrowserBubble();
+  void CloseExitBrowserBubble();
 #endif //SAMSUNG_TOOLBAR_UI
   // Accessors.
   Browser* browser() const { return browser_; }
index 12c35c2f2fde3659a0bd34531c0b5e811b959a0f..d91d4e1e24fbd527cf834e0fc5c4d708adc95005 100644 (file)
@@ -76,7 +76,8 @@ enum class NativePopupType {
   MENU_TREE = 3,
   CONTEXT_MENU = 4,
   MOST_VISITED = 5,
-  BOOKMARK = 6
+  BOOKMARK = 6,
+  EXIT = 7,
 };
 enum SynchronizationItem {
   Bookmarks = 0,