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

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

Issue 6680002: Pull the file picker code out of TabContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for jam@ Created 9 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 | « 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) 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 <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h"
11 #include "chrome/browser/ui/shell_dialogs.h" 12 #include "chrome/browser/ui/shell_dialogs.h"
13 #include "content/browser/tab_contents/tab_contents_observer.h"
12 #include "content/common/notification_observer.h" 14 #include "content/common/notification_observer.h"
13 #include "content/common/notification_registrar.h" 15 #include "content/common/notification_registrar.h"
14 #include "net/base/directory_lister.h" 16 #include "net/base/directory_lister.h"
15 17
16 class Profile; 18 class Profile;
17 class RenderViewHost; 19 class RenderViewHost;
18 struct ViewHostMsg_RunFileChooser_Params; 20 struct ViewHostMsg_RunFileChooser_Params;
19 21
20 class FileSelectHelper 22 class FileSelectHelper
21 : public SelectFileDialog::Listener, 23 : public SelectFileDialog::Listener,
22 public net::DirectoryLister::DirectoryListerDelegate, 24 public net::DirectoryLister::DirectoryListerDelegate,
23 public NotificationObserver { 25 public NotificationObserver {
24 public: 26 public:
25 explicit FileSelectHelper(Profile* profile); 27 explicit FileSelectHelper(Profile* profile);
26 ~FileSelectHelper(); 28 ~FileSelectHelper();
27 29
28 // SelectFileDialog::Listener
29 virtual void FileSelected(const FilePath& path, int index, void* params);
30 virtual void MultiFilesSelected(const std::vector<FilePath>& files,
31 void* params);
32 virtual void FileSelectionCanceled(void* params);
33
34 // net::DirectoryLister::DirectoryListerDelegate
35 virtual void OnListFile(
36 const net::DirectoryLister::DirectoryListerData& data);
37 virtual void OnListDone(int error);
38
39 // Show the file chooser dialog. 30 // Show the file chooser dialog.
40 void RunFileChooser(RenderViewHost* render_view_host, 31 void RunFileChooser(RenderViewHost* render_view_host,
41 const ViewHostMsg_RunFileChooser_Params& params); 32 const ViewHostMsg_RunFileChooser_Params& params);
42 33
43 private: 34 private:
44 // NotificationObserver implementation. 35 // SelectFileDialog::Listener overrides.
36 virtual void FileSelected(
37 const FilePath& path, int index, void* params) OVERRIDE;
38 virtual void MultiFilesSelected(const std::vector<FilePath>& files,
39 void* params) OVERRIDE;
40 virtual void FileSelectionCanceled(void* params) OVERRIDE;
41
42 // net::DirectoryLister::DirectoryListerDelegate overrides.
43 virtual void OnListFile(
44 const net::DirectoryLister::DirectoryListerData& data) OVERRIDE;
45 virtual void OnListDone(int error) OVERRIDE;
46
47 // NotificationObserver overrides.
45 virtual void Observe(NotificationType type, 48 virtual void Observe(NotificationType type,
46 const NotificationSource& source, 49 const NotificationSource& source,
47 const NotificationDetails& details); 50 const NotificationDetails& details) OVERRIDE;
48 51
49 // Helper method for handling the SelectFileDialog::Listener callbacks. 52 // Helper method for handling the SelectFileDialog::Listener callbacks.
50 void DirectorySelected(const FilePath& path); 53 void DirectorySelected(const FilePath& path);
51 54
52 // Helper method to get allowed extensions for select file dialog from 55 // Helper method to get allowed extensions for select file dialog from
53 // the specified accept types as defined in the spec: 56 // the specified accept types as defined in the spec:
54 // http://whatwg.org/html/number-state.html#attr-input-accept 57 // http://whatwg.org/html/number-state.html#attr-input-accept
55 SelectFileDialog::FileTypeInfo* GetFileTypesFromAcceptType( 58 SelectFileDialog::FileTypeInfo* GetFileTypesFromAcceptType(
56 const string16& accept_types); 59 const string16& accept_types);
57 60
(...skipping 15 matching lines...) Expand all
73 // The current directory lister results, which may update incrementally 76 // The current directory lister results, which may update incrementally
74 // as the listing proceeds. 77 // as the listing proceeds.
75 std::vector<FilePath> directory_lister_results_; 78 std::vector<FilePath> directory_lister_results_;
76 79
77 // Registrar for notifications regarding our RenderViewHost. 80 // Registrar for notifications regarding our RenderViewHost.
78 NotificationRegistrar notification_registrar_; 81 NotificationRegistrar notification_registrar_;
79 82
80 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); 83 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper);
81 }; 84 };
82 85
86 class FileSelectObserver : public TabContentsObserver {
87 public:
88 explicit FileSelectObserver(TabContents* tab_contents);
89 ~FileSelectObserver();
90
91 private:
92 // TabContentsObserver overrides.
93 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
94
95 // Called when a file selection is to be done.
96 void OnRunFileChooser(const ViewHostMsg_RunFileChooser_Params& params);
97
98 // FileSelectHelper, lazily created.
99 scoped_ptr<FileSelectHelper> file_select_helper_;
100
101 DISALLOW_COPY_AND_ASSIGN(FileSelectObserver);
102 };
103
83 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ 104 #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