| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/offline_pages/downloads/offline_page_download_b
ridge.h" | 5 #include "chrome/browser/android/offline_pages/downloads/offline_page_download_b
ridge.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "components/offline_pages/core/downloads/download_ui_item.h" | 27 #include "components/offline_pages/core/downloads/download_ui_item.h" |
| 28 #include "components/offline_pages/core/offline_page_feature.h" | 28 #include "components/offline_pages/core/offline_page_feature.h" |
| 29 #include "components/offline_pages/core/offline_page_model.h" | 29 #include "components/offline_pages/core/offline_page_model.h" |
| 30 #include "content/public/browser/browser_context.h" | 30 #include "content/public/browser/browser_context.h" |
| 31 #include "content/public/browser/download_manager.h" | 31 #include "content/public/browser/download_manager.h" |
| 32 #include "content/public/browser/download_url_parameters.h" | 32 #include "content/public/browser/download_url_parameters.h" |
| 33 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
| 34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 35 #include "jni/OfflinePageDownloadBridge_jni.h" | 35 #include "jni/OfflinePageDownloadBridge_jni.h" |
| 36 #include "net/base/filename_util.h" | 36 #include "net/base/filename_util.h" |
| 37 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 37 #include "url/gurl.h" | 38 #include "url/gurl.h" |
| 38 | 39 |
| 39 using base::android::AttachCurrentThread; | 40 using base::android::AttachCurrentThread; |
| 40 using base::android::ConvertJavaStringToUTF8; | 41 using base::android::ConvertJavaStringToUTF8; |
| 41 using base::android::ConvertUTF8ToJavaString; | 42 using base::android::ConvertUTF8ToJavaString; |
| 42 using base::android::ConvertUTF16ToJavaString; | 43 using base::android::ConvertUTF16ToJavaString; |
| 43 using base::android::JavaParamRef; | 44 using base::android::JavaParamRef; |
| 44 using base::android::ScopedJavaGlobalRef; | 45 using base::android::ScopedJavaGlobalRef; |
| 45 using base::android::ScopedJavaLocalRef; | 46 using base::android::ScopedJavaLocalRef; |
| 46 | 47 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 web_contents->GetController().GetLastCommittedEntry(); | 361 web_contents->GetController().GetLastCommittedEntry(); |
| 361 // |entry| should not be null since otherwise an empty URL is returned from | 362 // |entry| should not be null since otherwise an empty URL is returned from |
| 362 // calling GetLastCommittedURL and we should bail out earlier. | 363 // calling GetLastCommittedURL and we should bail out earlier. |
| 363 DCHECK(entry); | 364 DCHECK(entry); |
| 364 content::Referrer referrer = | 365 content::Referrer referrer = |
| 365 content::Referrer::SanitizeForRequest(url, entry->GetReferrer()); | 366 content::Referrer::SanitizeForRequest(url, entry->GetReferrer()); |
| 366 dl_params->set_referrer(referrer); | 367 dl_params->set_referrer(referrer); |
| 367 | 368 |
| 368 dl_params->set_prefer_cache(true); | 369 dl_params->set_prefer_cache(true); |
| 369 dl_params->set_prompt(false); | 370 dl_params->set_prompt(false); |
| 370 dlm->DownloadUrl(std::move(dl_params)); | 371 dlm->DownloadUrl(std::move(dl_params), NO_TRAFFIC_ANNOTATION_YET); |
| 371 return; | 372 return; |
| 372 } | 373 } |
| 373 | 374 |
| 374 ScopedJavaGlobalRef<jobject> j_tab_ref(env, j_tab); | 375 ScopedJavaGlobalRef<jobject> j_tab_ref(env, j_tab); |
| 375 | 376 |
| 376 OfflinePageUtils::CheckDuplicateDownloads( | 377 OfflinePageUtils::CheckDuplicateDownloads( |
| 377 tab->GetProfile()->GetOriginalProfile(), url, | 378 tab->GetProfile()->GetOriginalProfile(), url, |
| 378 base::Bind(&DuplicateCheckDone, url, original_url, j_tab_ref)); | 379 base::Bind(&DuplicateCheckDone, url, original_url, j_tab_ref)); |
| 379 } | 380 } |
| 380 | 381 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 DownloadUIAdapter::AttachToOfflinePageModel(base::WrapUnique(adapter), | 496 DownloadUIAdapter::AttachToOfflinePageModel(base::WrapUnique(adapter), |
| 496 offline_page_model); | 497 offline_page_model); |
| 497 } | 498 } |
| 498 | 499 |
| 499 return reinterpret_cast<jlong>( | 500 return reinterpret_cast<jlong>( |
| 500 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); | 501 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); |
| 501 } | 502 } |
| 502 | 503 |
| 503 } // namespace android | 504 } // namespace android |
| 504 } // namespace offline_pages | 505 } // namespace offline_pages |
| OLD | NEW |