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 5ac3fbae190d25365341d3dfc5a21e92a82a9943..ed36bd831df1f36fe66a719a9dde9f139dc8efd2 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" |
| @@ -389,8 +390,10 @@ bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) { |
| bool ChromeDownloadManagerDelegate::ShouldOpenWithWebIntents( |
| const DownloadItem* item) { |
| - if (!item->GetWebContents() || !item->GetWebContents()->GetDelegate()) |
| + if ((item->GetWebContents() && !item->GetWebContents()->GetDelegate()) && |
| + !web_intents::GetBrowserForBackgroundWebIntentDelivery(profile_)) { |
| return false; |
| + } |
| if (!item->GetForcedFilePath().empty()) |
| return false; |
| @@ -460,10 +463,16 @@ void ChromeDownloadManagerDelegate::OpenWithWebIntent( |
| content::WebIntentsDispatcher::Create(intent_data); |
| dispatcher->RegisterReplyNotification( |
| base::Bind(&OnWebIntentDispatchCompleted, item->GetFullPath())); |
| - // 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/09/10 15:43:35
DCHECK opportunity here? Should we ever end up he
|
| } |
| bool ChromeDownloadManagerDelegate::GenerateFileHash() { |
| @@ -733,6 +742,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. |