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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 253013002: Pass RenderFrameHost to WebContentObservers' message handlers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Android tests Created 6 years, 7 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/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 5dcbb66106436fb5239755a129bddde59d542f19..9206763125df51077b37495c618fb0e30b258341 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -210,11 +210,13 @@ ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env,
Java_ContentViewCore_getNativeContentViewCore(env, obj));
}
-ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env,
- jobject obj,
- WebContents* web_contents,
- ui::ViewAndroid* view_android,
- ui::WindowAndroid* window_android)
+ContentViewCoreImpl::ContentViewCoreImpl(
+ JNIEnv* env,
+ jobject obj,
+ WebContents* web_contents,
+ ui::ViewAndroid* view_android,
+ ui::WindowAndroid* window_android,
+ jobject java_bridge_retained_object_set)
: WebContentsObserver(web_contents),
java_ref_(env, obj),
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
@@ -244,6 +246,10 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env,
BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
web_contents->SetUserAgentOverride(spoofed_ua);
+ java_bridge_dispatcher_host_manager_.reset(
+ new JavaBridgeDispatcherHostManager(web_contents,
+ java_bridge_retained_object_set));
+
InitWebContents();
}
@@ -1275,8 +1281,7 @@ void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection(
JNIEnv* env,
jobject obj,
jboolean allow) {
- web_contents_->java_bridge_dispatcher_host_manager()
- ->SetAllowObjectContentsInspection(allow);
+ java_bridge_dispatcher_host_manager_->SetAllowObjectContentsInspection(allow);
}
void ContentViewCoreImpl::AddJavascriptInterface(
@@ -1284,31 +1289,26 @@ void ContentViewCoreImpl::AddJavascriptInterface(
jobject /* obj */,
jobject object,
jstring name,
- jclass safe_annotation_clazz,
- jobject retained_object_set) {
+ jclass safe_annotation_clazz) {
ScopedJavaLocalRef<jobject> scoped_object(env, object);
ScopedJavaLocalRef<jclass> scoped_clazz(env, safe_annotation_clazz);
- JavaObjectWeakGlobalRef weak_retained_object_set(env, retained_object_set);
// JavaBoundObject creates the NPObject with a ref count of 1, and
// JavaBridgeDispatcherHostManager takes its own ref.
- JavaBridgeDispatcherHostManager* java_bridge =
- web_contents_->java_bridge_dispatcher_host_manager();
- java_bridge->SetRetainedObjectSet(weak_retained_object_set);
- NPObject* bound_object =
- JavaBoundObject::Create(scoped_object,
- scoped_clazz,
- java_bridge->AsWeakPtr(),
- java_bridge->GetAllowObjectContentsInspection());
- java_bridge->AddNamedObject(ConvertJavaStringToUTF16(env, name),
- bound_object);
+ NPObject* bound_object = JavaBoundObject::Create(
+ scoped_object,
+ scoped_clazz,
+ java_bridge_dispatcher_host_manager_->AsWeakPtr(),
+ java_bridge_dispatcher_host_manager_->GetAllowObjectContentsInspection());
+ java_bridge_dispatcher_host_manager_->AddNamedObject(
+ ConvertJavaStringToUTF16(env, name), bound_object);
blink::WebBindings::releaseObject(bound_object);
}
void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env,
jobject /* obj */,
jstring name) {
- web_contents_->java_bridge_dispatcher_host_manager()->RemoveNamedObject(
+ java_bridge_dispatcher_host_manager_->RemoveNamedObject(
ConvertJavaStringToUTF16(env, name));
}
@@ -1680,12 +1680,14 @@ jlong Init(JNIEnv* env,
jobject obj,
jlong native_web_contents,
jlong view_android,
- jlong window_android) {
+ jlong window_android,
+ jobject retained_objects_set) {
ContentViewCoreImpl* view = new ContentViewCoreImpl(
env, obj,
reinterpret_cast<WebContents*>(native_web_contents),
reinterpret_cast<ui::ViewAndroid*>(view_android),
- reinterpret_cast<ui::WindowAndroid*>(window_android));
+ reinterpret_cast<ui::WindowAndroid*>(window_android),
+ retained_objects_set);
return reinterpret_cast<intptr_t>(view);
}
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/frame_host/interstitial_page_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698