Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: content/browser/android/web_contents_observer_proxy.cc

Issue 2411723002: Split MediaSessionStateChanged() and MediaSessionMetadataChanged() (Closed)
Patch Set: rebased Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 ReloadType reload_type) { 299 ReloadType reload_type) {
300 JNIEnv* env = AttachCurrentThread(); 300 JNIEnv* env = AttachCurrentThread();
301 ScopedJavaLocalRef<jobject> obj(java_observer_); 301 ScopedJavaLocalRef<jobject> obj(java_observer_);
302 ScopedJavaLocalRef<jstring> jstring_url( 302 ScopedJavaLocalRef<jstring> jstring_url(
303 ConvertUTF8ToJavaString(env, url.spec())); 303 ConvertUTF8ToJavaString(env, url.spec()));
304 304
305 Java_WebContentsObserverProxy_didStartNavigationToPendingEntry(env, obj, 305 Java_WebContentsObserverProxy_didStartNavigationToPendingEntry(env, obj,
306 jstring_url); 306 jstring_url);
307 } 307 }
308 308
309 void WebContentsObserverProxy::MediaSessionStateChanged( 309 void WebContentsObserverProxy::MediaSessionStateChanged(bool is_controllable,
310 bool is_controllable, 310 bool is_suspended) {
311 bool is_suspended, 311 JNIEnv* env = AttachCurrentThread();
312
313 ScopedJavaLocalRef<jobject> obj(java_observer_);
314
315 Java_WebContentsObserverProxy_mediaSessionStateChanged(
316 env, obj, is_controllable, is_suspended);
317 }
318
319 void WebContentsObserverProxy::MediaSessionMetadataChanged(
312 const base::Optional<MediaMetadata>& metadata) { 320 const base::Optional<MediaMetadata>& metadata) {
313 JNIEnv* env = AttachCurrentThread(); 321 JNIEnv* env = AttachCurrentThread();
314 322
315 ScopedJavaLocalRef<jobject> obj(java_observer_); 323 ScopedJavaLocalRef<jobject> obj(java_observer_);
316 ScopedJavaLocalRef<jobject> j_metadata; 324 ScopedJavaLocalRef<jobject> j_metadata;
317 325
318 if (metadata.has_value()) 326 if (metadata.has_value())
319 j_metadata = MediaMetadataAndroid::CreateJavaObject(env, metadata.value()); 327 j_metadata = MediaMetadataAndroid::CreateJavaObject(env, metadata.value());
320 328
321 Java_WebContentsObserverProxy_mediaSessionStateChanged( 329 Java_WebContentsObserverProxy_mediaSessionMetadataChanged(env, obj,
322 env, obj, is_controllable, is_suspended, j_metadata); 330 j_metadata);
323 } 331 }
324 332
325 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( 333 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded(
326 std::string* url) { 334 std::string* url) {
327 NavigationEntry* entry = 335 NavigationEntry* entry =
328 web_contents()->GetController().GetLastCommittedEntry(); 336 web_contents()->GetController().GetLastCommittedEntry();
329 // Note that GetBaseURLForDataURL is only used by the Android WebView. 337 // Note that GetBaseURLForDataURL is only used by the Android WebView.
330 // FIXME: Should we only return valid specs and "about:blank" for invalid 338 // FIXME: Should we only return valid specs and "about:blank" for invalid
331 // ones? This may break apps. 339 // ones? This may break apps.
332 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { 340 if (entry && !entry->GetBaseURLForDataURL().is_empty()) {
333 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); 341 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec();
334 } else if (!base_url_of_last_started_data_url_.is_empty()) { 342 } else if (!base_url_of_last_started_data_url_.is_empty()) {
335 // NavigationController can lose the pending entry and recreate it without 343 // NavigationController can lose the pending entry and recreate it without
336 // a base URL if there has been a loadUrl("javascript:...") after 344 // a base URL if there has been a loadUrl("javascript:...") after
337 // loadDataWithBaseUrl. 345 // loadDataWithBaseUrl.
338 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); 346 *url = base_url_of_last_started_data_url_.possibly_invalid_spec();
339 } 347 }
340 } 348 }
341 349
342 bool RegisterWebContentsObserverProxy(JNIEnv* env) { 350 bool RegisterWebContentsObserverProxy(JNIEnv* env) {
343 return RegisterNativesImpl(env); 351 return RegisterNativesImpl(env);
344 } 352 }
345 } // namespace content 353 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.h ('k') | content/browser/media/session/media_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698