OLD | NEW |
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_RENDER_VIEW_HOST_CHANGED, |
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, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 break; | 279 break; |
283 } | 280 } |
284 case NOTIFICATION_WEB_CONTENTS_CONNECTED: { | 281 case NOTIFICATION_WEB_CONTENTS_CONNECTED: { |
285 JNIEnv* env = AttachCurrentThread(); | 282 JNIEnv* env = AttachCurrentThread(); |
286 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 283 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
287 if (!obj.is_null()) { | 284 if (!obj.is_null()) { |
288 Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); | 285 Java_ContentViewCore_onWebContentsConnected(env, obj.obj()); |
289 } | 286 } |
290 break; | 287 break; |
291 } | 288 } |
292 case NOTIFICATION_WEB_CONTENTS_SWAPPED: { | |
293 JNIEnv* env = AttachCurrentThread(); | |
294 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
295 if (!obj.is_null()) { | |
296 Java_ContentViewCore_onWebContentsSwapped(env, obj.obj()); | |
297 } | |
298 } | |
299 } | 289 } |
300 } | 290 } |
301 | 291 |
302 RenderWidgetHostViewAndroid* | 292 RenderWidgetHostViewAndroid* |
303 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { | 293 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { |
304 RenderWidgetHostView* rwhv = NULL; | 294 RenderWidgetHostView* rwhv = NULL; |
305 if (web_contents_) { | 295 if (web_contents_) { |
306 rwhv = web_contents_->GetRenderWidgetHostView(); | 296 rwhv = web_contents_->GetRenderWidgetHostView(); |
307 if (web_contents_->ShowingInterstitialPage()) { | 297 if (web_contents_->ShowingInterstitialPage()) { |
308 rwhv = static_cast<InterstitialPageImpl*>( | 298 rwhv = static_cast<InterstitialPageImpl*>( |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1604 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1615 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1605 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1616 return reinterpret_cast<jint>(view); | 1606 return reinterpret_cast<jint>(view); |
1617 } | 1607 } |
1618 | 1608 |
1619 bool RegisterContentViewCore(JNIEnv* env) { | 1609 bool RegisterContentViewCore(JNIEnv* env) { |
1620 return RegisterNativesImpl(env); | 1610 return RegisterNativesImpl(env); |
1621 } | 1611 } |
1622 | 1612 |
1623 } // namespace content | 1613 } // namespace content |
OLD | NEW |