| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 const JavaParamRef<jstring>& j_client_id) { | 365 const JavaParamRef<jstring>& j_client_id) { |
| 365 offline_pages::ClientId client_id; | 366 offline_pages::ClientId client_id; |
| 366 client_id.name_space = ConvertJavaStringToUTF8(env, j_namespace); | 367 client_id.name_space = ConvertJavaStringToUTF8(env, j_namespace); |
| 367 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); | 368 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); |
| 368 | 369 |
| 369 RequestCoordinator* coordinator = | 370 RequestCoordinator* coordinator = |
| 370 offline_pages::RequestCoordinatorFactory::GetInstance()-> | 371 offline_pages::RequestCoordinatorFactory::GetInstance()-> |
| 371 GetForBrowserContext(browser_context_); | 372 GetForBrowserContext(browser_context_); |
| 372 | 373 |
| 373 coordinator->SavePageLater( | 374 coordinator->SavePageLater( |
| 374 GURL(ConvertJavaStringToUTF8(env, j_url)), client_id); | 375 GURL(ConvertJavaStringToUTF8(env, j_url)), client_id, kUserRequested); |
| 375 } | 376 } |
| 376 | 377 |
| 377 void OfflinePageBridge::DeletePages( | 378 void OfflinePageBridge::DeletePages( |
| 378 JNIEnv* env, | 379 JNIEnv* env, |
| 379 const JavaParamRef<jobject>& obj, | 380 const JavaParamRef<jobject>& obj, |
| 380 const JavaParamRef<jobject>& j_callback_obj, | 381 const JavaParamRef<jobject>& j_callback_obj, |
| 381 const JavaParamRef<jlongArray>& offline_ids_array) { | 382 const JavaParamRef<jlongArray>& offline_ids_array) { |
| 382 DCHECK(j_callback_obj); | 383 DCHECK(j_callback_obj); |
| 383 | 384 |
| 384 ScopedJavaGlobalRef<jobject> j_callback_ref; | 385 ScopedJavaGlobalRef<jobject> j_callback_ref; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 414 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), | 415 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), |
| 415 ConvertUTF8ToJavaString(env, client_id.id).obj()); | 416 ConvertUTF8ToJavaString(env, client_id.id).obj()); |
| 416 } | 417 } |
| 417 | 418 |
| 418 bool RegisterOfflinePageBridge(JNIEnv* env) { | 419 bool RegisterOfflinePageBridge(JNIEnv* env) { |
| 419 return RegisterNativesImpl(env); | 420 return RegisterNativesImpl(env); |
| 420 } | 421 } |
| 421 | 422 |
| 422 } // namespace android | 423 } // namespace android |
| 423 } // namespace offline_pages | 424 } // namespace offline_pages |
| OLD | NEW |