Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4709)

Unified Diff: chrome/browser/file_select_helper.cc

Issue 663473002: Add non-native file handling in FileSelectorHelper class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/file_select_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/file_select_helper.cc
diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc
index 4675d6481e20dc411008f4bbbce39e7134590cf8..85482a5299e9d9fe54795f1beb688a1d38ecc92c 100644
--- a/chrome/browser/file_select_helper.cc
+++ b/chrome/browser/file_select_helper.cc
@@ -32,6 +32,11 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/shell_dialogs/selected_file_info.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
+#include "content/public/browser/site_instance.h"
+#endif
+
using content::BrowserThread;
using content::FileChooserParams;
using content::RenderViewHost;
@@ -45,20 +50,6 @@ namespace {
// the renderer must start at 0 and increase.
const int kFileSelectEnumerationId = -1;
-void NotifyRenderViewHost(
- RenderViewHost* render_view_host,
- const std::vector<ui::SelectedFileInfo>& files,
- FileChooserParams::Mode dialog_mode) {
- std::vector<content::FileChooserFileInfo> chooser_files;
- for (size_t i = 0; i < files.size(); ++i) {
- content::FileChooserFileInfo chooser_file;
- chooser_file.file_path = files[i].local_path;
- chooser_file.display_name = files[i].display_name;
- chooser_files.push_back(chooser_file);
- }
- render_view_host->FilesSelectedInChooser(chooser_files, dialog_mode);
-}
-
// Converts a list of FilePaths to a list of ui::SelectedFileInfo.
std::vector<ui::SelectedFileInfo> FilePathListToSelectedFileInfoList(
const std::vector<base::FilePath>& paths) {
@@ -233,22 +224,62 @@ void FileSelectHelper::OnListDone(int id, int error) {
std::vector<ui::SelectedFileInfo> selected_files =
FilePathListToSelectedFileInfoList(entry->results_);
- if (id == kFileSelectEnumerationId)
- NotifyRenderViewHost(entry->rvh_, selected_files, dialog_mode_);
- else
+ if (id == kFileSelectEnumerationId) {
+ NotifyRenderViewHostAndEnd(selected_files);
+ } else {
entry->rvh_->DirectoryEnumerationFinished(id, entry->results_);
-
- EnumerateDirectoryEnd();
+ EnumerateDirectoryEnd();
+ }
}
void FileSelectHelper::NotifyRenderViewHostAndEnd(
const std::vector<ui::SelectedFileInfo>& files) {
- if (render_view_host_)
- NotifyRenderViewHost(render_view_host_, files, dialog_mode_);
+ std::vector<content::FileChooserFileInfo> chooser_files;
+
+ if (!render_view_host_) {
+ RunFileChooserEnd();
+ return;
+ }
+
+#if defined(OS_CHROMEOS)
+ if (!files.empty()) {
+ // Converts |files| into FileChooserFileInfo with handling of non-native
+ // files.
+ file_manager::util::ConvertSelectedFileInfoListToFileChooserFileInfoList(
+ file_manager::util::GetFileSystemContextForRenderViewHost(
+ profile_, render_view_host_),
+ web_contents_->GetSiteInstance()->GetSiteURL(),
+ files,
+ base::Bind(
+ &FileSelectHelper::ProcessSelectedFilesChromeOSAfterConversion,
+ this));
+ return;
+ }
+#endif // defined(OS_CHROMEOS)
+
+ for (size_t i = 0; i < files.size(); ++i) {
+ chooser_files[i].file_path = files[i].local_path;
+ chooser_files[i].display_name = files[i].display_name;
Avi (use Gerrit) 2014/10/17 19:38:52 How does this work? chooser_files starts empty, an
hirono 2014/10/20 04:10:48 Yes, this was completely wrong... Fixed.
+ }
+ render_view_host_->FilesSelectedInChooser(chooser_files, dialog_mode_);
+
+ // No members should be accessed from here on.
+ RunFileChooserEnd();
+}
+
+#if defined(OS_CHROMEOS)
+void FileSelectHelper::ProcessSelectedFilesChromeOSAfterConversion(
+ scoped_ptr<std::vector<content::FileChooserFileInfo>> list) {
+ if (render_view_host_) {
+ render_view_host_->FilesSelectedInChooser(
+ list ? *list : std::vector<content::FileChooserFileInfo>(),
+ dialog_mode_);
+ }
// No members should be accessed from here on.
RunFileChooserEnd();
}
+#endif // defined(OS_CHROMEOS)
void FileSelectHelper::DeleteTemporaryFiles() {
BrowserThread::PostTask(BrowserThread::FILE,
« no previous file with comments | « chrome/browser/file_select_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698