Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/web_contents/web_contents_android.h" | 5 #include "content/browser/web_contents/web_contents_android.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/memory/ptr_util.h" | |
| 14 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
| 15 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "content/browser/accessibility/browser_accessibility_android.h" | 18 #include "content/browser/accessibility/browser_accessibility_android.h" |
| 18 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
| 19 #include "content/browser/android/content_view_core_impl.h" | 20 #include "content/browser/android/content_view_core_impl.h" |
| 20 #include "content/browser/android/interstitial_page_delegate_android.h" | 21 #include "content/browser/android/interstitial_page_delegate_android.h" |
| 21 #include "content/browser/frame_host/interstitial_page_impl.h" | 22 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 22 #include "content/browser/media/android/browser_media_player_manager.h" | 23 #include "content/browser/media/android/browser_media_player_manager.h" |
| 23 #include "content/browser/media/android/media_web_contents_observer_android.h" | 24 #include "content/browser/media/android/media_web_contents_observer_android.h" |
| 25 #include "content/browser/media/session/media_session.h" | |
| 26 #include "content/browser/media/session/media_session_delegate_android.h" | |
| 24 #include "content/browser/renderer_host/render_view_host_impl.h" | 27 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 25 #include "content/browser/web_contents/web_contents_impl.h" | 28 #include "content/browser/web_contents/web_contents_impl.h" |
| 26 #include "content/common/devtools_messages.h" | 29 #include "content/common/devtools_messages.h" |
| 27 #include "content/common/frame_messages.h" | 30 #include "content/common/frame_messages.h" |
| 28 #include "content/common/input_messages.h" | 31 #include "content/common/input_messages.h" |
| 29 #include "content/common/view_messages.h" | 32 #include "content/common/view_messages.h" |
| 30 #include "content/public/browser/android/app_web_message_port_service.h" | 33 #include "content/public/browser/android/app_web_message_port_service.h" |
| 31 #include "content/public/browser/browser_context.h" | 34 #include "content/public/browser/browser_context.h" |
| 32 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/message_port_provider.h" | 36 #include "content/public/browser/message_port_provider.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 // base::Callback. | 609 // base::Callback. |
| 607 ScopedJavaGlobalRef<jobject> j_callback; | 610 ScopedJavaGlobalRef<jobject> j_callback; |
| 608 j_callback.Reset(env, callback); | 611 j_callback.Reset(env, callback); |
| 609 | 612 |
| 610 WebContentsImpl::AXTreeSnapshotCallback snapshot_callback = | 613 WebContentsImpl::AXTreeSnapshotCallback snapshot_callback = |
| 611 base::Bind(&AXTreeSnapshotCallback, j_callback); | 614 base::Bind(&AXTreeSnapshotCallback, j_callback); |
| 612 static_cast<WebContentsImpl*>(web_contents_)->RequestAXTreeSnapshot( | 615 static_cast<WebContentsImpl*>(web_contents_)->RequestAXTreeSnapshot( |
| 613 snapshot_callback); | 616 snapshot_callback); |
| 614 } | 617 } |
| 615 | 618 |
| 616 void WebContentsAndroid::ResumeMediaSession(JNIEnv* env, | 619 void WebContentsAndroid::AddMediaSessionDelegate(JNIEnv* env, |
| 617 const JavaParamRef<jobject>& obj) { | 620 const JavaParamRef<jobject>& ob j, |
| 618 web_contents_->ResumeMediaSession(); | 621 const JavaParamRef<jobject>& j_ delegate) { |
| 619 } | 622 MediaSessionDelegateAndroid::CreateAndRegister( |
|
whywhat
2016/10/20 15:38:33
perhaps the delegates could be owned by WebContent
Zhiqiang Zhang (Slow)
2016/10/20 16:22:32
I prefer not to pollute WebContents. Actually Medi
whywhat
2016/10/20 18:21:16
Can we just own MSO in MediaSession and avoid usin
| |
| 620 | 623 env, MediaSession::Get(web_contents()), j_delegate); |
| 621 void WebContentsAndroid::SuspendMediaSession(JNIEnv* env, | |
| 622 const JavaParamRef<jobject>& obj) { | |
| 623 web_contents_->SuspendMediaSession(); | |
| 624 } | |
| 625 | |
| 626 void WebContentsAndroid::StopMediaSession(JNIEnv* env, | |
| 627 const JavaParamRef<jobject>& obj) { | |
| 628 web_contents_->StopMediaSession(); | |
| 629 } | 624 } |
| 630 | 625 |
| 631 ScopedJavaLocalRef<jstring> WebContentsAndroid::GetEncoding( | 626 ScopedJavaLocalRef<jstring> WebContentsAndroid::GetEncoding( |
| 632 JNIEnv* env, | 627 JNIEnv* env, |
| 633 const JavaParamRef<jobject>& obj) const { | 628 const JavaParamRef<jobject>& obj) const { |
| 634 return base::android::ConvertUTF8ToJavaString(env, | 629 return base::android::ConvertUTF8ToJavaString(env, |
| 635 web_contents_->GetEncoding()); | 630 web_contents_->GetEncoding()); |
| 636 } | 631 } |
| 637 | 632 |
| 638 void WebContentsAndroid::GetContentBitmap( | 633 void WebContentsAndroid::GetContentBitmap( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 Java_WebContentsImpl_addToBitmapList(env, jbitmaps, jbitmap); | 722 Java_WebContentsImpl_addToBitmapList(env, jbitmaps, jbitmap); |
| 728 } | 723 } |
| 729 for (const gfx::Size& size : sizes) { | 724 for (const gfx::Size& size : sizes) { |
| 730 Java_WebContentsImpl_createSizeAndAddToList(env, jsizes, size.width(), | 725 Java_WebContentsImpl_createSizeAndAddToList(env, jsizes, size.width(), |
| 731 size.height()); | 726 size.height()); |
| 732 } | 727 } |
| 733 Java_WebContentsImpl_onDownloadImageFinished( | 728 Java_WebContentsImpl_onDownloadImageFinished( |
| 734 env, *obj, *callback, id, http_status_code, jurl, jbitmaps, jsizes); | 729 env, *obj, *callback, id, http_status_code, jurl, jbitmaps, jsizes); |
| 735 } | 730 } |
| 736 } // namespace content | 731 } // namespace content |
| OLD | NEW |