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 2a53563c4f309e698c4ece2b021b230e0d2537cd..596a7d006f87735882ce1d6cf3e1b6637861d6b1 100644 |
--- a/content/browser/android/content_view_core_impl.cc |
+++ b/content/browser/android/content_view_core_impl.cc |
@@ -37,10 +37,6 @@ |
#include "content/public/browser/browser_accessibility_state.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/favicon_status.h" |
-#include "content/public/browser/notification_details.h" |
-#include "content/public/browser/notification_service.h" |
-#include "content/public/browser/notification_source.h" |
-#include "content/public/browser/notification_types.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/common/content_client.h" |
#include "content/public/common/content_switches.h" |
@@ -201,9 +197,6 @@ ContentViewCoreImpl::~ContentViewCoreImpl() { |
Java_ContentViewCore_onNativeContentViewCoreDestroyed( |
env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); |
} |
- // Make sure nobody calls back into this object while we are tearing things |
- // down. |
- notification_registrar_.RemoveAll(); |
} |
void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, |
@@ -214,16 +207,6 @@ void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, |
void ContentViewCoreImpl::InitWebContents() { |
DCHECK(web_contents_); |
- notification_registrar_.Add( |
- this, NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
- Source<WebContents>(web_contents_)); |
- notification_registrar_.Add( |
- this, NOTIFICATION_RENDERER_PROCESS_CREATED, |
- content::NotificationService::AllBrowserContextsAndSources()); |
- notification_registrar_.Add( |
- this, NOTIFICATION_WEB_CONTENTS_CONNECTED, |
- Source<WebContents>(web_contents_)); |
- |
static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> |
SetContentViewCore(this); |
DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); |
@@ -231,64 +214,39 @@ void ContentViewCoreImpl::InitWebContents() { |
new ContentViewUserData(this)); |
} |
-void ContentViewCoreImpl::Observe(int type, |
- const NotificationSource& source, |
- const NotificationDetails& details) { |
- switch (type) { |
- case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { |
- std::pair<RenderViewHost*, RenderViewHost*>* switched_details = |
- Details<std::pair<RenderViewHost*, RenderViewHost*> >(details).ptr(); |
- int old_pid = 0; |
- if (switched_details->first) { |
- old_pid = GetRenderProcessIdFromRenderViewHost( |
- switched_details->first); |
- } |
- int new_pid = GetRenderProcessIdFromRenderViewHost( |
- web_contents_->GetRenderViewHost()); |
- if (new_pid != old_pid) { |
- // Notify the Java side of the change of the current renderer process. |
- JNIEnv* env = AttachCurrentThread(); |
- ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
- if (!obj.is_null()) { |
- Java_ContentViewCore_onRenderProcessSwap( |
- env, obj.obj(), old_pid, new_pid); |
- } |
- } |
- SetFocusInternal(HasFocus()); |
- break; |
- } |
- case NOTIFICATION_RENDERER_PROCESS_CREATED: { |
- // Notify the Java side of the current renderer process. |
- RenderProcessHost* source_process_host = |
- Source<RenderProcessHost>(source).ptr(); |
- RenderProcessHost* current_process_host = |
- web_contents_->GetRenderViewHost()->GetProcess(); |
- |
- if (source_process_host == current_process_host) { |
- int pid = GetRenderProcessIdFromRenderViewHost( |
- web_contents_->GetRenderViewHost()); |
- JNIEnv* env = AttachCurrentThread(); |
- ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
- if (!obj.is_null()) { |
- Java_ContentViewCore_onRenderProcessSwap(env, obj.obj(), 0, pid); |
- } |
- } |
- break; |
- } |
- case NOTIFICATION_WEB_CONTENTS_CONNECTED: { |
- JNIEnv* env = AttachCurrentThread(); |
- ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
- if (!obj.is_null()) { |
- Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); |
- } |
- break; |
- } |
- } |
-} |
- |
void ContentViewCoreImpl::RenderViewReady() { |
Avi (use Gerrit)
2013/11/21 21:28:26
== NOTIFICATION_WEB_CONTENTS_CONNECTED
|
if (device_orientation_ != 0) |
SendOrientationChangeEventInternal(); |
+ |
+ // The render process is ready (it may not have been ready at the time that |
+ // RenderViewHostChanged was received), so inform the Java side. |
+ int pid = GetRenderProcessIdFromRenderViewHost( |
+ web_contents_->GetRenderViewHost()); |
+ JNIEnv* env = AttachCurrentThread(); |
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
+ if (!obj.is_null()) { |
+ Java_ContentViewCore_onRenderProcessSwap(env, obj.obj(), 0, pid); |
+ } |
+} |
+ |
+void ContentViewCoreImpl::RenderViewHostChanged(RenderViewHost* old_host, |
+ RenderViewHost* new_host) { |
Avi (use Gerrit)
2013/11/21 21:28:26
== NOTIFICATION_RENDER_VIEW_HOST_CHANGED
|
+ int old_pid = 0; |
+ if (old_host) |
+ old_pid = GetRenderProcessIdFromRenderViewHost(old_host); |
+ int new_pid = GetRenderProcessIdFromRenderViewHost(new_host); |
+ |
+ if (new_pid != old_pid) { |
+ // Notify the Java side of the change of the current renderer process. |
+ JNIEnv* env = AttachCurrentThread(); |
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
+ if (!obj.is_null()) { |
+ Java_ContentViewCore_onRenderProcessSwap( |
+ env, obj.obj(), old_pid, new_pid); |
+ } |
+ } |
+ |
+ SetFocusInternal(HasFocus()); |
} |
RenderWidgetHostViewAndroid* |