diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/extensions/browser/api/file_system | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/extensions/browser/api/file_system')
3 files changed, 39 insertions, 26 deletions
diff --git a/chromium/extensions/browser/api/file_system/BUILD.gn b/chromium/extensions/browser/api/file_system/BUILD.gn index 262b58d976a..516aba105f1 100644 --- a/chromium/extensions/browser/api/file_system/BUILD.gn +++ b/chromium/extensions/browser/api/file_system/BUILD.gn @@ -19,6 +19,7 @@ source_set("file_system") { deps = [ "//base", + "//base/util/values:values_util", "//content/public/browser", "//extensions/browser/api/file_handlers", "//extensions/common", diff --git a/chromium/extensions/browser/api/file_system/file_system_api.cc b/chromium/extensions/browser/api/file_system/file_system_api.cc index 706354d8ecb..5c899c4eed3 100644 --- a/chromium/extensions/browser/api/file_system/file_system_api.cc +++ b/chromium/extensions/browser/api/file_system/file_system_api.cc @@ -22,9 +22,8 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "base/task/post_task.h" #include "base/task/thread_pool.h" -#include "base/value_conversions.h" +#include "base/util/values/values_util.h" #include "base/values.h" #include "build/build_config.h" #include "content/public/browser/browser_context.h" @@ -188,8 +187,8 @@ void PassFileInfoToUIThread(const FileInfoOptCallback& callback, DCHECK_CURRENTLY_ON(content::BrowserThread::IO); std::unique_ptr<base::File::Info> file_info( result == base::File::FILE_OK ? new base::File::Info(info) : NULL); - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(callback, std::move(file_info))); + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(callback, std::move(file_info))); } // Gets a WebContents instance handle for a platform app hosted in @@ -227,7 +226,7 @@ void SetLastChooseEntryDirectory(ExtensionPrefs* prefs, const base::FilePath& path) { prefs->UpdateExtensionPref( extension_id, kLastChooseEntryDirectory, - base::Value::ToUniquePtrValue(base::CreateFilePathValue(path))); + base::Value::ToUniquePtrValue(::util::FilePathToValue(path))); } } // namespace file_system_api @@ -395,8 +394,8 @@ void FileSystemChooseEntryFunction::ShowPicker( else if (g_paths_to_be_picked_for_test) test_paths = *g_paths_to_be_picked_for_test; - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, test_paths.size() > 0 ? base::BindOnce(&FileSystemChooseEntryFunction::FilesSelected, this, test_paths) @@ -498,9 +497,16 @@ void FileSystemChooseEntryFunction::FilesSelected( } else { last_choose_directory = paths[0].DirName(); } - file_system_api::SetLastChooseEntryDirectory( - ExtensionPrefs::Get(browser_context()), extension()->id(), - last_choose_directory); + + if (extension_->is_extension()) { + ExtensionsBrowserClient::Get()->SetLastSaveFilePath(browser_context(), + last_choose_directory); + } else { + file_system_api::SetLastChooseEntryDirectory( + ExtensionPrefs::Get(browser_context()), extension()->id(), + last_choose_directory); + } + if (is_directory_) { // Get the WebContents for the app window to be the parent window of the // confirmation dialog if necessary. @@ -542,8 +548,8 @@ void FileSystemChooseEntryFunction::ConfirmDirectoryAccessAsync( const base::FilePath check_path = non_native_path ? paths[0] : base::MakeAbsoluteFilePath(paths[0]); if (check_path.empty()) { - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&FileSystemChooseEntryFunction::FileSelectionCanceled, this)); return; @@ -559,23 +565,23 @@ void FileSystemChooseEntryFunction::ConfirmDirectoryAccessAsync( if (g_skip_directory_confirmation_for_test) { if (g_allow_directory_access_for_test) break; - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&FileSystemChooseEntryFunction::FileSelectionCanceled, this)); return; } - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &FileSystemChooseEntryFunction::ConfirmSensitiveDirectoryAccess, this, paths, web_contents)); return; } - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&FileSystemChooseEntryFunction::OnDirectoryAccessConfirmed, this, paths)); } @@ -619,10 +625,10 @@ void FileSystemChooseEntryFunction::BuildFileTypeInfo( ui::SelectFileDialog::FileTypeInfo* file_type_info, const base::FilePath::StringType& suggested_extension, const AcceptOptions* accepts, - const bool* acceptsAllTypes) { + const bool* accepts_all_types) { file_type_info->include_all_files = true; - if (acceptsAllTypes) - file_type_info->include_all_files = *acceptsAllTypes; + if (accepts_all_types) + file_type_info->include_all_files = *accepts_all_types; bool need_suggestion = !file_type_info->include_all_files && !suggested_extension.empty(); @@ -745,8 +751,14 @@ ExtensionFunction::ResponseAction FileSystemChooseEntryFunction::Run() { file_type_info.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH; - base::FilePath previous_path = file_system_api::GetLastChooseEntryDirectory( - ExtensionPrefs::Get(browser_context()), extension()->id()); + base::FilePath previous_path; + if (extension_->is_extension()) { + previous_path = + ExtensionsBrowserClient::Get()->GetSaveFilePath(browser_context()); + } else { + previous_path = file_system_api::GetLastChooseEntryDirectory( + ExtensionPrefs::Get(browser_context()), extension()->id()); + } if (previous_path.empty()) { SetInitialPathAndShowPicker(previous_path, suggested_name, file_type_info, @@ -826,8 +838,8 @@ ExtensionFunction::ResponseAction FileSystemRetainEntryFunction::Run() { // It is safe to use base::Unretained() for operation_runner(), since it // is owned by |context| which will delete it on the IO thread. - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( base::IgnoreResult( &storage::FileSystemOperationRunner::GetMetadata), diff --git a/chromium/extensions/browser/api/file_system/file_system_api.h b/chromium/extensions/browser/api/file_system/file_system_api.h index 7df036af4c6..2a95c4d89fd 100644 --- a/chromium/extensions/browser/api/file_system/file_system_api.h +++ b/chromium/extensions/browser/api/file_system/file_system_api.h @@ -140,7 +140,7 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction { ui::SelectFileDialog::FileTypeInfo* file_type_info, const base::FilePath::StringType& suggested_extension, const AcceptOptions* accepts, - const bool* acceptsAllTypes); + const bool* accepts_all_types); static void BuildSuggestion(const std::string* opt_name, base::FilePath* suggested_name, base::FilePath::StringType* suggested_extension); |