| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offline_page_bridge.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 using base::android::ConvertUTF8ToJavaString; | 34 using base::android::ConvertUTF8ToJavaString; |
| 35 using base::android::ScopedJavaGlobalRef; | 35 using base::android::ScopedJavaGlobalRef; |
| 36 using base::android::ScopedJavaLocalRef; | 36 using base::android::ScopedJavaLocalRef; |
| 37 | 37 |
| 38 namespace offline_pages { | 38 namespace offline_pages { |
| 39 namespace android { | 39 namespace android { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 const char kOfflinePageBridgeKey[] = "offline-page-bridge"; | 43 const char kOfflinePageBridgeKey[] = "offline-page-bridge"; |
| 44 const bool kUserRequested = true; |
| 44 | 45 |
| 45 void ToJavaOfflinePageList(JNIEnv* env, | 46 void ToJavaOfflinePageList(JNIEnv* env, |
| 46 jobject j_result_obj, | 47 jobject j_result_obj, |
| 47 const std::vector<OfflinePageItem>& offline_pages) { | 48 const std::vector<OfflinePageItem>& offline_pages) { |
| 48 for (const OfflinePageItem& offline_page : offline_pages) { | 49 for (const OfflinePageItem& offline_page : offline_pages) { |
| 49 Java_OfflinePageBridge_createOfflinePageAndAddToList( | 50 Java_OfflinePageBridge_createOfflinePageAndAddToList( |
| 50 env, j_result_obj, | 51 env, j_result_obj, |
| 51 ConvertUTF8ToJavaString(env, offline_page.url.spec()).obj(), | 52 ConvertUTF8ToJavaString(env, offline_page.url.spec()).obj(), |
| 52 offline_page.offline_id, | 53 offline_page.offline_id, |
| 53 ConvertUTF8ToJavaString(env, offline_page.client_id.name_space).obj(), | 54 ConvertUTF8ToJavaString(env, offline_page.client_id.name_space).obj(), |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 const JavaParamRef<jstring>& j_client_id) { | 360 const JavaParamRef<jstring>& j_client_id) { |
| 360 offline_pages::ClientId client_id; | 361 offline_pages::ClientId client_id; |
| 361 client_id.name_space = ConvertJavaStringToUTF8(env, j_namespace); | 362 client_id.name_space = ConvertJavaStringToUTF8(env, j_namespace); |
| 362 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); | 363 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); |
| 363 | 364 |
| 364 RequestCoordinator* coordinator = | 365 RequestCoordinator* coordinator = |
| 365 offline_pages::RequestCoordinatorFactory::GetInstance()-> | 366 offline_pages::RequestCoordinatorFactory::GetInstance()-> |
| 366 GetForBrowserContext(browser_context_); | 367 GetForBrowserContext(browser_context_); |
| 367 | 368 |
| 368 coordinator->SavePageLater( | 369 coordinator->SavePageLater( |
| 369 GURL(ConvertJavaStringToUTF8(env, j_url)), client_id); | 370 GURL(ConvertJavaStringToUTF8(env, j_url)), client_id, kUserRequested); |
| 370 } | 371 } |
| 371 | 372 |
| 372 void OfflinePageBridge::DeletePages( | 373 void OfflinePageBridge::DeletePages( |
| 373 JNIEnv* env, | 374 JNIEnv* env, |
| 374 const JavaParamRef<jobject>& obj, | 375 const JavaParamRef<jobject>& obj, |
| 375 const JavaParamRef<jobject>& j_callback_obj, | 376 const JavaParamRef<jobject>& j_callback_obj, |
| 376 const JavaParamRef<jlongArray>& offline_ids_array) { | 377 const JavaParamRef<jlongArray>& offline_ids_array) { |
| 377 DCHECK(j_callback_obj); | 378 DCHECK(j_callback_obj); |
| 378 | 379 |
| 379 ScopedJavaGlobalRef<jobject> j_callback_ref; | 380 ScopedJavaGlobalRef<jobject> j_callback_ref; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 409 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), | 410 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), |
| 410 ConvertUTF8ToJavaString(env, client_id.id).obj()); | 411 ConvertUTF8ToJavaString(env, client_id.id).obj()); |
| 411 } | 412 } |
| 412 | 413 |
| 413 bool RegisterOfflinePageBridge(JNIEnv* env) { | 414 bool RegisterOfflinePageBridge(JNIEnv* env) { |
| 414 return RegisterNativesImpl(env); | 415 return RegisterNativesImpl(env); |
| 415 } | 416 } |
| 416 | 417 |
| 417 } // namespace android | 418 } // namespace android |
| 418 } // namespace offline_pages | 419 } // namespace offline_pages |
| OLD | NEW |