| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_proxy.h" | 5 #include "content/browser/android/web_contents_observer_proxy.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 const JavaParamRef<jobject>& java_web_contents) { | 41 const JavaParamRef<jobject>& java_web_contents) { |
| 42 WebContents* web_contents = | 42 WebContents* web_contents = |
| 43 WebContents::FromJavaWebContents(java_web_contents); | 43 WebContents::FromJavaWebContents(java_web_contents); |
| 44 CHECK(web_contents); | 44 CHECK(web_contents); |
| 45 | 45 |
| 46 WebContentsObserverProxy* native_observer = | 46 WebContentsObserverProxy* native_observer = |
| 47 new WebContentsObserverProxy(env, obj, web_contents); | 47 new WebContentsObserverProxy(env, obj, web_contents); |
| 48 return reinterpret_cast<intptr_t>(native_observer); | 48 return reinterpret_cast<intptr_t>(native_observer); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void WebContentsObserverProxy::Destroy(JNIEnv* env, jobject obj) { | 51 void WebContentsObserverProxy::Destroy(JNIEnv* env, |
| 52 const JavaParamRef<jobject>& obj) { |
| 52 delete this; | 53 delete this; |
| 53 } | 54 } |
| 54 | 55 |
| 55 void WebContentsObserverProxy::WebContentsDestroyed() { | 56 void WebContentsObserverProxy::WebContentsDestroyed() { |
| 56 JNIEnv* env = AttachCurrentThread(); | 57 JNIEnv* env = AttachCurrentThread(); |
| 57 ScopedJavaLocalRef<jobject> obj(java_observer_); | 58 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 58 // The java side will destroy |this| | 59 // The java side will destroy |this| |
| 59 Java_WebContentsObserverProxy_destroy(env, obj.obj()); | 60 Java_WebContentsObserverProxy_destroy(env, obj.obj()); |
| 60 } | 61 } |
| 61 | 62 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 web_contents()->GetController().GetLastCommittedEntry(); | 305 web_contents()->GetController().GetLastCommittedEntry(); |
| 305 // Note that GetBaseURLForDataURL is only used by the Android WebView. | 306 // Note that GetBaseURLForDataURL is only used by the Android WebView. |
| 306 if (entry && !entry->GetBaseURLForDataURL().is_empty()) | 307 if (entry && !entry->GetBaseURLForDataURL().is_empty()) |
| 307 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); | 308 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); |
| 308 } | 309 } |
| 309 | 310 |
| 310 bool RegisterWebContentsObserverProxy(JNIEnv* env) { | 311 bool RegisterWebContentsObserverProxy(JNIEnv* env) { |
| 311 return RegisterNativesImpl(env); | 312 return RegisterNativesImpl(env); |
| 312 } | 313 } |
| 313 } // namespace content | 314 } // namespace content |
| OLD | NEW |