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/download_extension_api.h" | 5 #include "chrome/browser/download/download_extension_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <set> | 10 #include <set> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 const char kEndTimeKey[] = "endTime"; | 86 const char kEndTimeKey[] = "endTime"; |
87 const char kErrorKey[] = "error"; | 87 const char kErrorKey[] = "error"; |
88 const char kFileSizeKey[] = "fileSize"; | 88 const char kFileSizeKey[] = "fileSize"; |
89 const char kFilenameKey[] = "filename"; | 89 const char kFilenameKey[] = "filename"; |
90 const char kFilenameRegexKey[] = "filenameRegex"; | 90 const char kFilenameRegexKey[] = "filenameRegex"; |
91 const char kHeaderNameKey[] = "name"; | 91 const char kHeaderNameKey[] = "name"; |
92 const char kHeaderValueKey[] = "value"; | 92 const char kHeaderValueKey[] = "value"; |
93 const char kHeaderBinaryValueKey[] = "binaryValue"; | 93 const char kHeaderBinaryValueKey[] = "binaryValue"; |
94 const char kHeadersKey[] = "headers"; | 94 const char kHeadersKey[] = "headers"; |
95 const char kIdKey[] = "id"; | 95 const char kIdKey[] = "id"; |
96 const char kIncognito[] = "incognito"; | |
97 const char kIncognitoNone[] = "none"; | |
98 const char kIncognitoOnly[] = "only"; | |
96 const char kLimitKey[] = "limit"; | 99 const char kLimitKey[] = "limit"; |
97 const char kMethodKey[] = "method"; | 100 const char kMethodKey[] = "method"; |
98 const char kMimeKey[] = "mime"; | 101 const char kMimeKey[] = "mime"; |
99 const char kOrderByKey[] = "orderBy"; | 102 const char kOrderByKey[] = "orderBy"; |
100 const char kPausedKey[] = "paused"; | 103 const char kPausedKey[] = "paused"; |
101 const char kQueryKey[] = "query"; | 104 const char kQueryKey[] = "query"; |
102 const char kSaveAsKey[] = "saveAs"; | 105 const char kSaveAsKey[] = "saveAs"; |
103 const char kSizeKey[] = "size"; | 106 const char kSizeKey[] = "size"; |
104 const char kStartTimeKey[] = "startTime"; | 107 const char kStartTimeKey[] = "startTime"; |
105 const char kStartedAfterKey[] = "startedAfter"; | 108 const char kStartedAfterKey[] = "startedAfter"; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 if (item->GetDangerType() != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) | 192 if (item->GetDangerType() != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) |
190 json->SetBoolean(kDangerAcceptedKey, | 193 json->SetBoolean(kDangerAcceptedKey, |
191 item->GetSafetyState() == DownloadItem::DANGEROUS_BUT_VALIDATED); | 194 item->GetSafetyState() == DownloadItem::DANGEROUS_BUT_VALIDATED); |
192 json->SetString(kStateKey, StateString(item->GetState())); | 195 json->SetString(kStateKey, StateString(item->GetState())); |
193 json->SetBoolean(kPausedKey, item->IsPaused()); | 196 json->SetBoolean(kPausedKey, item->IsPaused()); |
194 json->SetString(kMimeKey, item->GetMimeType()); | 197 json->SetString(kMimeKey, item->GetMimeType()); |
195 json->SetInteger(kStartTimeKey, | 198 json->SetInteger(kStartTimeKey, |
196 (item->GetStartTime() - base::Time::UnixEpoch()).InMilliseconds()); | 199 (item->GetStartTime() - base::Time::UnixEpoch()).InMilliseconds()); |
197 json->SetInteger(kBytesReceivedKey, item->GetReceivedBytes()); | 200 json->SetInteger(kBytesReceivedKey, item->GetReceivedBytes()); |
198 json->SetInteger(kTotalBytesKey, item->GetTotalBytes()); | 201 json->SetInteger(kTotalBytesKey, item->GetTotalBytes()); |
202 json->SetBoolean(kIncognito, item->IsOtr()); | |
199 if (item->GetState() == DownloadItem::INTERRUPTED) { | 203 if (item->GetState() == DownloadItem::INTERRUPTED) { |
200 json->SetInteger(kErrorKey, static_cast<int>(item->GetLastReason())); | 204 json->SetInteger(kErrorKey, static_cast<int>(item->GetLastReason())); |
201 } else if (item->GetState() == DownloadItem::CANCELLED) { | 205 } else if (item->GetState() == DownloadItem::CANCELLED) { |
202 json->SetInteger(kErrorKey, static_cast<int>( | 206 json->SetInteger(kErrorKey, static_cast<int>( |
203 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); | 207 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); |
204 } | 208 } |
205 // TODO(benjhayden): Implement endTime and fileSize. | 209 // TODO(benjhayden): Implement endTime and fileSize. |
206 // json->SetInteger(kEndTimeKey, -1); | 210 // json->SetInteger(kEndTimeKey, -1); |
207 json->SetInteger(kFileSizeKey, item->GetTotalBytes()); | 211 json->SetInteger(kFileSizeKey, item->GetTotalBytes()); |
208 return scoped_ptr<base::DictionaryValue>(json); | 212 return scoped_ptr<base::DictionaryValue>(json); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 sorter_types[kStartTimeKey] = DownloadQuery::SORT_START_TIME; | 304 sorter_types[kStartTimeKey] = DownloadQuery::SORT_START_TIME; |
301 sorter_types[kStateKey] = DownloadQuery::SORT_STATE; | 305 sorter_types[kStateKey] = DownloadQuery::SORT_STATE; |
302 sorter_types[kTotalBytesKey] = DownloadQuery::SORT_TOTAL_BYTES; | 306 sorter_types[kTotalBytesKey] = DownloadQuery::SORT_TOTAL_BYTES; |
303 sorter_types[kUrlKey] = DownloadQuery::SORT_URL; | 307 sorter_types[kUrlKey] = DownloadQuery::SORT_URL; |
304 } | 308 } |
305 | 309 |
306 bool IsNotTemporaryDownloadFilter(const DownloadItem& item) { | 310 bool IsNotTemporaryDownloadFilter(const DownloadItem& item) { |
307 return !item.IsTemporary(); | 311 return !item.IsTemporary(); |
308 } | 312 } |
309 | 313 |
314 DownloadItem* GetItem(Browser* browser, Profile* profile, int id) { | |
315 if ((browser != NULL) && | |
316 (browser->profile() != NULL)) | |
317 profile = browser->profile(); | |
Randy Smith (Not in Mondays)
2012/05/03 19:07:21
This seems like a weird bit of functionality at th
benjhayden
2012/05/03 21:08:12
GetCurrentBrowser() may sometimes return NULL if t
| |
318 DownloadManager* download_manager = | |
319 DownloadServiceFactory::GetForProfile(profile)->GetDownloadManager(); | |
320 DownloadItem* download_item = | |
321 download_manager->GetActiveDownloadItem(id); | |
322 if (!download_item) { | |
323 if (profile->IsOffTheRecord()) { | |
324 // Try looking for the item in the original manager. | |
325 download_manager = DownloadServiceFactory::GetForProfile( | |
326 profile->GetOriginalProfile())->GetDownloadManager(); | |
327 download_item = download_manager->GetActiveDownloadItem(id); | |
328 } | |
329 // Do not try looking for the item in the off-the-record manager if profile | |
330 // is on the record. | |
331 } | |
332 return download_item; | |
333 } | |
334 | |
310 } // namespace | 335 } // namespace |
311 | 336 |
312 bool DownloadsFunctionInterface::RunImplImpl( | 337 bool DownloadsFunctionInterface::RunImplImpl( |
313 DownloadsFunctionInterface* pimpl) { | 338 DownloadsFunctionInterface* pimpl) { |
314 CHECK(pimpl); | 339 CHECK(pimpl); |
315 if (!pimpl->ParseArgs()) return false; | 340 if (!pimpl->ParseArgs()) return false; |
316 UMA_HISTOGRAM_ENUMERATION( | 341 UMA_HISTOGRAM_ENUMERATION( |
317 "Download.ApiFunctions", pimpl->function(), DOWNLOADS_FUNCTION_LAST); | 342 "Download.ApiFunctions", pimpl->function(), DOWNLOADS_FUNCTION_LAST); |
318 return pimpl->RunInternal(); | 343 return pimpl->RunInternal(); |
319 } | 344 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 result_.reset(base::Value::CreateIntegerValue(dl_id.local())); | 550 result_.reset(base::Value::CreateIntegerValue(dl_id.local())); |
526 } else { | 551 } else { |
527 error_ = net::ErrorToString(error); | 552 error_ = net::ErrorToString(error); |
528 } | 553 } |
529 SendResponse(error_.empty()); | 554 SendResponse(error_.empty()); |
530 } | 555 } |
531 | 556 |
532 DownloadsSearchFunction::DownloadsSearchFunction() | 557 DownloadsSearchFunction::DownloadsSearchFunction() |
533 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_SEARCH), | 558 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_SEARCH), |
534 query_(new DownloadQuery()), | 559 query_(new DownloadQuery()), |
560 include_on_the_record_(true), | |
561 include_incognito_(true), | |
535 get_id_(0), | 562 get_id_(0), |
536 has_get_id_(false) { | 563 has_get_id_(false) { |
537 } | 564 } |
538 | 565 |
539 DownloadsSearchFunction::~DownloadsSearchFunction() {} | 566 DownloadsSearchFunction::~DownloadsSearchFunction() {} |
540 | 567 |
541 bool DownloadsSearchFunction::ParseArgs() { | 568 bool DownloadsSearchFunction::ParseArgs() { |
542 static base::LazyInstance<FilterTypeMap> filter_types = | 569 static base::LazyInstance<FilterTypeMap> filter_types = |
543 LAZY_INSTANCE_INITIALIZER; | 570 LAZY_INSTANCE_INITIALIZER; |
544 if (filter_types.Get().size() == 0) | 571 if (filter_types.Get().size() == 0) |
545 InitFilterTypeMap(filter_types.Get()); | 572 InitFilterTypeMap(filter_types.Get()); |
546 | 573 |
547 base::DictionaryValue* query_json = NULL; | 574 base::DictionaryValue* query_json = NULL; |
548 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json)); | 575 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json)); |
549 for (base::DictionaryValue::Iterator query_json_field(*query_json); | 576 for (base::DictionaryValue::Iterator query_json_field(*query_json); |
550 query_json_field.HasNext(); query_json_field.Advance()) { | 577 query_json_field.HasNext(); query_json_field.Advance()) { |
551 FilterTypeMap::const_iterator filter_type = | 578 FilterTypeMap::const_iterator filter_type = |
552 filter_types.Get().find(query_json_field.key()); | 579 filter_types.Get().find(query_json_field.key()); |
553 | 580 |
554 if (filter_type != filter_types.Get().end()) { | 581 if (filter_type != filter_types.Get().end()) { |
555 if (!query_->AddFilter(filter_type->second, query_json_field.value())) { | 582 if (!query_->AddFilter(filter_type->second, query_json_field.value())) { |
556 error_ = download_extension_errors::kInvalidFilterError; | 583 error_ = download_extension_errors::kInvalidFilterError; |
557 return false; | 584 return false; |
558 } | 585 } |
559 } else if (query_json_field.key() == kIdKey) { | 586 } else if (query_json_field.key() == kIdKey) { |
560 EXTENSION_FUNCTION_VALIDATE(query_json_field.value().GetAsInteger( | 587 EXTENSION_FUNCTION_VALIDATE(query_json_field.value().GetAsInteger( |
561 &get_id_)); | 588 &get_id_)); |
562 has_get_id_ = true; | 589 has_get_id_ = true; |
590 } else if (query_json_field.key() == kIncognito) { | |
591 std::string incognito; | |
592 EXTENSION_FUNCTION_VALIDATE(query_json_field.value().GetAsString( | |
593 &incognito)); | |
594 if (incognito == kIncognitoNone) { | |
595 include_incognito_ = false; | |
596 } else if (incognito == kIncognitoOnly) { | |
597 include_on_the_record_ = false; | |
598 } else { | |
599 EXTENSION_FUNCTION_VALIDATE(false); | |
600 } | |
563 } else if (query_json_field.key() == kOrderByKey) { | 601 } else if (query_json_field.key() == kOrderByKey) { |
564 if (!ParseOrderBy(query_json_field.value())) | 602 if (!ParseOrderBy(query_json_field.value())) |
565 return false; | 603 return false; |
566 } else if (query_json_field.key() == kDangerKey) { | 604 } else if (query_json_field.key() == kDangerKey) { |
567 std::string danger_str; | 605 std::string danger_str; |
568 EXTENSION_FUNCTION_VALIDATE(query_json_field.value().GetAsString( | 606 EXTENSION_FUNCTION_VALIDATE(query_json_field.value().GetAsString( |
569 &danger_str)); | 607 &danger_str)); |
570 content::DownloadDangerType danger_type = | 608 content::DownloadDangerType danger_type = |
571 DangerEnumFromString(danger_str); | 609 DangerEnumFromString(danger_str); |
572 if (danger_type == content::DOWNLOAD_DANGER_TYPE_MAX) { | 610 if (danger_type == content::DOWNLOAD_DANGER_TYPE_MAX) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 error_ = download_extension_errors::kInvalidOrderByError; | 664 error_ = download_extension_errors::kInvalidOrderByError; |
627 return false; | 665 return false; |
628 } | 666 } |
629 query_->AddSorter(sorter_type->second, direction); | 667 query_->AddSorter(sorter_type->second, direction); |
630 } | 668 } |
631 return true; | 669 return true; |
632 } | 670 } |
633 | 671 |
634 bool DownloadsSearchFunction::RunInternal() { | 672 bool DownloadsSearchFunction::RunInternal() { |
635 DownloadQuery::DownloadVector all_items, cpp_results; | 673 DownloadQuery::DownloadVector all_items, cpp_results; |
636 DownloadManager* manager = DownloadServiceFactory::GetForProfile(profile()) | 674 Profile* original_profile = NULL; |
637 ->GetDownloadManager(); | 675 Profile* otr_profile = NULL; |
676 if (profile()->IsOffTheRecord()) { | |
677 otr_profile = profile(); | |
678 original_profile = profile()->GetOriginalProfile(); | |
679 } else { | |
680 original_profile = profile(); | |
681 } | |
682 DownloadManager* original_manager = DownloadServiceFactory::GetForProfile( | |
683 original_profile)->GetDownloadManager(); | |
684 DownloadManager* otr_manager = NULL; | |
685 if (otr_profile != NULL) { | |
686 otr_manager = DownloadServiceFactory::GetForProfile(otr_profile) | |
687 ->GetDownloadManager(); | |
688 } | |
638 if (has_get_id_) { | 689 if (has_get_id_) { |
639 DownloadItem* item = manager->GetDownloadItem(get_id_); | 690 DownloadItem* item = original_manager->GetDownloadItem(get_id_); |
691 if ((item == NULL) && (otr_manager != NULL)) | |
692 item = otr_manager->GetDownloadItem(get_id_); | |
640 if (item != NULL) | 693 if (item != NULL) |
641 all_items.push_back(item); | 694 all_items.push_back(item); |
642 } else { | 695 } else { |
643 manager->GetAllDownloads(FilePath(FILE_PATH_LITERAL("")), &all_items); | 696 if (include_on_the_record_) |
697 original_manager->GetAllDownloads( | |
698 FilePath(FILE_PATH_LITERAL("")), &all_items); | |
699 if (include_incognito_ && (otr_manager != NULL)) | |
700 otr_manager->GetAllDownloads( | |
701 FilePath(FILE_PATH_LITERAL("")), &all_items); | |
644 } | 702 } |
645 query_->Search(all_items.begin(), all_items.end(), &cpp_results); | 703 query_->Search(all_items.begin(), all_items.end(), &cpp_results); |
646 base::ListValue* json_results = new base::ListValue(); | 704 base::ListValue* json_results = new base::ListValue(); |
647 for (DownloadManager::DownloadVector::const_iterator it = cpp_results.begin(); | 705 for (DownloadManager::DownloadVector::const_iterator it = cpp_results.begin(); |
648 it != cpp_results.end(); ++it) { | 706 it != cpp_results.end(); ++it) { |
649 scoped_ptr<base::DictionaryValue> item(DownloadItemToJSON(*it)); | 707 scoped_ptr<base::DictionaryValue> item(DownloadItemToJSON(*it)); |
650 json_results->Append(item.release()); | 708 json_results->Append(item.release()); |
651 } | 709 } |
652 result_.reset(json_results); | 710 result_.reset(json_results); |
653 return true; | 711 return true; |
654 } | 712 } |
655 | 713 |
656 DownloadsPauseFunction::DownloadsPauseFunction() | 714 DownloadsPauseFunction::DownloadsPauseFunction() |
657 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_PAUSE), | 715 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_PAUSE), |
658 download_id_(DownloadId::Invalid().local()) { | 716 download_id_(DownloadId::Invalid().local()) { |
659 } | 717 } |
660 | 718 |
661 DownloadsPauseFunction::~DownloadsPauseFunction() {} | 719 DownloadsPauseFunction::~DownloadsPauseFunction() {} |
662 | 720 |
663 bool DownloadsPauseFunction::ParseArgs() { | 721 bool DownloadsPauseFunction::ParseArgs() { |
664 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &download_id_)); | 722 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &download_id_)); |
665 return true; | 723 return true; |
666 } | 724 } |
667 | 725 |
668 bool DownloadsPauseFunction::RunInternal() { | 726 bool DownloadsPauseFunction::RunInternal() { |
669 DownloadManager* download_manager = | 727 DownloadItem* download_item = GetItem( |
670 DownloadServiceFactory::GetForProfile(profile())->GetDownloadManager(); | 728 GetCurrentBrowser(), profile(), download_id_); |
671 DownloadItem* download_item = | 729 if ((download_item == NULL) || !download_item->IsInProgress()) { |
672 download_manager->GetActiveDownloadItem(download_id_); | |
673 DCHECK(!download_item || download_item->IsInProgress()); | |
674 | |
675 if (!download_item) { | |
676 // This could be due to an invalid download ID, or it could be due to the | 730 // This could be due to an invalid download ID, or it could be due to the |
677 // download not being currently active. | 731 // download not being currently active. |
678 error_ = download_extension_errors::kInvalidOperationError; | 732 error_ = download_extension_errors::kInvalidOperationError; |
679 } else if (!download_item->IsPaused()) { | 733 } else if (!download_item->IsPaused()) { |
680 // If download_item->IsPaused() already then we treat it as a success. | 734 // If download_item->IsPaused() already then we treat it as a success. |
681 download_item->TogglePause(); | 735 download_item->TogglePause(); |
682 } | 736 } |
683 return error_.empty(); | 737 return error_.empty(); |
684 } | 738 } |
685 | 739 |
686 DownloadsResumeFunction::DownloadsResumeFunction() | 740 DownloadsResumeFunction::DownloadsResumeFunction() |
687 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_RESUME), | 741 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_RESUME), |
688 download_id_(DownloadId::Invalid().local()) { | 742 download_id_(DownloadId::Invalid().local()) { |
689 } | 743 } |
690 | 744 |
691 DownloadsResumeFunction::~DownloadsResumeFunction() {} | 745 DownloadsResumeFunction::~DownloadsResumeFunction() {} |
692 | 746 |
693 bool DownloadsResumeFunction::ParseArgs() { | 747 bool DownloadsResumeFunction::ParseArgs() { |
694 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &download_id_)); | 748 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &download_id_)); |
695 return true; | 749 return true; |
696 } | 750 } |
697 | 751 |
698 bool DownloadsResumeFunction::RunInternal() { | 752 bool DownloadsResumeFunction::RunInternal() { |
699 DownloadManager* download_manager = | 753 DownloadItem* download_item = GetItem( |
700 DownloadServiceFactory::GetForProfile(profile())->GetDownloadManager(); | 754 GetCurrentBrowser(), profile(), download_id_); |
701 DownloadItem* download_item = | 755 if (download_item == NULL) { |
702 download_manager->GetActiveDownloadItem(download_id_); | |
703 DCHECK(!download_item || download_item->IsInProgress()); | |
704 | |
705 if (!download_item) { | |
706 // This could be due to an invalid download ID, or it could be due to the | 756 // This could be due to an invalid download ID, or it could be due to the |
707 // download not being currently active. | 757 // download not being currently active. |
708 error_ = download_extension_errors::kInvalidOperationError; | 758 error_ = download_extension_errors::kInvalidOperationError; |
709 } else if (download_item->IsPaused()) { | 759 } else if (download_item->IsPaused()) { |
710 // If !download_item->IsPaused() already, then we treat it as a success. | 760 // If !download_item->IsPaused() already, then we treat it as a success. |
711 download_item->TogglePause(); | 761 download_item->TogglePause(); |
712 } | 762 } |
713 return error_.empty(); | 763 return error_.empty(); |
714 } | 764 } |
715 | 765 |
716 DownloadsCancelFunction::DownloadsCancelFunction() | 766 DownloadsCancelFunction::DownloadsCancelFunction() |
717 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_CANCEL), | 767 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_CANCEL), |
718 download_id_(DownloadId::Invalid().local()) { | 768 download_id_(DownloadId::Invalid().local()) { |
719 } | 769 } |
720 | 770 |
721 DownloadsCancelFunction::~DownloadsCancelFunction() {} | 771 DownloadsCancelFunction::~DownloadsCancelFunction() {} |
722 | 772 |
723 bool DownloadsCancelFunction::ParseArgs() { | 773 bool DownloadsCancelFunction::ParseArgs() { |
724 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &download_id_)); | 774 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &download_id_)); |
725 return true; | 775 return true; |
726 } | 776 } |
727 | 777 |
728 bool DownloadsCancelFunction::RunInternal() { | 778 bool DownloadsCancelFunction::RunInternal() { |
729 DownloadManager* download_manager = | 779 DownloadItem* download_item = GetItem( |
730 DownloadServiceFactory::GetForProfile(profile())->GetDownloadManager(); | 780 GetCurrentBrowser(), profile(), download_id_); |
731 DownloadItem* download_item = | 781 if (download_item != NULL) |
732 download_manager->GetActiveDownloadItem(download_id_); | |
733 | |
734 if (download_item) | |
735 download_item->Cancel(true); | 782 download_item->Cancel(true); |
736 // |download_item| can be NULL if the download ID was invalid or if the | 783 // |download_item| can be NULL if the download ID was invalid or if the |
737 // download is not currently active. Either way, we don't consider it a | 784 // download is not currently active. Either way, we don't consider it a |
738 // failure. | 785 // failure. |
739 return error_.empty(); | 786 return error_.empty(); |
740 } | 787 } |
741 | 788 |
742 DownloadsEraseFunction::DownloadsEraseFunction() | 789 DownloadsEraseFunction::DownloadsEraseFunction() |
743 : AsyncDownloadsFunction(DOWNLOADS_FUNCTION_ERASE) { | 790 : AsyncDownloadsFunction(DOWNLOADS_FUNCTION_ERASE) { |
744 } | 791 } |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1074 ListValue args; | 1121 ListValue args; |
1075 args.Append(arg); | 1122 args.Append(arg); |
1076 std::string json_args; | 1123 std::string json_args; |
1077 base::JSONWriter::Write(&args, &json_args); | 1124 base::JSONWriter::Write(&args, &json_args); |
1078 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 1125 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
1079 event_name, | 1126 event_name, |
1080 json_args, | 1127 json_args, |
1081 profile_, | 1128 profile_, |
1082 GURL()); | 1129 GURL()); |
1083 } | 1130 } |
OLD | NEW |