| Index: content/browser/android/content_view_impl.cc
|
| diff --git a/content/browser/android/content_view_impl.cc b/content/browser/android/content_view_impl.cc
|
| index f3f07e4be522f75ddcf6d428816763bb9c4d620d..ea5a9131d14183402a3edf37d4921da6cb53672c 100644
|
| --- a/content/browser/android/content_view_impl.cc
|
| +++ b/content/browser/android/content_view_impl.cc
|
| @@ -13,10 +13,12 @@
|
| #include "content/public/browser/web_contents.h"
|
| #include "jni/content_view_jni.h"
|
|
|
| +using base::android::AttachCurrentThread;
|
| using base::android::ConvertUTF16ToJavaString;
|
| using base::android::ConvertUTF8ToJavaString;
|
| using base::android::GetClass;
|
| using base::android::HasField;
|
| +using base::android::ScopedJavaLocalRef;
|
|
|
| namespace {
|
| jfieldID g_native_content_view;
|
| @@ -24,6 +26,14 @@ jfieldID g_native_content_view;
|
|
|
| namespace content {
|
|
|
| +struct ContentViewImpl::JavaObject {
|
| + jweak obj;
|
| +
|
| + ScopedJavaLocalRef<jobject> View(JNIEnv* env) {
|
| + return GetRealObject(env, obj);
|
| + }
|
| +};
|
| +
|
| // ----------------------------------------------------------------------------
|
| // Implementation of static ContentView public interfaces
|
|
|
| @@ -45,9 +55,17 @@ ContentViewImpl::ContentViewImpl(JNIEnv* env, jobject obj,
|
| tab_crashed_(false) {
|
| DCHECK(web_contents) <<
|
| "A ContentViewImpl should be created with a valid WebContents.";
|
| +
|
| + InitJNI(env, obj);
|
| }
|
|
|
| ContentViewImpl::~ContentViewImpl() {
|
| + if (java_object_) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + env->DeleteWeakGlobalRef(java_object_->obj);
|
| + delete java_object_;
|
| + java_object_ = 0;
|
| + }
|
| }
|
|
|
| void ContentViewImpl::Destroy(JNIEnv* env, jobject obj) {
|
| @@ -60,6 +78,11 @@ void ContentViewImpl::Observe(int type,
|
| // TODO(jrg)
|
| }
|
|
|
| +void ContentViewImpl::InitJNI(JNIEnv* env, jobject obj) {
|
| + java_object_ = new JavaObject;
|
| + java_object_->obj = env->NewWeakGlobalRef(obj);
|
| +}
|
| +
|
| // ----------------------------------------------------------------------------
|
| // Methods called from Java via JNI
|
| // ----------------------------------------------------------------------------
|
| @@ -242,6 +265,15 @@ void ContentViewImpl::OnAcceleratedCompositingStateChange(
|
| NOTIMPLEMENTED() << "not upstreamed yet";
|
| }
|
|
|
| +void ContentViewImpl::StartContentIntent(const GURL& content_url) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + ScopedJavaLocalRef<jstring> jcontent_url =
|
| + ConvertUTF8ToJavaString(env, content_url.spec());
|
| + Java_ContentView_startContentIntent(env,
|
| + java_object_->View(env).obj(),
|
| + jcontent_url.obj());
|
| +}
|
| +
|
| // --------------------------------------------------------------------------
|
| // Methods called from Java via JNI
|
| // --------------------------------------------------------------------------
|
|
|