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

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

Issue 9600036: Move Render(View|Widget)Host and associated classes to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_FILE_SELECT_HELPER_H_ 5 #ifndef CHROME_BROWSER_FILE_SELECT_HELPER_H_
6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_ 6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "chrome/browser/ui/select_file_dialog.h" 13 #include "chrome/browser/ui/select_file_dialog.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "net/base/directory_lister.h" 16 #include "net/base/directory_lister.h"
17 17
18 class Profile; 18 class Profile;
19 class RenderViewHost;
20 19
21 namespace content { 20 namespace content {
21 class RenderViewHost;
22 struct FileChooserParams; 22 struct FileChooserParams;
23 } 23 }
24 24
25 // This class handles file-selection requests coming from WebUI elements 25 // This class handles file-selection requests coming from WebUI elements
26 // (via the ExtensionHost class). It implements both the initialisation 26 // (via the ExtensionHost class). It implements both the initialisation
27 // and listener functions for file-selection dialogs. 27 // and listener functions for file-selection dialogs.
28 class FileSelectHelper 28 class FileSelectHelper
29 : public base::RefCountedThreadSafe<FileSelectHelper>, 29 : public base::RefCountedThreadSafe<FileSelectHelper>,
30 public SelectFileDialog::Listener, 30 public SelectFileDialog::Listener,
31 public content::NotificationObserver { 31 public content::NotificationObserver {
32 public: 32 public:
33 explicit FileSelectHelper(Profile* profile); 33 explicit FileSelectHelper(Profile* profile);
34 34
35 // Show the file chooser dialog. 35 // Show the file chooser dialog.
36 void RunFileChooser(RenderViewHost* render_view_host, 36 void RunFileChooser(content::RenderViewHost* render_view_host,
37 content::WebContents* tab_contents, 37 content::WebContents* tab_contents,
38 const content::FileChooserParams& params); 38 const content::FileChooserParams& params);
39 39
40 // Enumerates all the files in directory. 40 // Enumerates all the files in directory.
41 void EnumerateDirectory(int request_id, 41 void EnumerateDirectory(int request_id,
42 RenderViewHost* render_view_host, 42 content::RenderViewHost* render_view_host,
43 const FilePath& path); 43 const FilePath& path);
44 44
45 private: 45 private:
46 friend class base::RefCountedThreadSafe<FileSelectHelper>; 46 friend class base::RefCountedThreadSafe<FileSelectHelper>;
47 virtual ~FileSelectHelper(); 47 virtual ~FileSelectHelper();
48 48
49 // Utility class which can listen for directory lister events and relay 49 // Utility class which can listen for directory lister events and relay
50 // them to the main object with the correct tracking id. 50 // them to the main object with the correct tracking id.
51 class DirectoryListerDispatchDelegate 51 class DirectoryListerDispatchDelegate
52 : public net::DirectoryLister::DirectoryListerDelegate { 52 : public net::DirectoryLister::DirectoryListerDelegate {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual void FileSelectionCanceled(void* params) OVERRIDE; 87 virtual void FileSelectionCanceled(void* params) OVERRIDE;
88 88
89 // content::NotificationObserver overrides. 89 // content::NotificationObserver overrides.
90 virtual void Observe(int type, 90 virtual void Observe(int type,
91 const content::NotificationSource& source, 91 const content::NotificationSource& source,
92 const content::NotificationDetails& details) OVERRIDE; 92 const content::NotificationDetails& details) OVERRIDE;
93 93
94 // Kicks off a new directory enumeration. 94 // Kicks off a new directory enumeration.
95 void StartNewEnumeration(const FilePath& path, 95 void StartNewEnumeration(const FilePath& path,
96 int request_id, 96 int request_id,
97 RenderViewHost* render_view_host); 97 content::RenderViewHost* render_view_host);
98 98
99 // Callbacks from directory enumeration. 99 // Callbacks from directory enumeration.
100 virtual void OnListFile( 100 virtual void OnListFile(
101 int id, 101 int id,
102 const net::DirectoryLister::DirectoryListerData& data); 102 const net::DirectoryLister::DirectoryListerData& data);
103 virtual void OnListDone(int id, int error); 103 virtual void OnListDone(int id, int error);
104 104
105 // Cleans up and releases this instance. This must be called after the last 105 // Cleans up and releases this instance. This must be called after the last
106 // callback is received from the enumeration code. 106 // callback is received from the enumeration code.
107 void EnumerateDirectoryEnd(); 107 void EnumerateDirectoryEnd();
108 108
109 // Helper method to get allowed extensions for select file dialog from 109 // Helper method to get allowed extensions for select file dialog from
110 // the specified accept types as defined in the spec: 110 // the specified accept types as defined in the spec:
111 // http://whatwg.org/html/number-state.html#attr-input-accept 111 // http://whatwg.org/html/number-state.html#attr-input-accept
112 // |accept_types| contains only valid lowercased MIME types. 112 // |accept_types| contains only valid lowercased MIME types.
113 SelectFileDialog::FileTypeInfo* GetFileTypesFromAcceptType( 113 SelectFileDialog::FileTypeInfo* GetFileTypesFromAcceptType(
114 const std::vector<string16>& accept_types); 114 const std::vector<string16>& accept_types);
115 115
116 // Profile used to set/retrieve the last used directory. 116 // Profile used to set/retrieve the last used directory.
117 Profile* profile_; 117 Profile* profile_;
118 118
119 // The RenderViewHost and WebContents for the page showing a file dialog 119 // The RenderViewHost and WebContents for the page showing a file dialog
120 // (may only be one such dialog). 120 // (may only be one such dialog).
121 RenderViewHost* render_view_host_; 121 content::RenderViewHost* render_view_host_;
122 content::WebContents* web_contents_; 122 content::WebContents* web_contents_;
123 123
124 // Dialog box used for choosing files to upload from file form fields. 124 // Dialog box used for choosing files to upload from file form fields.
125 scoped_refptr<SelectFileDialog> select_file_dialog_; 125 scoped_refptr<SelectFileDialog> select_file_dialog_;
126 scoped_ptr<SelectFileDialog::FileTypeInfo> select_file_types_; 126 scoped_ptr<SelectFileDialog::FileTypeInfo> select_file_types_;
127 127
128 // The type of file dialog last shown. 128 // The type of file dialog last shown.
129 SelectFileDialog::Type dialog_type_; 129 SelectFileDialog::Type dialog_type_;
130 130
131 // Maintain a list of active directory enumerations. These could come from 131 // Maintain a list of active directory enumerations. These could come from
132 // the file select dialog or from drag-and-drop of directories, so there could 132 // the file select dialog or from drag-and-drop of directories, so there could
133 // be more than one going on at a time. 133 // be more than one going on at a time.
134 struct ActiveDirectoryEnumeration; 134 struct ActiveDirectoryEnumeration;
135 std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_; 135 std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_;
136 136
137 // Registrar for notifications regarding our RenderViewHost. 137 // Registrar for notifications regarding our RenderViewHost.
138 content::NotificationRegistrar notification_registrar_; 138 content::NotificationRegistrar notification_registrar_;
139 139
140 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); 140 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper);
141 }; 141 };
142 142
143 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ 143 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.cc ('k') | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698