| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 | 183 |
| 184 void OfflinePageDownloadBridge::DeleteItemByGuid( | 184 void OfflinePageDownloadBridge::DeleteItemByGuid( |
| 185 JNIEnv* env, | 185 JNIEnv* env, |
| 186 const JavaParamRef<jobject>& obj, | 186 const JavaParamRef<jobject>& obj, |
| 187 const JavaParamRef<jstring>& j_guid) { | 187 const JavaParamRef<jstring>& j_guid) { |
| 188 std::string guid = ConvertJavaStringToUTF8(env, j_guid); | 188 std::string guid = ConvertJavaStringToUTF8(env, j_guid); |
| 189 download_ui_adapter_->DeleteItem(guid); | 189 download_ui_adapter_->DeleteItem(guid); |
| 190 } | 190 } |
| 191 | 191 |
| 192 ScopedJavaLocalRef<jstring> OfflinePageDownloadBridge::GetOfflineUrlByGuid( | |
| 193 JNIEnv* env, | |
| 194 const JavaParamRef<jobject>& obj, | |
| 195 const JavaParamRef<jstring>& j_guid) { | |
| 196 std::string guid = ConvertJavaStringToUTF8(env, j_guid); | |
| 197 GURL url = download_ui_adapter_->GetOfflineUrlByGuid(guid); | |
| 198 if (!url.is_valid()) | |
| 199 return ScopedJavaLocalRef<jstring>(); | |
| 200 return ConvertUTF8ToJavaString(env, url.spec()); | |
| 201 } | |
| 202 | |
| 203 void OfflinePageDownloadBridge::StartDownload( | 192 void OfflinePageDownloadBridge::StartDownload( |
| 204 JNIEnv* env, | 193 JNIEnv* env, |
| 205 const JavaParamRef<jobject>& obj, | 194 const JavaParamRef<jobject>& obj, |
| 206 const JavaParamRef<jobject>& j_tab) { | 195 const JavaParamRef<jobject>& j_tab) { |
| 207 TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab); | 196 TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab); |
| 208 if (!tab) | 197 if (!tab) |
| 209 return; | 198 return; |
| 210 | 199 |
| 211 content::WebContents* web_contents = tab->web_contents(); | 200 content::WebContents* web_contents = tab->web_contents(); |
| 212 if (!web_contents) | 201 if (!web_contents) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 339 |
| 351 DownloadUIAdapter* adapter = | 340 DownloadUIAdapter* adapter = |
| 352 DownloadUIAdapter::FromOfflinePageModel(offline_page_model); | 341 DownloadUIAdapter::FromOfflinePageModel(offline_page_model); |
| 353 | 342 |
| 354 return reinterpret_cast<jlong>( | 343 return reinterpret_cast<jlong>( |
| 355 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); | 344 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); |
| 356 } | 345 } |
| 357 | 346 |
| 358 } // namespace android | 347 } // namespace android |
| 359 } // namespace offline_pages | 348 } // namespace offline_pages |
| OLD | NEW |