OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "components/autofill/content/browser/content_autofill_driver.h" | 47 #include "components/autofill/content/browser/content_autofill_driver.h" |
48 #include "components/autofill/core/browser/autofill_manager.h" | 48 #include "components/autofill/core/browser/autofill_manager.h" |
49 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 49 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
50 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 50 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
51 #include "components/navigation_interception/intercept_navigation_delegate.h" | 51 #include "components/navigation_interception/intercept_navigation_delegate.h" |
52 #include "content/public/browser/android/content_view_core.h" | 52 #include "content/public/browser/android/content_view_core.h" |
53 #include "content/public/browser/android/synchronous_compositor.h" | 53 #include "content/public/browser/android/synchronous_compositor.h" |
54 #include "content/public/browser/browser_thread.h" | 54 #include "content/public/browser/browser_thread.h" |
55 #include "content/public/browser/cert_store.h" | 55 #include "content/public/browser/cert_store.h" |
56 #include "content/public/browser/favicon_status.h" | 56 #include "content/public/browser/favicon_status.h" |
| 57 #include "content/public/browser/message_port_provider.h" |
57 #include "content/public/browser/navigation_entry.h" | 58 #include "content/public/browser/navigation_entry.h" |
58 #include "content/public/browser/render_frame_host.h" | 59 #include "content/public/browser/render_frame_host.h" |
59 #include "content/public/browser/render_process_host.h" | 60 #include "content/public/browser/render_process_host.h" |
60 #include "content/public/browser/render_view_host.h" | 61 #include "content/public/browser/render_view_host.h" |
61 #include "content/public/browser/web_contents.h" | 62 #include "content/public/browser/web_contents.h" |
62 #include "content/public/common/renderer_preferences.h" | 63 #include "content/public/common/renderer_preferences.h" |
63 #include "content/public/common/ssl_status.h" | 64 #include "content/public/common/ssl_status.h" |
64 #include "jni/AwContents_jni.h" | 65 #include "jni/AwContents_jni.h" |
65 #include "net/base/auth.h" | 66 #include "net/base/auth.h" |
66 #include "net/cert/x509_certificate.h" | 67 #include "net/cert/x509_certificate.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 127 |
127 base::subtle::Atomic32 g_instance_count = 0; | 128 base::subtle::Atomic32 g_instance_count = 0; |
128 | 129 |
129 void OnIoThreadClientReady(content::RenderFrameHost* rfh) { | 130 void OnIoThreadClientReady(content::RenderFrameHost* rfh) { |
130 int render_process_id = rfh->GetProcess()->GetID(); | 131 int render_process_id = rfh->GetProcess()->GetID(); |
131 int render_frame_id = rfh->GetRoutingID(); | 132 int render_frame_id = rfh->GetRoutingID(); |
132 AwResourceDispatcherHostDelegate::OnIoThreadClientReady( | 133 AwResourceDispatcherHostDelegate::OnIoThreadClientReady( |
133 render_process_id, render_frame_id); | 134 render_process_id, render_frame_id); |
134 } | 135 } |
135 | 136 |
| 137 void OnMessageChannelCreated(ScopedJavaGlobalRef<jobject>* callback, |
| 138 int* port1, |
| 139 int* port2) { |
| 140 JNIEnv* env = AttachCurrentThread(); |
| 141 Java_AwContents_onMessageChannelCreated(env, *port1, *port2, |
| 142 callback->obj()); |
| 143 } |
| 144 |
| 145 void PostMessageToFrameOnIOThread(WebContents* web_contents, |
| 146 base::string16* source_origin, |
| 147 base::string16* target_origin, |
| 148 base::string16* data, |
| 149 std::vector<int>* ports) { |
| 150 content::MessagePortProvider::PostMessageToFrame(web_contents, |
| 151 *source_origin, *target_origin, *data, *ports); |
| 152 } |
| 153 |
136 } // namespace | 154 } // namespace |
137 | 155 |
138 // static | 156 // static |
139 AwContents* AwContents::FromWebContents(WebContents* web_contents) { | 157 AwContents* AwContents::FromWebContents(WebContents* web_contents) { |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 return AwContentsUserData::GetContents(web_contents); | 159 return AwContentsUserData::GetContents(web_contents); |
142 } | 160 } |
143 | 161 |
144 // static | 162 // static |
145 AwContents* AwContents::FromID(int render_process_id, int render_view_id) { | 163 AwContents* AwContents::FromID(int render_process_id, int render_view_id) { |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 } | 1067 } |
1050 | 1068 |
1051 void AwContents::TrimMemory(JNIEnv* env, | 1069 void AwContents::TrimMemory(JNIEnv* env, |
1052 jobject obj, | 1070 jobject obj, |
1053 jint level, | 1071 jint level, |
1054 jboolean visible) { | 1072 jboolean visible) { |
1055 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1073 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1056 browser_view_renderer_.TrimMemory(level, visible); | 1074 browser_view_renderer_.TrimMemory(level, visible); |
1057 } | 1075 } |
1058 | 1076 |
| 1077 // TODO(sgurun) add support for posting a frame whose name is known (only |
| 1078 // main frame is supported at this time, see crbug.com/389721) |
| 1079 void AwContents::PostMessageToFrame(JNIEnv* env, jobject obj, |
| 1080 jstring frame_name, jstring message, jstring source_origin, |
| 1081 jstring target_origin, jintArray msgPorts) { |
| 1082 |
| 1083 base::string16* j_source_origin = new base::string16; |
| 1084 ConvertJavaStringToUTF16(env, source_origin, j_source_origin); |
| 1085 base::string16* j_target_origin = new base::string16; |
| 1086 ConvertJavaStringToUTF16(env, target_origin, j_target_origin); |
| 1087 base::string16* j_message = new base::string16; |
| 1088 ConvertJavaStringToUTF16(env, message, j_message); |
| 1089 std::vector<int>* j_ports = new std::vector<int>; |
| 1090 |
| 1091 if (msgPorts != nullptr) |
| 1092 base::android::JavaIntArrayToIntVector(env, msgPorts, j_ports); |
| 1093 |
| 1094 BrowserThread::PostTask( |
| 1095 BrowserThread::IO, |
| 1096 FROM_HERE, |
| 1097 base::Bind(&PostMessageToFrameOnIOThread, |
| 1098 web_contents_.get(), |
| 1099 base::Owned(j_source_origin), |
| 1100 base::Owned(j_target_origin), |
| 1101 base::Owned(j_message), |
| 1102 base::Owned(j_ports))); |
| 1103 } |
| 1104 |
| 1105 void AwContents::CreateMessageChannel(JNIEnv* env, jobject obj, |
| 1106 jobject callback) { |
| 1107 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| 1108 j_callback->Reset(env, callback); |
| 1109 |
| 1110 int* port1 = new int; |
| 1111 int* port2 = new int; |
| 1112 BrowserThread::PostTaskAndReply( |
| 1113 BrowserThread::IO, |
| 1114 FROM_HERE, |
| 1115 base::Bind(&content::MessagePortProvider::CreateMessageChannel, |
| 1116 web_contents_.get(), |
| 1117 port1, |
| 1118 port2), |
| 1119 base::Bind(&OnMessageChannelCreated, |
| 1120 base::Owned(j_callback), |
| 1121 base::Owned(port1), |
| 1122 base::Owned(port2))); |
| 1123 } |
| 1124 |
| 1125 |
1059 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1126 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1060 g_should_download_favicons = true; | 1127 g_should_download_favicons = true; |
1061 } | 1128 } |
1062 | 1129 |
1063 } // namespace android_webview | 1130 } // namespace android_webview |
OLD | NEW |