Skip to content

Commit 9f136c3

Browse files
Sydney LiSydney Li
Sydney Li
authored and
Sydney Li
committed
Pull in file chooser from Chromium
fix brave/browser-laptop#10666 fix brave/browser-laptop#8601 Auditors: @darkdh, @bbondy, @bsclifton, @bridiver
1 parent d152082 commit 9f136c3

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

atom/browser/common_web_contents_delegate.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "chrome/browser/certificate_viewer.h"
2323
#include "chrome/browser/ssl/security_state_tab_helper.h"
2424
#include "chrome/browser/ui/browser.h"
25+
#include "chrome/browser/file_select_helper.h"
2526
#include "chrome/browser/ui/browser_dialogs.h"
2627
#include "chrome/common/pref_names.h"
2728
#include "chrome/grit/generated_resources.h"
@@ -278,9 +279,7 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
278279
void CommonWebContentsDelegate::RunFileChooser(
279280
content::RenderFrameHost* render_frame_host,
280281
const content::FileChooserParams& params) {
281-
if (!web_dialog_helper_)
282-
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
283-
web_dialog_helper_->RunFileChooser(render_frame_host, params);
282+
FileSelectHelper::RunFileChooser(render_frame_host, params);
284283
}
285284

286285
void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,

brave/browser/brave_browser_context.cc

+8
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,14 @@ BraveBrowserContext::GetIOTaskRunner() {
637637
GetPath(), BrowserThread::GetBlockingPool());
638638
}
639639

640+
base::FilePath BraveBrowserContext::last_selected_directory() {
641+
return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
642+
}
643+
644+
void BraveBrowserContext::set_last_selected_directory(const base::FilePath& path) {
645+
GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
646+
}
647+
640648
} // namespace brave
641649

642650
namespace atom {

brave/browser/brave_browser_context.h

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class BraveBrowserContext : public Profile {
8787
bool HasOffTheRecordProfile() override;
8888
Profile* GetOriginalProfile() override;
8989
bool IsSameProfile(Profile* profile) override;
90+
base::FilePath last_selected_directory() override;
91+
void set_last_selected_directory(const base::FilePath& path) override;
9092

9193
user_prefs::PrefRegistrySyncable* pref_registry() const override {
9294
return pref_registry_.get(); }

chromium_src/BUILD.gn

+10
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ source_set("browser") {
192192
"//chrome/browser/extensions/global_shortcut_listener_win.cc",
193193
"//chrome/browser/extensions/global_shortcut_listener_win.h",
194194

195+
"//chrome/browser/file_select_helper.cc",
196+
"//chrome/browser/file_select_helper_mac.mm",
197+
"//chrome/browser/file_select_helper.h",
198+
195199
"chrome/browser/first_run/first_run.cc",
196200
"//chrome/browser/first_run/first_run.h",
197201
"//chrome/browser/first_run/upgrade_util.h",
@@ -239,6 +243,12 @@ source_set("browser") {
239243
"chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc",
240244
"//chrome/browser/ui/webui/chrome_web_ui_controller_factory.h",
241245

246+
"//chrome/browser/platform_util.h",
247+
"//chrome/browser/platform_util.cc",
248+
"//chrome/browser/platform_util_mac.mm",
249+
"//chrome/browser/platform_util_linux.cc",
250+
"//chrome/browser/platform_util_win.cc",
251+
242252
"//chrome/browser/process_singleton_posix.cc",
243253
"//chrome/browser/process_singleton_win.cc",
244254
"//chrome/browser/process_singleton.h",

chromium_src/chrome/browser/profiles/profile.h

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class Profile : public atom::AtomBrowserContext {
129129
// TODO(wjmaclean): Remove this when HostZoomMap migrates to StoragePartition.
130130
virtual ChromeZoomLevelPrefs* GetZoomLevelPrefs();
131131

132+
virtual base::FilePath last_selected_directory() = 0;
133+
virtual void set_last_selected_directory(const base::FilePath& path) = 0;
134+
132135
// Return whether 2 profiles are the same. 2 profiles are the same if they
133136
// represent the same profile. This can happen if there is pointer equality
134137
// or if one profile is the incognito version of another profile (or vice

patches/master_patch.patch

+13
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ index e659aec2f7d606037a7867d6ae1f7186d96ce8eb..a446553206403b575e3e0b3b49027b41
159159
"safe_browsing::mojom::SafeBrowsing",
160160
"spellcheck::mojom::SpellCheckHost",
161161
"spellcheck::mojom::SpellCheckPanelHost",
162+
diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc
163+
index 2580748f689b7aac2a48e9b7389802e381fa4925..eb3c928a9709e4770e231aff07c3f9aaddb04ef5 100644
164+
--- a/chrome/browser/file_select_helper.cc
165+
+++ b/chrome/browser/file_select_helper.cc
166+
@@ -576,7 +576,7 @@ void FileSelectHelper::RunFileChooserOnUIThread(
167+
return;
168+
169+
select_file_dialog_ = ui::SelectFileDialog::Create(
170+
- this, std::make_unique<ChromeSelectFilePolicy>(web_contents_));
171+
+ this, std::make_unique<ChromeSelectFilePolicy>(nullptr));
172+
if (!select_file_dialog_.get())
173+
return;
174+
162175
diff --git a/chrome/browser/importer/external_process_importer_client.h b/chrome/browser/importer/external_process_importer_client.h
163176
index 864a6951115dda5ed74963f18b35692960397d50..3e1a2b719521ac2c60bae05f94e409bc4c7da022 100644
164177
--- a/chrome/browser/importer/external_process_importer_client.h

0 commit comments

Comments
 (0)