Expose method on DownloadDisplayController to show the security subpage

This CL adds a method to open the security subpage on the
DownloadDisplayController. This allows code outside of
//c/b/ui/views/download to pop open the security subpage view. This is
useful in a couple of cases for deep scanning (see dependent CLs)

Bug: 1466284
Change-Id: I81447c8aea43898ffaf2db6d35d89a3b256d3ab2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4807937
Reviewed-by: Lily Chen <[email protected]>
Commit-Queue: Daniel Rubery <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1188031}
diff --git a/chrome/browser/download/bubble/download_display.h b/chrome/browser/download/bubble/download_display.h
index 20d156cf..b4b1de2 100644
--- a/chrome/browser/download/bubble/download_display.h
+++ b/chrome/browser/download/bubble/download_display.h
@@ -5,6 +5,10 @@
 #ifndef CHROME_BROWSER_DOWNLOAD_BUBBLE_DOWNLOAD_DISPLAY_H_
 #define CHROME_BROWSER_DOWNLOAD_BUBBLE_DOWNLOAD_DISPLAY_H_
 
+namespace offline_items_collection {
+struct ContentId;
+}
+
 class DownloadDisplay {
  public:
   // Shows the download display.
@@ -38,6 +42,9 @@
   // bubble because we will just temporarily reveal the toolbar when the
   // downloads finish.
   virtual bool ShouldShowExclusiveAccessBubble() = 0;
+  // Open the security subpage for the download with `id`, if it exists.
+  virtual void OpenSecuritySubpage(
+      const offline_items_collection::ContentId& id) = 0;
 
  protected:
   virtual ~DownloadDisplay();
diff --git a/chrome/browser/download/bubble/download_display_controller.cc b/chrome/browser/download/bubble/download_display_controller.cc
index 2a3f10ddb..09302aa 100644
--- a/chrome/browser/download/bubble/download_display_controller.cc
+++ b/chrome/browser/download/bubble/download_display_controller.cc
@@ -198,6 +198,11 @@
   UpdateButtonStateFromAllModelsInfo();
 }
 
+void DownloadDisplayController::OpenSecuritySubpage(
+    const offline_items_collection::ContentId& id) {
+  display_->OpenSecuritySubpage(id);
+}
+
 void DownloadDisplayController::UpdateToolbarButtonState(
     const DownloadDisplayController::AllDownloadUIModelsInfo& info) {
   if (info.all_models_size == 0) {
diff --git a/chrome/browser/download/bubble/download_display_controller.h b/chrome/browser/download/bubble/download_display_controller.h
index 0f05fae..0cb22fa2 100644
--- a/chrome/browser/download/bubble/download_display_controller.h
+++ b/chrome/browser/download/bubble/download_display_controller.h
@@ -131,6 +131,8 @@
   // Returns the DownloadDisplay. Should always return a valid display.
   DownloadDisplay* download_display_for_testing() { return display_; }
 
+  void OpenSecuritySubpage(const offline_items_collection::ContentId& id);
+
  private:
   friend class DownloadDisplayControllerTest;
 
diff --git a/chrome/browser/download/bubble/download_display_controller_unittest.cc b/chrome/browser/download/bubble/download_display_controller_unittest.cc
index 9c6f2b0..91060c8a 100644
--- a/chrome/browser/download/bubble/download_display_controller_unittest.cc
+++ b/chrome/browser/download/bubble/download_display_controller_unittest.cc
@@ -101,6 +101,8 @@
   void SetShouldShowExclusiveAccessBubble(bool show) {
     should_show_exclusive_access_bubble_ = show;
   }
+  void OpenSecuritySubpage(
+      const offline_items_collection::ContentId&) override {}
 
  private:
   bool shown_ = false;
diff --git a/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc b/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
index 4cdc185..1315608 100644
--- a/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
+++ b/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
@@ -341,6 +341,11 @@
          browser_view->CanUserExitFullscreen();
 }
 
+void DownloadToolbarButtonView::OpenSecuritySubpage(
+    const offline_items_collection::ContentId& id) {
+  OpenSecurityDialog(id);
+}
+
 // This function shows the partial view. If the main view is already showing,
 // we do not show the partial view. If the partial view is already showing,
 // there is nothing to do here, the controller should update the partial view.
diff --git a/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.h b/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.h
index 9d8a679d..74e9fbf6 100644
--- a/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.h
+++ b/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.h
@@ -77,6 +77,8 @@
   bool IsShowingDetails() override;
   bool IsFullscreenWithParentViewHidden() override;
   bool ShouldShowExclusiveAccessBubble() override;
+  void OpenSecuritySubpage(
+      const offline_items_collection::ContentId& id) override;
 
   // ToolbarButton:
   void UpdateIcon() override;