| 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/web_contents_observer_android.h" | 5 #include "content/browser/android/web_contents_observer_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include <jni.h> | 9 #include <jni.h> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 reinterpret_cast<ContentViewCore*>(native_content_view_core); | 41 reinterpret_cast<ContentViewCore*>(native_content_view_core); |
| 42 WebContentsObserverAndroid* native_observer = new WebContentsObserverAndroid( | 42 WebContentsObserverAndroid* native_observer = new WebContentsObserverAndroid( |
| 43 env, obj, content_view_core->GetWebContents()); | 43 env, obj, content_view_core->GetWebContents()); |
| 44 return reinterpret_cast<intptr_t>(native_observer); | 44 return reinterpret_cast<intptr_t>(native_observer); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void WebContentsObserverAndroid::Destroy(JNIEnv* env, jobject obj) { | 47 void WebContentsObserverAndroid::Destroy(JNIEnv* env, jobject obj) { |
| 48 delete this; | 48 delete this; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void WebContentsObserverAndroid::WebContentsDestroyed( | 51 void WebContentsObserverAndroid::WebContentsDestroyed() { |
| 52 WebContents* web_contents) { | |
| 53 JNIEnv* env = AttachCurrentThread(); | 52 JNIEnv* env = AttachCurrentThread(); |
| 54 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); | 53 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); |
| 55 if (obj.is_null()) { | 54 if (obj.is_null()) { |
| 56 delete this; | 55 delete this; |
| 57 } else { | 56 } else { |
| 58 // The java side will destroy |this| | 57 // The java side will destroy |this| |
| 59 Java_WebContentsObserverAndroid_detachFromWebContents(env, obj.obj()); | 58 Java_WebContentsObserverAndroid_detachFromWebContents(env, obj.obj()); |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 | 61 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (obj.is_null()) | 278 if (obj.is_null()) |
| 280 return; | 279 return; |
| 281 Java_WebContentsObserverAndroid_didFirstVisuallyNonEmptyPaint( | 280 Java_WebContentsObserverAndroid_didFirstVisuallyNonEmptyPaint( |
| 282 env, obj.obj(), page_id); | 281 env, obj.obj(), page_id); |
| 283 } | 282 } |
| 284 | 283 |
| 285 bool RegisterWebContentsObserverAndroid(JNIEnv* env) { | 284 bool RegisterWebContentsObserverAndroid(JNIEnv* env) { |
| 286 return RegisterNativesImpl(env); | 285 return RegisterNativesImpl(env); |
| 287 } | 286 } |
| 288 } // namespace content | 287 } // namespace content |
| OLD | NEW |