Make content::FileSelectListener a RefCounted

We can avoid a raw pointer reference to FileSelectListener.

* content/public/browser/file_select_listener.h
  Make content:FileSelectListener a RefCounted.

* content/browser/web_contents/file_chooser_impl.{cc,h}
  - Adjust a FileSelectListener subclass for RefCounted.
  - Change the FileSelectListenerImpl raw pointer member to
    scoped_refptr<FileSelectListenerImpl>.
  - Remove FileChooserImpl::ResetListenerImpl(). It was called when
    FileSelectLisetnerImpl was deleted in order to clear
    FileChooserImpl::listener_impl_ raw pointer member. Now
    FileChooserImpl has ownership of FileSelectListenerImpl.

* chrome/browser/file_select_helper_unittest.cc
* content/browser/web_contents/web_contents_impl_browsertest.cc
  Adjust FileSelectListener subclasses for RefCounted.

* Other files
  Mechanical changes; std::unique_ptr<> ==> scoped_refptr<>

This CL doesn't have any user-visible behavior changes.


Change-Id: I643aeb7aa0c717dad9716028317cab061d8df510
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2275338
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Istiaque Ahmed <[email protected]>
Reviewed-by: Bo <[email protected]>
Commit-Queue: Kent Tamura <[email protected]>
Cr-Commit-Position: refs/heads/master@{#784640}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 4f56a70..cf4d0c4 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -5019,7 +5019,7 @@
 
 void WebContentsImpl::EnumerateDirectory(
     RenderFrameHost* render_frame_host,
-    std::unique_ptr<FileChooserImpl::FileSelectListenerImpl> listener,
+    scoped_refptr<FileChooserImpl::FileSelectListenerImpl> listener,
     const base::FilePath& directory_path) {
   // Any explicit focusing of another window while this WebContents is in
   // fullscreen can be used to confuse the user, so drop fullscreen.
@@ -5723,7 +5723,7 @@
 
 void WebContentsImpl::RunFileChooser(
     RenderFrameHost* render_frame_host,
-    std::unique_ptr<FileChooserImpl::FileSelectListenerImpl> listener,
+    scoped_refptr<FileChooserImpl::FileSelectListenerImpl> listener,
     const blink::mojom::FileChooserParams& params) {
   // Any explicit focusing of another window while this WebContents is in
   // fullscreen can be used to confuse the user, so drop fullscreen.