| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/web_contents/web_contents_android.h" | 5 #include "content/browser/web_contents/web_contents_android.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 WebContentsViewAndroid* view = | 639 WebContentsViewAndroid* view = |
| 640 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); | 640 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); |
| 641 view->SetOverscrollRefreshHandler( | 641 view->SetOverscrollRefreshHandler( |
| 642 base::MakeUnique<ui::OverscrollRefreshHandler>( | 642 base::MakeUnique<ui::OverscrollRefreshHandler>( |
| 643 overscroll_refresh_handler)); | 643 overscroll_refresh_handler)); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void WebContentsAndroid::GetContentBitmap( | 646 void WebContentsAndroid::GetContentBitmap( |
| 647 JNIEnv* env, | 647 JNIEnv* env, |
| 648 const JavaParamRef<jobject>& obj, | 648 const JavaParamRef<jobject>& obj, |
| 649 const JavaParamRef<jobject>& jcallback, | 649 jint width, |
| 650 const JavaParamRef<jobject>& color_type, | 650 jint height, |
| 651 jfloat scale, | 651 const JavaParamRef<jobject>& jcallback) { |
| 652 jfloat x, | |
| 653 jfloat y, | |
| 654 jfloat width, | |
| 655 jfloat height) { | |
| 656 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 652 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 657 const ReadbackRequestCallback result_callback = base::Bind( | 653 const ReadbackRequestCallback result_callback = base::Bind( |
| 658 &WebContentsAndroid::OnFinishGetContentBitmap, weak_factory_.GetWeakPtr(), | 654 &WebContentsAndroid::OnFinishGetContentBitmap, weak_factory_.GetWeakPtr(), |
| 659 ScopedJavaGlobalRef<jobject>(env, obj), | 655 ScopedJavaGlobalRef<jobject>(env, obj), |
| 660 ScopedJavaGlobalRef<jobject>(env, jcallback)); | 656 ScopedJavaGlobalRef<jobject>(env, jcallback)); |
| 661 SkColorType pref_color_type = gfx::ConvertToSkiaColorType(color_type); | 657 if (!view) { |
| 662 if (!view || pref_color_type == kUnknown_SkColorType) { | |
| 663 result_callback.Run(SkBitmap(), READBACK_FAILED); | 658 result_callback.Run(SkBitmap(), READBACK_FAILED); |
| 664 return; | 659 return; |
| 665 } | 660 } |
| 666 if (!view->IsSurfaceAvailableForCopy()) { | 661 view->CopyFromSurface(gfx::Rect(), gfx::Size(width, height), result_callback, |
| 667 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 662 kN32_SkColorType); |
| 668 return; | |
| 669 } | |
| 670 view->GetScaledContentBitmap(scale, | |
| 671 pref_color_type, | |
| 672 gfx::Rect(x, y, width, height), | |
| 673 result_callback); | |
| 674 } | 663 } |
| 675 | 664 |
| 676 void WebContentsAndroid::ReloadLoFiImages(JNIEnv* env, | 665 void WebContentsAndroid::ReloadLoFiImages(JNIEnv* env, |
| 677 const JavaParamRef<jobject>& obj) { | 666 const JavaParamRef<jobject>& obj) { |
| 678 static_cast<WebContentsImpl*>(web_contents_)->ReloadLoFiImages(); | 667 static_cast<WebContentsImpl*>(web_contents_)->ReloadLoFiImages(); |
| 679 } | 668 } |
| 680 | 669 |
| 681 int WebContentsAndroid::DownloadImage( | 670 int WebContentsAndroid::DownloadImage( |
| 682 JNIEnv* env, | 671 JNIEnv* env, |
| 683 const base::android::JavaParamRef<jobject>& obj, | 672 const base::android::JavaParamRef<jobject>& obj, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); | 749 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); |
| 761 } | 750 } |
| 762 | 751 |
| 763 void WebContentsAndroid::SetMediaSession( | 752 void WebContentsAndroid::SetMediaSession( |
| 764 const ScopedJavaLocalRef<jobject>& j_media_session) { | 753 const ScopedJavaLocalRef<jobject>& j_media_session) { |
| 765 JNIEnv* env = base::android::AttachCurrentThread(); | 754 JNIEnv* env = base::android::AttachCurrentThread(); |
| 766 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); | 755 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); |
| 767 } | 756 } |
| 768 | 757 |
| 769 } // namespace content | 758 } // namespace content |
| OLD | NEW |