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

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

Issue 2102883002: Update FileSelectHelper to use RenderFrameHost notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment on why test is disabled. Created 4 years, 5 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 | « no previous file | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 15 matching lines...) Expand all
26 namespace content { 26 namespace content {
27 struct FileChooserFileInfo; 27 struct FileChooserFileInfo;
28 class RenderViewHost; 28 class RenderViewHost;
29 class WebContents; 29 class WebContents;
30 } 30 }
31 31
32 namespace ui { 32 namespace ui {
33 struct SelectedFileInfo; 33 struct SelectedFileInfo;
34 } 34 }
35 35
36 // This class handles file-selection requests coming from WebUI elements 36 // This class handles file-selection requests coming from renderer processes.
37 // (via the extensions::ExtensionHost class). It implements both the 37 // It implements both the initialisation and listener functions for
38 // initialisation and listener functions for file-selection dialogs. 38 // file-selection dialogs.
39 // 39 //
40 // Since FileSelectHelper has-a NotificationRegistrar, it needs to live on and 40 // Since FileSelectHelper has-a NotificationRegistrar, it needs to live on and
41 // be destroyed on the UI thread. References to FileSelectHelper may be passed 41 // be destroyed on the UI thread. References to FileSelectHelper may be passed
42 // on to other threads. 42 // on to other threads.
43 class FileSelectHelper : public base::RefCountedThreadSafe< 43 class FileSelectHelper : public base::RefCountedThreadSafe<
44 FileSelectHelper, 44 FileSelectHelper,
45 content::BrowserThread::DeleteOnUIThread>, 45 content::BrowserThread::DeleteOnUIThread>,
46 public ui::SelectFileDialog::Listener, 46 public ui::SelectFileDialog::Listener,
47 public content::WebContentsObserver, 47 public content::WebContentsObserver,
48 public content::NotificationObserver { 48 public content::NotificationObserver {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const std::vector<ui::SelectedFileInfo>& files, 125 const std::vector<ui::SelectedFileInfo>& files,
126 void* params) override; 126 void* params) override;
127 void FileSelectionCanceled(void* params) override; 127 void FileSelectionCanceled(void* params) override;
128 128
129 // content::NotificationObserver overrides. 129 // content::NotificationObserver overrides.
130 void Observe(int type, 130 void Observe(int type,
131 const content::NotificationSource& source, 131 const content::NotificationSource& source,
132 const content::NotificationDetails& details) override; 132 const content::NotificationDetails& details) override;
133 133
134 // content::WebContentsObserver overrides. 134 // content::WebContentsObserver overrides.
135 void RenderViewHostChanged(content::RenderViewHost* old_host, 135 void RenderFrameHostChanged(content::RenderFrameHost* old_host,
136 content::RenderViewHost* new_host) override; 136 content::RenderFrameHost* new_host) override;
137 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
137 void WebContentsDestroyed() override; 138 void WebContentsDestroyed() override;
138 139
139 void EnumerateDirectory(int request_id, 140 void EnumerateDirectory(int request_id,
140 content::RenderViewHost* render_view_host, 141 content::RenderViewHost* render_view_host,
141 const base::FilePath& path); 142 const base::FilePath& path);
142 143
143 // Kicks off a new directory enumeration. 144 // Kicks off a new directory enumeration.
144 void StartNewEnumeration(const base::FilePath& path, 145 void StartNewEnumeration(const base::FilePath& path,
145 int request_id, 146 int request_id,
146 content::RenderViewHost* render_view_host); 147 content::RenderViewHost* render_view_host);
(...skipping 19 matching lines...) Expand all
166 void ProcessSelectedFilesMacOnUIThread( 167 void ProcessSelectedFilesMacOnUIThread(
167 const std::vector<ui::SelectedFileInfo>& files, 168 const std::vector<ui::SelectedFileInfo>& files,
168 const std::vector<base::FilePath>& zipped_files); 169 const std::vector<base::FilePath>& zipped_files);
169 170
170 // Zips the package at |path| into a temporary destination. Returns the 171 // Zips the package at |path| into a temporary destination. Returns the
171 // temporary destination, if the zip was successful. Otherwise returns an 172 // temporary destination, if the zip was successful. Otherwise returns an
172 // empty path. 173 // empty path.
173 static base::FilePath ZipPackage(const base::FilePath& path); 174 static base::FilePath ZipPackage(const base::FilePath& path);
174 #endif // defined(OS_MACOSX) 175 #endif // defined(OS_MACOSX)
175 176
176 // Utility method that passes |files| to the render view host, and ends the 177 // Utility method that passes |files| to the RenderFrameHost, and ends the
177 // file chooser. 178 // file chooser.
178 void NotifyRenderViewHostAndEnd( 179 void NotifyRenderFrameHostAndEnd(
179 const std::vector<ui::SelectedFileInfo>& files); 180 const std::vector<ui::SelectedFileInfo>& files);
180 181
181 // Sends the result to the render process, and call |RunFileChooserEnd|. 182 // Sends the result to the render process, and call |RunFileChooserEnd|.
182 void NotifyRenderViewHostAndEndAfterConversion( 183 void NotifyRenderFrameHostAndEndAfterConversion(
183 const std::vector<content::FileChooserFileInfo>& list); 184 const std::vector<content::FileChooserFileInfo>& list);
184 185
185 // Schedules the deletion of the files in |temporary_files_| and clears the 186 // Schedules the deletion of the files in |temporary_files_| and clears the
186 // vector. 187 // vector.
187 void DeleteTemporaryFiles(); 188 void DeleteTemporaryFiles();
188 189
189 // Cleans up when the RenderViewHost of our WebContents changes. 190 // Cleans up when the initiator of the file chooser is no longer valid.
190 void CleanUpOnRenderViewHostChange(); 191 void CleanUp();
191 192
192 // Helper method to get allowed extensions for select file dialog from 193 // Helper method to get allowed extensions for select file dialog from
193 // the specified accept types as defined in the spec: 194 // the specified accept types as defined in the spec:
194 // http://whatwg.org/html/number-state.html#attr-input-accept 195 // http://whatwg.org/html/number-state.html#attr-input-accept
195 // |accept_types| contains only valid lowercased MIME types or file extensions 196 // |accept_types| contains only valid lowercased MIME types or file extensions
196 // beginning with a period (.). 197 // beginning with a period (.).
197 static std::unique_ptr<ui::SelectFileDialog::FileTypeInfo> 198 static std::unique_ptr<ui::SelectFileDialog::FileTypeInfo>
198 GetFileTypesFromAcceptType(const std::vector<base::string16>& accept_types); 199 GetFileTypesFromAcceptType(const std::vector<base::string16>& accept_types);
199 200
200 // Check the accept type is valid. It is expected to be all lower case with 201 // Check the accept type is valid. It is expected to be all lower case with
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 content::NotificationRegistrar notification_registrar_; 246 content::NotificationRegistrar notification_registrar_;
246 247
247 // Temporary files only used on OSX. This class is responsible for deleting 248 // Temporary files only used on OSX. This class is responsible for deleting
248 // these files when they are no longer needed. 249 // these files when they are no longer needed.
249 std::vector<base::FilePath> temporary_files_; 250 std::vector<base::FilePath> temporary_files_;
250 251
251 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); 252 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper);
252 }; 253 };
253 254
254 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ 255 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_
OLDNEW
« 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