Chromium Code Reviews| 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..4f613d7148df2410eabb1ebd783bc11154d05b25 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,15 @@ 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( |
|
benjhayden
2012/08/27 20:45:58
I see GetBrowserForBackgroundWebIntentDelivery use
|
| + profile_); |
| + } |
| + delegate->WebIntentDispatch(NULL, dispatcher); |
|
benjhayden
2012/08/27 20:45:58
GetBrowserForBackgroundWebIntentDelivery may retur
|
| } |
| bool ChromeDownloadManagerDelegate::GenerateFileHash() { |
| @@ -709,6 +712,8 @@ void ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone( |
| } |
| if (download_prefs_->IsDownloadPathManaged()) |
| should_prompt = false; |
| + if (ShouldOpenWithWebIntents(download)) |
| + should_prompt = false; |
| // Determine the proper path for a download, by either one of the following: |
| // 1) using the default download directory. |