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

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 bridiver committed Oct 25, 2017
1 parent 0aa85d0 commit 4a4d3de
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 279 deletions.
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);
}

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

0 comments on commit 4a4d3de

Please sign in to comment.