Index: content/browser/web_contents/web_contents_android.cc |
diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc |
index c86f394c0361f650b97fb0efa254cfee34c76ab3..d8edc7b3a12c6c157916cb9b2b418215f808c0c0 100644 |
--- a/content/browser/web_contents/web_contents_android.cc |
+++ b/content/browser/web_contents/web_contents_android.cc |
@@ -7,11 +7,19 @@ |
#include "base/android/jni_android.h" |
#include "base/android/jni_string.h" |
#include "base/logging.h" |
+#include "content/browser/android/interstitial_page_delegate_android.h" |
+#include "content/browser/frame_host/interstitial_page_impl.h" |
+#include "content/browser/media/media_web_contents_observer.h" |
+#include "content/browser/renderer_host/render_view_host_impl.h" |
+#include "content/common/frame_messages.h" |
+#include "content/common/input_messages.h" |
+#include "content/common/view_messages.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/web_contents.h" |
#include "jni/WebContentsImpl_jni.h" |
using base::android::AttachCurrentThread; |
+using base::android::ConvertJavaStringToUTF8; |
namespace content { |
@@ -77,4 +85,116 @@ void WebContentsAndroid::InsertCSS( |
web_contents_->InsertCSS(base::android::ConvertJavaStringToUTF8(env, jcss)); |
} |
+RenderWidgetHostViewAndroid* |
+ WebContentsAndroid::GetRenderWidgetHostViewAndroid() { |
+ RenderWidgetHostView* rwhv = NULL; |
+ rwhv = web_contents_->GetRenderWidgetHostView(); |
+ if (web_contents_->ShowingInterstitialPage()) { |
+ rwhv = static_cast<InterstitialPageImpl*>( |
+ web_contents_->GetInterstitialPage())-> |
+ GetRenderViewHost()->GetView(); |
+ } |
+ return static_cast<RenderWidgetHostViewAndroid*>(rwhv); |
+} |
+ |
+jint WebContentsAndroid::GetBackgroundColor(JNIEnv* env, jobject obj) { |
+ RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
+ if (!rwhva) |
+ return SK_ColorWHITE; |
+ return rwhva->GetCachedBackgroundColor(); |
+} |
+ |
+void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) { |
+ web_contents_->WasHidden(); |
+ PauseVideo(); |
+} |
+ |
+void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) { |
+ web_contents_->WasShown(); |
+} |
+ |
+void WebContentsAndroid::PauseVideo() { |
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
+ web_contents_->GetRenderViewHost()); |
+ if (rvhi) |
+ rvhi->media_web_contents_observer()->PauseVideo(); |
+} |
+ |
+void WebContentsAndroid::AddStyleSheetByURL( |
+ JNIEnv* env, |
+ jobject obj, |
+ jstring url) { |
+ web_contents_->GetMainFrame()->Send(new FrameMsg_AddStyleSheetByURL( |
+ web_contents_->GetMainFrame()->GetRoutingID(), |
+ ConvertJavaStringToUTF8(env, url))); |
+} |
+ |
+void WebContentsAndroid::ShowInterstitialPage( |
+ JNIEnv* env, |
+ jobject obj, |
+ jstring jurl, |
+ jlong delegate_ptr) { |
+ GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); |
+ InterstitialPageDelegateAndroid* delegate = |
+ reinterpret_cast<InterstitialPageDelegateAndroid*>(delegate_ptr); |
+ InterstitialPage* interstitial = InterstitialPage::Create( |
+ web_contents_, false, url, delegate); |
+ delegate->set_interstitial_page(interstitial); |
+ interstitial->Show(); |
+} |
+ |
+jboolean WebContentsAndroid::IsShowingInterstitialPage(JNIEnv* env, |
+ jobject obj) { |
+ return web_contents_->ShowingInterstitialPage(); |
+} |
+ |
+jboolean WebContentsAndroid::IsRenderWidgetHostViewReady( |
+ JNIEnv* env, |
+ jobject obj) { |
+ RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
+ return view && view->HasValidFrame(); |
+} |
+ |
+void WebContentsAndroid::ExitFullscreen(JNIEnv* env, jobject obj) { |
+ RenderViewHost* host = web_contents_->GetRenderViewHost(); |
+ if (!host) |
+ return; |
+ host->ExitFullscreen(); |
+} |
+ |
+void WebContentsAndroid::UpdateTopControlsState( |
+ JNIEnv* env, |
+ jobject obj, |
+ bool enable_hiding, |
+ bool enable_showing, |
+ bool animate) { |
+ RenderViewHost* host = web_contents_->GetRenderViewHost(); |
+ if (!host) |
+ return; |
+ host->Send(new ViewMsg_UpdateTopControlsState(host->GetRoutingID(), |
+ enable_hiding, |
+ enable_showing, |
+ animate)); |
+} |
+ |
+void WebContentsAndroid::ShowImeIfNeeded(JNIEnv* env, jobject obj) { |
+ RenderViewHost* host = web_contents_->GetRenderViewHost(); |
+ host->Send(new ViewMsg_ShowImeIfNeeded(host->GetRoutingID())); |
+} |
+ |
+void WebContentsAndroid::ScrollFocusedEditableNodeIntoView( |
+ JNIEnv* env, |
+ jobject obj) { |
+ RenderViewHost* host = web_contents_->GetRenderViewHost(); |
no sievers
2014/07/18 19:42:03
Is there a reason why some call sites do a null-ch
AKVT
2014/07/19 10:39:33
Thanks. null-check has been made as uniform in all
|
+ host->Send(new InputMsg_ScrollFocusedEditableNodeIntoRect( |
+ host->GetRoutingID(), gfx::Rect())); |
+} |
+ |
+void WebContentsAndroid::SelectWordAroundCaret(JNIEnv* env, jobject obj) { |
+ RenderViewHost* host = web_contents_->GetRenderViewHost(); |
+ if (!host) |
+ return; |
+ host->SelectWordAroundCaret(); |
+} |
+ |
} // namespace content |