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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 mime_type == "application/vnd.openxmlformats-officedocument." | 385 mime_type == "application/vnd.openxmlformats-officedocument." |
386 "wordprocessingml.document" || | 386 "wordprocessingml.document" || |
387 mime_type == "application/vnd.openxmlformats-officedocument." | 387 mime_type == "application/vnd.openxmlformats-officedocument." |
388 "presentationml.presentation" || | 388 "presentationml.presentation" || |
389 mime_type == "application/vnd.openxmlformats-officedocument." | 389 mime_type == "application/vnd.openxmlformats-officedocument." |
390 "spreadsheetml.sheet") { | 390 "spreadsheetml.sheet") { |
391 return true; | 391 return true; |
392 } | 392 } |
393 #endif // defined(OS_CHROMEOS) | 393 #endif // defined(OS_CHROMEOS) |
394 | 394 |
| 395 // If QuickOffice extension is installed, use web intents to handle the |
| 396 // downloaded file. |
| 397 const char* kQuickOfficeExtensionId = "gbkeegbaiigmenfmjfclcdgdpimamgkj"; |
| 398 ExtensionServiceInterface* extension_service = |
| 399 profile_->GetExtensionService(); |
| 400 |
| 401 const ExtensionSet* set = extension_service->extensions(); |
| 402 for (ExtensionSet::const_iterator it = set->begin(); |
| 403 it != set->end(); ++it) { |
| 404 LOG(INFO) << "Have extension " << (*it)->id(); |
| 405 } |
| 406 |
| 407 if (extension_service && |
| 408 extension_service->GetInstalledExtension(kQuickOfficeExtensionId) && |
| 409 extension_service->IsExtensionEnabled(kQuickOfficeExtensionId)) { |
| 410 LOG(INFO) << "Adding office type policy!"; |
| 411 if (mime_type == "application/msword" || |
| 412 mime_type == "application/vnd.ms-powerpoint" || |
| 413 mime_type == "application/vnd.ms-excel" || |
| 414 mime_type == "application/vnd.openxmlformats-officedocument." |
| 415 "wordprocessingml.document" || |
| 416 mime_type == "application/vnd.openxmlformats-officedocument." |
| 417 "presentationml.presentation" || |
| 418 mime_type == "application/vnd.openxmlformats-officedocument." |
| 419 "spreadsheetml.sheet") { |
| 420 return true; |
| 421 } |
| 422 } |
| 423 |
395 return false; | 424 return false; |
396 } | 425 } |
397 | 426 |
398 void ChromeDownloadManagerDelegate::OpenWithWebIntent( | 427 void ChromeDownloadManagerDelegate::OpenWithWebIntent( |
399 const DownloadItem* item) { | 428 const DownloadItem* item) { |
400 webkit_glue::WebIntentData intent_data( | 429 webkit_glue::WebIntentData intent_data( |
401 ASCIIToUTF16("http://webintents.org/view"), | 430 ASCIIToUTF16("http://webintents.org/view"), |
402 ASCIIToUTF16(item->GetMimeType()), | 431 ASCIIToUTF16(item->GetMimeType()), |
403 item->GetFullPath(), | 432 item->GetFullPath(), |
404 item->GetReceivedBytes()); | 433 item->GetReceivedBytes()); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 int32 download_id, int64 db_handle) { | 864 int32 download_id, int64 db_handle) { |
836 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 865 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
837 // call this function with an invalid |db_handle|. For instance, this can | 866 // call this function with an invalid |db_handle|. For instance, this can |
838 // happen when the history database is offline. We cannot have multiple | 867 // happen when the history database is offline. We cannot have multiple |
839 // DownloadItems with the same invalid db_handle, so we need to assign a | 868 // DownloadItems with the same invalid db_handle, so we need to assign a |
840 // unique |db_handle| here. | 869 // unique |db_handle| here. |
841 if (db_handle == DownloadItem::kUninitializedHandle) | 870 if (db_handle == DownloadItem::kUninitializedHandle) |
842 db_handle = download_history_->GetNextFakeDbHandle(); | 871 db_handle = download_history_->GetNextFakeDbHandle(); |
843 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 872 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
844 } | 873 } |
OLD | NEW |