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

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

Issue 1132163004: Remove NOTIFICATION_RENDER_VIEW_HOST_CHANGED. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments #1 Created 5 years, 7 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
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 <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/common/file_chooser_params.h" 16 #include "content/public/common/file_chooser_params.h"
16 #include "net/base/directory_lister.h" 17 #include "net/base/directory_lister.h"
17 #include "ui/shell_dialogs/select_file_dialog.h" 18 #include "ui/shell_dialogs/select_file_dialog.h"
18 19
19 class Profile; 20 class Profile;
20 21
21 namespace content { 22 namespace content {
22 struct FileChooserFileInfo; 23 struct FileChooserFileInfo;
23 class RenderViewHost; 24 class RenderViewHost;
24 class WebContents; 25 class WebContents;
25 } 26 }
26 27
27 namespace ui { 28 namespace ui {
28 struct SelectedFileInfo; 29 struct SelectedFileInfo;
29 } 30 }
30 31
31 // This class handles file-selection requests coming from WebUI elements 32 // This class handles file-selection requests coming from WebUI elements
32 // (via the extensions::ExtensionHost class). It implements both the 33 // (via the extensions::ExtensionHost class). It implements both the
33 // initialisation and listener functions for file-selection dialogs. 34 // initialisation and listener functions for file-selection dialogs.
34 class FileSelectHelper 35 class FileSelectHelper : public base::RefCountedThreadSafe<FileSelectHelper>,
35 : public base::RefCountedThreadSafe<FileSelectHelper>, 36 public ui::SelectFileDialog::Listener,
36 public ui::SelectFileDialog::Listener, 37 public content::WebContentsObserver,
37 public content::NotificationObserver { 38 public content::NotificationObserver {
38 public: 39 public:
39 40
40 // Show the file chooser dialog. 41 // Show the file chooser dialog.
41 static void RunFileChooser(content::WebContents* tab, 42 static void RunFileChooser(content::WebContents* tab,
42 const content::FileChooserParams& params); 43 const content::FileChooserParams& params);
43 44
44 // Enumerates all the files in directory. 45 // Enumerates all the files in directory.
45 static void EnumerateDirectory(content::WebContents* tab, 46 static void EnumerateDirectory(content::WebContents* tab,
46 int request_id, 47 int request_id,
47 const base::FilePath& path); 48 const base::FilePath& path);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 void MultiFilesSelectedWithExtraInfo( 99 void MultiFilesSelectedWithExtraInfo(
99 const std::vector<ui::SelectedFileInfo>& files, 100 const std::vector<ui::SelectedFileInfo>& files,
100 void* params) override; 101 void* params) override;
101 void FileSelectionCanceled(void* params) override; 102 void FileSelectionCanceled(void* params) override;
102 103
103 // content::NotificationObserver overrides. 104 // content::NotificationObserver overrides.
104 void Observe(int type, 105 void Observe(int type,
105 const content::NotificationSource& source, 106 const content::NotificationSource& source,
106 const content::NotificationDetails& details) override; 107 const content::NotificationDetails& details) override;
107 108
109 // content::WebContentsObserver overrides.
110 void RenderViewHostChanged(content::RenderViewHost* old_host,
111 content::RenderViewHost* new_host) override;
112 void WebContentsDestroyed() override;
113
108 void EnumerateDirectory(int request_id, 114 void EnumerateDirectory(int request_id,
109 content::RenderViewHost* render_view_host, 115 content::RenderViewHost* render_view_host,
110 const base::FilePath& path); 116 const base::FilePath& path);
111 117
112 // Kicks off a new directory enumeration. 118 // Kicks off a new directory enumeration.
113 void StartNewEnumeration(const base::FilePath& path, 119 void StartNewEnumeration(const base::FilePath& path,
114 int request_id, 120 int request_id,
115 content::RenderViewHost* render_view_host); 121 content::RenderViewHost* render_view_host);
116 122
117 // Callbacks from directory enumeration. 123 // Callbacks from directory enumeration.
(...skipping 30 matching lines...) Expand all
148 const std::vector<ui::SelectedFileInfo>& files); 154 const std::vector<ui::SelectedFileInfo>& files);
149 155
150 // Sends the result to the render process, and call |RunFileChooserEnd|. 156 // Sends the result to the render process, and call |RunFileChooserEnd|.
151 void NotifyRenderViewHostAndEndAfterConversion( 157 void NotifyRenderViewHostAndEndAfterConversion(
152 const std::vector<content::FileChooserFileInfo>& list); 158 const std::vector<content::FileChooserFileInfo>& list);
153 159
154 // Schedules the deletion of the files in |temporary_files_| and clears the 160 // Schedules the deletion of the files in |temporary_files_| and clears the
155 // vector. 161 // vector.
156 void DeleteTemporaryFiles(); 162 void DeleteTemporaryFiles();
157 163
164 // Cleans up when the RenderViewHost of our WebContents changes.
165 void CleanUpOnRenderViewHostChange();
166
158 // Helper method to get allowed extensions for select file dialog from 167 // Helper method to get allowed extensions for select file dialog from
159 // the specified accept types as defined in the spec: 168 // the specified accept types as defined in the spec:
160 // http://whatwg.org/html/number-state.html#attr-input-accept 169 // http://whatwg.org/html/number-state.html#attr-input-accept
161 // |accept_types| contains only valid lowercased MIME types or file extensions 170 // |accept_types| contains only valid lowercased MIME types or file extensions
162 // beginning with a period (.). 171 // beginning with a period (.).
163 static scoped_ptr<ui::SelectFileDialog::FileTypeInfo> 172 static scoped_ptr<ui::SelectFileDialog::FileTypeInfo>
164 GetFileTypesFromAcceptType( 173 GetFileTypesFromAcceptType(
165 const std::vector<base::string16>& accept_types); 174 const std::vector<base::string16>& accept_types);
166 175
167 // Check the accept type is valid. It is expected to be all lower case with 176 // Check the accept type is valid. It is expected to be all lower case with
(...skipping 28 matching lines...) Expand all
196 content::NotificationRegistrar notification_registrar_; 205 content::NotificationRegistrar notification_registrar_;
197 206
198 // Temporary files only used on OSX. This class is responsible for deleting 207 // Temporary files only used on OSX. This class is responsible for deleting
199 // these files when they are no longer needed. 208 // these files when they are no longer needed.
200 std::vector<base::FilePath> temporary_files_; 209 std::vector<base::FilePath> temporary_files_;
201 210
202 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); 211 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper);
203 }; 212 };
204 213
205 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ 214 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/file_select_helper.cc » ('j') | chrome/browser/file_select_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698