| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 ASCIIToUTF16("http://webintents.org/view"), | 392 ASCIIToUTF16("http://webintents.org/view"), |
| 393 ASCIIToUTF16(item->GetMimeType()), | 393 ASCIIToUTF16(item->GetMimeType()), |
| 394 item->GetFullPath(), | 394 item->GetFullPath(), |
| 395 item->GetReceivedBytes()); | 395 item->GetReceivedBytes()); |
| 396 | 396 |
| 397 // RCH specifies that the receiver gets the url, but with Web Intents | 397 // RCH specifies that the receiver gets the url, but with Web Intents |
| 398 // it isn't really needed. | 398 // it isn't really needed. |
| 399 intent_data.extra_data.insert(make_pair( | 399 intent_data.extra_data.insert(make_pair( |
| 400 ASCIIToUTF16("url"), ASCIIToUTF16(item->GetURL().spec()))); | 400 ASCIIToUTF16("url"), ASCIIToUTF16(item->GetURL().spec()))); |
| 401 | 401 |
| 402 // The SuggestedFilename is not always filled in in the DownloadItem. | 402 // Pass the downloaded filename to the service app as the name hint. |
| 403 // When it is, it comes from the purpose-built HTML algorithm, but | 403 intent_data.extra_data.insert( |
| 404 // in practice it is frequently just inferred. | 404 make_pair(ASCIIToUTF16("filename"), |
| 405 string16 filename = UTF8ToUTF16(item->GetSuggestedFilename()); | 405 item->GetFileNameToReportUser().LossyDisplayName())); |
| 406 if (filename.empty()) | |
| 407 filename = item->GetFileNameToReportUser().LossyDisplayName(); | |
| 408 intent_data.extra_data.insert(make_pair(ASCIIToUTF16("filename"), filename)); | |
| 409 | 406 |
| 410 content::WebIntentsDispatcher* dispatcher = | 407 content::WebIntentsDispatcher* dispatcher = |
| 411 content::WebIntentsDispatcher::Create(intent_data); | 408 content::WebIntentsDispatcher::Create(intent_data); |
| 412 // TODO(gbillock): try to get this to be able to delegate to the Browser | 409 // TODO(gbillock): try to get this to be able to delegate to the Browser |
| 413 // object directly, passing a NULL WebContents? | 410 // object directly, passing a NULL WebContents? |
| 414 item->GetWebContents()->GetDelegate()->WebIntentDispatch( | 411 item->GetWebContents()->GetDelegate()->WebIntentDispatch( |
| 415 item->GetWebContents(), dispatcher); | 412 item->GetWebContents(), dispatcher); |
| 416 } | 413 } |
| 417 | 414 |
| 418 bool ChromeDownloadManagerDelegate::GenerateFileHash() { | 415 bool ChromeDownloadManagerDelegate::GenerateFileHash() { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 int32 download_id, int64 db_handle) { | 772 int32 download_id, int64 db_handle) { |
| 776 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 773 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 777 // call this function with an invalid |db_handle|. For instance, this can | 774 // call this function with an invalid |db_handle|. For instance, this can |
| 778 // happen when the history database is offline. We cannot have multiple | 775 // happen when the history database is offline. We cannot have multiple |
| 779 // DownloadItems with the same invalid db_handle, so we need to assign a | 776 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 780 // unique |db_handle| here. | 777 // unique |db_handle| here. |
| 781 if (db_handle == DownloadItem::kUninitializedHandle) | 778 if (db_handle == DownloadItem::kUninitializedHandle) |
| 782 db_handle = download_history_->GetNextFakeDbHandle(); | 779 db_handle = download_history_->GetNextFakeDbHandle(); |
| 783 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 780 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 784 } | 781 } |
| OLD | NEW |