summaryrefslogtreecommitdiffstats
path: root/chrome/browser/file_select_helper.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 18:26:21 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 18:26:21 +0000
commit3a29a6eb503d6b73bbc1c9c9dd58614547190ae1 (patch)
tree554a8fec764691de7d0c9ca9f7c8549b33a08050 /chrome/browser/file_select_helper.cc
parent8a9bc222357bbf7eb6be477ffd74521ca2e82944 (diff)
downloadchromium_src-3a29a6eb503d6b73bbc1c9c9dd58614547190ae1.zip
chromium_src-3a29a6eb503d6b73bbc1c9c9dd58614547190ae1.tar.gz
chromium_src-3a29a6eb503d6b73bbc1c9c9dd58614547190ae1.tar.bz2
Handle the ViewHostMsg_RunFileChooser and ViewHostMsg_EnumerateDirectory IPC messages which are sent
by content(renderer) via the TabContentsDelegate. We eventually want to get rid of the pattern of sending IPC messages from content and handling them in chrome and vice versa. BUG=87335 Review URL: http://codereview.chromium.org/7721003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/file_select_helper.cc')
-rw-r--r--chrome/browser/file_select_helper.cc58
1 files changed, 8 insertions, 50 deletions
diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc
index ed5a194..832ed1c 100644
--- a/chrome/browser/file_select_helper.cc
+++ b/chrome/browser/file_select_helper.cc
@@ -12,7 +12,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
-#include "content/browser/child_process_security_policy.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
@@ -84,6 +83,8 @@ void FileSelectHelper::FileSelected(const FilePath& path,
render_view_host_->FilesSelectedInChooser(files);
// We are done with this showing of the dialog.
render_view_host_ = NULL;
+ // No members should be accessed from here on.
+ delete this;
}
void FileSelectHelper::MultiFilesSelected(const std::vector<FilePath>& files,
@@ -96,6 +97,8 @@ void FileSelectHelper::MultiFilesSelected(const std::vector<FilePath>& files,
render_view_host_->FilesSelectedInChooser(files);
// We are done with this showing of the dialog.
render_view_host_ = NULL;
+ // No members should be accessed from here on.
+ delete this;
}
void FileSelectHelper::FileSelectionCanceled(void* params) {
@@ -108,6 +111,8 @@ void FileSelectHelper::FileSelectionCanceled(void* params) {
// We are done with this showing of the dialog.
render_view_host_ = NULL;
+ // No members should be accessed from here on.
+ delete this;
}
void FileSelectHelper::StartNewEnumeration(const FilePath& path,
@@ -159,6 +164,8 @@ void FileSelectHelper::OnListDone(int id, int error) {
entry->rvh_->FilesSelectedInChooser(entry->results_);
else
entry->rvh_->DirectoryEnumerationFinished(id, entry->results_);
+ // No members should be accessed from here on.
+ delete this;
}
SelectFileDialog::FileTypeInfo* FileSelectHelper::GetFileTypesFromAcceptType(
@@ -297,52 +304,3 @@ void FileSelectHelper::Observe(int type,
render_view_host_ = NULL;
}
-FileSelectObserver::FileSelectObserver(TabContents* tab_contents)
- : TabContentsObserver(tab_contents) {
-}
-
-FileSelectObserver::~FileSelectObserver() {
-}
-
-bool FileSelectObserver::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(FileSelectObserver, message)
- IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
- IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
-void FileSelectObserver::OnRunFileChooser(
- const ViewHostMsg_RunFileChooser_Params& params) {
- if (!file_select_helper_.get()) {
- Profile* profile =
- Profile::FromBrowserContext(tab_contents()->browser_context());
- file_select_helper_.reset(new FileSelectHelper(profile));
- }
- file_select_helper_->RunFileChooser(tab_contents()->render_view_host(),
- tab_contents(),
- params);
-}
-
-void FileSelectObserver::OnEnumerateDirectory(int request_id,
- const FilePath& path) {
- ChildProcessSecurityPolicy* policy =
- ChildProcessSecurityPolicy::GetInstance();
- if (!policy->CanReadDirectory(
- tab_contents()->render_view_host()->process()->id(),
- path)) {
- return;
- }
-
- if (!file_select_helper_.get()) {
- Profile* profile =
- Profile::FromBrowserContext(tab_contents()->browser_context());
- file_select_helper_.reset(new FileSelectHelper(profile));
- }
- file_select_helper_->EnumerateDirectory(request_id,
- tab_contents()->render_view_host(),
- path);
-}