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::OnFinishGetScaledContentBitmap( |
596 const base::Callback<void(bool, const SkBitmap&)>& compositor_callback, | |
597 bool success, | |
no sievers
2014/01/29 21:13:48
Looks like you don't need this method anymore but
powei
2014/01/30 00:54:12
Done.
| |
598 const SkBitmap& bitmap) { | |
599 compositor_callback.Run(success, bitmap); | |
600 } | |
601 | |
602 void ContentViewCoreImpl::GetScaledContentBitmap( | |
595 float scale, | 603 float scale, |
596 gfx::Size* out_size) { | 604 gfx::Size* out_size, |
605 const base::Callback<void(bool, const SkBitmap&)>& compositor_callback) { | |
597 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 606 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
598 if (!view) | 607 if (!view || !view->IsSurfaceAvailableForCopy()) { |
599 return 0; | 608 compositor_callback.Run(false, SkBitmap()); |
609 return; | |
610 } | |
600 | 611 |
601 return view->GetScaledContentTexture(scale, out_size); | 612 base::Callback<void(bool, const SkBitmap&)> callback = |
613 base::Bind(&ContentViewCoreImpl::OnFinishGetScaledContentBitmap, | |
614 compositor_callback); | |
615 view->GetScaledContentBitmap(scale, out_size, callback); | |
602 } | 616 } |
603 | 617 |
604 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { | 618 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { |
605 JNIEnv* env = AttachCurrentThread(); | 619 JNIEnv* env = AttachCurrentThread(); |
606 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 620 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
607 if (j_obj.is_null()) | 621 if (j_obj.is_null()) |
608 return; | 622 return; |
609 ScopedJavaLocalRef<jstring> jcontent_url = | 623 ScopedJavaLocalRef<jstring> jcontent_url = |
610 ConvertUTF8ToJavaString(env, content_url.spec()); | 624 ConvertUTF8ToJavaString(env, content_url.spec()); |
611 Java_ContentViewCore_startContentIntent(env, | 625 Java_ContentViewCore_startContentIntent(env, |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1705 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1719 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1706 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1720 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1707 return reinterpret_cast<intptr_t>(view); | 1721 return reinterpret_cast<intptr_t>(view); |
1708 } | 1722 } |
1709 | 1723 |
1710 bool RegisterContentViewCore(JNIEnv* env) { | 1724 bool RegisterContentViewCore(JNIEnv* env) { |
1711 return RegisterNativesImpl(env); | 1725 return RegisterNativesImpl(env); |
1712 } | 1726 } |
1713 | 1727 |
1714 } // namespace content | 1728 } // namespace content |
OLD | NEW |