Chromium Code Reviews| 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 | |
|
boliu
2016/10/24 17:02:46
nit: maybe could remove these empty lines? very mu
Zhiqiang Zhang (Slow)
2016/10/24 17:33:10
Done.
| |
| 349 ScopedJavaLocalRef<jobject> obj(java_observer_); | |
| 350 | |
| 351 Java_WebContentsObserverProxy_mediaSessionEnabledAction( | |
| 352 env, obj, static_cast<int>(action)); | |
| 353 } | |
| 354 | |
| 355 void WebContentsObserverProxy::MediaSessionDisabledAction( | |
| 356 blink::mojom::MediaSessionAction action) { | |
| 357 JNIEnv* env = AttachCurrentThread(); | |
| 358 | |
| 359 ScopedJavaLocalRef<jobject> obj(java_observer_); | |
| 360 | |
| 361 Java_WebContentsObserverProxy_mediaSessionDisabledAction( | |
| 362 env, obj, static_cast<int>(action)); | |
| 363 } | |
| 364 | |
| 345 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( | 365 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( |
| 346 std::string* url) { | 366 std::string* url) { |
| 347 NavigationEntry* entry = | 367 NavigationEntry* entry = |
| 348 web_contents()->GetController().GetLastCommittedEntry(); | 368 web_contents()->GetController().GetLastCommittedEntry(); |
| 349 // Note that GetBaseURLForDataURL is only used by the Android WebView. | 369 // Note that GetBaseURLForDataURL is only used by the Android WebView. |
| 350 // FIXME: Should we only return valid specs and "about:blank" for invalid | 370 // FIXME: Should we only return valid specs and "about:blank" for invalid |
| 351 // ones? This may break apps. | 371 // ones? This may break apps. |
| 352 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { | 372 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { |
| 353 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); | 373 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); |
| 354 } else if (!base_url_of_last_started_data_url_.is_empty()) { | 374 } else if (!base_url_of_last_started_data_url_.is_empty()) { |
| 355 // NavigationController can lose the pending entry and recreate it without | 375 // NavigationController can lose the pending entry and recreate it without |
| 356 // a base URL if there has been a loadUrl("javascript:...") after | 376 // a base URL if there has been a loadUrl("javascript:...") after |
| 357 // loadDataWithBaseUrl. | 377 // loadDataWithBaseUrl. |
| 358 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); | 378 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); |
| 359 } | 379 } |
| 360 } | 380 } |
| 361 | 381 |
| 362 bool RegisterWebContentsObserverProxy(JNIEnv* env) { | 382 bool RegisterWebContentsObserverProxy(JNIEnv* env) { |
| 363 return RegisterNativesImpl(env); | 383 return RegisterNativesImpl(env); |
| 364 } | 384 } |
| 365 } // namespace content | 385 } // namespace content |
| OLD | NEW |