| 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 "content/browser/android/download_controller_android_impl.h" | 5 #include "content/browser/android/download_controller_android_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 // download is in the COMPLETE state. Only handle one. | 500 // download is in the COMPLETE state. Only handle one. |
| 501 item->RemoveObserver(this); | 501 item->RemoveObserver(this); |
| 502 | 502 |
| 503 // Call onDownloadCompleted | 503 // Call onDownloadCompleted |
| 504 Java_DownloadController_onDownloadCompleted( | 504 Java_DownloadController_onDownloadCompleted( |
| 505 env, GetJavaObject()->Controller(env).obj(), jurl.obj(), | 505 env, GetJavaObject()->Controller(env).obj(), jurl.obj(), |
| 506 jmime_type.obj(), jfilename.obj(), jpath.obj(), | 506 jmime_type.obj(), jfilename.obj(), jpath.obj(), |
| 507 item->GetReceivedBytes(), item->GetId(), jguid.obj(), | 507 item->GetReceivedBytes(), item->GetId(), jguid.obj(), |
| 508 joriginal_url.obj(), jreferrer_url.obj(), item->HasUserGesture()); | 508 joriginal_url.obj(), jreferrer_url.obj(), item->HasUserGesture()); |
| 509 DownloadControllerAndroid::RecordDownloadCancelReason( | 509 DownloadControllerAndroid::RecordDownloadCancelReason( |
| 510 DownloadControllerAndroid::CANCEL_REASON_NOT_CANCELED); | 510 DownloadControllerAndroid::CANCEL_REASON_NOT_CANCELED); |
| 511 break; | 511 break; |
| 512 case DownloadItem::CANCELLED: | 512 case DownloadItem::CANCELLED: |
| 513 Java_DownloadController_onDownloadCancelled( | 513 Java_DownloadController_onDownloadCancelled( |
| 514 env, GetJavaObject()->Controller(env).obj(), item->GetId(), | 514 env, GetJavaObject()->Controller(env).obj(), item->GetId(), |
| 515 jguid.obj()); | 515 jguid.obj()); |
| 516 break; | 516 break; |
| 517 case DownloadItem::INTERRUPTED: | 517 case DownloadItem::INTERRUPTED: |
| 518 // When device loses/changes network, we get a NETWORK_TIMEOUT, | 518 // When device loses/changes network, we get a NETWORK_TIMEOUT, |
| 519 // NETWORK_FAILED or NETWORK_DISCONNECTED error. Download should auto | 519 // NETWORK_FAILED or NETWORK_DISCONNECTED error. Download should auto |
| 520 // resume in this case. | 520 // resume in this case. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 WebContents* web_contents, | 585 WebContents* web_contents, |
| 586 const std::string& download_guid, | 586 const std::string& download_guid, |
| 587 bool accept) { | 587 bool accept) { |
| 588 if (!web_contents) | 588 if (!web_contents) |
| 589 return; | 589 return; |
| 590 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>( | 590 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>( |
| 591 BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())); | 591 BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())); |
| 592 DownloadItem* item = dlm->GetDownloadByGuid(download_guid); | 592 DownloadItem* item = dlm->GetDownloadByGuid(download_guid); |
| 593 if (!item) | 593 if (!item) |
| 594 return; | 594 return; |
| 595 if (accept) | 595 if (accept) { |
| 596 item->ValidateDangerousDownload(); | 596 item->ValidateDangerousDownload(); |
| 597 else | 597 } else { |
| 598 DownloadControllerAndroid::RecordDownloadCancelReason( |
| 599 DownloadControllerAndroid:: |
| 600 CANCEL_REASON_DANGEROUS_DOWNLOAD_INFOBAR_DISMISSED); |
| 598 item->Remove(); | 601 item->Remove(); |
| 602 } |
| 599 } | 603 } |
| 600 | 604 |
| 601 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( | 605 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( |
| 602 net::URLRequest* request) | 606 net::URLRequest* request) |
| 603 : has_user_gesture(false) { | 607 : has_user_gesture(false) { |
| 604 request->GetResponseHeaderByName("content-disposition", &content_disposition); | 608 request->GetResponseHeaderByName("content-disposition", &content_disposition); |
| 605 | 609 |
| 606 if (request->response_headers()) | 610 if (request->response_headers()) |
| 607 request->response_headers()->GetMimeType(&original_mime_type); | 611 request->response_headers()->GetMimeType(&original_mime_type); |
| 608 | 612 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 622 if (info) | 626 if (info) |
| 623 has_user_gesture = info->HasUserGesture(); | 627 has_user_gesture = info->HasUserGesture(); |
| 624 } | 628 } |
| 625 | 629 |
| 626 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( | 630 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( |
| 627 const DownloadInfoAndroid& other) = default; | 631 const DownloadInfoAndroid& other) = default; |
| 628 | 632 |
| 629 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} | 633 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} |
| 630 | 634 |
| 631 } // namespace content | 635 } // namespace content |
| OLD | NEW |