| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 const JavaParamRef<jobject>& j_callback_obj, | 296 const JavaParamRef<jobject>& j_callback_obj, |
| 297 const JavaParamRef<jobject>& j_web_contents, | 297 const JavaParamRef<jobject>& j_web_contents, |
| 298 const JavaParamRef<jstring>& j_namespace, | 298 const JavaParamRef<jstring>& j_namespace, |
| 299 const JavaParamRef<jstring>& j_client_id) { | 299 const JavaParamRef<jstring>& j_client_id) { |
| 300 DCHECK(j_callback_obj); | 300 DCHECK(j_callback_obj); |
| 301 DCHECK(j_web_contents); | 301 DCHECK(j_web_contents); |
| 302 | 302 |
| 303 ScopedJavaGlobalRef<jobject> j_callback_ref; | 303 ScopedJavaGlobalRef<jobject> j_callback_ref; |
| 304 j_callback_ref.Reset(env, j_callback_obj); | 304 j_callback_ref.Reset(env, j_callback_obj); |
| 305 | 305 |
| 306 GURL url; |
| 307 std::unique_ptr<OfflinePageArchiver> archiver; |
| 308 |
| 306 content::WebContents* web_contents = | 309 content::WebContents* web_contents = |
| 307 content::WebContents::FromJavaWebContents(j_web_contents); | 310 content::WebContents::FromJavaWebContents(j_web_contents); |
| 308 GURL url(web_contents->GetLastCommittedURL()); | 311 if (web_contents) { |
| 309 | 312 url = web_contents->GetLastCommittedURL(); |
| 310 std::unique_ptr<OfflinePageArchiver> archiver( | 313 archiver.reset(new OfflinePageMHTMLArchiver(web_contents)); |
| 311 new OfflinePageMHTMLArchiver(web_contents)); | 314 } |
| 312 | 315 |
| 313 offline_pages::ClientId client_id; | 316 offline_pages::ClientId client_id; |
| 314 client_id.name_space = ConvertJavaStringToUTF8(env, j_namespace); | 317 client_id.name_space = ConvertJavaStringToUTF8(env, j_namespace); |
| 315 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); | 318 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); |
| 316 | 319 |
| 317 offline_page_model_->SavePage( | 320 offline_page_model_->SavePage( |
| 318 url, client_id, std::move(archiver), | 321 url, client_id, std::move(archiver), |
| 319 base::Bind(&SavePageCallback, j_callback_ref, url)); | 322 base::Bind(&SavePageCallback, j_callback_ref, url)); |
| 320 } | 323 } |
| 321 | 324 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), | 402 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), |
| 400 ConvertUTF8ToJavaString(env, client_id.id).obj()); | 403 ConvertUTF8ToJavaString(env, client_id.id).obj()); |
| 401 } | 404 } |
| 402 | 405 |
| 403 bool RegisterOfflinePageBridge(JNIEnv* env) { | 406 bool RegisterOfflinePageBridge(JNIEnv* env) { |
| 404 return RegisterNativesImpl(env); | 407 return RegisterNativesImpl(env); |
| 405 } | 408 } |
| 406 | 409 |
| 407 } // namespace android | 410 } // namespace android |
| 408 } // namespace offline_pages | 411 } // namespace offline_pages |
| OLD | NEW |