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

Side by Side Diff: chrome/browser/file_select_helper.h

Issue 3209002: Input file type now supported in extension popups. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Synced Created 10 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_FILE_SELECT_HELPER_H_ 5 #ifndef CHROME_BROWSER_FILE_SELECT_HELPER_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_FILE_SELECT_HELPER_H_ 6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "chrome/browser/shell_dialogs.h" 11 #include "chrome/browser/shell_dialogs.h"
12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
13 #include "chrome/common/notification_observer.h"
14 #include "chrome/common/notification_registrar.h"
13 #include "net/base/directory_lister.h" 15 #include "net/base/directory_lister.h"
14 16
17 class Profile;
15 class RenderViewHost; 18 class RenderViewHost;
16 class TabContents;
17 struct ViewHostMsg_RunFileChooser_Params; 19 struct ViewHostMsg_RunFileChooser_Params;
18 20
19 class TabContentsFileSelectHelper 21 class FileSelectHelper
20 : public SelectFileDialog::Listener, 22 : public SelectFileDialog::Listener,
21 public net::DirectoryLister::DirectoryListerDelegate, 23 public net::DirectoryLister::DirectoryListerDelegate,
22 public RenderViewHostDelegate::FileSelect { 24 public RenderViewHostDelegate::FileSelect,
25 public NotificationObserver {
23 public: 26 public:
24 explicit TabContentsFileSelectHelper(TabContents* tab_contents); 27 explicit FileSelectHelper(Profile* profile);
25 28 ~FileSelectHelper();
26 ~TabContentsFileSelectHelper();
27 29
28 // SelectFileDialog::Listener 30 // SelectFileDialog::Listener
29 virtual void FileSelected(const FilePath& path, int index, void* params); 31 virtual void FileSelected(const FilePath& path, int index, void* params);
30 virtual void MultiFilesSelected(const std::vector<FilePath>& files, 32 virtual void MultiFilesSelected(const std::vector<FilePath>& files,
31 void* params); 33 void* params);
32 virtual void FileSelectionCanceled(void* params); 34 virtual void FileSelectionCanceled(void* params);
33 35
34 // net::DirectoryLister::DirectoryListerDelegate 36 // net::DirectoryLister::DirectoryListerDelegate
35 virtual void OnListFile( 37 virtual void OnListFile(
36 const net::DirectoryLister::DirectoryListerData& data); 38 const net::DirectoryLister::DirectoryListerData& data);
37 virtual void OnListDone(int error); 39 virtual void OnListDone(int error);
38 40
39 // RenderViewHostDelegate::FileSelect 41 // RenderViewHostDelegate::FileSelect
40 virtual void RunFileChooser(const ViewHostMsg_RunFileChooser_Params& params); 42 virtual void RunFileChooser(RenderViewHost* render_view_host,
43 const ViewHostMsg_RunFileChooser_Params& params);
41 44
42 private: 45 private:
43 // Returns the RenderViewHost of tab_contents_. 46 // NotificationObserver implementation.
44 RenderViewHost* GetRenderViewHost(); 47 virtual void Observe(NotificationType type,
48 const NotificationSource& source,
49 const NotificationDetails& details);
45 50
46 // Helper method for handling the SelectFileDialog::Listener callbacks. 51 // Helper method for handling the SelectFileDialog::Listener callbacks.
47 void DirectorySelected(const FilePath& path); 52 void DirectorySelected(const FilePath& path);
48 53
49 // Helper method to get allowed extensions for select file dialog from 54 // Helper method to get allowed extensions for select file dialog from
50 // the specified accept types as defined in the spec: 55 // the specified accept types as defined in the spec:
51 // http://whatwg.org/html/number-state.html#attr-input-accept 56 // http://whatwg.org/html/number-state.html#attr-input-accept
52 SelectFileDialog::FileTypeInfo* GetFileTypesFromAcceptType( 57 SelectFileDialog::FileTypeInfo* GetFileTypesFromAcceptType(
53 const string16& accept_types); 58 const string16& accept_types);
54 59
55 // The tab contents this class is helping. |tab_contents_| owns this object, 60 // Profile used to set/retrieve the last used directory.
56 // so this pointer is guaranteed to be valid. 61 Profile* profile_;
57 TabContents* tab_contents_; 62
63 // The RenderViewHost for the page we are associated with.
64 RenderViewHost* render_view_host_;
58 65
59 // Dialog box used for choosing files to upload from file form fields. 66 // Dialog box used for choosing files to upload from file form fields.
60 scoped_refptr<SelectFileDialog> select_file_dialog_; 67 scoped_refptr<SelectFileDialog> select_file_dialog_;
61 68
62 // The type of file dialog last shown. 69 // The type of file dialog last shown.
63 SelectFileDialog::Type dialog_type_; 70 SelectFileDialog::Type dialog_type_;
64 71
65 // The current directory lister (runs on a separate thread). 72 // The current directory lister (runs on a separate thread).
66 scoped_refptr<net::DirectoryLister> directory_lister_; 73 scoped_refptr<net::DirectoryLister> directory_lister_;
67 74
68 // The current directory lister results, which may update incrementally 75 // The current directory lister results, which may update incrementally
69 // as the listing proceeds. 76 // as the listing proceeds.
70 std::vector<FilePath> directory_lister_results_; 77 std::vector<FilePath> directory_lister_results_;
71 78
72 DISALLOW_COPY_AND_ASSIGN(TabContentsFileSelectHelper); 79 // Registrar for notifications regarding our RenderViewHost.
80 NotificationRegistrar notification_registrar_;
81
82 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper);
73 }; 83 };
74 84
75 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_FILE_SELECT_HELPER_H_ 85 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698