| 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" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/optional.h" | 12 #include "base/optional.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_impl.h" | 14 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 14 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
| 15 #include "content/common/android/media_metadata_android.h" | 16 #include "content/common/android/media_metadata_android.h" |
| 16 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
| 17 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| 18 #include "content/public/browser/navigation_handle.h" | 19 #include "content/public/browser/navigation_handle.h" |
| 19 #include "content/public/common/media_metadata.h" | 20 #include "content/public/common/media_metadata.h" |
| 20 #include "jni/WebContentsObserverProxy_jni.h" | 21 #include "jni/WebContentsObserverProxy_jni.h" |
| 21 | 22 |
| 22 using base::android::AttachCurrentThread; | 23 using base::android::AttachCurrentThread; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 ScopedJavaLocalRef<jobject> obj(java_observer_); | 300 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 300 Java_WebContentsObserverProxy_wasShown(env, obj); | 301 Java_WebContentsObserverProxy_wasShown(env, obj); |
| 301 } | 302 } |
| 302 | 303 |
| 303 void WebContentsObserverProxy::WasHidden() { | 304 void WebContentsObserverProxy::WasHidden() { |
| 304 JNIEnv* env = AttachCurrentThread(); | 305 JNIEnv* env = AttachCurrentThread(); |
| 305 ScopedJavaLocalRef<jobject> obj(java_observer_); | 306 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 306 Java_WebContentsObserverProxy_wasHidden(env, obj); | 307 Java_WebContentsObserverProxy_wasHidden(env, obj); |
| 307 } | 308 } |
| 308 | 309 |
| 310 void WebContentsObserverProxy::TitleWasSet(NavigationEntry* entry, |
| 311 bool explicit_set) { |
| 312 JNIEnv* env = AttachCurrentThread(); |
| 313 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 314 ScopedJavaLocalRef<jstring> jstring_title = ConvertUTF8ToJavaString( |
| 315 env, |
| 316 base::UTF16ToUTF8(web_contents()->GetTitle())); |
| 317 Java_WebContentsObserverProxy_titleWasSet(env, obj, jstring_title); |
| 318 } |
| 319 |
| 309 void WebContentsObserverProxy::DidStartNavigationToPendingEntry( | 320 void WebContentsObserverProxy::DidStartNavigationToPendingEntry( |
| 310 const GURL& url, | 321 const GURL& url, |
| 311 ReloadType reload_type) { | 322 ReloadType reload_type) { |
| 312 JNIEnv* env = AttachCurrentThread(); | 323 JNIEnv* env = AttachCurrentThread(); |
| 313 ScopedJavaLocalRef<jobject> obj(java_observer_); | 324 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 314 ScopedJavaLocalRef<jstring> jstring_url( | 325 ScopedJavaLocalRef<jstring> jstring_url( |
| 315 ConvertUTF8ToJavaString(env, url.spec())); | 326 ConvertUTF8ToJavaString(env, url.spec())); |
| 316 | 327 |
| 317 Java_WebContentsObserverProxy_didStartNavigationToPendingEntry(env, obj, | 328 Java_WebContentsObserverProxy_didStartNavigationToPendingEntry(env, obj, |
| 318 jstring_url); | 329 jstring_url); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 332 // a base URL if there has been a loadUrl("javascript:...") after | 343 // a base URL if there has been a loadUrl("javascript:...") after |
| 333 // loadDataWithBaseUrl. | 344 // loadDataWithBaseUrl. |
| 334 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); | 345 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); |
| 335 } | 346 } |
| 336 } | 347 } |
| 337 | 348 |
| 338 bool RegisterWebContentsObserverProxy(JNIEnv* env) { | 349 bool RegisterWebContentsObserverProxy(JNIEnv* env) { |
| 339 return RegisterNativesImpl(env); | 350 return RegisterNativesImpl(env); |
| 340 } | 351 } |
| 341 } // namespace content | 352 } // namespace content |
| OLD | NEW |