Add support for java versions of WebContents and NavigationController.
This is on the path of cleaning of ContentViewCore, which has been a
dumping ground for all things webcontents-y. The hope is to move to a
world where java mimics other platforms more closely.
BUG=
Review URL: https://codereview.chromium.org/82693007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239506 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 81edfed0..3c5437c 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -92,6 +92,7 @@
#if defined(OS_ANDROID)
#include "content/browser/android/date_time_chooser_android.h"
#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
+#include "content/browser/web_contents/web_contents_android.h"
#include "content/common/java_bridge_messages.h"
#include "content/public/browser/android/content_view_core.h"
#endif
@@ -157,6 +158,10 @@
const char kDotGoogleDotCom[] = ".google.com";
+#if defined(OS_ANDROID)
+const char kWebContentsAndroidKey[] = "web_contents_android";
+#endif // OS_ANDROID
+
base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> >
g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
@@ -3666,6 +3671,19 @@
}
#if defined(OS_ANDROID)
+base::android::ScopedJavaLocalRef<jobject>
+WebContentsImpl::GetJavaWebContents() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ WebContentsAndroid* web_contents_android =
+ static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey));
+ if (!web_contents_android) {
+ web_contents_android = new WebContentsAndroid(this);
+ SetUserData(kWebContentsAndroidKey, web_contents_android);
+ }
+ return web_contents_android->GetJavaObject();
+}
+
bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() {
return CreateRenderViewForRenderManager(GetRenderViewHost(),
MSG_ROUTING_NONE);