From 4a4d3ded78c310b76641afd5daa6f112bbfb0a7a Mon Sep 17 00:00:00 2001 From: Sydney Li Date: Thu, 19 Oct 2017 23:07:05 +0100 Subject: [PATCH 1/5] Pull in file chooser from Chromium fix brave/browser-laptop#10666 fix brave/browser-laptop#8601 Auditors: @darkdh, @bbondy, @bsclifton, @bridiver --- atom/browser/BUILD.gn | 2 - atom/browser/common_web_contents_delegate.cc | 10 +- atom/browser/common_web_contents_delegate.h | 2 - atom/browser/web_dialog_helper.cc | 222 ------------------ atom/browser/web_dialog_helper.h | 45 ---- brave/browser/brave_browser_context.cc | 8 + brave/browser/brave_browser_context.h | 2 + chromium_src/BUILD.gn | 20 +- .../chrome/browser/profiles/profile.h | 3 + patches/master_patch.patch | 17 ++ 10 files changed, 52 insertions(+), 279 deletions(-) delete mode 100644 atom/browser/web_dialog_helper.cc delete mode 100644 atom/browser/web_dialog_helper.h diff --git a/atom/browser/BUILD.gn b/atom/browser/BUILD.gn index 5cfd0fc300..3609cc033b 100644 --- a/atom/browser/BUILD.gn +++ b/atom/browser/BUILD.gn @@ -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", diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index c3d21410df..54a703544a 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -14,7 +14,6 @@ #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" @@ -22,6 +21,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" @@ -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( diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index f80120fd37..a15cc243c3 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -20,7 +20,6 @@ namespace atom { class AtomBrowserContext; class NativeWindow; -class WebDialogHelper; class CommonWebContentsDelegate : public content::WebContentsDelegate, @@ -144,7 +143,6 @@ class CommonWebContentsDelegate // Whether window is fullscreened by window api. bool native_fullscreen_; - std::unique_ptr web_dialog_helper_; scoped_refptr devtools_file_system_indexer_; // Make sure BrowserContext is alwasys destroyed after WebContents. diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc deleted file mode 100644 index fcd598b1aa..0000000000 --- a/atom/browser/web_dialog_helper.cc +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/web_dialog_helper.h" - -#include -#include - -#include "atom/browser/atom_browser_context.h" -#include "atom/browser/native_window.h" -#include "atom/browser/ui/file_dialog.h" -#include "base/bind.h" -#include "base/files/file_enumerator.h" -#include "base/files/file_path.h" -#include "base/strings/utf_string_conversions.h" -#include "chrome/common/pref_names.h" -#include "components/prefs/pref_service.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/file_chooser_file_info.h" -#include "content/public/common/file_chooser_params.h" -#include "net/base/mime_util.h" -#include "ui/shell_dialogs/selected_file_info.h" - -namespace { - -class FileSelectHelper : public base::RefCounted, - public content::WebContentsObserver { - public: - FileSelectHelper(content::RenderFrameHost* render_frame_host, - const content::FileChooserParams::Mode& mode) - : render_frame_host_(render_frame_host), mode_(mode) { - auto web_contents = content::WebContents::FromRenderFrameHost( - render_frame_host); - content::WebContentsObserver::Observe(web_contents); - } - - void ShowOpenDialog(const file_dialog::DialogSettings& settings) { - auto callback = base::Bind(&FileSelectHelper::OnOpenDialogDone, this); - file_dialog::ShowOpenDialog(settings, callback); - } - - void ShowSaveDialog(const file_dialog::DialogSettings& settings) { - auto callback = base::Bind(&FileSelectHelper::OnSaveDialogDone, this); - file_dialog::ShowSaveDialog(settings, callback); - } - - private: - friend class base::RefCounted; - - ~FileSelectHelper() override {} - - void OnOpenDialogDone(bool result, const std::vector& paths) { - std::vector file_info; - if (result) { - for (auto& path : paths) { - content::FileChooserFileInfo info; - info.file_path = path; - info.display_name = path.BaseName().value(); - file_info.push_back(info); - } - - if (render_frame_host_ && !paths.empty()) { - auto browser_context = static_cast( - render_frame_host_->GetProcess()->GetBrowserContext()); - browser_context->prefs()->SetFilePath(prefs::kSelectFileLastDirectory, - paths[0].DirName()); - } - } - OnFilesSelected(file_info); - } - - void OnSaveDialogDone(bool result, const base::FilePath& path) { - std::vector file_info; - if (result) { - content::FileChooserFileInfo info; - info.file_path = path; - info.display_name = path.BaseName().value(); - file_info.push_back(info); - } - OnFilesSelected(file_info); - } - - void OnFilesSelected( - const std::vector& file_info) { - if (render_frame_host_) - render_frame_host_->FilesSelectedInChooser(file_info, mode_); - } - - // content::WebContentsObserver: - void RenderFrameHostChanged(content::RenderFrameHost* old_host, - content::RenderFrameHost* new_host) override { - if (old_host == render_frame_host_) - render_frame_host_ = nullptr; - } - - // content::WebContentsObserver: - void RenderFrameDeleted(content::RenderFrameHost* deleted_host) override { - if (deleted_host == render_frame_host_) - render_frame_host_ = nullptr; - } - - // content::WebContentsObserver: - void WebContentsDestroyed() override { - render_frame_host_ = nullptr; - } - - content::RenderFrameHost* render_frame_host_; - content::FileChooserParams::Mode mode_; -}; - -file_dialog::Filters GetFileTypesFromAcceptType( - const std::vector& accept_types) { - file_dialog::Filters filters; - if (accept_types.empty()) - return filters; - - std::vector extensions; - - for (const auto& accept_type : accept_types) { - std::string ascii_type = base::UTF16ToASCII(accept_type); - if (ascii_type[0] == '.') { - // If the type starts with a period it is assumed to be a file extension, - // like `.txt`, // so we just have to add it to the list. - base::FilePath::StringType extension( - ascii_type.begin(), ascii_type.end()); - // Skip the first character. - extensions.push_back(extension.substr(1)); - } else { - // For MIME Type, `audio/*, vidio/*, image/* - net::GetExtensionsForMimeType(ascii_type, &extensions); - } - } - - // If no valid exntesion is added, return empty filters. - if (extensions.empty()) - return filters; - - filters.push_back(file_dialog::Filter()); - for (const auto& extension : extensions) { -#if defined(OS_WIN) - filters[0].second.push_back(base::UTF16ToASCII(extension)); -#else - filters[0].second.push_back(extension); -#endif - } - return filters; -} - -} // namespace - -namespace atom { - -WebDialogHelper::WebDialogHelper(NativeWindow* window) - : window_(window), - weak_factory_(this) { -} - -WebDialogHelper::~WebDialogHelper() { -} - - -void WebDialogHelper::RunFileChooser( - content::RenderFrameHost* render_frame_host, - const content::FileChooserParams& params) { - std::vector result; - - file_dialog::DialogSettings settings; - settings.filters = GetFileTypesFromAcceptType(params.accept_types); - settings.parent_window = window_; - settings.title = base::UTF16ToUTF8(params.title); - - scoped_refptr file_select_helper( - new FileSelectHelper(render_frame_host, params.mode)); - if (params.mode == content::FileChooserParams::Save) { - settings.default_path = params.default_file_name; - file_select_helper->ShowSaveDialog(settings); - } else { - int flags = file_dialog::FILE_DIALOG_CREATE_DIRECTORY; - switch (params.mode) { - case content::FileChooserParams::OpenMultiple: - flags |= file_dialog::FILE_DIALOG_MULTI_SELECTIONS; - case content::FileChooserParams::Open: - flags |= file_dialog::FILE_DIALOG_OPEN_FILE; - break; - case content::FileChooserParams::UploadFolder: - flags |= file_dialog::FILE_DIALOG_OPEN_DIRECTORY; - break; - default: - NOTREACHED(); - } - - AtomBrowserContext* browser_context = static_cast( - window_->web_contents()->GetBrowserContext()); - settings.default_path = browser_context->prefs()->GetFilePath( - prefs::kSelectFileLastDirectory).Append(params.default_file_name); - settings.properties = flags; - file_select_helper->ShowOpenDialog(settings); - } -} - -void WebDialogHelper::EnumerateDirectory(content::WebContents* web_contents, - int request_id, - const base::FilePath& dir) { - int types = base::FileEnumerator::FILES | - base::FileEnumerator::DIRECTORIES | - base::FileEnumerator::INCLUDE_DOT_DOT; - base::FileEnumerator file_enum(dir, false, types); - - base::FilePath path; - std::vector paths; - while (!(path = file_enum.Next()).empty()) - paths.push_back(path); - - web_contents->GetRenderViewHost()->DirectoryEnumerationFinished( - request_id, paths); -} - -} // namespace atom diff --git a/atom/browser/web_dialog_helper.h b/atom/browser/web_dialog_helper.h deleted file mode 100644 index 67fe68031c..0000000000 --- a/atom/browser/web_dialog_helper.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_BROWSER_WEB_DIALOG_HELPER_H_ -#define ATOM_BROWSER_WEB_DIALOG_HELPER_H_ - -#include "base/memory/weak_ptr.h" - -namespace base { -class FilePath; -} - -namespace content { -struct FileChooserParams; -class RenderFrameHost; -class WebContents; -} - -namespace atom { - -class NativeWindow; - -class WebDialogHelper { - public: - explicit WebDialogHelper(NativeWindow* window); - ~WebDialogHelper(); - - void RunFileChooser(content::RenderFrameHost* render_frame_host, - const content::FileChooserParams& params); - void EnumerateDirectory(content::WebContents* web_contents, - int request_id, - const base::FilePath& path); - - private: - NativeWindow* window_; - - base::WeakPtrFactory weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(WebDialogHelper); -}; - -} // namespace atom - -#endif // ATOM_BROWSER_WEB_DIALOG_HELPER_H_ diff --git a/brave/browser/brave_browser_context.cc b/brave/browser/brave_browser_context.cc index d1bbe7999a..32dfc5079a 100644 --- a/brave/browser/brave_browser_context.cc +++ b/brave/browser/brave_browser_context.cc @@ -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 { diff --git a/brave/browser/brave_browser_context.h b/brave/browser/brave_browser_context.h index 861af8c6d7..79500f8bcd 100644 --- a/brave/browser/brave_browser_context.h +++ b/brave/browser/brave_browser_context.h @@ -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(); } diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index b4c52875e6..e048910414 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -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", @@ -232,6 +236,9 @@ 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", @@ -239,6 +246,12 @@ source_set("browser") { "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", @@ -286,6 +299,12 @@ source_set("browser") { "//chrome/browser/service_process/service_process_control_mac.mm", ] + if (use_aura) { + sources += [ + "//chrome/browser/platform_util_aura.cc", + ] + } + if (is_win || is_mac) { sources += [ "//chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc", @@ -297,7 +316,6 @@ source_set("browser") { sources += [ "//chrome/browser/win/browser_util.h", "//chrome/browser/win/browser_util.cc", - "//chrome/browser/platform_util_aura.cc", "//chrome/browser/ui/views/color_chooser_dialog.cc", "//chrome/browser/ui/views/color_chooser_dialog.h", "//chrome/browser/ui/views/color_chooser_win.cc", diff --git a/chromium_src/chrome/browser/profiles/profile.h b/chromium_src/chrome/browser/profiles/profile.h index 4e83685558..5d72ed7292 100644 --- a/chromium_src/chrome/browser/profiles/profile.h +++ b/chromium_src/chrome/browser/profiles/profile.h @@ -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 diff --git a/patches/master_patch.patch b/patches/master_patch.patch index 4ac918c449..ca3e47ed0b 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -522,6 +522,23 @@ index 7acc7baa7cd01b9627e8d231a3a7848cf4ec2295..e857daff2ba3910223f1039f66364faa // Finds TabStripModel which has a WebContents whose id is the given // web_contents_id, and returns the WebContents index and the TabStripModel. int FindTabStripModelById(int64_t target_web_contents_id, +diff --git a/chrome/browser/ui/chrome_select_file_policy.cc b/chrome/browser/ui/chrome_select_file_policy.cc +index 43dd8ee370f089af922b387fc57baa4183d9540a..c1392ba4beb20bc96c656cf5e6880e22e03348a2 100644 +--- a/chrome/browser/ui/chrome_select_file_policy.cc ++++ b/chrome/browser/ui/chrome_select_file_policy.cc +@@ -30,10 +30,12 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { + void ChromeSelectFilePolicy::SelectFileDenied() { + // Show the InfoBar saying that file-selection dialogs are disabled. + if (source_contents_) { ++#ifdef MUON_CHROMIUM_BUILD + SimpleAlertInfoBarDelegate::Create( + InfoBarService::FromWebContents(source_contents_), + infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr, + l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true); ++#endif + } else { + LOG(WARNING) << "File-selection dialogs are disabled but no WebContents " + << "is given to display the InfoBar."; diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index 653e7692e33d0ee06428366141e5c23043f66b0d..72e13e247e6ddaae02cd08cefafb43051f886055 100644 --- a/chrome/common/BUILD.gn From e187f62e93649c668c8a419624e7136b89a2a0d3 Mon Sep 17 00:00:00 2001 From: bridiver Date: Wed, 25 Oct 2017 15:41:37 -0700 Subject: [PATCH 2/5] provide implementation instead of patching --- chromium_src/BUILD.gn | 2 +- patches/master_patch.patch | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index e048910414..f8ce7b2f00 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -237,7 +237,7 @@ source_set("browser") { "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/chrome_select_file_policy.cc", "chrome/browser/ui/profile_error_dialog.cc", diff --git a/patches/master_patch.patch b/patches/master_patch.patch index ca3e47ed0b..4ac918c449 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -522,23 +522,6 @@ index 7acc7baa7cd01b9627e8d231a3a7848cf4ec2295..e857daff2ba3910223f1039f66364faa // Finds TabStripModel which has a WebContents whose id is the given // web_contents_id, and returns the WebContents index and the TabStripModel. int FindTabStripModelById(int64_t target_web_contents_id, -diff --git a/chrome/browser/ui/chrome_select_file_policy.cc b/chrome/browser/ui/chrome_select_file_policy.cc -index 43dd8ee370f089af922b387fc57baa4183d9540a..c1392ba4beb20bc96c656cf5e6880e22e03348a2 100644 ---- a/chrome/browser/ui/chrome_select_file_policy.cc -+++ b/chrome/browser/ui/chrome_select_file_policy.cc -@@ -30,10 +30,12 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { - void ChromeSelectFilePolicy::SelectFileDenied() { - // Show the InfoBar saying that file-selection dialogs are disabled. - if (source_contents_) { -+#ifdef MUON_CHROMIUM_BUILD - SimpleAlertInfoBarDelegate::Create( - InfoBarService::FromWebContents(source_contents_), - infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr, - l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true); -+#endif - } else { - LOG(WARNING) << "File-selection dialogs are disabled but no WebContents " - << "is given to display the InfoBar."; diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index 653e7692e33d0ee06428366141e5c23043f66b0d..72e13e247e6ddaae02cd08cefafb43051f886055 100644 --- a/chrome/common/BUILD.gn From be268c20c284a13c38bc9f8622b5dd135de1d48b Mon Sep 17 00:00:00 2001 From: bridiver Date: Wed, 25 Oct 2017 15:44:09 -0700 Subject: [PATCH 3/5] remove kSelectFileLastDirectory registration from atom browser context --- atom/browser/atom_browser_context.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 9abbf9cdfa..fab4bba234 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -153,8 +153,6 @@ std::vector AtomBrowserContext::GetCookieableSchemes() { } void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) { - pref_registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory, - base::FilePath()); // moved to user_prefs in brave_browser_context pref_registry->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, base::FilePath()); From 720f837c64e5587f07a53780ac64e5374b5cebf6 Mon Sep 17 00:00:00 2001 From: bridiver Date: Wed, 25 Oct 2017 15:46:47 -0700 Subject: [PATCH 4/5] lint fixes --- atom/browser/common_web_contents_delegate.cc | 6 +++--- brave/browser/brave_browser_context.cc | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 54a703544a..ef28803f54 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -19,9 +19,9 @@ #include "base/strings/utf_string_conversions.h" #include "brave/browser/brave_javascript_dialog_manager.h" #include "chrome/browser/certificate_viewer.h" +#include "chrome/browser/file_select_helper.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" @@ -278,13 +278,13 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser( void CommonWebContentsDelegate::RunFileChooser( content::RenderFrameHost* render_frame_host, const content::FileChooserParams& params) { - FileSelectHelper::RunFileChooser(render_frame_host, params); + FileSelectHelper::RunFileChooser(render_frame_host, params); } void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest, int request_id, const base::FilePath& path) { - FileSelectHelper::EnumerateDirectory(guest, request_id, path); + FileSelectHelper::EnumerateDirectory(guest, request_id, path); } void CommonWebContentsDelegate::EnterFullscreenModeForTab( diff --git a/brave/browser/brave_browser_context.cc b/brave/browser/brave_browser_context.cc index 32dfc5079a..bef6e75cb2 100644 --- a/brave/browser/brave_browser_context.cc +++ b/brave/browser/brave_browser_context.cc @@ -638,11 +638,12 @@ BraveBrowserContext::GetIOTaskRunner() { } base::FilePath BraveBrowserContext::last_selected_directory() { - return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); + return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); } -void BraveBrowserContext::set_last_selected_directory(const base::FilePath& path) { - GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); +void BraveBrowserContext::set_last_selected_directory( + const base::FilePath& path) { + GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); } } // namespace brave From cf2554eaab6e2bf7f98d8295cb333d2f0dbba415 Mon Sep 17 00:00:00 2001 From: bridiver Date: Wed, 25 Oct 2017 16:04:51 -0700 Subject: [PATCH 5/5] fix file select dialog --- app/mac/BUILD.gn | 2 ++ chromium_src/BUILD.gn | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/mac/BUILD.gn b/app/mac/BUILD.gn index c0f27583d1..3c48dd10bd 100644 --- a/app/mac/BUILD.gn +++ b/app/mac/BUILD.gn @@ -109,6 +109,7 @@ mac_framework_bundle("electron_framework") { "//electron:electron_framework_resources", "//build/config:exe_and_shlib_deps", ":electron_xibs", + "//chrome/app/nibs:localizer_table", ] ldflags = [ @@ -343,6 +344,7 @@ config("external_binaries_config") { mac_xib_bundle_data("electron_xibs") { sources = [ "resources/MainMenu.xib", + "//chrome/app/nibs/SaveAccessoryView.xib", ] } diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index f8ce7b2f00..ff14b1fa75 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -238,6 +238,8 @@ source_set("browser") { "//chrome/browser/ui/chrome_select_file_policy.h", "chrome/browser/ui/chrome_select_file_policy.cc", + "//chrome/browser/ui/cocoa/ui_localizer.h", + "//chrome/browser/ui/cocoa/ui_localizer.mm", "chrome/browser/ui/profile_error_dialog.cc",