Index: chrome/browser/download/chrome_download_manager_delegate.cc |
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc |
index f3e7c054241574c09632573c425fed64a7f8c135..a3af42d00c87e87612544af0397a4b7d546cff1c 100644 |
--- a/chrome/browser/download/chrome_download_manager_delegate.cc |
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc |
@@ -29,6 +29,7 @@ |
#include "chrome/browser/extensions/api/downloads/downloads_api.h" |
#include "chrome/browser/extensions/crx_installer.h" |
#include "chrome/browser/extensions/extension_service.h" |
+#include "chrome/browser/intents/web_intents_util.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/safe_browsing/safe_browsing_service.h" |
@@ -369,9 +370,6 @@ bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) { |
bool ChromeDownloadManagerDelegate::ShouldOpenWithWebIntents( |
const DownloadItem* item) { |
- if (!item->GetWebContents() || !item->GetWebContents()->GetDelegate()) |
- return false; |
- |
std::string mime_type = item->GetMimeType(); |
if (mime_type == "application/rss+xml" || |
mime_type == "application/atom+xml") { |
@@ -436,10 +434,16 @@ void ChromeDownloadManagerDelegate::OpenWithWebIntent( |
content::WebIntentsDispatcher* dispatcher = |
content::WebIntentsDispatcher::Create(intent_data); |
- // TODO(gbillock): try to get this to be able to delegate to the Browser |
- // object directly, passing a NULL WebContents? |
- item->GetWebContents()->GetDelegate()->WebIntentDispatch( |
- item->GetWebContents(), dispatcher); |
+ |
+ content::WebContentsDelegate* delegate = NULL; |
+ if (item->GetWebContents() && item->GetWebContents()->GetDelegate()) { |
+ delegate = item->GetWebContents()->GetDelegate(); |
+ } else { |
+ delegate = web_intents::GetBrowserForBackgroundWebIntentDelivery( |
+ profile_); |
+ } |
+ if (delegate) |
+ delegate->WebIntentDispatch(NULL, dispatcher); |
Randy Smith (Not in Mondays)
2012/08/28 18:03:43
Shouldn't this logic be duplicated in ShouldOpenWi
Greg Billock
2012/08/28 18:38:00
What I found in my testing is that for target=_bla
|
} |
bool ChromeDownloadManagerDelegate::GenerateFileHash() { |
@@ -709,6 +713,8 @@ void ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone( |
} |
if (download_prefs_->IsDownloadPathManaged()) |
should_prompt = false; |
+ if (ShouldOpenWithWebIntents(download)) |
Randy Smith (Not in Mondays)
2012/08/28 18:03:43
Help me understand the reason for this? I'm worri
Greg Billock
2012/08/28 18:38:00
Yes, we definitely do. What I'm trying to do here
benjhayden
2012/08/28 18:42:14
Can you show how Save Pages use this code path?
I
Randy Smith (Not in Mondays)
2012/08/28 19:05:19
I don't completely understand the use case--do you
Greg Billock
2012/09/10 20:19:07
Ah! I somehow didn't see this #11 in the thread. I
|
+ should_prompt = false; |
// Determine the proper path for a download, by either one of the following: |
// 1) using the default download directory. |