| Index: content/browser/download/download_item_impl.cc
|
| diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
|
| index d8a808b8db6d6d17cc75a6f987b9ad7f3300b33a..30a0232f69d82a91e9f35f3050e7aa375dc906a5 100644
|
| --- a/content/browser/download/download_item_impl.cc
|
| +++ b/content/browser/download/download_item_impl.cc
|
| @@ -23,11 +23,18 @@
|
| #include "content/browser/download/download_interrupt_reasons_impl.h"
|
| #include "content/browser/download/download_request_handle.h"
|
| #include "content/browser/download/download_stats.h"
|
| +#include "content/browser/intents/internal_web_intents_dispatcher.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| #include "content/public/browser/download_persistent_store_info.h"
|
| +#include "content/public/browser/resource_context.h"
|
| +#include "content/public/browser/web_contents_delegate.h"
|
| +#include "content/public/browser/web_intents_dispatcher.h"
|
| #include "net/base/net_util.h"
|
| +#include "webkit/blob/blob_data.h"
|
| +#include "webkit/blob/blob_storage_controller.h"
|
| +#include "webkit/glue/web_intent_data.h"
|
|
|
| using content::BrowserThread;
|
| using content::DownloadFile;
|
| @@ -771,6 +778,12 @@ void DownloadItemImpl::OnDownloadRenamedToFinalName(const FilePath& full_path) {
|
|
|
| Rename(full_path);
|
|
|
| + if (delegate_->ShouldOpenWithWebIntent(this)) {
|
| + DispatchAsWebIntent();
|
| + Completed();
|
| + return;
|
| + }
|
| +
|
| if (delegate_->ShouldOpenDownload(this)) {
|
| Completed();
|
| } else {
|
| @@ -778,6 +791,26 @@ void DownloadItemImpl::OnDownloadRenamedToFinalName(const FilePath& full_path) {
|
| }
|
| }
|
|
|
| +void DownloadItemImpl::DispatchAsWebIntent() {
|
| + // TODO(gbillock): should this read non-binary files and pass them
|
| + // as unserialized text? Probably so...
|
| + webkit_glue::WebIntentData intent_data(
|
| + ASCIIToUTF16("http://webintents.org/view"),
|
| + ASCIIToUTF16(GetMimeType()),
|
| + GetFullPath().AsUTF8Unsafe(),
|
| + GetReceivedBytes());
|
| + intent_data.extra_data.insert(make_pair(
|
| + ASCIIToUTF16("url"), ASCIIToUTF16(GetURL().spec())));
|
| +
|
| + // TODO(gbillock): need to ChildProcessSecurityPolicy::GrantReadFile(someone)
|
| + // here? Or on the receiving end?
|
| +
|
| + content::WebIntentsDispatcher* dispatcher =
|
| + new InternalWebIntentsDispatcher(intent_data);
|
| + GetWebContents()->GetDelegate()->WebIntentDispatch(GetWebContents(),
|
| + dispatcher);
|
| +}
|
| +
|
| bool DownloadItemImpl::MatchesQuery(const string16& query) const {
|
| if (query.empty())
|
| return true;
|
|
|