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/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "content/browser/accessibility/browser_accessibility_android.h" | 18 #include "content/browser/accessibility/browser_accessibility_android.h" |
19 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
20 #include "content/browser/android/app_web_message_port.h" | |
20 #include "content/browser/android/content_view_core_impl.h" | 21 #include "content/browser/android/content_view_core_impl.h" |
21 #include "content/browser/android/interstitial_page_delegate_android.h" | 22 #include "content/browser/android/interstitial_page_delegate_android.h" |
22 #include "content/browser/frame_host/interstitial_page_impl.h" | 23 #include "content/browser/frame_host/interstitial_page_impl.h" |
23 #include "content/browser/media/android/browser_media_player_manager.h" | 24 #include "content/browser/media/android/browser_media_player_manager.h" |
24 #include "content/browser/media/android/media_web_contents_observer_android.h" | 25 #include "content/browser/media/android/media_web_contents_observer_android.h" |
25 #include "content/browser/renderer_host/render_view_host_impl.h" | 26 #include "content/browser/renderer_host/render_view_host_impl.h" |
26 #include "content/browser/web_contents/web_contents_impl.h" | 27 #include "content/browser/web_contents/web_contents_impl.h" |
27 #include "content/browser/web_contents/web_contents_view_android.h" | 28 #include "content/browser/web_contents/web_contents_view_android.h" |
28 #include "content/common/devtools_messages.h" | 29 #include "content/common/devtools_messages.h" |
29 #include "content/common/frame_messages.h" | 30 #include "content/common/frame_messages.h" |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 static_cast<ConsoleMessageLevel>(level), | 558 static_cast<ConsoleMessageLevel>(level), |
558 ConvertJavaStringToUTF8(env, message)); | 559 ConvertJavaStringToUTF8(env, message)); |
559 } | 560 } |
560 | 561 |
561 void WebContentsAndroid::PostMessageToFrame( | 562 void WebContentsAndroid::PostMessageToFrame( |
562 JNIEnv* env, | 563 JNIEnv* env, |
563 const JavaParamRef<jobject>& obj, | 564 const JavaParamRef<jobject>& obj, |
564 const JavaParamRef<jstring>& jframe_name, | 565 const JavaParamRef<jstring>& jframe_name, |
565 const JavaParamRef<jstring>& jmessage, | 566 const JavaParamRef<jstring>& jmessage, |
566 const JavaParamRef<jstring>& jtarget_origin, | 567 const JavaParamRef<jstring>& jtarget_origin, |
567 const JavaParamRef<jintArray>& jsent_ports) { | 568 const JavaParamRef<jobjectArray>& jports) { |
568 base::string16 source_origin; | 569 base::string16 source_origin; |
569 base::string16 target_origin(ConvertJavaStringToUTF16(env, jtarget_origin)); | 570 base::string16 target_origin(ConvertJavaStringToUTF16(env, jtarget_origin)); |
570 base::string16 message(ConvertJavaStringToUTF16(env, jmessage)); | 571 base::string16 message(ConvertJavaStringToUTF16(env, jmessage)); |
571 std::vector<int> ports; | 572 std::vector<MessagePort> ports( |
573 AppWebMessagePort::UnwrapJavaArray(env, jports)); | |
572 | 574 |
573 if (!jsent_ports.is_null()) | |
574 base::android::JavaIntArrayToIntVector(env, jsent_ports, &ports); | |
575 content::MessagePortProvider::PostMessageToFrame( | 575 content::MessagePortProvider::PostMessageToFrame( |
sgurun-gerrit only
2017/01/27 01:16:37
can we move the code in messageportprovider::postm
| |
576 web_contents_, source_origin, target_origin, message, ports); | 576 web_contents_, source_origin, target_origin, message, ports); |
577 } | 577 } |
578 | 578 |
579 void WebContentsAndroid::CreateMessageChannel( | 579 void WebContentsAndroid::CreateMessageChannel( |
580 JNIEnv* env, | 580 JNIEnv* env, |
581 const JavaParamRef<jobject>& obj, | 581 const JavaParamRef<jobject>& obj, |
582 const JavaParamRef<jobjectArray>& ports) { | 582 const JavaParamRef<jobjectArray>& ports) { |
583 content::MessagePortProvider::GetAppWebMessagePortService() | 583 content::MessagePortProvider::GetAppWebMessagePortService() |
584 ->CreateMessageChannel(env, ports, web_contents_); | 584 ->CreateMessageChannel(env, ports, web_contents_); |
sgurun-gerrit only
2017/01/27 01:16:37
this will not need to get appwebmessageportservice
| |
585 } | 585 } |
586 | 586 |
587 jboolean WebContentsAndroid::HasAccessedInitialDocument( | 587 jboolean WebContentsAndroid::HasAccessedInitialDocument( |
588 JNIEnv* env, | 588 JNIEnv* env, |
589 const JavaParamRef<jobject>& jobj) { | 589 const JavaParamRef<jobject>& jobj) { |
590 return static_cast<WebContentsImpl*>(web_contents_)-> | 590 return static_cast<WebContentsImpl*>(web_contents_)-> |
591 HasAccessedInitialDocument(); | 591 HasAccessedInitialDocument(); |
592 } | 592 } |
593 | 593 |
594 jint WebContentsAndroid::GetThemeColor(JNIEnv* env, | 594 jint WebContentsAndroid::GetThemeColor(JNIEnv* env, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); | 733 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); |
734 } | 734 } |
735 | 735 |
736 void WebContentsAndroid::SetMediaSession( | 736 void WebContentsAndroid::SetMediaSession( |
737 const ScopedJavaLocalRef<jobject>& j_media_session) { | 737 const ScopedJavaLocalRef<jobject>& j_media_session) { |
738 JNIEnv* env = base::android::AttachCurrentThread(); | 738 JNIEnv* env = base::android::AttachCurrentThread(); |
739 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); | 739 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); |
740 } | 740 } |
741 | 741 |
742 } // namespace content | 742 } // namespace content |
OLD | NEW |