summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_active_document.cc5
-rw-r--r--chrome_frame/chrome_active_document.h2
-rw-r--r--chrome_frame/chrome_frame_activex_base.h18
-rw-r--r--chrome_frame/chrome_frame_delegate.h3
-rw-r--r--chrome_frame/chrome_frame_npapi.cc3
-rw-r--r--chrome_frame/chrome_frame_npapi.h2
-rw-r--r--chrome_frame/chrome_frame_plugin.h11
-rw-r--r--chrome_frame/test/chrome_frame_unittests.cc4
-rw-r--r--chrome_frame/utils.cc19
-rw-r--r--chrome_frame/utils.h3
10 files changed, 56 insertions, 14 deletions
diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc
index d03a6f5..79253d1 100644
--- a/chrome_frame/chrome_active_document.cc
+++ b/chrome_frame/chrome_active_document.cc
@@ -715,7 +715,8 @@ bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) {
return Base::PreProcessContextMenu(menu);
}
-bool ChromeActiveDocument::HandleContextMenuCommand(UINT cmd) {
+bool ChromeActiveDocument::HandleContextMenuCommand(UINT cmd,
+ const IPC::ContextMenuParams& params) {
ScopedComPtr<IWebBrowser2> web_browser2;
DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive());
@@ -733,7 +734,7 @@ bool ChromeActiveDocument::HandleContextMenuCommand(UINT cmd) {
break;
default:
- return Base::HandleContextMenuCommand(cmd);
+ return Base::HandleContextMenuCommand(cmd, params);
}
return true;
diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h
index dbd430f..6b57f2e 100644
--- a/chrome_frame/chrome_active_document.h
+++ b/chrome_frame/chrome_active_document.h
@@ -236,7 +236,7 @@ END_EXEC_COMMAND_MAP()
// Callbacks from ChromeFramePlugin<T>
bool PreProcessContextMenu(HMENU menu);
- bool HandleContextMenuCommand(UINT cmd);
+ bool HandleContextMenuCommand(UINT cmd, const IPC::ContextMenuParams& params);
// Should connections initiated by this class try to block
// responses served with the X-Frame-Options header?
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h
index 6a7183f..28ca868 100644
--- a/chrome_frame/chrome_frame_activex_base.h
+++ b/chrome_frame/chrome_frame_activex_base.h
@@ -40,6 +40,7 @@
#include "chrome_frame/com_message_event.h"
#include "chrome_frame/com_type_info_holder.h"
#include "chrome_frame/urlmon_url_request.h"
+#include "grit/generated_resources.h"
// Include without path to make GYP build see it.
#include "chrome_tab.h" // NOLINT
@@ -288,11 +289,26 @@ END_MSG_MAP()
return CComControlBase::IOleObject_SetClientSite(client_site);
}
- bool HandleContextMenuCommand(UINT cmd) {
+ bool HandleContextMenuCommand(UINT cmd,
+ const IPC::ContextMenuParams& params) {
if (cmd == IDC_ABOUT_CHROME_FRAME) {
int tab_handle = automation_client_->tab()->handle();
OnOpenURL(tab_handle, GURL("about:version"), GURL(), NEW_WINDOW);
return true;
+ } else {
+ switch (cmd) {
+ case IDS_CONTENT_CONTEXT_SAVEAUDIOAS:
+ case IDS_CONTENT_CONTEXT_SAVEVIDEOAS:
+ case IDS_CONTENT_CONTEXT_SAVEIMAGEAS:
+ case IDS_CONTENT_CONTEXT_SAVELINKAS: {
+ const GURL& referrer = params.frame_url.is_empty() ?
+ params.page_url : params.frame_url;
+ const GURL& url = (cmd == IDS_CONTENT_CONTEXT_SAVELINKAS ?
+ params.link_url : params.src_url);
+ DoFileDownloadInIE(UTF8ToWide(url.spec()).c_str());
+ return true;
+ }
+ }
}
return false;
diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h
index 1742ad0..49ae1c1 100644
--- a/chrome_frame/chrome_frame_delegate.h
+++ b/chrome_frame/chrome_frame_delegate.h
@@ -91,7 +91,8 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate {
const std::string& origin,
const std::string& target) {}
virtual void OnHandleContextMenu(int tab_handle, HANDLE menu_handle,
- int x_pos, int y_pos, int align_flags) {}
+ int align_flags,
+ const IPC::ContextMenuParams& params) {}
virtual void OnRequestStart(int tab_handle, int request_id,
const IPC::AutomationURLRequest& request) {}
virtual void OnRequestRead(int tab_handle, int request_id,
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index 509f083..d3e1f91 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -1605,7 +1605,8 @@ NPAPIUrlRequest* ChromeFrameNPAPI::RequestFromNotifyData(
return request;
}
-bool ChromeFrameNPAPI::HandleContextMenuCommand(UINT cmd) {
+bool ChromeFrameNPAPI::HandleContextMenuCommand(UINT cmd,
+ const IPC::ContextMenuParams& params) {
if (cmd == IDC_ABOUT_CHROME_FRAME) {
// TODO: implement "About Chrome Frame"
}
diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h
index 1d35b4c..45b4028 100644
--- a/chrome_frame/chrome_frame_npapi.h
+++ b/chrome_frame/chrome_frame_npapi.h
@@ -125,7 +125,7 @@ END_MSG_MAP()
// Initialize string->identifier mapping, public to allow unittesting.
static void InitializeIdentifiers();
- bool HandleContextMenuCommand(UINT cmd);
+ bool HandleContextMenuCommand(UINT cmd, const IPC::ContextMenuParams& params);
protected:
// Handler for accelerator messages passed on from the hosted chrome
// instance.
diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h
index 36f2fc2..0e16001 100644
--- a/chrome_frame/chrome_frame_plugin.h
+++ b/chrome_frame/chrome_frame_plugin.h
@@ -93,7 +93,8 @@ END_MSG_MAP()
}
virtual void OnHandleContextMenu(int tab_handle, HANDLE menu_handle,
- int x_pos, int y_pos, int align_flags) {
+ int align_flags,
+ const IPC::ContextMenuParams& params) {
if (!menu_handle || !automation_client_.get()) {
NOTREACHED();
return;
@@ -109,9 +110,9 @@ END_MSG_MAP()
T* pThis = static_cast<T*>(this);
if (pThis->PreProcessContextMenu(copy)) {
UINT flags = align_flags | TPM_LEFTBUTTON | TPM_RETURNCMD | TPM_RECURSE;
- UINT selected = TrackPopupMenuEx(copy, flags, x_pos, y_pos, GetWindow(),
- NULL);
- if (selected != 0 && !pThis->HandleContextMenuCommand(selected)) {
+ UINT selected = TrackPopupMenuEx(copy, flags, params.screen_x,
+ params.screen_y, GetWindow(), NULL);
+ if (selected != 0 && !pThis->HandleContextMenuCommand(selected, params)) {
automation_client_->SendContextMenuCommandToChromeFrame(selected);
}
}
@@ -175,7 +176,7 @@ END_MSG_MAP()
// Return true if menu command is processed, otherwise the command will be
// passed to Chrome for execution. Override in most-derived class if needed.
- bool HandleContextMenuCommand(UINT cmd) {
+ bool HandleContextMenuCommand(UINT cmd, const IPC::ContextMenuParams& params) {
return false;
}
diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc
index 1b4eaee..fc4fd1a 100644
--- a/chrome_frame/test/chrome_frame_unittests.cc
+++ b/chrome_frame/test/chrome_frame_unittests.cc
@@ -714,8 +714,8 @@ struct MockCFDelegate : public ChromeFrameDelegateImpl {
const std::string& message,
const std::string& origin,
const std::string& target));
- MOCK_METHOD5(OnHandleContextMenu, void(int tab_handle, HANDLE menu_handle,
- int x_pos, int y_pos, int align_flags));
+ MOCK_METHOD4(OnHandleContextMenu, void(int tab_handle, HANDLE menu_handle,
+ int align_flags, const IPC::ContextMenuParams& params));
MOCK_METHOD3(OnRequestStart, void(int tab_handle, int request_id,
const IPC::AutomationURLRequest& request));
MOCK_METHOD3(OnRequestRead, void(int tab_handle, int request_id,
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index be955bf..88b46c5 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -415,6 +415,25 @@ bool IsIEInPrivate() {
return incognito_mode;
}
+HRESULT DoFileDownloadInIE(const wchar_t* url) {
+ DCHECK(url);
+
+ HMODULE mod = ::GetModuleHandleA("ieframe.dll");
+ if (!mod)
+ mod = ::GetModuleHandleA("shdocvw.dll");
+
+ if (!mod) {
+ NOTREACHED();
+ return E_UNEXPECTED;
+ }
+
+ typedef HRESULT (WINAPI* DoFileDownloadFn)(const wchar_t*);
+ DoFileDownloadFn fn = reinterpret_cast<DoFileDownloadFn>(
+ ::GetProcAddress(mod, "DoFileDownload"));
+ DCHECK(fn);
+ return fn ? fn(url) : E_UNEXPECTED;
+}
+
bool GetModuleVersion(HMODULE module, uint32* high, uint32* low) {
DCHECK(module != NULL)
<< "Please use GetModuleHandle(NULL) to get the process name";
diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h
index 8750794..d10b7c0 100644
--- a/chrome_frame/utils.h
+++ b/chrome_frame/utils.h
@@ -165,6 +165,9 @@ bool GetModuleVersion(HMODULE module, uint32* high, uint32* low);
// whether current process is IEXPLORE.
bool IsIEInPrivate();
+// Calls [ieframe|shdocvw]!DoFileDownload to initiate a download.
+HRESULT DoFileDownloadInIE(const wchar_t* url);
+
// Creates a copy of a menu. We need this when original menu comes from
// a process with higher integrity.
HMENU UtilCloneContextMenu(HMENU original_menu);