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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 OpenWithWebIntent(item); | 253 OpenWithWebIntent(item); |
254 item->DelayedDownloadOpened(); | 254 item->DelayedDownloadOpened(); |
255 return false; | 255 return false; |
256 } | 256 } |
257 | 257 |
258 return true; | 258 return true; |
259 } | 259 } |
260 | 260 |
261 bool ChromeDownloadManagerDelegate::ShouldOpenWithWebIntents( | 261 bool ChromeDownloadManagerDelegate::ShouldOpenWithWebIntents( |
262 const DownloadItem* item) { | 262 const DownloadItem* item) { |
| 263 std::string mime_type = item->GetMimeType(); |
| 264 if (mime_type == "application/rss+xml" || |
| 265 mime_type == "application/atom+xml") { |
| 266 return true; |
| 267 } |
| 268 |
| 269 #if defined(OS_CHROMEOS) |
| 270 if (mime_type == "application/msword" || |
| 271 mime_type == "application/vnd.ms-powerpoint" || |
| 272 mime_type == "application/vnd.ms-excel" || |
| 273 mime_type == "application/vnd.openxmlformats-officedocument." |
| 274 "wordprocessingml.document" || |
| 275 mime_type == "application/vnd.openxmlformats-officedocument." |
| 276 "presentationml.presentation" || |
| 277 mime_type == "application/vnd.openxmlformats-officedocument." |
| 278 "spreadsheetml.sheet") { |
| 279 return true; |
| 280 } |
| 281 #endif // defined(OS_CHROMEOS) |
| 282 |
263 return false; | 283 return false; |
264 } | 284 } |
265 | 285 |
266 void ChromeDownloadManagerDelegate::OpenWithWebIntent( | 286 void ChromeDownloadManagerDelegate::OpenWithWebIntent( |
267 const DownloadItem* item) { | 287 const DownloadItem* item) { |
268 webkit_glue::WebIntentData intent_data( | 288 webkit_glue::WebIntentData intent_data( |
269 ASCIIToUTF16("http://webintents.org/view"), | 289 ASCIIToUTF16("http://webintents.org/view"), |
270 ASCIIToUTF16(item->GetMimeType()), | 290 ASCIIToUTF16(item->GetMimeType()), |
271 item->GetFullPath(), | 291 item->GetFullPath(), |
272 item->GetReceivedBytes()); | 292 item->GetReceivedBytes()); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 int32 download_id, int64 db_handle) { | 697 int32 download_id, int64 db_handle) { |
678 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 698 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
679 // call this function with an invalid |db_handle|. For instance, this can | 699 // call this function with an invalid |db_handle|. For instance, this can |
680 // happen when the history database is offline. We cannot have multiple | 700 // happen when the history database is offline. We cannot have multiple |
681 // DownloadItems with the same invalid db_handle, so we need to assign a | 701 // DownloadItems with the same invalid db_handle, so we need to assign a |
682 // unique |db_handle| here. | 702 // unique |db_handle| here. |
683 if (db_handle == DownloadItem::kUninitializedHandle) | 703 if (db_handle == DownloadItem::kUninitializedHandle) |
684 db_handle = download_history_->GetNextFakeDbHandle(); | 704 db_handle = download_history_->GetNextFakeDbHandle(); |
685 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 705 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
686 } | 706 } |
OLD | NEW |