Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1224)

Unified Diff: content/browser/web_contents/web_contents_android.cc

Issue 414423002: Removing ContentViewCore dependencies from few functions which acts as direct wrapper to WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6033d2c0e8b15235ef776b46e363513e9f8d109e..29031460646f9ded25a6ccfe9a84d2369ee5c78e 100644
--- a/content/browser/web_contents/web_contents_android.cc
+++ b/content/browser/web_contents/web_contents_android.cc
@@ -11,15 +11,19 @@
#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/browser/transition_request_manager.h"
+#include "content/browser/web_contents/web_contents_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_context.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;
+using base::android::ConvertUTF8ToJavaString;
namespace content {
@@ -104,6 +108,116 @@ jint WebContentsAndroid::GetBackgroundColor(JNIEnv* env, jobject obj) {
return rwhva->GetCachedBackgroundColor();
}
+ScopedJavaLocalRef<jstring> WebContentsAndroid::GetURL(
+ JNIEnv* env,
+ jobject obj) const {
+ return ConvertUTF8ToJavaString(env, web_contents_->GetURL().spec());
+}
+
+jboolean WebContentsAndroid::IsIncognito(JNIEnv* env, jobject obj) {
+ return web_contents_->GetBrowserContext()->IsOffTheRecord();
+}
+
+void WebContentsAndroid::SelectPopupMenuItems(
+ JNIEnv* env,
+ jobject obj,
+ jintArray indices) {
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
+ web_contents_->GetRenderViewHost());
+ DCHECK(rvhi);
+ if (indices == NULL) {
+ rvhi->DidCancelPopupMenu();
+ return;
+ }
+
+ int selected_count = env->GetArrayLength(indices);
+ std::vector<int> selected_indices;
+ jint* indices_ptr = env->GetIntArrayElements(indices, NULL);
+ for (int i = 0; i < selected_count; ++i)
+ selected_indices.push_back(indices_ptr[i]);
+ env->ReleaseIntArrayElements(indices, indices_ptr, JNI_ABORT);
+ rvhi->DidSelectPopupMenuItems(selected_indices);
+}
+
+void WebContentsAndroid::HideTextHandles(JNIEnv* env, jobject obj) {
+ if (GetRenderWidgetHostViewAndroid())
+ GetRenderWidgetHostViewAndroid()->HideTextHandles();
+}
+
+void WebContentsAndroid::ResetGestureDetection(JNIEnv* env, jobject obj) {
+ RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
+ if (rwhv)
+ rwhv->ResetGestureDetection();
+}
+
+void WebContentsAndroid::SetDoubleTapSupportEnabled(
+ JNIEnv* env,
+ jobject obj,
+ jboolean enabled) {
+ RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
+ if (rwhv)
+ rwhv->SetDoubleTapSupportEnabled(enabled);
+}
+
+void WebContentsAndroid::SetMultiTouchZoomSupportEnabled(
+ JNIEnv* env,
+ jobject obj,
+ jboolean enabled) {
+ RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
+ if (rwhv)
+ rwhv->SetMultiTouchZoomSupportEnabled(enabled);
+}
+
+void WebContentsAndroid::ResumeResponseDeferredAtStart(
+ JNIEnv* env,
+ jobject obj) {
+ static_cast<WebContentsImpl*>(web_contents_)->
+ ResumeResponseDeferredAtStart();
+}
+
+void WebContentsAndroid::SetHasPendingNavigationTransitionForTesting(
+ JNIEnv* env,
+ jobject obj) {
+ RenderFrameHost* frame = static_cast<WebContentsImpl*>(web_contents_)->
+ GetMainFrame();
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(
+ &TransitionRequestManager::SetHasPendingTransitionRequest,
+ base::Unretained(TransitionRequestManager::GetInstance()),
+ frame->GetProcess()->GetID(),
+ frame->GetRoutingID(),
+ true));
+}
+
+void WebContentsAndroid::SetBackgroundOpaque(
+ JNIEnv* env,
+ jobject jobj,
+ jboolean opaque) {
+ if (GetRenderWidgetHostViewAndroid())
+ GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque);
+}
+
+void WebContentsAndroid::RequestTextSurroundingSelection(
+ int max_length,
+ const base::Callback<
+ void(
+ const base::string16& content,
+ int start_offset,
+ int end_offset)>& callback) {
+ DCHECK(!callback.is_null());
+ RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame();
+ if (!focused_frame)
+ return;
+ if (GetRenderWidgetHostViewAndroid()) {
+ GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback(
+ callback);
+ focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest(
+ focused_frame->GetRoutingID(), max_length));
+ }
+}
+
void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) {
web_contents_->WasHidden();
PauseVideo();

Powered by Google App Engine
This is Rietveld 408576698