summaryrefslogtreecommitdiffstats
path: root/chrome/browser/file_select_helper.h
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 19:13:45 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 19:13:45 +0000
commit9f054aa1ed3502d46224c63fb30167976fddfbbc (patch)
treed39c9a503ed47469b6ed39f29a9bcbb6cd883bd5 /chrome/browser/file_select_helper.h
parentb00274f8b9c012f696582352efa93d037de7ba3a (diff)
downloadchromium_src-9f054aa1ed3502d46224c63fb30167976fddfbbc.zip
chromium_src-9f054aa1ed3502d46224c63fb30167976fddfbbc.tar.gz
chromium_src-9f054aa1ed3502d46224c63fb30167976fddfbbc.tar.bz2
Fix crash when running the file chooser dialog from PPAPI.BUG=97637TEST=manual
Review URL: http://codereview.chromium.org/7994015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/file_select_helper.h')
-rw-r--r--chrome/browser/file_select_helper.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/chrome/browser/file_select_helper.h b/chrome/browser/file_select_helper.h
index 149962d..12d6e1a 100644
--- a/chrome/browser/file_select_helper.h
+++ b/chrome/browser/file_select_helper.h
@@ -25,11 +25,11 @@ struct ViewHostMsg_RunFileChooser_Params;
// (via the ExtensionHost class). It implements both the initialisation
// and listener functions for file-selection dialogs.
class FileSelectHelper
- : public SelectFileDialog::Listener,
+ : public base::RefCountedThreadSafe<FileSelectHelper>,
+ public SelectFileDialog::Listener,
public NotificationObserver {
public:
explicit FileSelectHelper(Profile* profile);
- virtual ~FileSelectHelper();
// Show the file chooser dialog.
void RunFileChooser(RenderViewHost* render_view_host,
@@ -42,6 +42,9 @@ class FileSelectHelper
const FilePath& path);
private:
+ friend class base::RefCountedThreadSafe<FileSelectHelper>;
+ virtual ~FileSelectHelper();
+
// Utility class which can listen for directory lister events and relay
// them to the main object with the correct tracking id.
class DirectoryListerDispatchDelegate
@@ -66,6 +69,15 @@ class FileSelectHelper
DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate);
};
+ void RunFileChooserOnFileThread(
+ const ViewHostMsg_RunFileChooser_Params& params);
+ void RunFileChooserOnUIThread(
+ const ViewHostMsg_RunFileChooser_Params& params);
+
+ // Cleans up and releases this instance. This must be called after the last
+ // callback is received from the file chooser dialog.
+ void RunFileChooserEnd();
+
// SelectFileDialog::Listener overrides.
virtual void FileSelected(
const FilePath& path, int index, void* params) OVERRIDE;
@@ -89,6 +101,10 @@ class FileSelectHelper
const net::DirectoryLister::DirectoryListerData& data);
virtual void OnListDone(int id, int error);
+ // Cleans up and releases this instance. This must be called after the last
+ // callback is received from the enumeration code.
+ void EnumerateDirectoryEnd();
+
// 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
@@ -98,12 +114,14 @@ class FileSelectHelper
// Profile used to set/retrieve the last used directory.
Profile* profile_;
- // The RenderViewHost for the page showing a file dialog (may only be one
- // such dialog).
+ // The RenderViewHost and TabContents for the page showing a file dialog
+ // (may only be one such dialog).
RenderViewHost* render_view_host_;
+ TabContents* tab_contents_;
// Dialog box used for choosing files to upload from file form fields.
scoped_refptr<SelectFileDialog> select_file_dialog_;
+ scoped_ptr<SelectFileDialog::FileTypeInfo> select_file_types_;
// The type of file dialog last shown.
SelectFileDialog::Type dialog_type_;