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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 23618036: Merge NOTIFICATION_RENDER_VIEW_HOST_CHANGED into NOTIFICATION_WEB_CONTENTS_SWAPPED. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, 212 void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env,
213 jobject obj) { 213 jobject obj) {
214 DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj)); 214 DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj));
215 java_ref_.reset(); 215 java_ref_.reset();
216 } 216 }
217 217
218 void ContentViewCoreImpl::InitWebContents() { 218 void ContentViewCoreImpl::InitWebContents() {
219 DCHECK(web_contents_); 219 DCHECK(web_contents_);
220 notification_registrar_.Add( 220 notification_registrar_.Add(
221 this, NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 221 this, NOTIFICATION_WEB_CONTENTS_SWAPPED,
222 Source<NavigationController>(&web_contents_->GetController())); 222 Source<WebContents>(web_contents_));
joth 2013/09/06 21:33:25 you're registering this twice now
Avi (use Gerrit) 2013/09/06 21:39:07 Yep; fixed.
223 notification_registrar_.Add( 223 notification_registrar_.Add(
224 this, NOTIFICATION_RENDERER_PROCESS_CREATED, 224 this, NOTIFICATION_RENDERER_PROCESS_CREATED,
225 content::NotificationService::AllBrowserContextsAndSources()); 225 content::NotificationService::AllBrowserContextsAndSources());
226 notification_registrar_.Add( 226 notification_registrar_.Add(
227 this, NOTIFICATION_WEB_CONTENTS_CONNECTED, 227 this, NOTIFICATION_WEB_CONTENTS_CONNECTED,
228 Source<WebContents>(web_contents_)); 228 Source<WebContents>(web_contents_));
229 notification_registrar_.Add( 229 notification_registrar_.Add(
230 this, NOTIFICATION_WEB_CONTENTS_SWAPPED, 230 this, NOTIFICATION_WEB_CONTENTS_SWAPPED,
231 Source<WebContents>(web_contents_)); 231 Source<WebContents>(web_contents_));
232 232
233 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> 233 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
234 SetContentViewCore(this); 234 SetContentViewCore(this);
235 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); 235 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey));
236 web_contents_->SetUserData(kContentViewUserDataKey, 236 web_contents_->SetUserData(kContentViewUserDataKey,
237 new ContentViewUserData(this)); 237 new ContentViewUserData(this));
238 } 238 }
239 239
240 void ContentViewCoreImpl::Observe(int type, 240 void ContentViewCoreImpl::Observe(int type,
241 const NotificationSource& source, 241 const NotificationSource& source,
242 const NotificationDetails& details) { 242 const NotificationDetails& details) {
243 switch (type) { 243 switch (type) {
244 case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { 244 case NOTIFICATION_WEB_CONTENTS_SWAPPED: {
245 std::pair<RenderViewHost*, RenderViewHost*>* switched_details = 245 std::pair<RenderViewHost*, RenderViewHost*>* switched_details =
246 Details<std::pair<RenderViewHost*, RenderViewHost*> >(details).ptr(); 246 Details<std::pair<RenderViewHost*, RenderViewHost*> >(details).ptr();
247 int old_pid = 0; 247 int old_pid = 0;
248 if (switched_details->first) { 248 if (switched_details->first) {
249 old_pid = GetRenderProcessIdFromRenderViewHost( 249 old_pid = GetRenderProcessIdFromRenderViewHost(
250 switched_details->first); 250 switched_details->first);
251 } 251 }
252 int new_pid = GetRenderProcessIdFromRenderViewHost( 252 int new_pid = GetRenderProcessIdFromRenderViewHost(
253 web_contents_->GetRenderViewHost()); 253 web_contents_->GetRenderViewHost());
254 if (new_pid != old_pid) { 254 if (new_pid != old_pid) {
(...skipping 26 matching lines...) Expand all
281 break; 281 break;
282 } 282 }
283 case NOTIFICATION_WEB_CONTENTS_CONNECTED: { 283 case NOTIFICATION_WEB_CONTENTS_CONNECTED: {
284 JNIEnv* env = AttachCurrentThread(); 284 JNIEnv* env = AttachCurrentThread();
285 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 285 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
286 if (!obj.is_null()) { 286 if (!obj.is_null()) {
287 Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); 287 Java_ContentViewCore_onWebContentsConnected(env, obj.obj());
288 } 288 }
289 break; 289 break;
290 } 290 }
291 case NOTIFICATION_WEB_CONTENTS_SWAPPED: {
292 JNIEnv* env = AttachCurrentThread();
293 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
294 if (!obj.is_null()) {
295 Java_ContentViewCore_onWebContentsSwapped(env, obj.obj());
joth 2013/09/06 21:33:25 onWebContentsSwapped would never be called after t
Avi (use Gerrit) 2013/09/06 21:39:07 Note that onWebContentsSwapped was never called wi
296 }
297 }
298 } 291 }
299 } 292 }
300 293
301 RenderWidgetHostViewAndroid* 294 RenderWidgetHostViewAndroid*
302 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { 295 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() {
303 RenderWidgetHostView* rwhv = NULL; 296 RenderWidgetHostView* rwhv = NULL;
304 if (web_contents_) { 297 if (web_contents_) {
305 rwhv = web_contents_->GetRenderWidgetHostView(); 298 rwhv = web_contents_->GetRenderWidgetHostView();
306 if (web_contents_->ShowingInterstitialPage()) { 299 if (web_contents_->ShowingInterstitialPage()) {
307 rwhv = static_cast<InterstitialPageImpl*>( 300 rwhv = static_cast<InterstitialPageImpl*>(
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 reinterpret_cast<ui::ViewAndroid*>(view_android), 1573 reinterpret_cast<ui::ViewAndroid*>(view_android),
1581 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1574 reinterpret_cast<ui::WindowAndroid*>(window_android));
1582 return reinterpret_cast<jint>(view); 1575 return reinterpret_cast<jint>(view);
1583 } 1576 }
1584 1577
1585 bool RegisterContentViewCore(JNIEnv* env) { 1578 bool RegisterContentViewCore(JNIEnv* env) {
1586 return RegisterNativesImpl(env); 1579 return RegisterNativesImpl(env);
1587 } 1580 }
1588 1581
1589 } // namespace content 1582 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_process_manager.cc ('k') | content/browser/web_contents/render_view_host_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698