summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 23:59:17 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 23:59:17 +0000
commit35f13ab63b056a8e36c06e41655684915c183701 (patch)
tree913426da932aa18f73f44950d50b1de0398c3968 /chrome
parentd65f129bee77d3a4f6ac186641fe11fd890ef077 (diff)
downloadchromium_src-35f13ab63b056a8e36c06e41655684915c183701.zip
chromium_src-35f13ab63b056a8e36c06e41655684915c183701.tar.gz
chromium_src-35f13ab63b056a8e36c06e41655684915c183701.tar.bz2
Handle right-click->"Save Link As" in the host browser.
TEST=Right click on a link in CF and select "save link as". You should immediately get the host browser's download UI. Before there could be a significant wait before this happened. BUG=23561 Review URL: http://codereview.chromium.org/506042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/external_tab_container.cc23
-rw-r--r--chrome/test/automation/automation_messages.h71
-rw-r--r--chrome/test/automation/automation_messages_internal.h7
3 files changed, 95 insertions, 6 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 2a6c237..2775960 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -440,11 +440,20 @@ bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) {
POINT screen_pt = { params.x, params.y };
MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1);
+ IPC::ContextMenuParams ipc_params;
+ ipc_params.screen_x = screen_pt.x;
+ ipc_params.screen_y = screen_pt.y;
+ ipc_params.link_url = params.link_url;
+ ipc_params.unfiltered_link_url = params.unfiltered_link_url;
+ ipc_params.src_url = params.src_url;
+ ipc_params.page_url = params.page_url;
+ ipc_params.frame_url = params.frame_url;
+
bool rtl = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT;
automation_->Send(
new AutomationMsg_ForwardContextMenuToExternalHost(0, tab_handle_,
- external_context_menu_->GetMenuHandle(), screen_pt.x, screen_pt.y,
- rtl ? TPM_RIGHTALIGN : TPM_LEFTALIGN));
+ external_context_menu_->GetMenuHandle(),
+ rtl ? TPM_RIGHTALIGN : TPM_LEFTALIGN, ipc_params));
return true;
}
@@ -455,6 +464,16 @@ bool ExternalTabContainer::ExecuteContextMenuCommand(int command) {
return false;
}
+ switch (command) {
+ case IDS_CONTENT_CONTEXT_SAVEAUDIOAS:
+ case IDS_CONTENT_CONTEXT_SAVEVIDEOAS:
+ case IDS_CONTENT_CONTEXT_SAVEIMAGEAS:
+ case IDS_CONTENT_CONTEXT_SAVELINKAS: {
+ NOTREACHED(); // Should be handled in host.
+ break;
+ }
+ }
+
external_context_menu_->ExecuteCommand(command);
return true;
}
diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h
index 388b6f2..b7f3013 100644
--- a/chrome/test/automation/automation_messages.h
+++ b/chrome/test/automation/automation_messages.h
@@ -454,6 +454,77 @@ struct ParamTraits<NavigationInfo> {
}
};
+// A stripped down version of ContextMenuParams in webkit/glue/context_menu.h.
+struct ContextMenuParams {
+ // The x coordinate for displaying the menu.
+ int screen_x;
+
+ // The y coordinate for displaying the menu.
+ int screen_y;
+
+ // This is the URL of the link that encloses the node the context menu was
+ // invoked on.
+ GURL link_url;
+
+ // The link URL to be used ONLY for "copy link address". We don't validate
+ // this field in the frontend process.
+ GURL unfiltered_link_url;
+
+ // This is the source URL for the element that the context menu was
+ // invoked on. Example of elements with source URLs are img, audio, and
+ // video.
+ GURL src_url;
+
+ // This is the URL of the top level page that the context menu was invoked
+ // on.
+ GURL page_url;
+
+ // This is the URL of the subframe that the context menu was invoked on.
+ GURL frame_url;
+};
+
+// Traits for ContextMenuParams structure to pack/unpack.
+template <>
+struct ParamTraits<ContextMenuParams> {
+ typedef ContextMenuParams param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.screen_x);
+ WriteParam(m, p.screen_y);
+ WriteParam(m, p.link_url);
+ WriteParam(m, p.unfiltered_link_url);
+ WriteParam(m, p.src_url);
+ WriteParam(m, p.page_url);
+ WriteParam(m, p.frame_url);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return ReadParam(m, iter, &p->screen_x) &&
+ ReadParam(m, iter, &p->screen_y) &&
+ ReadParam(m, iter, &p->link_url) &&
+ ReadParam(m, iter, &p->unfiltered_link_url) &&
+ ReadParam(m, iter, &p->src_url) &&
+ ReadParam(m, iter, &p->page_url) &&
+ ReadParam(m, iter, &p->frame_url);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.screen_x, l);
+ l->append(L", ");
+ LogParam(p.screen_y, l);
+ l->append(L", ");
+ LogParam(p.link_url, l);
+ l->append(L", ");
+ LogParam(p.unfiltered_link_url, l);
+ l->append(L", ");
+ LogParam(p.src_url, l);
+ l->append(L", ");
+ LogParam(p.page_url, l);
+ l->append(L", ");
+ LogParam(p.frame_url, l);
+ l->append(L")");
+ }
+};
+
+
} // namespace IPC
#define MESSAGES_INTERNAL_FILE \
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 754c335..b90280b 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -944,12 +944,11 @@ IPC_BEGIN_MESSAGES(Automation)
string16 /* chrome_locale */)
#if defined(OS_WIN)
- IPC_MESSAGE_ROUTED5(AutomationMsg_ForwardContextMenuToExternalHost,
+ IPC_MESSAGE_ROUTED4(AutomationMsg_ForwardContextMenuToExternalHost,
int /* tab_handle */,
HANDLE /* source menu handle */,
- int /* the x coordinate for displaying the menu */,
- int /* the y coordinate for displaying the menu */,
- int /* align flags */)
+ int /* align flags */,
+ IPC::ContextMenuParams /* params */)
IPC_MESSAGE_ROUTED2(AutomationMsg_ForwardContextMenuCommandToChrome,
int /* tab_handle */,