Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Pull in file chooser from Chromium #349

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions atom/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ source_set("browser") {
"web_contents_permission_helper.h",
"web_contents_preferences.cc",
"web_contents_preferences.h",
"web_dialog_helper.cc",
"web_dialog_helper.h",
"window_list.cc",
"window_list.h",
"window_list_observer.h",
Expand Down
10 changes: 3 additions & 7 deletions atom/browser/common_web_contents_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_dialog_helper.h"
#include "atom/common/atom_constants.h"
#include "base/files/file_util.h"
#include "base/strings/utf_string_conversions.h"
#include "brave/browser/brave_javascript_dialog_manager.h"
#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,17 +278,13 @@ 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,
int request_id,
const base::FilePath& path) {
if (!web_dialog_helper_)
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
FileSelectHelper::EnumerateDirectory(guest, request_id, path);
}

void CommonWebContentsDelegate::EnterFullscreenModeForTab(
Expand Down
2 changes: 0 additions & 2 deletions atom/browser/common_web_contents_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace atom {

class AtomBrowserContext;
class NativeWindow;
class WebDialogHelper;

class CommonWebContentsDelegate
: public content::WebContentsDelegate,
Expand Down Expand Up @@ -144,7 +143,6 @@ class CommonWebContentsDelegate
// Whether window is fullscreened by window api.
bool native_fullscreen_;

std::unique_ptr<WebDialogHelper> web_dialog_helper_;
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;

// Make sure BrowserContext is alwasys destroyed after WebContents.
Expand Down
222 changes: 0 additions & 222 deletions atom/browser/web_dialog_helper.cc

This file was deleted.

45 changes: 0 additions & 45 deletions atom/browser/web_dialog_helper.h

This file was deleted.

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually have two prefs files. One of them is leftover from electron and is a PrefRegistrySimple so it wasn't compatible with other changes, but it still has a few prefs in it and kSelectFileLastDirectory is one of them AtomBrowserContext::RegisterPrefs. Checking with @bbondy to see if we care about migrating it (in which case we should handle it like kDownloadDefaultDirectory), otherwise we should remove it from AtomBrowserContext

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also it should be registered in BraveBrowserContext with RegisterFilePathPref

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like it's fine to just remove the old pref from AtomBrowserContext

}

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
Loading