Commit 675dd4aa authored by ajith.v@samsung.com's avatar ajith.v@samsung.com

Removing ContentView dependencies for few functions which acts as WebContents wrapper.

Review URL: https://codereview.chromium.org/381593002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284334 0039d316-1c4b-4281-b951-d872f2087c98
parent c11d252f
...@@ -359,23 +359,6 @@ jint ContentViewCoreImpl::GetBackgroundColor(JNIEnv* env, jobject obj) { ...@@ -359,23 +359,6 @@ jint ContentViewCoreImpl::GetBackgroundColor(JNIEnv* env, jobject obj) {
return rwhva->GetCachedBackgroundColor(); return rwhva->GetCachedBackgroundColor();
} }
void ContentViewCoreImpl::OnHide(JNIEnv* env, jobject obj) {
Hide();
}
void ContentViewCoreImpl::OnShow(JNIEnv* env, jobject obj) {
Show();
}
void ContentViewCoreImpl::Show() {
GetWebContents()->WasShown();
}
void ContentViewCoreImpl::Hide() {
GetWebContents()->WasHidden();
PauseVideo();
}
void ContentViewCoreImpl::PauseVideo() { void ContentViewCoreImpl::PauseVideo() {
RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
web_contents_->GetRenderViewHost()); web_contents_->GetRenderViewHost());
...@@ -1188,16 +1171,6 @@ void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) { ...@@ -1188,16 +1171,6 @@ void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) {
web_contents_->GetController().PruneAllButLastCommitted(); web_contents_->GetController().PruneAllButLastCommitted();
} }
void ContentViewCoreImpl::AddStyleSheetByURL(
JNIEnv* env, jobject obj, jstring url) {
if (!web_contents_)
return;
web_contents_->GetMainFrame()->Send(new FrameMsg_AddStyleSheetByURL(
web_contents_->GetMainFrame()->GetRoutingID(),
ConvertJavaStringToUTF8(env, url)));
}
void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection( void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection(
JNIEnv* env, JNIEnv* env,
jobject obj, jobject obj,
...@@ -1239,68 +1212,6 @@ void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) { ...@@ -1239,68 +1212,6 @@ void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) {
} }
} }
void ContentViewCoreImpl::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 ContentViewCoreImpl::IsShowingInterstitialPage(JNIEnv* env,
jobject obj) {
return web_contents_->ShowingInterstitialPage();
}
jboolean ContentViewCoreImpl::IsRenderWidgetHostViewReady(JNIEnv* env,
jobject obj) {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
return view && view->HasValidFrame();
}
void ContentViewCoreImpl::ExitFullscreen(JNIEnv* env, jobject obj) {
RenderViewHost* host = web_contents_->GetRenderViewHost();
if (!host)
return;
host->ExitFullscreen();
}
void ContentViewCoreImpl::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 ContentViewCoreImpl::ShowImeIfNeeded(JNIEnv* env, jobject obj) {
RenderViewHost* host = web_contents_->GetRenderViewHost();
host->Send(new ViewMsg_ShowImeIfNeeded(host->GetRoutingID()));
}
void ContentViewCoreImpl::ScrollFocusedEditableNodeIntoView(JNIEnv* env,
jobject obj) {
RenderViewHost* host = web_contents_->GetRenderViewHost();
host->Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(
host->GetRoutingID(), gfx::Rect()));
}
void ContentViewCoreImpl::SelectWordAroundCaret(JNIEnv* env, jobject obj) {
RenderViewHost* host = web_contents_->GetRenderViewHost();
if (!host)
return;
host->SelectWordAroundCaret();
}
namespace { namespace {
static void AddNavigationEntryToHistory(JNIEnv* env, jobject obj, static void AddNavigationEntryToHistory(JNIEnv* env, jobject obj,
......
...@@ -158,7 +158,6 @@ class ContentViewCoreImpl : public ContentViewCore, ...@@ -158,7 +158,6 @@ class ContentViewCoreImpl : public ContentViewCore,
jobject obj, jobject obj,
jboolean enabled); jboolean enabled);
void AddStyleSheetByURL(JNIEnv* env, jobject obj, jstring url);
void ClearHistory(JNIEnv* env, jobject obj); void ClearHistory(JNIEnv* env, jobject obj);
void EvaluateJavaScript(JNIEnv* env, void EvaluateJavaScript(JNIEnv* env,
jobject obj, jobject obj,
...@@ -169,21 +168,15 @@ class ContentViewCoreImpl : public ContentViewCore, ...@@ -169,21 +168,15 @@ class ContentViewCoreImpl : public ContentViewCore,
jstring message, jstring source_origin, jstring target_origin); jstring message, jstring source_origin, jstring target_origin);
long GetNativeImeAdapter(JNIEnv* env, jobject obj); long GetNativeImeAdapter(JNIEnv* env, jobject obj);
void SetFocus(JNIEnv* env, jobject obj, jboolean focused); void SetFocus(JNIEnv* env, jobject obj, jboolean focused);
void ScrollFocusedEditableNodeIntoView(JNIEnv* env, jobject obj);
void SelectWordAroundCaret(JNIEnv* env, jobject obj);
jint GetBackgroundColor(JNIEnv* env, jobject obj); jint GetBackgroundColor(JNIEnv* env, jobject obj);
void SetBackgroundColor(JNIEnv* env, jobject obj, jint color); void SetBackgroundColor(JNIEnv* env, jobject obj, jint color);
void OnShow(JNIEnv* env, jobject obj);
void OnHide(JNIEnv* env, jobject obj);
void ClearSslPreferences(JNIEnv* env, jobject /* obj */); void ClearSslPreferences(JNIEnv* env, jobject /* obj */);
void SetUseDesktopUserAgent(JNIEnv* env, void SetUseDesktopUserAgent(JNIEnv* env,
jobject /* obj */, jobject /* obj */,
jboolean state, jboolean state,
jboolean reload_on_state_change); jboolean reload_on_state_change);
bool GetUseDesktopUserAgent(JNIEnv* env, jobject /* obj */); bool GetUseDesktopUserAgent(JNIEnv* env, jobject /* obj */);
void Show();
void Hide();
void SetAllowJavascriptInterfacesInspection(JNIEnv* env, void SetAllowJavascriptInterfacesInspection(JNIEnv* env,
jobject obj, jobject obj,
jboolean allow); jboolean allow);
...@@ -202,20 +195,6 @@ class ContentViewCoreImpl : public ContentViewCore, ...@@ -202,20 +195,6 @@ class ContentViewCoreImpl : public ContentViewCore,
base::android::ScopedJavaLocalRef<jstring> base::android::ScopedJavaLocalRef<jstring>
GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, jobject obj); GetOriginalUrlForActiveNavigationEntry(JNIEnv* env, jobject obj);
void WasResized(JNIEnv* env, jobject obj); void WasResized(JNIEnv* env, jobject obj);
jboolean IsRenderWidgetHostViewReady(JNIEnv* env, jobject obj);
void ExitFullscreen(JNIEnv* env, jobject obj);
void UpdateTopControlsState(JNIEnv* env,
jobject obj,
bool enable_hiding,
bool enable_showing,
bool animate);
void ShowImeIfNeeded(JNIEnv* env, jobject obj);
void ShowInterstitialPage(JNIEnv* env,
jobject obj,
jstring jurl,
jlong delegate);
jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj);
void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled); void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled);
......
...@@ -7,11 +7,19 @@ ...@@ -7,11 +7,19 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/logging.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/browser_thread.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "jni/WebContentsImpl_jni.h" #include "jni/WebContentsImpl_jni.h"
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
using base::android::ConvertJavaStringToUTF8;
namespace content { namespace content {
...@@ -77,4 +85,120 @@ void WebContentsAndroid::InsertCSS( ...@@ -77,4 +85,120 @@ void WebContentsAndroid::InsertCSS(
web_contents_->InsertCSS(base::android::ConvertJavaStringToUTF8(env, jcss)); 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();
if (!host)
return;
host->Send(new ViewMsg_ShowImeIfNeeded(host->GetRoutingID()));
}
void WebContentsAndroid::ScrollFocusedEditableNodeIntoView(
JNIEnv* env,
jobject obj) {
RenderViewHost* host = web_contents_->GetRenderViewHost();
if (!host)
return;
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 } // namespace content
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "content/browser/frame_host/navigation_controller_android.h" #include "content/browser/frame_host/navigation_controller_android.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
namespace content { namespace content {
...@@ -39,10 +40,32 @@ class CONTENT_EXPORT WebContentsAndroid ...@@ -39,10 +40,32 @@ class CONTENT_EXPORT WebContentsAndroid
base::android::ScopedJavaLocalRef<jstring> GetVisibleURL(JNIEnv* env, base::android::ScopedJavaLocalRef<jstring> GetVisibleURL(JNIEnv* env,
jobject obj) const; jobject obj) const;
void Stop(JNIEnv* env, jobject obj); void Stop(JNIEnv* env, jobject obj);
jint GetBackgroundColor(JNIEnv* env, jobject obj);
void OnHide(JNIEnv* env, jobject obj);
void OnShow(JNIEnv* env, jobject obj);
void PauseVideo();
void AddStyleSheetByURL(
JNIEnv* env, jobject obj, jstring url);
void ShowInterstitialPage(
JNIEnv* env, jobject obj, jstring jurl, jlong delegate_ptr);
jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj);
jboolean IsRenderWidgetHostViewReady(JNIEnv* env, jobject obj);
void ExitFullscreen(JNIEnv* env, jobject obj);
void UpdateTopControlsState(
JNIEnv* env,
jobject obj,
bool enable_hiding,
bool enable_showing,
bool animate);
void ShowImeIfNeeded(JNIEnv* env, jobject obj);
void ScrollFocusedEditableNodeIntoView(JNIEnv* env, jobject obj);
void SelectWordAroundCaret(JNIEnv* env, jobject obj);
void InsertCSS(JNIEnv* env, jobject jobj, jstring jcss); void InsertCSS(JNIEnv* env, jobject jobj, jstring jcss);
private: private:
RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid();
WebContents* web_contents_; WebContents* web_contents_;
NavigationControllerAndroid navigation_controller_; NavigationControllerAndroid navigation_controller_;
base::android::ScopedJavaGlobalRef<jobject> obj_; base::android::ScopedJavaGlobalRef<jobject> obj_;
......
...@@ -16,7 +16,6 @@ import android.content.res.Configuration; ...@@ -16,7 +16,6 @@ import android.content.res.Configuration;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
...@@ -860,10 +859,8 @@ public class ContentViewCore ...@@ -860,10 +859,8 @@ public class ContentViewCore
} }
public int getBackgroundColor() { public int getBackgroundColor() {
if (mNativeContentViewCore != 0) { assert mWebContents != null;
return nativeGetBackgroundColor(mNativeContentViewCore); return mWebContents.getBackgroundColor();
}
return Color.WHITE;
} }
@CalledByNative @CalledByNative
...@@ -931,16 +928,16 @@ public class ContentViewCore ...@@ -931,16 +928,16 @@ public class ContentViewCore
@VisibleForTesting @VisibleForTesting
public void showInterstitialPage( public void showInterstitialPage(
String url, InterstitialPageDelegateAndroid delegate) { String url, InterstitialPageDelegateAndroid delegate) {
if (mNativeContentViewCore == 0) return; assert mWebContents != null;
nativeShowInterstitialPage(mNativeContentViewCore, url, delegate.getNative()); mWebContents.showInterstitialPage(url, delegate.getNative());
} }
/** /**
* @return Whether the page is currently showing an interstitial, such as a bad HTTPS page. * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
*/ */
public boolean isShowingInterstitialPage() { public boolean isShowingInterstitialPage() {
return mNativeContentViewCore == 0 ? assert mWebContents != null;
false : nativeIsShowingInterstitialPage(mNativeContentViewCore); return mWebContents.isShowingInterstitialPage();
} }
/** /**
...@@ -1406,7 +1403,8 @@ public class ContentViewCore ...@@ -1406,7 +1403,8 @@ public class ContentViewCore
* main frame's document. * main frame's document.
*/ */
void addStyleSheetByURL(String url) { void addStyleSheetByURL(String url) {
nativeAddStyleSheetByURL(mNativeContentViewCore, url); assert mWebContents != null;
mWebContents.addStyleSheetByURL(url);
} }
/** Callback interface for evaluateJavaScript(). */ /** Callback interface for evaluateJavaScript(). */
...@@ -1462,8 +1460,8 @@ public class ContentViewCore ...@@ -1462,8 +1460,8 @@ public class ContentViewCore
* To be called when the ContentView is shown. * To be called when the ContentView is shown.
*/ */
public void onShow() { public void onShow() {
assert mNativeContentViewCore != 0; assert mWebContents != null;
nativeOnShow(mNativeContentViewCore); mWebContents.onShow();
setAccessibilityState(mAccessibilityManager.isEnabled()); setAccessibilityState(mAccessibilityManager.isEnabled());
} }
...@@ -1479,10 +1477,10 @@ public class ContentViewCore ...@@ -1479,10 +1477,10 @@ public class ContentViewCore
* To be called when the ContentView is hidden. * To be called when the ContentView is hidden.
*/ */
public void onHide() { public void onHide() {
assert mNativeContentViewCore != 0; assert mWebContents != null;
hidePopups(); hidePopups();
setInjectedAccessibility(false); setInjectedAccessibility(false);
nativeOnHide(mNativeContentViewCore); mWebContents.onHide();
} }
/** /**
...@@ -1676,11 +1674,8 @@ public class ContentViewCore ...@@ -1676,11 +1674,8 @@ public class ContentViewCore
} }
private void scrollFocusedEditableNodeIntoView() { private void scrollFocusedEditableNodeIntoView() {
if (mNativeContentViewCore == 0) return; assert mWebContents != null;
// The native side keeps track of whether the zoom and scroll actually occurred. It is mWebContents.scrollFocusedEditableNodeIntoView();
// more efficient to do it this way and sometimes fire an unnecessary message rather
// than synchronize with the renderer and always have an additional message.
nativeScrollFocusedEditableNodeIntoView(mNativeContentViewCore);
} }
/** /**
...@@ -1688,8 +1683,8 @@ public class ContentViewCore ...@@ -1688,8 +1683,8 @@ public class ContentViewCore
* The caller can check if selection actually occurred by listening to OnSelectionChanged. * The caller can check if selection actually occurred by listening to OnSelectionChanged.
*/ */
public void selectWordAroundCaret() { public void selectWordAroundCaret() {
if (mNativeContentViewCore == 0) return; assert mWebContents != null;
nativeSelectWordAroundCaret(mNativeContentViewCore); mWebContents.selectWordAroundCaret();
} }
/** /**
...@@ -2333,7 +2328,8 @@ public class ContentViewCore ...@@ -2333,7 +2328,8 @@ public class ContentViewCore
* Shows the IME if the focused widget could accept text input. * Shows the IME if the focused widget could accept text input.
*/ */
public void showImeIfNeeded() { public void showImeIfNeeded() {
if (mNativeContentViewCore != 0) nativeShowImeIfNeeded(mNativeContentViewCore); assert mWebContents != null;
mWebContents.showImeIfNeeded();
} }
/** /**
...@@ -2850,8 +2846,8 @@ public class ContentViewCore ...@@ -2850,8 +2846,8 @@ public class ContentViewCore
* once the texture is actually ready. * once the texture is actually ready.
*/ */
public boolean isReady() { public boolean isReady() {
if (mNativeContentViewCore == 0) return false; assert mWebContents != null;
return nativeIsRenderWidgetHostViewReady(mNativeContentViewCore); return mWebContents.isReady();
} }
@CalledByNative @CalledByNative
...@@ -3070,7 +3066,8 @@ public class ContentViewCore ...@@ -3070,7 +3066,8 @@ public class ContentViewCore
* Inform WebKit that Fullscreen mode has been exited by the user. * Inform WebKit that Fullscreen mode has been exited by the user.
*/ */
public void exitFullscreen() { public void exitFullscreen() {
if (mNativeContentViewCore != 0) nativeExitFullscreen(mNativeContentViewCore); assert mWebContents != null;
mWebContents.exitFullscreen();
} }
/** /**
...@@ -3082,10 +3079,9 @@ public class ContentViewCore ...@@ -3082,10 +3079,9 @@ public class ContentViewCore
*/ */
public void updateTopControlsState(boolean enableHiding, boolean enableShowing, public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
boolean animate) { boolean animate) {
if (mNativeContentViewCore != 0) { assert mWebContents != null;
nativeUpdateTopControlsState( mWebContents.updateTopControlsState(
mNativeContentViewCore, enableHiding, enableShowing, animate); enableHiding, enableShowing, animate);
}
} }
/** /**
...@@ -3283,10 +3279,6 @@ public class ContentViewCore ...@@ -3283,10 +3279,6 @@ public class ContentViewCore
private native String nativeGetURL(long nativeContentViewCoreImpl); private native String nativeGetURL(long nativeContentViewCoreImpl);
private native void nativeShowInterstitialPage(
long nativeContentViewCoreImpl, String url, long nativeInterstitialPageDelegateAndroid);
private native boolean nativeIsShowingInterstitialPage(long nativeContentViewCoreImpl);
private native boolean nativeIsIncognito(long nativeContentViewCoreImpl); private native boolean nativeIsIncognito(long nativeContentViewCoreImpl);
private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused); private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused);
...@@ -3355,15 +3347,8 @@ public class ContentViewCore ...@@ -3355,15 +3347,8 @@ public class ContentViewCore
private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImpl, int[] indices); private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImpl, int[] indices);
private native void nativeScrollFocusedEditableNodeIntoView(long nativeContentViewCoreImpl);
private native void nativeSelectWordAroundCaret(long nativeContentViewCoreImpl);
private native void nativeClearHistory(long nativeContentViewCoreImpl); private native void nativeClearHistory(long nativeContentViewCoreImpl);
private native void nativeAddStyleSheetByURL(long nativeContentViewCoreImpl,
String stylesheetUrl);
private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl, private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
String script, JavaScriptCallback callback, boolean startRenderer); String script, JavaScriptCallback callback, boolean startRenderer);
...@@ -3374,11 +3359,6 @@ public class ContentViewCore ...@@ -3374,11 +3359,6 @@ public class ContentViewCore
private native int nativeGetCurrentRenderProcessId(long nativeContentViewCoreImpl); private native int nativeGetCurrentRenderProcessId(long nativeContentViewCoreImpl);
private native int nativeGetBackgroundColor(long nativeContentViewCoreImpl);
private native void nativeOnShow(long nativeContentViewCoreImpl);
private native void nativeOnHide(long nativeContentViewCoreImpl);
private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreImpl, private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreImpl,
boolean enabled, boolean reloadOnChange); boolean enabled, boolean reloadOnChange);
private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCoreImpl); private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCoreImpl);
...@@ -3402,14 +3382,6 @@ public class ContentViewCore ...@@ -3402,14 +3382,6 @@ public class ContentViewCore
private native void nativeWasResized(long nativeContentViewCoreImpl); private native void nativeWasResized(long nativeContentViewCoreImpl);
private native boolean nativeIsRenderWidgetHostViewReady(long nativeContentViewCoreImpl);
private native void nativeExitFullscreen(long nativeContentViewCoreImpl);
private native void nativeUpdateTopControlsState(long nativeContentViewCoreImpl,
boolean enableHiding, boolean enableShowing, boolean animate);
private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl);
private native void nativeSetAccessibilityEnabled( private native void nativeSetAccessibilityEnabled(
long nativeContentViewCoreImpl, boolean enabled); long nativeContentViewCoreImpl, boolean enabled);
......
...@@ -70,8 +70,89 @@ import org.chromium.content_public.browser.WebContents; ...@@ -70,8 +70,89 @@ import org.chromium.content_public.browser.WebContents;
nativeInsertCSS(mNativeWebContentsAndroid, css); nativeInsertCSS(mNativeWebContentsAndroid, css);
} }
@Override
public void onHide() {
nativeOnHide(mNativeWebContentsAndroid);
}
@Override
public void onShow() {
nativeOnShow(mNativeWebContentsAndroid);
}
@Override
public int getBackgroundColor() {
return nativeGetBackgroundColor(mNativeWebContentsAndroid);
}
@Override
public void addStyleSheetByURL(String url) {
nativeAddStyleSheetByURL(mNativeWebContentsAndroid, url);
}
@Override
public void showInterstitialPage(
String url, long interstitialPageDelegateAndroid) {
nativeShowInterstitialPage(mNativeWebContentsAndroid, url, interstitialPageDelegateAndroid);
}
@Override
public boolean isShowingInterstitialPage() {
return nativeIsShowingInterstitialPage(mNativeWebContentsAndroid);
}
@Override
public boolean isReady() {
return nativeIsRenderWidgetHostViewReady(mNativeWebContentsAndroid);
}
@Override
public void exitFullscreen() {
nativeExitFullscreen(mNativeWebContentsAndroid);
}
@Override
public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
boolean animate) {
nativeUpdateTopControlsState(mNativeWebContentsAndroid, enableHiding,
enableShowing, animate);
}
@Override
public void showImeIfNeeded() {
nativeShowImeIfNeeded(mNativeWebContentsAndroid);
}
@Override
public void scrollFocusedEditableNodeIntoView() {
// The native side keeps track of whether the zoom and scroll actually occurred. It is
// more efficient to do it this way and sometimes fire an unnecessary message rather
// than synchronize with the renderer and always have an additional message.
nativeScrollFocusedEditableNodeIntoView(mNativeWebContentsAndroid);
}
@Override
public void selectWordAroundCaret() {
nativeSelectWordAroundCaret(mNativeWebContentsAndroid);
}
private native String nativeGetTitle(long nativeWebContentsAndroid); private native String nativeGetTitle(long nativeWebContentsAndroid);
private native String nativeGetVisibleURL(long nativeWebContentsAndroid); private native String nativeGetVisibleURL(long nativeWebContentsAndroid);
private native void nativeStop(long nativeWebContentsAndroid); private native void nativeStop(long nativeWebContentsAndroid);
private native void nativeInsertCSS(long nativeWebContentsAndroid, String css); private native void nativeInsertCSS(long nativeWebContentsAndroid, String css);
private native void nativeOnHide(long nativeWebContentsAndroid);
private native void nativeOnShow(long nativeWebContentsAndroid);
private native int nativeGetBackgroundColor(long nativeWebContentsAndroid);
private native void nativeAddStyleSheetByURL(long nativeWebContentsAndroid,
String url);
private native void nativeShowInterstitialPage(long nativeWebContentsAndroid,
String url, long nativeInterstitialPageDelegateAndroid);
private native boolean nativeIsShowingInterstitialPage(long nativeWebContentsAndroid);
private native boolean nativeIsRenderWidgetHostViewReady(long nativeWebContentsAndroid);
private native void nativeExitFullscreen(long nativeWebContentsAndroid);
private native void nativeUpdateTopControlsState(long nativeWebContentsAndroid,
boolean enableHiding, boolean enableShowing, boolean animate);
private native void nativeShowImeIfNeeded(long nativeWebContentsAndroid);
private native void nativeScrollFocusedEditableNodeIntoView(long nativeWebContentsAndroid);
private native void nativeSelectWordAroundCaret(long nativeWebContentsAndroid);
} }
...@@ -32,4 +32,78 @@ public interface WebContents { ...@@ -32,4 +32,78 @@ public interface WebContents {
* Inserts css into main frame's document. * Inserts css into main frame's document.
*/ */
void insertCSS(String css); void insertCSS(String css);
/**
* To be called when the ContentView is hidden.
*/
public void onHide();
/**
* To be called when the ContentView is shown.
*/
public void onShow();
/**
* Get the Background color from underlying RenderWidgetHost for this WebContent.
*/
public int getBackgroundColor();
/**
* Requests the renderer insert a link to the specified stylesheet in the
* main frame's document.
*/
void addStyleSheetByURL(String url);
/**
* Shows an interstitial page driven by the passed in delegate.
*
* @param url The URL being blocked by the interstitial.
* @param delegate The delegate handling the interstitial.
*/
public void showInterstitialPage(
String url, long interstitialPageDelegateAndroid);
/**
* @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
*/
public boolean isShowingInterstitialPage();
/**
* If the view is ready to draw contents to the screen. In hardware mode,
* the initialization of the surface texture may not occur until after the
* view has been added to the layout. This method will return {@code true}
* once the texture is actually ready.
*/
public boolean isReady();
/**
* Inform WebKit that Fullscreen mode has been exited by the user.
*/
public void exitFullscreen();
/**
* Changes whether hiding the top controls is enabled.
*
* @param enableHiding Whether hiding the top controls should be enabled or not.
* @param enableShowing Whether showing the top controls should be enabled or not.
* @param animate Whether the transition should be animated or not.
*/
public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
boolean animate);
/**
* Shows the IME if the focused widget could accept text input.
*/
public void showImeIfNeeded();
/**
* Brings the Editable to the visible area while IME is up to make easier for inputing text.
*/
public void scrollFocusedEditableNodeIntoView();
/**
* Selects the word around the caret, if any.
* The caller can check if selection actually occurred by listening to OnSelectionChanged.
*/
public void selectWordAroundCaret();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment