| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 void DownloadControllerAndroidImpl::DangerousDownloadValidated( | 357 void DownloadControllerAndroidImpl::DangerousDownloadValidated( |
| 358 WebContents* web_contents, int download_id, bool accept) { | 358 WebContents* web_contents, int download_id, bool accept) { |
| 359 if (!web_contents) | 359 if (!web_contents) |
| 360 return; | 360 return; |
| 361 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>( | 361 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>( |
| 362 BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())); | 362 BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())); |
| 363 DownloadItem* item = dlm->GetDownload(download_id); | 363 DownloadItem* item = dlm->GetDownload(download_id); |
| 364 if (!item) | 364 if (!item) |
| 365 return; | 365 return; |
| 366 if (accept) | 366 if (accept) |
| 367 item->DangerousDownloadValidated(); | 367 item->ValidateDangerousDownload(); |
| 368 else | 368 else |
| 369 item->Delete(content::DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 369 item->Remove(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( | 372 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( |
| 373 net::URLRequest* request) { | 373 net::URLRequest* request) { |
| 374 request->GetResponseHeaderByName("content-disposition", &content_disposition); | 374 request->GetResponseHeaderByName("content-disposition", &content_disposition); |
| 375 | 375 |
| 376 if (request->response_headers()) | 376 if (request->response_headers()) |
| 377 request->response_headers()->GetMimeType(&original_mime_type); | 377 request->response_headers()->GetMimeType(&original_mime_type); |
| 378 | 378 |
| 379 request->extra_request_headers().GetHeader( | 379 request->extra_request_headers().GetHeader( |
| 380 net::HttpRequestHeaders::kUserAgent, &user_agent); | 380 net::HttpRequestHeaders::kUserAgent, &user_agent); |
| 381 GURL referer_url(request->referrer()); | 381 GURL referer_url(request->referrer()); |
| 382 if (referer_url.is_valid()) | 382 if (referer_url.is_valid()) |
| 383 referer = referer_url.spec(); | 383 referer = referer_url.spec(); |
| 384 if (!request->url_chain().empty()) { | 384 if (!request->url_chain().empty()) { |
| 385 original_url = request->url_chain().front(); | 385 original_url = request->url_chain().front(); |
| 386 url = request->url_chain().back(); | 386 url = request->url_chain().back(); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} | 390 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} |
| 391 | 391 |
| 392 } // namespace content | 392 } // namespace content |
| OLD | NEW |