| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 JNIEnv* env, | 152 JNIEnv* env, |
| 153 const JavaParamRef<jobject>& obj, | 153 const JavaParamRef<jobject>& obj, |
| 154 const JavaParamRef<jstring>& online_url) { | 154 const JavaParamRef<jstring>& online_url) { |
| 155 const OfflinePageItem* offline_page = offline_page_model_->GetPageByOnlineURL( | 155 const OfflinePageItem* offline_page = offline_page_model_->GetPageByOnlineURL( |
| 156 GURL(ConvertJavaStringToUTF8(env, online_url))); | 156 GURL(ConvertJavaStringToUTF8(env, online_url))); |
| 157 if (!offline_page) | 157 if (!offline_page) |
| 158 return ScopedJavaLocalRef<jobject>(); | 158 return ScopedJavaLocalRef<jobject>(); |
| 159 return CreateOfflinePageItem(env, *offline_page); | 159 return CreateOfflinePageItem(env, *offline_page); |
| 160 } | 160 } |
| 161 | 161 |
| 162 ScopedJavaLocalRef<jobject> OfflinePageBridge::GetPageByOfflineUrl( |
| 163 JNIEnv* env, |
| 164 const JavaParamRef<jobject>& obj, |
| 165 const JavaParamRef<jstring>& j_offline_url) { |
| 166 const OfflinePageItem* offline_page = |
| 167 offline_page_model_->GetPageByOfflineURL( |
| 168 GURL(ConvertJavaStringToUTF8(env, j_offline_url))); |
| 169 if (!offline_page) |
| 170 return ScopedJavaLocalRef<jobject>(); |
| 171 return CreateOfflinePageItem(env, *offline_page); |
| 172 } |
| 173 |
| 162 void OfflinePageBridge::SavePage(JNIEnv* env, | 174 void OfflinePageBridge::SavePage(JNIEnv* env, |
| 163 const JavaParamRef<jobject>& obj, | 175 const JavaParamRef<jobject>& obj, |
| 164 const JavaParamRef<jobject>& j_callback_obj, | 176 const JavaParamRef<jobject>& j_callback_obj, |
| 165 const JavaParamRef<jobject>& j_web_contents, | 177 const JavaParamRef<jobject>& j_web_contents, |
| 166 jlong bookmark_id) { | 178 jlong bookmark_id) { |
| 167 DCHECK(j_callback_obj); | 179 DCHECK(j_callback_obj); |
| 168 DCHECK(j_web_contents); | 180 DCHECK(j_web_contents); |
| 169 | 181 |
| 170 ScopedJavaGlobalRef<jobject> j_callback_ref; | 182 ScopedJavaGlobalRef<jobject> j_callback_ref; |
| 171 j_callback_ref.Reset(env, j_callback_obj); | 183 j_callback_ref.Reset(env, j_callback_obj); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 return reinterpret_cast<jlong>(new OfflinePageBridge( | 279 return reinterpret_cast<jlong>(new OfflinePageBridge( |
| 268 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); | 280 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); |
| 269 } | 281 } |
| 270 | 282 |
| 271 bool RegisterOfflinePageBridge(JNIEnv* env) { | 283 bool RegisterOfflinePageBridge(JNIEnv* env) { |
| 272 return RegisterNativesImpl(env); | 284 return RegisterNativesImpl(env); |
| 273 } | 285 } |
| 274 | 286 |
| 275 } // namespace android | 287 } // namespace android |
| 276 } // namespace offline_pages | 288 } // namespace offline_pages |
| OLD | NEW |