| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 Java_WebContentsImpl_onAccessibilitySnapshot(env, j_root, callback); | 189 Java_WebContentsImpl_onAccessibilitySnapshot(env, j_root, callback); |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace | 192 } // namespace |
| 193 | 193 |
| 194 // static | 194 // static |
| 195 WebContents* WebContents::FromJavaWebContents( | 195 WebContents* WebContents::FromJavaWebContents( |
| 196 const JavaRef<jobject>& jweb_contents_android) { | 196 const JavaRef<jobject>& jweb_contents_android) { |
| 197 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 197 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 198 if (jweb_contents_android.is_null()) | 198 if (jweb_contents_android.is_null()) |
| 199 return NULL; | 199 return nullptr; |
| 200 | 200 |
| 201 WebContentsAndroid* web_contents_android = | 201 WebContentsAndroid* web_contents_android = |
| 202 reinterpret_cast<WebContentsAndroid*>( | 202 reinterpret_cast<WebContentsAndroid*>( |
| 203 Java_WebContentsImpl_getNativePointer(AttachCurrentThread(), | 203 Java_WebContentsImpl_getNativePointer(AttachCurrentThread(), |
| 204 jweb_contents_android)); | 204 jweb_contents_android)); |
| 205 if (!web_contents_android) | 205 if (!web_contents_android) |
| 206 return NULL; | 206 return nullptr; |
| 207 return web_contents_android->web_contents(); | 207 return web_contents_android->web_contents(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // static | 210 // static |
| 211 static void DestroyWebContents(JNIEnv* env, | 211 static void DestroyWebContents(JNIEnv* env, |
| 212 const JavaParamRef<jclass>& clazz, | 212 const JavaParamRef<jclass>& clazz, |
| 213 jlong jweb_contents_android_ptr) { | 213 jlong jweb_contents_android_ptr) { |
| 214 WebContentsAndroid* web_contents_android = | 214 WebContentsAndroid* web_contents_android = |
| 215 reinterpret_cast<WebContentsAndroid*>(jweb_contents_android_ptr); | 215 reinterpret_cast<WebContentsAndroid*>(jweb_contents_android_ptr); |
| 216 if (!web_contents_android) | 216 if (!web_contents_android) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 web_contents_->SelectAll(); | 329 web_contents_->SelectAll(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void WebContentsAndroid::Unselect(JNIEnv* env, | 332 void WebContentsAndroid::Unselect(JNIEnv* env, |
| 333 const JavaParamRef<jobject>& obj) { | 333 const JavaParamRef<jobject>& obj) { |
| 334 web_contents_->Unselect(); | 334 web_contents_->Unselect(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 RenderWidgetHostViewAndroid* | 337 RenderWidgetHostViewAndroid* |
| 338 WebContentsAndroid::GetRenderWidgetHostViewAndroid() { | 338 WebContentsAndroid::GetRenderWidgetHostViewAndroid() { |
| 339 RenderWidgetHostView* rwhv = NULL; | 339 RenderWidgetHostView* rwhv = nullptr; |
| 340 rwhv = web_contents_->GetRenderWidgetHostView(); | 340 rwhv = web_contents_->GetRenderWidgetHostView(); |
| 341 if (web_contents_->ShowingInterstitialPage()) { | 341 if (web_contents_->ShowingInterstitialPage()) { |
| 342 rwhv = web_contents_->GetInterstitialPage() | 342 rwhv = web_contents_->GetInterstitialPage() |
| 343 ->GetMainFrame() | 343 ->GetMainFrame() |
| 344 ->GetRenderViewHost() | 344 ->GetRenderViewHost() |
| 345 ->GetWidget() | 345 ->GetWidget() |
| 346 ->GetView(); | 346 ->GetView(); |
| 347 } | 347 } |
| 348 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); | 348 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); |
| 349 } | 349 } |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 } | 683 } |
| 684 | 684 |
| 685 void WebContentsAndroid::DismissTextHandles( | 685 void WebContentsAndroid::DismissTextHandles( |
| 686 JNIEnv* env, | 686 JNIEnv* env, |
| 687 const base::android::JavaParamRef<jobject>& obj) { | 687 const base::android::JavaParamRef<jobject>& obj) { |
| 688 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 688 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 689 if (view) | 689 if (view) |
| 690 view->DismissTextHandles(); | 690 view->DismissTextHandles(); |
| 691 } | 691 } |
| 692 | 692 |
| 693 bool WebContentsAndroid::IsContextSecure( |
| 694 JNIEnv* env, |
| 695 const JavaParamRef<jobject>& obj) { |
| 696 WebContents* web_contents = WebContents::FromJavaWebContents(obj); |
| 697 return web_contents != nullptr && web_contents->IsContextSecure(); |
| 698 } |
| 699 |
| 693 void WebContentsAndroid::OnFinishGetContentBitmap( | 700 void WebContentsAndroid::OnFinishGetContentBitmap( |
| 694 const JavaRef<jobject>& obj, | 701 const JavaRef<jobject>& obj, |
| 695 const JavaRef<jobject>& callback, | 702 const JavaRef<jobject>& callback, |
| 696 const SkBitmap& bitmap, | 703 const SkBitmap& bitmap, |
| 697 ReadbackResponse response) { | 704 ReadbackResponse response) { |
| 698 JNIEnv* env = base::android::AttachCurrentThread(); | 705 JNIEnv* env = base::android::AttachCurrentThread(); |
| 699 ScopedJavaLocalRef<jobject> java_bitmap; | 706 ScopedJavaLocalRef<jobject> java_bitmap; |
| 700 if (response == READBACK_SUCCESS) | 707 if (response == READBACK_SUCCESS) |
| 701 java_bitmap = gfx::ConvertToJavaBitmap(&bitmap); | 708 java_bitmap = gfx::ConvertToJavaBitmap(&bitmap); |
| 702 Java_WebContentsImpl_onGetContentBitmapFinished(env, obj, callback, | 709 Java_WebContentsImpl_onGetContentBitmapFinished(env, obj, callback, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); | 741 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); |
| 735 } | 742 } |
| 736 | 743 |
| 737 void WebContentsAndroid::SetMediaSession( | 744 void WebContentsAndroid::SetMediaSession( |
| 738 const ScopedJavaLocalRef<jobject>& j_media_session) { | 745 const ScopedJavaLocalRef<jobject>& j_media_session) { |
| 739 JNIEnv* env = base::android::AttachCurrentThread(); | 746 JNIEnv* env = base::android::AttachCurrentThread(); |
| 740 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); | 747 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); |
| 741 } | 748 } |
| 742 | 749 |
| 743 } // namespace content | 750 } // namespace content |
| OLD | NEW |