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

Unified Diff: chrome/browser/file_select_helper.h

Issue 6623015: Add a path for a web page to request the enumeration of a directory. This, t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « no previous file | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/file_select_helper.h
===================================================================
--- chrome/browser/file_select_helper.h (revision 76768)
+++ chrome/browser/file_select_helper.h (working copy)
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_FILE_SELECT_HELPER_H_
#pragma once
+#include <map>
#include <vector>
#include "chrome/browser/ui/shell_dialogs.h"
@@ -19,7 +20,6 @@
class FileSelectHelper
: public SelectFileDialog::Listener,
- public net::DirectoryLister::DirectoryListerDelegate,
public NotificationObserver {
public:
explicit FileSelectHelper(Profile* profile);
@@ -31,24 +31,57 @@
void* params);
virtual void FileSelectionCanceled(void* params);
- // net::DirectoryLister::DirectoryListerDelegate
- virtual void OnListFile(
- const net::DirectoryLister::DirectoryListerData& data);
- virtual void OnListDone(int error);
-
// Show the file chooser dialog.
void RunFileChooser(RenderViewHost* render_view_host,
const ViewHostMsg_RunFileChooser_Params& params);
+ // Enumerates all the files in directory.
+ void EnumerateDirectory(int request_id,
+ RenderViewHost* render_view_host,
+ const FilePath& path);
+
private:
+ // Utility class which can listen for directory lister events and relay
+ // them to the main object with the correct tracking id.
+ class DirectoryListerDispatchDelegate
+ : public net::DirectoryLister::DirectoryListerDelegate {
+ public:
+ DirectoryListerDispatchDelegate(FileSelectHelper* parent, int id)
+ : parent_(parent),
+ id_(id) {}
+ ~DirectoryListerDispatchDelegate() {}
+ virtual void OnListFile(
+ const net::DirectoryLister::DirectoryListerData& data) {
+ parent_->OnListFile(id_, data);
+ }
+ virtual void OnListDone(int error) {
+ parent_->OnListDone(id_, error);
+ }
+ private:
+ // This FileSelectHelper owns this object.
+ FileSelectHelper* parent_;
+ int id_;
+
+ DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate);
+ };
+
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
- // Helper method for handling the SelectFileDialog::Listener callbacks.
- void DirectorySelected(const FilePath& path);
+ // Kicks off a new directory enumeration.
+ void StartNewEnumeration(const FilePath& path,
+ int request_id,
+ RenderViewHost* render_view_host);
+ // Callbacks from directory enumeration.
+ virtual void OnListFile(
+ int id,
+ const net::DirectoryLister::DirectoryListerData& data);
+ virtual void OnListDone(int id,
+ int error);
Jay Civelli 2011/03/07 17:27:12 Nit: this can fit on the previous line.
+
// Helper method to get allowed extensions for select file dialog from
// the specified accept types as defined in the spec:
// http://whatwg.org/html/number-state.html#attr-input-accept
@@ -58,7 +91,8 @@
// Profile used to set/retrieve the last used directory.
Profile* profile_;
- // The RenderViewHost for the page we are associated with.
+ // The RenderViewHost for the page showing a file dialog (may only be one
+ // such dialog).
RenderViewHost* render_view_host_;
// Dialog box used for choosing files to upload from file form fields.
@@ -67,13 +101,17 @@
// The type of file dialog last shown.
SelectFileDialog::Type dialog_type_;
- // The current directory lister (runs on a separate thread).
- scoped_refptr<net::DirectoryLister> directory_lister_;
+ // Maintain a list of active directory enumerations. These could come from
+ // the file select dialog or from drag-and-drop of directories, so there could
+ // be more than one going on at a time.
+ struct ActiveDirectoryEnumeration {
+ scoped_ptr<DirectoryListerDispatchDelegate> delegate_;
+ scoped_refptr<net::DirectoryLister> lister_;
+ RenderViewHost* rvh_;
+ std::vector<FilePath> results_;
+ };
+ std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_;
- // The current directory lister results, which may update incrementally
- // as the listing proceeds.
- std::vector<FilePath> directory_lister_results_;
-
// Registrar for notifications regarding our RenderViewHost.
NotificationRegistrar notification_registrar_;
« no previous file with comments | « no previous file | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698