From 2c1f33f143ffe53634b93598e16530b033a6969c Mon Sep 17 00:00:00 2001 From: Sydney Li Date: Thu, 19 Oct 2017 23:07:05 +0100 Subject: [PATCH 1/4] Pull in file chooser from Chromium fix brave/browser-laptop#10666 fix brave/browser-laptop#8601 Auditors: @darkdh, @bbondy, @bsclifton, @bridiver --- atom/browser/common_web_contents_delegate.cc | 5 ++--- brave/browser/brave_browser_context.cc | 8 ++++++++ brave/browser/brave_browser_context.h | 2 ++ chromium_src/BUILD.gn | 13 +++++++++++++ chromium_src/chrome/browser/profiles/profile.h | 3 +++ patches/master_patch.patch | 13 +++++++++++++ 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index c3d21410df..509cd8d0eb 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -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" @@ -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, 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..dfc35292d0 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", 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 8346839623..42d0f3c7dd 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -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(web_contents_)); ++ this, std::make_unique(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 From bb662877e94ebe3bc62ce7daa517db3cd6567611 Mon Sep 17 00:00:00 2001 From: Sydney Li Date: Thu, 19 Oct 2017 15:46:16 -0700 Subject: [PATCH 2/4] missing symbol fix --- patches/master_patch.patch | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/patches/master_patch.patch b/patches/master_patch.patch index 42d0f3c7dd..3b40a9b2e2 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -159,19 +159,6 @@ 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(web_contents_)); -+ this, std::make_unique(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 @@ -523,6 +510,25 @@ 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..82c2d42db72350935c8d9827b017123b1864f963 100644 +--- a/chrome/browser/ui/chrome_select_file_policy.cc ++++ b/chrome/browser/ui/chrome_select_file_policy.cc +@@ -30,10 +30,10 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { + void ChromeSelectFilePolicy::SelectFileDenied() { + // Show the InfoBar saying that file-selection dialogs are disabled. + if (source_contents_) { +- SimpleAlertInfoBarDelegate::Create( +- InfoBarService::FromWebContents(source_contents_), +- infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr, +- l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true); ++// SimpleAlertInfoBarDelegate::Create( ++// InfoBarService::FromWebContents(source_contents_), ++// infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr, ++// l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true); + } 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 944b5fc3a42ee964d194655d31d7e2e5213f33c0 Mon Sep 17 00:00:00 2001 From: Sydney Li Date: Thu, 19 Oct 2017 16:16:27 -0700 Subject: [PATCH 3/4] remove web_dialog_helper and add platform_utils_aura --- atom/browser/BUILD.gn | 2 - atom/browser/common_web_contents_delegate.cc | 1 - atom/browser/web_dialog_helper.cc | 222 ------------------- atom/browser/web_dialog_helper.h | 45 ---- chromium_src/BUILD.gn | 7 +- patches/master_patch.patch | 18 +- 6 files changed, 14 insertions(+), 281 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 509cd8d0eb..1a24e1cca2 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" 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/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index dfc35292d0..e048910414 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -299,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", @@ -310,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/patches/master_patch.patch b/patches/master_patch.patch index 3b40a9b2e2..6ba8c63464 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -511,21 +511,19 @@ index 7acc7baa7cd01b9627e8d231a3a7848cf4ec2295..e857daff2ba3910223f1039f66364faa // 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..82c2d42db72350935c8d9827b017123b1864f963 100644 +index 43dd8ee370f089af922b387fc57baa4183d9540a..d033fe58b08c52f888d9e42b9334029dd1481876 100644 --- a/chrome/browser/ui/chrome_select_file_policy.cc +++ b/chrome/browser/ui/chrome_select_file_policy.cc -@@ -30,10 +30,10 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { +@@ -30,10 +30,12 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { void ChromeSelectFilePolicy::SelectFileDenied() { // Show the InfoBar saying that file-selection dialogs are disabled. if (source_contents_) { -- SimpleAlertInfoBarDelegate::Create( -- InfoBarService::FromWebContents(source_contents_), -- infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr, -- l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true); -+// SimpleAlertInfoBarDelegate::Create( -+// InfoBarService::FromWebContents(source_contents_), -+// infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr, -+// l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true); ++#if !defined(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."; From 12e7af4c4aa0f721dc2cafa4baaee1dd9e300b97 Mon Sep 17 00:00:00 2001 From: Sydney Li Date: Fri, 20 Oct 2017 09:14:58 +0100 Subject: [PATCH 4/4] Use chromium's EnumerateDirectory --- atom/browser/common_web_contents_delegate.cc | 4 +--- atom/browser/common_web_contents_delegate.h | 2 -- patches/master_patch.patch | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 1a24e1cca2..54a703544a 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -284,9 +284,7 @@ void CommonWebContentsDelegate::RunFileChooser( 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/patches/master_patch.patch b/patches/master_patch.patch index 6ba8c63464..e64782f029 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -511,14 +511,14 @@ index 7acc7baa7cd01b9627e8d231a3a7848cf4ec2295..e857daff2ba3910223f1039f66364faa // 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..d033fe58b08c52f888d9e42b9334029dd1481876 100644 +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_) { -+#if !defined(MUON_CHROMIUM_BUILD) ++#ifdef MUON_CHROMIUM_BUILD SimpleAlertInfoBarDelegate::Create( InfoBarService::FromWebContents(source_contents_), infobars::InfoBarDelegate::CHROME_SELECT_FILE_POLICY, nullptr,