OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 DCHECK(web_contents_); | 212 DCHECK(web_contents_); |
213 notification_registrar_.Add( | 213 notification_registrar_.Add( |
214 this, NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 214 this, NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
215 Source<NavigationController>(&web_contents_->GetController())); | 215 Source<NavigationController>(&web_contents_->GetController())); |
216 notification_registrar_.Add( | 216 notification_registrar_.Add( |
217 this, NOTIFICATION_RENDERER_PROCESS_CREATED, | 217 this, NOTIFICATION_RENDERER_PROCESS_CREATED, |
218 content::NotificationService::AllBrowserContextsAndSources()); | 218 content::NotificationService::AllBrowserContextsAndSources()); |
219 notification_registrar_.Add( | 219 notification_registrar_.Add( |
220 this, NOTIFICATION_WEB_CONTENTS_CONNECTED, | 220 this, NOTIFICATION_WEB_CONTENTS_CONNECTED, |
221 Source<WebContents>(web_contents_)); | 221 Source<WebContents>(web_contents_)); |
| 222 notification_registrar_.Add( |
| 223 this, NOTIFICATION_WEB_CONTENTS_SWAPPED, |
| 224 Source<WebContents>(web_contents_)); |
222 | 225 |
223 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> | 226 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> |
224 SetContentViewCore(this); | 227 SetContentViewCore(this); |
225 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); | 228 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); |
226 web_contents_->SetUserData(kContentViewUserDataKey, | 229 web_contents_->SetUserData(kContentViewUserDataKey, |
227 new ContentViewUserData(this)); | 230 new ContentViewUserData(this)); |
228 } | 231 } |
229 | 232 |
230 void ContentViewCoreImpl::Observe(int type, | 233 void ContentViewCoreImpl::Observe(int type, |
231 const NotificationSource& source, | 234 const NotificationSource& source, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 break; | 274 break; |
272 } | 275 } |
273 case NOTIFICATION_WEB_CONTENTS_CONNECTED: { | 276 case NOTIFICATION_WEB_CONTENTS_CONNECTED: { |
274 JNIEnv* env = AttachCurrentThread(); | 277 JNIEnv* env = AttachCurrentThread(); |
275 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 278 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
276 if (!obj.is_null()) { | 279 if (!obj.is_null()) { |
277 Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); | 280 Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); |
278 } | 281 } |
279 break; | 282 break; |
280 } | 283 } |
| 284 case NOTIFICATION_WEB_CONTENTS_SWAPPED: { |
| 285 JNIEnv* env = AttachCurrentThread(); |
| 286 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 287 if (!obj.is_null()) { |
| 288 Java_ContentViewCore_onWebContentsSwapped(env, obj.obj()); |
| 289 } |
| 290 } |
281 } | 291 } |
282 } | 292 } |
283 | 293 |
284 RenderWidgetHostViewAndroid* | 294 RenderWidgetHostViewAndroid* |
285 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { | 295 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { |
286 RenderWidgetHostView* rwhv = NULL; | 296 RenderWidgetHostView* rwhv = NULL; |
287 if (web_contents_) { | 297 if (web_contents_) { |
288 rwhv = web_contents_->GetRenderWidgetHostView(); | 298 rwhv = web_contents_->GetRenderWidgetHostView(); |
289 if (web_contents_->ShowingInterstitialPage()) { | 299 if (web_contents_->ShowingInterstitialPage()) { |
290 rwhv = static_cast<InterstitialPageImpl*>( | 300 rwhv = static_cast<InterstitialPageImpl*>( |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 reinterpret_cast<WebContents*>(native_web_contents), | 1489 reinterpret_cast<WebContents*>(native_web_contents), |
1480 reinterpret_cast<ui::WindowAndroid*>(native_window)); | 1490 reinterpret_cast<ui::WindowAndroid*>(native_window)); |
1481 return reinterpret_cast<jint>(view); | 1491 return reinterpret_cast<jint>(view); |
1482 } | 1492 } |
1483 | 1493 |
1484 bool RegisterContentViewCore(JNIEnv* env) { | 1494 bool RegisterContentViewCore(JNIEnv* env) { |
1485 return RegisterNativesImpl(env); | 1495 return RegisterNativesImpl(env); |
1486 } | 1496 } |
1487 | 1497 |
1488 } // namespace content | 1498 } // namespace content |
OLD | NEW |