From ea4a361195824c08d16ecaa881fcd68683e6951e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Aug 2021 15:16:17 +0900 Subject: [PATCH 1/3] chore: cherry-pick for for 1234009 from chromium --- patches/chromium/.patches | 1 + patches/chromium/cherry-pick-1234009.patch | 137 +++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 patches/chromium/cherry-pick-1234009.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 53a2e796021a4..3cc4c7ee06519 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -182,3 +182,4 @@ cherry-pick-cd98d7c0dae9.patch replace_first_of_two_waitableevents_in_creditcardaccessmanager.patch cherry-pick-ac9dc1235e28.patch cherry-pick-1227933.patch +cherry-pick-1234009.patch diff --git a/patches/chromium/cherry-pick-1234009.patch b/patches/chromium/cherry-pick-1234009.patch new file mode 100644 index 0000000000000..d0a2d803368d2 --- /dev/null +++ b/patches/chromium/cherry-pick-1234009.patch @@ -0,0 +1,137 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Sam McNally +Date: Tue Aug 10 02:14:43 2021 +0000 +Subject: Defer looking up the WebContents for the directory confirmation dialog. + +Look up the WebContents to use for the sensitive directory confirmation +dialog immediately before it's used instead of before performing some +blocking file access to determine whether it's necessary. + +(cherry picked from commit 18236a0db8341302120c60781ae3129e94fbaf1c) + +Bug: 1234009 +Change-Id: I5e00c7fa199b3da522e1fdb73242891d7f5f7423 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3063743 +Reviewed-by: Alex Danilo +Reviewed-by: Ben Wells +Commit-Queue: Sam McNally +Cr-Original-Commit-Position: refs/heads/master@{#907467} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3083204 +Bot-Commit: Rubber Stamper +Cr-Commit-Position: refs/branch-heads/4577@{#648} +Cr-Branched-From: 761ddde228655e313424edec06497d0c56b0f3c4-refs/heads/master@{#902210} + +diff --git a/extensions/browser/api/file_system/file_system_api.cc b/extensions/browser/api/file_system/file_system_api.cc +index e9023c877b7b..110f768c12d9 100644 +--- a/extensions/browser/api/file_system/file_system_api.cc ++++ b/extensions/browser/api/file_system/file_system_api.cc +@@ -197,6 +197,9 @@ void PassFileInfoToUIThread(FileInfoOptCallback callback, + content::WebContents* GetWebContentsForRenderFrameHost( + content::BrowserContext* browser_context, + content::RenderFrameHost* render_frame_host) { ++ if (!render_frame_host) ++ return nullptr; ++ + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(render_frame_host); + // Check if there is an app window associated with the web contents; if not, +@@ -508,15 +511,6 @@ void FileSystemChooseEntryFunction::FilesSelected( + } + + if (is_directory_) { +- // Get the WebContents for the app window to be the parent window of the +- // confirmation dialog if necessary. +- content::WebContents* const web_contents = GetWebContentsForRenderFrameHost( +- browser_context(), render_frame_host()); +- if (!web_contents) { +- Respond(Error(kInvalidCallingPage)); +- return; +- } +- + DCHECK_EQ(paths.size(), 1u); + bool non_native_path = false; + #if BUILDFLAG(IS_CHROMEOS_ASH) +@@ -530,7 +524,7 @@ void FileSystemChooseEntryFunction::FilesSelected( + FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT}, + base::BindOnce( + &FileSystemChooseEntryFunction::ConfirmDirectoryAccessAsync, this, +- non_native_path, paths, web_contents)); ++ non_native_path, paths)); + return; + } + +@@ -543,8 +537,7 @@ void FileSystemChooseEntryFunction::FileSelectionCanceled() { + + void FileSystemChooseEntryFunction::ConfirmDirectoryAccessAsync( + bool non_native_path, +- const std::vector& paths, +- content::WebContents* web_contents) { ++ const std::vector& paths) { + const base::FilePath check_path = + non_native_path ? paths[0] : base::MakeAbsoluteFilePath(paths[0]); + if (check_path.empty()) { +@@ -576,7 +569,7 @@ void FileSystemChooseEntryFunction::ConfirmDirectoryAccessAsync( + FROM_HERE, + base::BindOnce( + &FileSystemChooseEntryFunction::ConfirmSensitiveDirectoryAccess, +- this, paths, web_contents)); ++ this, paths)); + return; + } + +@@ -587,8 +580,7 @@ void FileSystemChooseEntryFunction::ConfirmDirectoryAccessAsync( + } + + void FileSystemChooseEntryFunction::ConfirmSensitiveDirectoryAccess( +- const std::vector& paths, +- content::WebContents* web_contents) { ++ const std::vector& paths) { + if (ExtensionsBrowserClient::Get()->IsShuttingDown()) { + FileSelectionCanceled(); + return; +@@ -601,6 +593,13 @@ void FileSystemChooseEntryFunction::ConfirmSensitiveDirectoryAccess( + return; + } + ++ content::WebContents* const web_contents = ++ GetWebContentsForRenderFrameHost(browser_context(), render_frame_host()); ++ if (!web_contents) { ++ Respond(Error(kInvalidCallingPage)); ++ return; ++ } ++ + delegate->ConfirmSensitiveDirectoryAccess( + app_file_handler_util::HasFileSystemWritePermission(extension_.get()), + base::UTF8ToUTF16(extension_->name()), web_contents, +diff --git a/extensions/browser/api/file_system/file_system_api.h b/extensions/browser/api/file_system/file_system_api.h +index ae1588ce8536..0895a174a0dd 100644 +--- a/extensions/browser/api/file_system/file_system_api.h ++++ b/extensions/browser/api/file_system/file_system_api.h +@@ -19,10 +19,6 @@ + #include "extensions/common/api/file_system.h" + #include "ui/shell_dialogs/select_file_dialog.h" + +-namespace content { +-class WebContents; +-} // namespace content +- + namespace extensions { + class ExtensionPrefs; + +@@ -168,13 +164,12 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction { + // directory. If so, calls ConfirmSensitiveDirectoryAccess. Otherwise, calls + // OnDirectoryAccessConfirmed. + void ConfirmDirectoryAccessAsync(bool non_native_path, +- const std::vector& paths, +- content::WebContents* web_contents); ++ const std::vector& paths); + + // Shows a dialog to confirm whether the user wants to open the directory. + // Calls OnDirectoryAccessConfirmed or FileSelectionCanceled. +- void ConfirmSensitiveDirectoryAccess(const std::vector& paths, +- content::WebContents* web_contents); ++ void ConfirmSensitiveDirectoryAccess( ++ const std::vector& paths); + + void OnDirectoryAccessConfirmed(const std::vector& paths); + From 5fce9a03f26d52f9309212d491b37a1ac9a38f77 Mon Sep 17 00:00:00 2001 From: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Date: Thu, 19 Aug 2021 06:26:29 +0000 Subject: [PATCH 2/3] chore: update patches --- patches/chromium/cherry-pick-1234009.patch | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/patches/chromium/cherry-pick-1234009.patch b/patches/chromium/cherry-pick-1234009.patch index d0a2d803368d2..44c919c9065b9 100644 --- a/patches/chromium/cherry-pick-1234009.patch +++ b/patches/chromium/cherry-pick-1234009.patch @@ -1,7 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Sam McNally -Date: Tue Aug 10 02:14:43 2021 +0000 -Subject: Defer looking up the WebContents for the directory confirmation dialog. +Date: Tue, 10 Aug 2021 02:14:43 +0000 +Subject: Defer looking up the WebContents for the directory confirmation + dialog. Look up the WebContents to use for the sensitive directory confirmation dialog immediately before it's used instead of before performing some @@ -22,7 +23,7 @@ Cr-Commit-Position: refs/branch-heads/4577@{#648} Cr-Branched-From: 761ddde228655e313424edec06497d0c56b0f3c4-refs/heads/master@{#902210} diff --git a/extensions/browser/api/file_system/file_system_api.cc b/extensions/browser/api/file_system/file_system_api.cc -index e9023c877b7b..110f768c12d9 100644 +index e9023c877b7b35c0067642f05bc540858cbd7706..110f768c12d94fcfae0ac509fd0ce61c0e6049b8 100644 --- a/extensions/browser/api/file_system/file_system_api.cc +++ b/extensions/browser/api/file_system/file_system_api.cc @@ -197,6 +197,9 @@ void PassFileInfoToUIThread(FileInfoOptCallback callback, @@ -104,7 +105,7 @@ index e9023c877b7b..110f768c12d9 100644 app_file_handler_util::HasFileSystemWritePermission(extension_.get()), base::UTF8ToUTF16(extension_->name()), web_contents, diff --git a/extensions/browser/api/file_system/file_system_api.h b/extensions/browser/api/file_system/file_system_api.h -index ae1588ce8536..0895a174a0dd 100644 +index ae1588ce8536e4cee5474c3d4db370e95018c52e..0895a174a0dd1ba031fa358fe6451a1ebf198594 100644 --- a/extensions/browser/api/file_system/file_system_api.h +++ b/extensions/browser/api/file_system/file_system_api.h @@ -19,10 +19,6 @@ From 330171d17d0daf8cd27e781cc30afd243b338279 Mon Sep 17 00:00:00 2001 From: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Date: Mon, 30 Aug 2021 10:46:40 +0000 Subject: [PATCH 3/3] chore: update patches --- patches/chromium/cherry-pick-1234009.patch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/patches/chromium/cherry-pick-1234009.patch b/patches/chromium/cherry-pick-1234009.patch index 44c919c9065b9..e475f309c142a 100644 --- a/patches/chromium/cherry-pick-1234009.patch +++ b/patches/chromium/cherry-pick-1234009.patch @@ -23,10 +23,10 @@ Cr-Commit-Position: refs/branch-heads/4577@{#648} Cr-Branched-From: 761ddde228655e313424edec06497d0c56b0f3c4-refs/heads/master@{#902210} diff --git a/extensions/browser/api/file_system/file_system_api.cc b/extensions/browser/api/file_system/file_system_api.cc -index e9023c877b7b35c0067642f05bc540858cbd7706..110f768c12d94fcfae0ac509fd0ce61c0e6049b8 100644 +index a128893387beac06fb1256416ae234af251378db..870298116be17a2bb0874f8b32c8926ec19ed0d4 100644 --- a/extensions/browser/api/file_system/file_system_api.cc +++ b/extensions/browser/api/file_system/file_system_api.cc -@@ -197,6 +197,9 @@ void PassFileInfoToUIThread(FileInfoOptCallback callback, +@@ -196,6 +196,9 @@ void PassFileInfoToUIThread(FileInfoOptCallback callback, content::WebContents* GetWebContentsForRenderFrameHost( content::BrowserContext* browser_context, content::RenderFrameHost* render_frame_host) { @@ -51,7 +51,7 @@ index e9023c877b7b35c0067642f05bc540858cbd7706..110f768c12d94fcfae0ac509fd0ce61c - DCHECK_EQ(paths.size(), 1u); bool non_native_path = false; - #if BUILDFLAG(IS_CHROMEOS_ASH) + #if defined(OS_CHROMEOS) @@ -530,7 +524,7 @@ void FileSystemChooseEntryFunction::FilesSelected( FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT}, base::BindOnce( @@ -105,10 +105,10 @@ index e9023c877b7b35c0067642f05bc540858cbd7706..110f768c12d94fcfae0ac509fd0ce61c app_file_handler_util::HasFileSystemWritePermission(extension_.get()), base::UTF8ToUTF16(extension_->name()), web_contents, diff --git a/extensions/browser/api/file_system/file_system_api.h b/extensions/browser/api/file_system/file_system_api.h -index ae1588ce8536e4cee5474c3d4db370e95018c52e..0895a174a0dd1ba031fa358fe6451a1ebf198594 100644 +index 2a95c4d89fd2746aec0792f231bd20eac1b82d63..95ae48b3338ca90c25c098cd23655a84236aa6e6 100644 --- a/extensions/browser/api/file_system/file_system_api.h +++ b/extensions/browser/api/file_system/file_system_api.h -@@ -19,10 +19,6 @@ +@@ -18,10 +18,6 @@ #include "extensions/common/api/file_system.h" #include "ui/shell_dialogs/select_file_dialog.h" @@ -119,7 +119,7 @@ index ae1588ce8536e4cee5474c3d4db370e95018c52e..0895a174a0dd1ba031fa358fe6451a1e namespace extensions { class ExtensionPrefs; -@@ -168,13 +164,12 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction { +@@ -167,13 +163,12 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction { // directory. If so, calls ConfirmSensitiveDirectoryAccess. Otherwise, calls // OnDirectoryAccessConfirmed. void ConfirmDirectoryAccessAsync(bool non_native_path,