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

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: java? 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_));
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(
230 this, NOTIFICATION_WEB_CONTENTS_SWAPPED,
231 Source<WebContents>(web_contents_));
232 229
233 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> 230 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
234 SetContentViewCore(this); 231 SetContentViewCore(this);
235 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); 232 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey));
236 web_contents_->SetUserData(kContentViewUserDataKey, 233 web_contents_->SetUserData(kContentViewUserDataKey,
237 new ContentViewUserData(this)); 234 new ContentViewUserData(this));
238 } 235 }
239 236
240 void ContentViewCoreImpl::Observe(int type, 237 void ContentViewCoreImpl::Observe(int type,
241 const NotificationSource& source, 238 const NotificationSource& source,
242 const NotificationDetails& details) { 239 const NotificationDetails& details) {
243 switch (type) { 240 switch (type) {
244 case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { 241 case NOTIFICATION_WEB_CONTENTS_SWAPPED: {
245 std::pair<RenderViewHost*, RenderViewHost*>* switched_details = 242 std::pair<RenderViewHost*, RenderViewHost*>* switched_details =
246 Details<std::pair<RenderViewHost*, RenderViewHost*> >(details).ptr(); 243 Details<std::pair<RenderViewHost*, RenderViewHost*> >(details).ptr();
247 int old_pid = 0; 244 int old_pid = 0;
248 if (switched_details->first) { 245 if (switched_details->first) {
249 old_pid = GetRenderProcessIdFromRenderViewHost( 246 old_pid = GetRenderProcessIdFromRenderViewHost(
250 switched_details->first); 247 switched_details->first);
251 } 248 }
252 int new_pid = GetRenderProcessIdFromRenderViewHost( 249 int new_pid = GetRenderProcessIdFromRenderViewHost(
253 web_contents_->GetRenderViewHost()); 250 web_contents_->GetRenderViewHost());
254 if (new_pid != old_pid) { 251 if (new_pid != old_pid) {
255 // Notify the Java side of the change of the current renderer process. 252 // Notify the Java side of the change of the current renderer process.
256 JNIEnv* env = AttachCurrentThread(); 253 JNIEnv* env = AttachCurrentThread();
257 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 254 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
258 if (!obj.is_null()) { 255 if (!obj.is_null()) {
259 Java_ContentViewCore_onRenderProcessSwap( 256 Java_ContentViewCore_onRenderProcessSwap(
260 env, obj.obj(), old_pid, new_pid); 257 env, obj.obj(), old_pid, new_pid);
258 Java_ContentViewCore_onWebContentsSwapped(env, obj.obj()); //?
261 } 259 }
262 } 260 }
263 break; 261 break;
264 } 262 }
265 case NOTIFICATION_RENDERER_PROCESS_CREATED: { 263 case NOTIFICATION_RENDERER_PROCESS_CREATED: {
266 // Notify the Java side of the current renderer process. 264 // Notify the Java side of the current renderer process.
267 RenderProcessHost* source_process_host = 265 RenderProcessHost* source_process_host =
268 Source<RenderProcessHost>(source).ptr(); 266 Source<RenderProcessHost>(source).ptr();
269 RenderProcessHost* current_process_host = 267 RenderProcessHost* current_process_host =
270 web_contents_->GetRenderViewHost()->GetProcess(); 268 web_contents_->GetRenderViewHost()->GetProcess();
(...skipping 10 matching lines...) Expand all
281 break; 279 break;
282 } 280 }
283 case NOTIFICATION_WEB_CONTENTS_CONNECTED: { 281 case NOTIFICATION_WEB_CONTENTS_CONNECTED: {
284 JNIEnv* env = AttachCurrentThread(); 282 JNIEnv* env = AttachCurrentThread();
285 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 283 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
286 if (!obj.is_null()) { 284 if (!obj.is_null()) {
287 Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); 285 Java_ContentViewCore_onWebContentsConnected(env, obj.obj());
288 } 286 }
289 break; 287 break;
290 } 288 }
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());
296 }
297 }
298 } 289 }
299 } 290 }
300 291
301 RenderWidgetHostViewAndroid* 292 RenderWidgetHostViewAndroid*
302 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { 293 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() {
303 RenderWidgetHostView* rwhv = NULL; 294 RenderWidgetHostView* rwhv = NULL;
304 if (web_contents_) { 295 if (web_contents_) {
305 rwhv = web_contents_->GetRenderWidgetHostView(); 296 rwhv = web_contents_->GetRenderWidgetHostView();
306 if (web_contents_->ShowingInterstitialPage()) { 297 if (web_contents_->ShowingInterstitialPage()) {
307 rwhv = static_cast<InterstitialPageImpl*>( 298 rwhv = static_cast<InterstitialPageImpl*>(
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 reinterpret_cast<ui::ViewAndroid*>(view_android), 1571 reinterpret_cast<ui::ViewAndroid*>(view_android),
1581 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1572 reinterpret_cast<ui::WindowAndroid*>(window_android));
1582 return reinterpret_cast<jint>(view); 1573 return reinterpret_cast<jint>(view);
1583 } 1574 }
1584 1575
1585 bool RegisterContentViewCore(JNIEnv* env) { 1576 bool RegisterContentViewCore(JNIEnv* env) {
1586 return RegisterNativesImpl(env); 1577 return RegisterNativesImpl(env);
1587 } 1578 }
1588 1579
1589 } // namespace content 1580 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698