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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 // Prevent login prompts for 401/407 responses. | 638 // Prevent login prompts for 401/407 responses. |
639 download_params->set_load_flags(net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); | 639 download_params->set_load_flags(net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); |
640 | 640 |
641 DownloadManager* manager = BrowserContext::GetDownloadManager( | 641 DownloadManager* manager = BrowserContext::GetDownloadManager( |
642 current_profile); | 642 current_profile); |
643 manager->DownloadUrl(download_params.Pass()); | 643 manager->DownloadUrl(download_params.Pass()); |
644 RecordApiFunctions(DOWNLOADS_FUNCTION_DOWNLOAD); | 644 RecordApiFunctions(DOWNLOADS_FUNCTION_DOWNLOAD); |
645 return true; | 645 return true; |
646 } | 646 } |
647 | 647 |
648 void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { | 648 void DownloadsDownloadFunction::OnStarted( |
| 649 DownloadItem* item, net::Error error) { |
649 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 650 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
650 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; | 651 VLOG(1) << __FUNCTION__ << " " << item << " " << error; |
651 if (dl_id.local() >= 0) { | 652 if (item) { |
652 SetResult(base::Value::CreateIntegerValue(dl_id.local())); | 653 DCHECK_EQ(net::OK, error); |
| 654 SetResult(base::Value::CreateIntegerValue(item->GetId())); |
653 } else { | 655 } else { |
| 656 DCHECK_NE(net::OK, error); |
654 error_ = net::ErrorToString(error); | 657 error_ = net::ErrorToString(error); |
655 } | 658 } |
656 SendResponse(error_.empty()); | 659 SendResponse(error_.empty()); |
657 } | 660 } |
658 | 661 |
659 DownloadsSearchFunction::DownloadsSearchFunction() {} | 662 DownloadsSearchFunction::DownloadsSearchFunction() {} |
660 DownloadsSearchFunction::~DownloadsSearchFunction() {} | 663 DownloadsSearchFunction::~DownloadsSearchFunction() {} |
661 | 664 |
662 bool DownloadsSearchFunction::RunImpl() { | 665 bool DownloadsSearchFunction::RunImpl() { |
663 scoped_ptr<extensions::api::downloads::Search::Params> params( | 666 scoped_ptr<extensions::api::downloads::Search::Params> params( |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 if (profile_->HasOffTheRecordProfile() && | 1009 if (profile_->HasOffTheRecordProfile() && |
1007 !profile_->IsOffTheRecord()) { | 1010 !profile_->IsOffTheRecord()) { |
1008 DispatchEventInternal( | 1011 DispatchEventInternal( |
1009 profile_->GetOffTheRecordProfile(), | 1012 profile_->GetOffTheRecordProfile(), |
1010 event_name, | 1013 event_name, |
1011 json_args, | 1014 json_args, |
1012 scoped_ptr<base::ListValue>(args->DeepCopy())); | 1015 scoped_ptr<base::ListValue>(args->DeepCopy())); |
1013 } | 1016 } |
1014 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); | 1017 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); |
1015 } | 1018 } |
OLD | NEW |