OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/callback_helpers.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "cc/layers/layer.h" | 18 #include "cc/layers/layer.h" |
18 #include "cc/output/begin_frame_args.h" | 19 #include "cc/output/begin_frame_args.h" |
19 #include "content/browser/android/content_video_view.h" | 20 #include "content/browser/android/content_video_view.h" |
20 #include "content/browser/android/interstitial_page_delegate_android.h" | 21 #include "content/browser/android/interstitial_page_delegate_android.h" |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { | 585 void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { |
585 JNIEnv* env = AttachCurrentThread(); | 586 JNIEnv* env = AttachCurrentThread(); |
586 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 587 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
587 if (obj.is_null()) | 588 if (obj.is_null()) |
588 return; | 589 return; |
589 Java_ContentViewCore_showPastePopup(env, obj.obj(), | 590 Java_ContentViewCore_showPastePopup(env, obj.obj(), |
590 static_cast<jint>(x_dip), | 591 static_cast<jint>(x_dip), |
591 static_cast<jint>(y_dip)); | 592 static_cast<jint>(y_dip)); |
592 } | 593 } |
593 | 594 |
594 unsigned int ContentViewCoreImpl::GetScaledContentTexture( | 595 void ContentViewCoreImpl::GetScaledContentBitmap( |
595 float scale, | 596 float scale, |
596 gfx::Size* out_size) { | 597 gfx::Size* out_size, |
| 598 const base::Callback<void(bool, const SkBitmap&)>& compositor_callback) { |
597 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 599 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
598 if (!view) | 600 if (!view || !view->IsSurfaceAvailableForCopy()) { |
599 return 0; | 601 compositor_callback.Run(false, SkBitmap()); |
| 602 return; |
| 603 } |
600 | 604 |
601 return view->GetScaledContentTexture(scale, out_size); | 605 view->GetScaledContentBitmap(scale, out_size, compositor_callback); |
602 } | 606 } |
603 | 607 |
604 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { | 608 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { |
605 JNIEnv* env = AttachCurrentThread(); | 609 JNIEnv* env = AttachCurrentThread(); |
606 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 610 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
607 if (j_obj.is_null()) | 611 if (j_obj.is_null()) |
608 return; | 612 return; |
609 ScopedJavaLocalRef<jstring> jcontent_url = | 613 ScopedJavaLocalRef<jstring> jcontent_url = |
610 ConvertUTF8ToJavaString(env, content_url.spec()); | 614 ConvertUTF8ToJavaString(env, content_url.spec()); |
611 Java_ContentViewCore_startContentIntent(env, | 615 Java_ContentViewCore_startContentIntent(env, |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1709 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1706 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1710 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1707 return reinterpret_cast<intptr_t>(view); | 1711 return reinterpret_cast<intptr_t>(view); |
1708 } | 1712 } |
1709 | 1713 |
1710 bool RegisterContentViewCore(JNIEnv* env) { | 1714 bool RegisterContentViewCore(JNIEnv* env) { |
1711 return RegisterNativesImpl(env); | 1715 return RegisterNativesImpl(env); |
1712 } | 1716 } |
1713 | 1717 |
1714 } // namespace content | 1718 } // namespace content |
OLD | NEW |