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
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 2c4a4a3..0caced4e1 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -294,6 +294,8 @@
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -1093,6 +1095,16 @@
Details<const bool>(&is_editable_node));
}
+void TabContents::OnRunFileChooser(
+ const ViewHostMsg_RunFileChooser_Params& params) {
+ delegate()->RunFileChooser(this, params);
+}
+
+void TabContents::OnEnumerateDirectory(int request_id,
+ const FilePath& path) {
+ delegate()->EnumerateDirectory(this, request_id, path);
+}
+
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading and calls the base implementation.
void TabContents::SetIsLoading(bool is_loading,
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 846fc93..ad4f178 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -54,6 +54,7 @@
struct ViewHostMsg_FrameNavigate_Params;
struct WebPreferences;
class WebUI;
+struct ViewHostMsg_RunFileChooser_Params;
// Describes what goes in the main content area of a tab. TabContents is
// the only type of TabContents, and these should be merged together.
@@ -568,6 +569,9 @@
int maximum_percent,
bool remember);
void OnFocusedNodeChanged(bool is_editable_node);
+ // Called when a file selection is to be done.
+ void OnRunFileChooser(const ViewHostMsg_RunFileChooser_Params& params);
+ void OnEnumerateDirectory(int request_id, const FilePath& path);
// Changes the IsLoading state and notifies delegate as needed
// |details| is used to provide details on the load that just finished
diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc
index 2a8e703..ac03388 100644
--- a/content/browser/tab_contents/tab_contents_delegate.cc
+++ b/content/browser/tab_contents/tab_contents_delegate.cc
@@ -280,6 +280,14 @@
return JavaScriptDialogCreatorStub::GetInstance();
}
+void TabContentsDelegate::RunFileChooser(
+ TabContents* tab, const ViewHostMsg_RunFileChooser_Params& params) {
+}
+
+void TabContentsDelegate::EnumerateDirectory(TabContents* tab, int request_id,
+ const FilePath& path) {
+}
+
TabContentsDelegate::~TabContentsDelegate() {
while (!attached_contents_.empty()) {
TabContents* tab_contents = *attached_contents_.begin();
diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h
index 75214cc7..1118cf7 100644
--- a/content/browser/tab_contents/tab_contents_delegate.h
+++ b/content/browser/tab_contents/tab_contents_delegate.h
@@ -39,6 +39,8 @@
struct NativeWebKeyboardEvent;
class RenderViewHost;
class TabContents;
+struct ViewHostMsg_RunFileChooser_Params;
+class FilePath;
// Objects implement this interface to get notified about changes in the
// TabContents and to provide necessary functionality.
@@ -298,6 +300,16 @@
// and displays nothing.
virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator();
+ // Called when a file selection is to be done.
+ virtual void RunFileChooser(TabContents* tab,
+ const ViewHostMsg_RunFileChooser_Params& params);
+
+ // Request to enumerate a directory. This is equivalent to running the file
+ // chooser in directory-enumeration mode and having the user select the given
+ // directory.
+ virtual void EnumerateDirectory(TabContents* tab, int request_id,
+ const FilePath& path);
+
protected:
virtual ~TabContentsDelegate();