| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 ScopedJavaLocalRef<jobject> obj(java_observer_); | 335 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 336 ScopedJavaLocalRef<jobject> j_metadata; | 336 ScopedJavaLocalRef<jobject> j_metadata; |
| 337 | 337 |
| 338 if (metadata.has_value()) | 338 if (metadata.has_value()) |
| 339 j_metadata = MediaMetadataAndroid::CreateJavaObject(env, metadata.value()); | 339 j_metadata = MediaMetadataAndroid::CreateJavaObject(env, metadata.value()); |
| 340 | 340 |
| 341 Java_WebContentsObserverProxy_mediaSessionMetadataChanged(env, obj, | 341 Java_WebContentsObserverProxy_mediaSessionMetadataChanged(env, obj, |
| 342 j_metadata); | 342 j_metadata); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void WebContentsObserverProxy::MediaSessionEnabledAction( |
| 346 blink::mojom::MediaSessionAction action) { |
| 347 JNIEnv* env = AttachCurrentThread(); |
| 348 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 349 Java_WebContentsObserverProxy_mediaSessionEnabledAction( |
| 350 env, obj, static_cast<int>(action)); |
| 351 } |
| 352 |
| 353 void WebContentsObserverProxy::MediaSessionDisabledAction( |
| 354 blink::mojom::MediaSessionAction action) { |
| 355 JNIEnv* env = AttachCurrentThread(); |
| 356 ScopedJavaLocalRef<jobject> obj(java_observer_); |
| 357 Java_WebContentsObserverProxy_mediaSessionDisabledAction( |
| 358 env, obj, static_cast<int>(action)); |
| 359 } |
| 360 |
| 345 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( | 361 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( |
| 346 std::string* url) { | 362 std::string* url) { |
| 347 NavigationEntry* entry = | 363 NavigationEntry* entry = |
| 348 web_contents()->GetController().GetLastCommittedEntry(); | 364 web_contents()->GetController().GetLastCommittedEntry(); |
| 349 // Note that GetBaseURLForDataURL is only used by the Android WebView. | 365 // Note that GetBaseURLForDataURL is only used by the Android WebView. |
| 350 // FIXME: Should we only return valid specs and "about:blank" for invalid | 366 // FIXME: Should we only return valid specs and "about:blank" for invalid |
| 351 // ones? This may break apps. | 367 // ones? This may break apps. |
| 352 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { | 368 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { |
| 353 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); | 369 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); |
| 354 } else if (!base_url_of_last_started_data_url_.is_empty()) { | 370 } else if (!base_url_of_last_started_data_url_.is_empty()) { |
| 355 // NavigationController can lose the pending entry and recreate it without | 371 // NavigationController can lose the pending entry and recreate it without |
| 356 // a base URL if there has been a loadUrl("javascript:...") after | 372 // a base URL if there has been a loadUrl("javascript:...") after |
| 357 // loadDataWithBaseUrl. | 373 // loadDataWithBaseUrl. |
| 358 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); | 374 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); |
| 359 } | 375 } |
| 360 } | 376 } |
| 361 | 377 |
| 362 bool RegisterWebContentsObserverProxy(JNIEnv* env) { | 378 bool RegisterWebContentsObserverProxy(JNIEnv* env) { |
| 363 return RegisterNativesImpl(env); | 379 return RegisterNativesImpl(env); |
| 364 } | 380 } |
| 365 } // namespace content | 381 } // namespace content |
| OLD | NEW |