Skip to content

Commit

Permalink
Pull in file chooser from Chromium
Browse files Browse the repository at this point in the history
  • Loading branch information
Sydney Li authored and Sydney Li committed Oct 19, 2017
1 parent d152082 commit 2c1f33f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
5 changes: 2 additions & 3 deletions atom/browser/common_web_contents_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "chrome/browser/certificate_viewer.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
Expand Down Expand Up @@ -278,9 +279,7 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
void CommonWebContentsDelegate::RunFileChooser(
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
if (!web_dialog_helper_)
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
web_dialog_helper_->RunFileChooser(render_frame_host, params);
FileSelectHelper::RunFileChooser(render_frame_host, params);
}

void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,
Expand Down
8 changes: 8 additions & 0 deletions brave/browser/brave_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,14 @@ BraveBrowserContext::GetIOTaskRunner() {
GetPath(), BrowserThread::GetBlockingPool());
}

base::FilePath BraveBrowserContext::last_selected_directory() {
return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
}

void BraveBrowserContext::set_last_selected_directory(const base::FilePath& path) {
GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
}

} // namespace brave

namespace atom {
Expand Down
2 changes: 2 additions & 0 deletions brave/browser/brave_browser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class BraveBrowserContext : public Profile {
bool HasOffTheRecordProfile() override;
Profile* GetOriginalProfile() override;
bool IsSameProfile(Profile* profile) override;
base::FilePath last_selected_directory() override;
void set_last_selected_directory(const base::FilePath& path) override;

user_prefs::PrefRegistrySyncable* pref_registry() const override {
return pref_registry_.get(); }
Expand Down
13 changes: 13 additions & 0 deletions chromium_src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ source_set("browser") {
"//chrome/browser/extensions/global_shortcut_listener_win.cc",
"//chrome/browser/extensions/global_shortcut_listener_win.h",

"//chrome/browser/file_select_helper.cc",
"//chrome/browser/file_select_helper_mac.mm",
"//chrome/browser/file_select_helper.h",

"chrome/browser/first_run/first_run.cc",
"//chrome/browser/first_run/first_run.h",
"//chrome/browser/first_run/upgrade_util.h",
Expand Down Expand Up @@ -232,13 +236,22 @@ source_set("browser") {
"//chrome/browser/ui/browser.h",
"chrome/browser/ui/browser_otr_state.cc",

"//chrome/browser/ui/chrome_select_file_policy.h",
"//chrome/browser/ui/chrome_select_file_policy.cc",

"chrome/browser/ui/profile_error_dialog.cc",

"//chrome/browser/ui/web_contents_sizer.cc",
"//chrome/browser/ui/web_contents_sizer.h",
"chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc",
"//chrome/browser/ui/webui/chrome_web_ui_controller_factory.h",

"//chrome/browser/platform_util.h",
"//chrome/browser/platform_util.cc",
"//chrome/browser/platform_util_mac.mm",
"//chrome/browser/platform_util_linux.cc",
"//chrome/browser/platform_util_win.cc",

"//chrome/browser/process_singleton_posix.cc",
"//chrome/browser/process_singleton_win.cc",
"//chrome/browser/process_singleton.h",
Expand Down
3 changes: 3 additions & 0 deletions chromium_src/chrome/browser/profiles/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Profile : public atom::AtomBrowserContext {
// TODO(wjmaclean): Remove this when HostZoomMap migrates to StoragePartition.
virtual ChromeZoomLevelPrefs* GetZoomLevelPrefs();

virtual base::FilePath last_selected_directory() = 0;
virtual void set_last_selected_directory(const base::FilePath& path) = 0;

// Return whether 2 profiles are the same. 2 profiles are the same if they
// represent the same profile. This can happen if there is pointer equality
// or if one profile is the incognito version of another profile (or vice
Expand Down
13 changes: 13 additions & 0 deletions patches/master_patch.patch
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ index e659aec2f7d606037a7867d6ae1f7186d96ce8eb..a446553206403b575e3e0b3b49027b41
"safe_browsing::mojom::SafeBrowsing",
"spellcheck::mojom::SpellCheckHost",
"spellcheck::mojom::SpellCheckPanelHost",
diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc
index 2580748f689b7aac2a48e9b7389802e381fa4925..eb3c928a9709e4770e231aff07c3f9aaddb04ef5 100644
--- a/chrome/browser/file_select_helper.cc
+++ b/chrome/browser/file_select_helper.cc
@@ -576,7 +576,7 @@ void FileSelectHelper::RunFileChooserOnUIThread(
return;

select_file_dialog_ = ui::SelectFileDialog::Create(
- this, std::make_unique<ChromeSelectFilePolicy>(web_contents_));
+ this, std::make_unique<ChromeSelectFilePolicy>(nullptr));
if (!select_file_dialog_.get())
return;

diff --git a/chrome/browser/importer/external_process_importer_client.h b/chrome/browser/importer/external_process_importer_client.h
index 864a6951115dda5ed74963f18b35692960397d50..3e1a2b719521ac2c60bae05f94e409bc4c7da022 100644
--- a/chrome/browser/importer/external_process_importer_client.h
Expand Down

0 comments on commit 2c1f33f

Please sign in to comment.