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

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

Issue 2453623003: Decouple MediaSession messages from WebContents (full patch) (Closed)
Patch Set: nit Created 4 years, 1 month 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 ReloadType reload_type) { 311 ReloadType reload_type) {
312 JNIEnv* env = AttachCurrentThread(); 312 JNIEnv* env = AttachCurrentThread();
313 ScopedJavaLocalRef<jobject> obj(java_observer_); 313 ScopedJavaLocalRef<jobject> obj(java_observer_);
314 ScopedJavaLocalRef<jstring> jstring_url( 314 ScopedJavaLocalRef<jstring> jstring_url(
315 ConvertUTF8ToJavaString(env, url.spec())); 315 ConvertUTF8ToJavaString(env, url.spec()));
316 316
317 Java_WebContentsObserverProxy_didStartNavigationToPendingEntry(env, obj, 317 Java_WebContentsObserverProxy_didStartNavigationToPendingEntry(env, obj,
318 jstring_url); 318 jstring_url);
319 } 319 }
320 320
321 void WebContentsObserverProxy::MediaSessionStateChanged(bool is_controllable,
322 bool is_suspended) {
323 JNIEnv* env = AttachCurrentThread();
324
325 ScopedJavaLocalRef<jobject> obj(java_observer_);
326
327 Java_WebContentsObserverProxy_mediaSessionStateChanged(
328 env, obj, is_controllable, is_suspended);
329 }
330
331 void WebContentsObserverProxy::MediaSessionMetadataChanged(
332 const base::Optional<MediaMetadata>& metadata) {
333 JNIEnv* env = AttachCurrentThread();
334
335 ScopedJavaLocalRef<jobject> obj(java_observer_);
336 ScopedJavaLocalRef<jobject> j_metadata;
337
338 if (metadata.has_value())
339 j_metadata = MediaMetadataAndroid::CreateJavaObject(env, metadata.value());
340
341 Java_WebContentsObserverProxy_mediaSessionMetadataChanged(env, obj,
342 j_metadata);
343 }
344
345 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( 321 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded(
346 std::string* url) { 322 std::string* url) {
347 NavigationEntry* entry = 323 NavigationEntry* entry =
348 web_contents()->GetController().GetLastCommittedEntry(); 324 web_contents()->GetController().GetLastCommittedEntry();
349 // Note that GetBaseURLForDataURL is only used by the Android WebView. 325 // Note that GetBaseURLForDataURL is only used by the Android WebView.
350 // FIXME: Should we only return valid specs and "about:blank" for invalid 326 // FIXME: Should we only return valid specs and "about:blank" for invalid
351 // ones? This may break apps. 327 // ones? This may break apps.
352 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { 328 if (entry && !entry->GetBaseURLForDataURL().is_empty()) {
353 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); 329 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec();
354 } else if (!base_url_of_last_started_data_url_.is_empty()) { 330 } else if (!base_url_of_last_started_data_url_.is_empty()) {
355 // NavigationController can lose the pending entry and recreate it without 331 // NavigationController can lose the pending entry and recreate it without
356 // a base URL if there has been a loadUrl("javascript:...") after 332 // a base URL if there has been a loadUrl("javascript:...") after
357 // loadDataWithBaseUrl. 333 // loadDataWithBaseUrl.
358 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); 334 *url = base_url_of_last_started_data_url_.possibly_invalid_spec();
359 } 335 }
360 } 336 }
361 337
362 bool RegisterWebContentsObserverProxy(JNIEnv* env) { 338 bool RegisterWebContentsObserverProxy(JNIEnv* env) {
363 return RegisterNativesImpl(env); 339 return RegisterNativesImpl(env);
364 } 340 }
365 } // namespace content 341 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.h ('k') | content/browser/media/session/audio_focus_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698