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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 env, obj.obj(), jstring_url.obj()); | 308 env, obj.obj(), jstring_url.obj()); |
309 } | 309 } |
310 | 310 |
311 void WebContentsObserverProxy::MediaSessionStateChanged( | 311 void WebContentsObserverProxy::MediaSessionStateChanged( |
312 bool is_controllable, | 312 bool is_controllable, |
313 bool is_suspended, | 313 bool is_suspended, |
314 const MediaMetadata& metadata) { | 314 const MediaMetadata& metadata) { |
315 JNIEnv* env = AttachCurrentThread(); | 315 JNIEnv* env = AttachCurrentThread(); |
316 | 316 |
317 ScopedJavaLocalRef<jobject> obj(java_observer_); | 317 ScopedJavaLocalRef<jobject> obj(java_observer_); |
318 | |
319 // TODO(zqzhang): the metadata is sent though JNI everytime the | |
320 // media session play/pause state changes. Need to find a way to | |
321 // seprate the state change and Metadata update. | |
palmer
2016/06/20 21:34:20
It's a good idea to attach a crbug link to all TOD
Zhiqiang Zhang (Slow)
2016/06/21 11:08:42
Done.
| |
318 ScopedJavaLocalRef<jobject> j_metadata = | 322 ScopedJavaLocalRef<jobject> j_metadata = |
319 MediaMetadataAndroid::CreateJavaObject(env, metadata); | 323 MediaMetadataAndroid::CreateJavaObject(env, metadata); |
320 | 324 |
321 Java_WebContentsObserverProxy_mediaSessionStateChanged( | 325 Java_WebContentsObserverProxy_mediaSessionStateChanged( |
322 env, obj.obj(), is_controllable, is_suspended, j_metadata.obj()); | 326 env, obj.obj(), is_controllable, is_suspended, j_metadata.obj()); |
323 } | 327 } |
324 | 328 |
325 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( | 329 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded( |
326 std::string* url) { | 330 std::string* url) { |
327 NavigationEntry* entry = | 331 NavigationEntry* entry = |
328 web_contents()->GetController().GetLastCommittedEntry(); | 332 web_contents()->GetController().GetLastCommittedEntry(); |
329 // Note that GetBaseURLForDataURL is only used by the Android WebView. | 333 // Note that GetBaseURLForDataURL is only used by the Android WebView. |
330 // FIXME: Should we only return valid specs and "about:blank" for invalid | 334 // FIXME: Should we only return valid specs and "about:blank" for invalid |
331 // ones? This may break apps. | 335 // ones? This may break apps. |
332 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { | 336 if (entry && !entry->GetBaseURLForDataURL().is_empty()) { |
333 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); | 337 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec(); |
334 } else if (!base_url_of_last_started_data_url_.is_empty()) { | 338 } else if (!base_url_of_last_started_data_url_.is_empty()) { |
335 // NavigationController can lose the pending entry and recreate it without | 339 // NavigationController can lose the pending entry and recreate it without |
336 // a base URL if there has been a loadUrl("javascript:...") after | 340 // a base URL if there has been a loadUrl("javascript:...") after |
337 // loadDataWithBaseUrl. | 341 // loadDataWithBaseUrl. |
338 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); | 342 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); |
339 } | 343 } |
340 } | 344 } |
341 | 345 |
342 bool RegisterWebContentsObserverProxy(JNIEnv* env) { | 346 bool RegisterWebContentsObserverProxy(JNIEnv* env) { |
343 return RegisterNativesImpl(env); | 347 return RegisterNativesImpl(env); |
344 } | 348 } |
345 } // namespace content | 349 } // namespace content |
OLD | NEW |