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
3 // found in the LICENSE file.
5 #include "android_webview/native/aw_contents.h"
9 #include "android_webview/browser/aw_browser_context.h"
10 #include "android_webview/browser/aw_browser_main_parts.h"
11 #include "android_webview/browser/aw_resource_context.h"
12 #include "android_webview/browser/browser_view_renderer.h"
13 #include "android_webview/browser/deferred_gpu_command_service.h"
14 #include "android_webview/browser/net_disk_cache_remover.h"
15 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
16 #include "android_webview/browser/scoped_app_gl_state_restore.h"
17 #include "android_webview/browser/shared_renderer_state.h"
18 #include "android_webview/common/aw_hit_test_data.h"
19 #include "android_webview/common/devtools_instrumentation.h"
20 #include "android_webview/native/aw_autofill_client.h"
21 #include "android_webview/native/aw_browser_dependency_factory.h"
22 #include "android_webview/native/aw_contents_client_bridge.h"
23 #include "android_webview/native/aw_contents_io_thread_client_impl.h"
24 #include "android_webview/native/aw_message_port_service_impl.h"
25 #include "android_webview/native/aw_pdf_exporter.h"
26 #include "android_webview/native/aw_picture.h"
27 #include "android_webview/native/aw_web_contents_delegate.h"
28 #include "android_webview/native/java_browser_view_renderer_helper.h"
29 #include "android_webview/native/permission/aw_permission_request.h"
30 #include "android_webview/native/permission/permission_request_handler.h"
31 #include "android_webview/native/permission/simple_permission_request.h"
32 #include "android_webview/native/state_serializer.h"
33 #include "android_webview/public/browser/draw_gl.h"
34 #include "base/android/jni_android.h"
35 #include "base/android/jni_array.h"
36 #include "base/android/jni_string.h"
37 #include "base/android/locale_utils.h"
38 #include "base/android/scoped_java_ref.h"
39 #include "base/atomicops.h"
40 #include "base/bind.h"
41 #include "base/callback.h"
42 #include "base/command_line.h"
43 #include "base/memory/memory_pressure_listener.h"
44 #include "base/message_loop/message_loop.h"
45 #include "base/pickle.h"
46 #include "base/strings/string16.h"
47 #include "base/supports_user_data.h"
48 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
49 #include "components/autofill/core/browser/autofill_manager.h"
50 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
51 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
52 #include "components/navigation_interception/intercept_navigation_delegate.h"
53 #include "content/public/browser/android/content_view_core.h"
54 #include "content/public/browser/android/synchronous_compositor.h"
55 #include "content/public/browser/browser_thread.h"
56 #include "content/public/browser/cert_store.h"
57 #include "content/public/browser/child_process_security_policy.h"
58 #include "content/public/browser/favicon_status.h"
59 #include "content/public/browser/message_port_provider.h"
60 #include "content/public/browser/navigation_entry.h"
61 #include "content/public/browser/render_frame_host.h"
62 #include "content/public/browser/render_process_host.h"
63 #include "content/public/browser/render_view_host.h"
64 #include "content/public/browser/web_contents.h"
65 #include "content/public/common/content_switches.h"
66 #include "content/public/common/message_port_types.h"
67 #include "content/public/common/renderer_preferences.h"
68 #include "content/public/common/ssl_status.h"
69 #include "jni/AwContents_jni.h"
70 #include "net/base/auth.h"
71 #include "net/cert/x509_certificate.h"
72 #include "third_party/skia/include/core/SkPicture.h"
73 #include "ui/gfx/android/java_bitmap.h"
74 #include "ui/gfx/geometry/rect_f.h"
75 #include "ui/gfx/geometry/size.h"
76 #include "ui/gfx/image/image.h"
78 struct AwDrawSWFunctionTable
;
80 using autofill::ContentAutofillDriverFactory
;
81 using autofill::AutofillManager
;
82 using base::android::AttachCurrentThread
;
83 using base::android::ConvertJavaStringToUTF16
;
84 using base::android::ConvertJavaStringToUTF8
;
85 using base::android::ConvertUTF16ToJavaString
;
86 using base::android::ConvertUTF8ToJavaString
;
87 using base::android::JavaRef
;
88 using base::android::ScopedJavaGlobalRef
;
89 using base::android::ScopedJavaLocalRef
;
90 using data_reduction_proxy::DataReductionProxySettings
;
91 using navigation_interception::InterceptNavigationDelegate
;
92 using content::BrowserThread
;
93 using content::ContentViewCore
;
94 using content::WebContents
;
97 static AwDrawGLFunction DrawGLFunction
;
98 static void DrawGLFunction(long view_context
,
99 AwDrawGLInfo
* draw_info
,
101 // |view_context| is the value that was returned from the java
102 // AwContents.onPrepareDrawGL; this cast must match the code there.
103 reinterpret_cast<android_webview::SharedRendererState
*>(view_context
)
108 namespace android_webview
{
112 bool g_should_download_favicons
= false;
114 bool g_force_auxiliary_bitmap_rendering
= false;
116 std::string g_locale
;
118 const void* kAwContentsUserDataKey
= &kAwContentsUserDataKey
;
120 class AwContentsUserData
: public base::SupportsUserData::Data
{
122 explicit AwContentsUserData(AwContents
* ptr
) : contents_(ptr
) {}
124 static AwContents
* GetContents(WebContents
* web_contents
) {
127 AwContentsUserData
* data
= static_cast<AwContentsUserData
*>(
128 web_contents
->GetUserData(kAwContentsUserDataKey
));
129 return data
? data
->contents_
: NULL
;
133 AwContents
* contents_
;
136 base::subtle::Atomic32 g_instance_count
= 0;
138 void OnIoThreadClientReady(content::RenderFrameHost
* rfh
) {
139 int render_process_id
= rfh
->GetProcess()->GetID();
140 int render_frame_id
= rfh
->GetRoutingID();
141 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(
142 render_process_id
, render_frame_id
);
148 AwContents
* AwContents::FromWebContents(WebContents
* web_contents
) {
149 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
150 return AwContentsUserData::GetContents(web_contents
);
154 AwContents
* AwContents::FromID(int render_process_id
, int render_view_id
) {
155 const content::RenderViewHost
* rvh
=
156 content::RenderViewHost::FromID(render_process_id
, render_view_id
);
157 if (!rvh
) return NULL
;
158 content::WebContents
* web_contents
=
159 content::WebContents::FromRenderViewHost(rvh
);
160 if (!web_contents
) return NULL
;
161 return FromWebContents(web_contents
);
165 void SetLocale(JNIEnv
* env
,
166 const JavaParamRef
<jclass
>&,
167 const JavaParamRef
<jstring
>& locale
) {
168 g_locale
= ConvertJavaStringToUTF8(env
, locale
);
172 std::string
AwContents::GetLocale() {
177 AwBrowserPermissionRequestDelegate
* AwBrowserPermissionRequestDelegate::FromID(
178 int render_process_id
, int render_frame_id
) {
179 AwContents
* aw_contents
= AwContents::FromWebContents(
180 content::WebContents::FromRenderFrameHost(
181 content::RenderFrameHost::FromID(render_process_id
,
186 AwContents::AwContents(scoped_ptr
<WebContents
> web_contents
)
187 : web_contents_(web_contents
.Pass()),
188 browser_view_renderer_(
190 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI
)),
191 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) {
192 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count
, 1);
193 icon_helper_
.reset(new IconHelper(web_contents_
.get()));
194 icon_helper_
->SetListener(this);
195 web_contents_
->SetUserData(android_webview::kAwContentsUserDataKey
,
196 new AwContentsUserData(this));
197 browser_view_renderer_
.RegisterWithWebContents(web_contents_
.get());
198 render_view_host_ext_
.reset(
199 new AwRenderViewHostExt(this, web_contents_
.get()));
201 permission_request_handler_
.reset(
202 new PermissionRequestHandler(this, web_contents_
.get()));
204 AwAutofillClient
* autofill_manager_delegate
=
205 AwAutofillClient::FromWebContents(web_contents_
.get());
206 if (autofill_manager_delegate
)
207 InitAutofillIfNecessary(autofill_manager_delegate
->GetSaveFormData());
208 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
209 switches::kSingleProcess
)) {
210 // TODO(boliu): Figure out how to deal with this more nicely.
211 content::SynchronousCompositor::SetClientForWebContents(
212 web_contents_
.get(), &browser_view_renderer_
);
216 void AwContents::SetJavaPeers(JNIEnv
* env
,
219 jobject web_contents_delegate
,
220 jobject contents_client_bridge
,
221 jobject io_thread_client
,
222 jobject intercept_navigation_delegate
) {
223 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
224 // The |aw_content| param is technically spurious as it duplicates |obj| but
225 // is passed over anyway to make the binding more explicit.
226 java_ref_
= JavaObjectWeakGlobalRef(env
, aw_contents
);
228 web_contents_delegate_
.reset(
229 new AwWebContentsDelegate(env
, web_contents_delegate
));
230 web_contents_
->SetDelegate(web_contents_delegate_
.get());
232 contents_client_bridge_
.reset(
233 new AwContentsClientBridge(env
, contents_client_bridge
));
234 AwContentsClientBridgeBase::Associate(web_contents_
.get(),
235 contents_client_bridge_
.get());
237 AwContentsIoThreadClientImpl::Associate(
238 web_contents_
.get(), ScopedJavaLocalRef
<jobject
>(env
, io_thread_client
));
240 InterceptNavigationDelegate::Associate(
242 make_scoped_ptr(new InterceptNavigationDelegate(
243 env
, intercept_navigation_delegate
)));
245 // Finally, having setup the associations, release any deferred requests
246 web_contents_
->ForEachFrame(base::Bind(&OnIoThreadClientReady
));
249 void AwContents::SetSaveFormData(bool enabled
) {
250 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
251 InitAutofillIfNecessary(enabled
);
252 // We need to check for the existence, since autofill_manager_delegate
253 // may not be created when the setting is false.
254 if (AwAutofillClient::FromWebContents(web_contents_
.get())) {
255 AwAutofillClient::FromWebContents(web_contents_
.get())->
256 SetSaveFormData(enabled
);
260 void AwContents::InitAutofillIfNecessary(bool enabled
) {
261 // Do not initialize if the feature is not enabled.
264 // Check if the autofill driver factory already exists.
265 content::WebContents
* web_contents
= web_contents_
.get();
266 if (ContentAutofillDriverFactory::FromWebContents(web_contents
))
269 AwAutofillClient::CreateForWebContents(web_contents
);
270 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
271 web_contents
, AwAutofillClient::FromWebContents(web_contents
),
272 base::android::GetDefaultLocale(),
273 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER
);
276 void AwContents::SetAwAutofillClient(jobject client
) {
277 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
278 JNIEnv
* env
= AttachCurrentThread();
279 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
282 Java_AwContents_setAwAutofillClient(env
, obj
.obj(), client
);
285 AwContents::~AwContents() {
286 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_
.get()));
287 content::SynchronousCompositor::SetClientForWebContents(web_contents_
.get(),
289 web_contents_
->RemoveUserData(kAwContentsUserDataKey
);
290 if (find_helper_
.get())
291 find_helper_
->SetListener(NULL
);
292 if (icon_helper_
.get())
293 icon_helper_
->SetListener(NULL
);
294 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count
, -1);
295 // When the last WebView is destroyed free all discardable memory allocated by
296 // Chromium, because the app process may continue to run for a long time
297 // without ever using another WebView.
298 if (base::subtle::NoBarrier_Load(&g_instance_count
) == 0) {
299 base::MemoryPressureListener::NotifyMemoryPressure(
300 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL
);
304 base::android::ScopedJavaLocalRef
<jobject
>
305 AwContents::GetWebContents(JNIEnv
* env
, jobject obj
) {
306 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
307 DCHECK(web_contents_
);
309 return base::android::ScopedJavaLocalRef
<jobject
>();
311 return web_contents_
->GetJavaWebContents();
314 void AwContents::Destroy(JNIEnv
* env
, jobject obj
) {
319 static jlong
Init(JNIEnv
* env
,
320 const JavaParamRef
<jclass
>&,
321 const JavaParamRef
<jobject
>& browser_context
) {
322 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather
323 // than hard-code the default instance lookup here.
324 scoped_ptr
<WebContents
> web_contents(content::WebContents::Create(
325 content::WebContents::CreateParams(AwBrowserContext::GetDefault())));
326 // Return an 'uninitialized' instance; most work is deferred until the
327 // subsequent SetJavaPeers() call.
328 return reinterpret_cast<intptr_t>(new AwContents(web_contents
.Pass()));
331 static void SetForceAuxiliaryBitmapRendering(
333 const JavaParamRef
<jclass
>&,
334 jboolean force_auxiliary_bitmap_rendering
) {
335 g_force_auxiliary_bitmap_rendering
= force_auxiliary_bitmap_rendering
;
338 static void SetAwDrawSWFunctionTable(JNIEnv
* env
,
339 const JavaParamRef
<jclass
>&,
340 jlong function_table
) {
341 RasterHelperSetAwDrawSWFunctionTable(
342 reinterpret_cast<AwDrawSWFunctionTable
*>(function_table
));
345 static void SetAwDrawGLFunctionTable(JNIEnv
* env
,
346 const JavaParamRef
<jclass
>&,
347 jlong function_table
) {}
349 static jlong
GetAwDrawGLFunction(JNIEnv
* env
, const JavaParamRef
<jclass
>&) {
350 return reinterpret_cast<intptr_t>(&DrawGLFunction
);
354 jint
GetNativeInstanceCount(JNIEnv
* env
, const JavaParamRef
<jclass
>&) {
355 return base::subtle::NoBarrier_Load(&g_instance_count
);
358 jlong
AwContents::GetAwDrawGLViewContext(JNIEnv
* env
, jobject obj
) {
359 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
360 return reinterpret_cast<intptr_t>(
361 browser_view_renderer_
.GetAwDrawGLViewContext());
365 void DocumentHasImagesCallback(const ScopedJavaGlobalRef
<jobject
>& message
,
367 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(),
373 void AwContents::DocumentHasImages(JNIEnv
* env
, jobject obj
, jobject message
) {
374 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
375 ScopedJavaGlobalRef
<jobject
> j_message
;
376 j_message
.Reset(env
, message
);
377 render_view_host_ext_
->DocumentHasImages(
378 base::Bind(&DocumentHasImagesCallback
, j_message
));
382 void GenerateMHTMLCallback(ScopedJavaGlobalRef
<jobject
>* callback
,
383 const base::FilePath
& path
, int64 size
) {
384 JNIEnv
* env
= AttachCurrentThread();
385 // Android files are UTF8, so the path conversion below is safe.
386 Java_AwContents_generateMHTMLCallback(
388 ConvertUTF8ToJavaString(env
, path
.AsUTF8Unsafe()).obj(),
389 size
, callback
->obj());
393 void AwContents::GenerateMHTML(JNIEnv
* env
, jobject obj
,
394 jstring jpath
, jobject callback
) {
395 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
396 ScopedJavaGlobalRef
<jobject
>* j_callback
= new ScopedJavaGlobalRef
<jobject
>();
397 j_callback
->Reset(env
, callback
);
398 base::FilePath
target_path(ConvertJavaStringToUTF8(env
, jpath
));
399 web_contents_
->GenerateMHTML(
401 base::Bind(&GenerateMHTMLCallback
, base::Owned(j_callback
), target_path
));
404 void AwContents::CreatePdfExporter(JNIEnv
* env
,
406 jobject pdfExporter
) {
408 new AwPdfExporter(env
,
410 web_contents_
.get()));
413 bool AwContents::OnReceivedHttpAuthRequest(const JavaRef
<jobject
>& handler
,
414 const std::string
& host
,
415 const std::string
& realm
) {
416 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
417 JNIEnv
* env
= AttachCurrentThread();
418 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
422 ScopedJavaLocalRef
<jstring
> jhost
= ConvertUTF8ToJavaString(env
, host
);
423 ScopedJavaLocalRef
<jstring
> jrealm
= ConvertUTF8ToJavaString(env
, realm
);
424 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
425 "onReceivedHttpAuthRequest");
426 Java_AwContents_onReceivedHttpAuthRequest(env
, obj
.obj(), handler
.obj(),
427 jhost
.obj(), jrealm
.obj());
431 void AwContents::SetOffscreenPreRaster(bool enabled
) {
432 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
433 browser_view_renderer_
.SetOffscreenPreRaster(enabled
);
436 void AwContents::AddVisitedLinks(JNIEnv
* env
,
438 jobjectArray jvisited_links
) {
439 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
440 std::vector
<base::string16
> visited_link_strings
;
441 base::android::AppendJavaStringArrayToStringVector(
442 env
, jvisited_links
, &visited_link_strings
);
444 std::vector
<GURL
> visited_link_gurls
;
445 std::vector
<base::string16
>::const_iterator itr
;
446 for (itr
= visited_link_strings
.begin(); itr
!= visited_link_strings
.end();
448 visited_link_gurls
.push_back(GURL(*itr
));
451 AwBrowserContext::FromWebContents(web_contents_
.get())
452 ->AddVisitedURLs(visited_link_gurls
);
455 bool RegisterAwContents(JNIEnv
* env
) {
456 return RegisterNativesImpl(env
);
461 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef
& java_ref
,
462 const GURL
& origin
) {
463 JNIEnv
* env
= AttachCurrentThread();
464 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref
.get(env
);
466 ScopedJavaLocalRef
<jstring
> j_origin(
467 ConvertUTF8ToJavaString(env
, origin
.spec()));
468 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
469 "onGeolocationPermissionsShowPrompt");
470 Java_AwContents_onGeolocationPermissionsShowPrompt(env
,
476 void ShowGeolocationPromptHelper(const JavaObjectWeakGlobalRef
& java_ref
,
477 const GURL
& origin
) {
478 JNIEnv
* env
= AttachCurrentThread();
479 if (java_ref
.get(env
).obj()) {
480 content::BrowserThread::PostTask(
481 content::BrowserThread::UI
,
483 base::Bind(&ShowGeolocationPromptHelperTask
,
489 } // anonymous namespace
491 void AwContents::ShowGeolocationPrompt(const GURL
& requesting_frame
,
492 base::Callback
<void(bool)> callback
) {
493 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
495 GURL origin
= requesting_frame
.GetOrigin();
496 bool show_prompt
= pending_geolocation_prompts_
.empty();
497 pending_geolocation_prompts_
.push_back(OriginCallback(origin
, callback
));
499 ShowGeolocationPromptHelper(java_ref_
, origin
);
504 void AwContents::InvokeGeolocationCallback(JNIEnv
* env
,
508 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
509 if (pending_geolocation_prompts_
.empty())
512 GURL
callback_origin(base::android::ConvertJavaStringToUTF16(env
, origin
));
513 if (callback_origin
.GetOrigin() ==
514 pending_geolocation_prompts_
.front().first
) {
515 pending_geolocation_prompts_
.front().second
.Run(value
);
516 pending_geolocation_prompts_
.pop_front();
517 if (!pending_geolocation_prompts_
.empty()) {
518 ShowGeolocationPromptHelper(java_ref_
,
519 pending_geolocation_prompts_
.front().first
);
524 void AwContents::HideGeolocationPrompt(const GURL
& origin
) {
525 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
526 bool removed_current_outstanding_callback
= false;
527 std::list
<OriginCallback
>::iterator it
= pending_geolocation_prompts_
.begin();
528 while (it
!= pending_geolocation_prompts_
.end()) {
529 if ((*it
).first
== origin
.GetOrigin()) {
530 if (it
== pending_geolocation_prompts_
.begin()) {
531 removed_current_outstanding_callback
= true;
533 it
= pending_geolocation_prompts_
.erase(it
);
539 if (removed_current_outstanding_callback
) {
540 JNIEnv
* env
= AttachCurrentThread();
541 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
543 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
544 "onGeolocationPermissionsHidePrompt");
545 Java_AwContents_onGeolocationPermissionsHidePrompt(env
, j_ref
.obj());
547 if (!pending_geolocation_prompts_
.empty()) {
548 ShowGeolocationPromptHelper(java_ref_
,
549 pending_geolocation_prompts_
.front().first
);
554 void AwContents::OnPermissionRequest(
555 base::android::ScopedJavaLocalRef
<jobject
> j_request
,
556 AwPermissionRequest
* request
) {
557 DCHECK(!j_request
.is_null());
560 JNIEnv
* env
= AttachCurrentThread();
561 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
562 if (j_ref
.is_null()) {
563 permission_request_handler_
->CancelRequest(request
->GetOrigin(),
564 request
->GetResources());
568 Java_AwContents_onPermissionRequest(env
, j_ref
.obj(), j_request
.obj());
571 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest
* request
) {
572 JNIEnv
* env
= AttachCurrentThread();
573 ScopedJavaLocalRef
<jobject
> j_request
= request
->GetJavaObject();
574 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
575 if (j_request
.is_null() || j_ref
.is_null())
578 Java_AwContents_onPermissionRequestCanceled(
579 env
, j_ref
.obj(), j_request
.obj());
582 void AwContents::PreauthorizePermission(
587 permission_request_handler_
->PreauthorizePermission(
588 GURL(base::android::ConvertJavaStringToUTF8(env
, origin
)), resources
);
591 void AwContents::RequestProtectedMediaIdentifierPermission(
593 const base::Callback
<void(bool)>& callback
) {
594 permission_request_handler_
->SendRequest(
595 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
596 origin
, AwPermissionRequest::ProtectedMediaId
, callback
)));
599 void AwContents::CancelProtectedMediaIdentifierPermissionRequests(
600 const GURL
& origin
) {
601 permission_request_handler_
->CancelRequest(
602 origin
, AwPermissionRequest::ProtectedMediaId
);
605 void AwContents::RequestGeolocationPermission(
607 const base::Callback
<void(bool)>& callback
) {
608 JNIEnv
* env
= AttachCurrentThread();
609 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
613 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env
, obj
.obj())) {
614 ShowGeolocationPrompt(origin
, callback
);
617 permission_request_handler_
->SendRequest(
618 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
619 origin
, AwPermissionRequest::Geolocation
, callback
)));
622 void AwContents::CancelGeolocationPermissionRequests(const GURL
& origin
) {
623 JNIEnv
* env
= AttachCurrentThread();
624 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
628 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env
, obj
.obj())) {
629 HideGeolocationPrompt(origin
);
632 permission_request_handler_
->CancelRequest(
633 origin
, AwPermissionRequest::Geolocation
);
636 void AwContents::RequestMIDISysexPermission(
638 const base::Callback
<void(bool)>& callback
) {
639 permission_request_handler_
->SendRequest(
640 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
641 origin
, AwPermissionRequest::MIDISysex
, callback
)));
644 void AwContents::CancelMIDISysexPermissionRequests(const GURL
& origin
) {
645 permission_request_handler_
->CancelRequest(
646 origin
, AwPermissionRequest::AwPermissionRequest::MIDISysex
);
649 void AwContents::FindAllAsync(JNIEnv
* env
, jobject obj
, jstring search_string
) {
650 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
651 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env
, search_string
));
654 void AwContents::FindNext(JNIEnv
* env
, jobject obj
, jboolean forward
) {
655 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
656 GetFindHelper()->FindNext(forward
);
659 void AwContents::ClearMatches(JNIEnv
* env
, jobject obj
) {
660 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
661 GetFindHelper()->ClearMatches();
664 void AwContents::ClearCache(
667 jboolean include_disk_files
) {
668 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
669 render_view_host_ext_
->ClearCache();
671 if (include_disk_files
) {
672 RemoveHttpDiskCache(web_contents_
->GetBrowserContext(),
673 web_contents_
->GetRoutingID());
677 FindHelper
* AwContents::GetFindHelper() {
678 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
679 if (!find_helper_
.get()) {
680 find_helper_
.reset(new FindHelper(web_contents_
.get()));
681 find_helper_
->SetListener(this);
683 return find_helper_
.get();
686 void AwContents::OnFindResultReceived(int active_ordinal
,
689 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
690 JNIEnv
* env
= AttachCurrentThread();
691 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
695 Java_AwContents_onFindResultReceived(
696 env
, obj
.obj(), active_ordinal
, match_count
, finished
);
699 bool AwContents::ShouldDownloadFavicon(const GURL
& icon_url
) {
700 return g_should_download_favicons
;
703 void AwContents::OnReceivedIcon(const GURL
& icon_url
, const SkBitmap
& bitmap
) {
704 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
705 JNIEnv
* env
= AttachCurrentThread();
706 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
710 content::NavigationEntry
* entry
=
711 web_contents_
->GetController().GetLastCommittedEntry();
714 entry
->GetFavicon().valid
= true;
715 entry
->GetFavicon().url
= icon_url
;
716 entry
->GetFavicon().image
= gfx::Image::CreateFrom1xBitmap(bitmap
);
719 Java_AwContents_onReceivedIcon(
720 env
, obj
.obj(), gfx::ConvertToJavaBitmap(&bitmap
).obj());
723 void AwContents::OnReceivedTouchIconUrl(const std::string
& url
,
725 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
726 JNIEnv
* env
= AttachCurrentThread();
727 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
731 Java_AwContents_onReceivedTouchIconUrl(
732 env
, obj
.obj(), ConvertUTF8ToJavaString(env
, url
).obj(), precomposed
);
735 bool AwContents::RequestDrawGL(bool wait_for_completion
) {
736 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
737 JNIEnv
* env
= AttachCurrentThread();
738 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
741 return Java_AwContents_requestDrawGL(env
, obj
.obj(), wait_for_completion
);
744 void AwContents::PostInvalidate() {
745 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
746 JNIEnv
* env
= AttachCurrentThread();
747 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
749 Java_AwContents_postInvalidateOnAnimation(env
, obj
.obj());
752 void AwContents::OnNewPicture() {
753 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
754 JNIEnv
* env
= AttachCurrentThread();
755 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
756 if (!obj
.is_null()) {
757 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
759 Java_AwContents_onNewPicture(env
, obj
.obj());
763 base::android::ScopedJavaLocalRef
<jbyteArray
> AwContents::GetCertificate(
766 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
767 content::NavigationEntry
* entry
=
768 web_contents_
->GetController().GetLastCommittedEntry();
770 return ScopedJavaLocalRef
<jbyteArray
>();
771 // Get the certificate
772 int cert_id
= entry
->GetSSL().cert_id
;
773 scoped_refptr
<net::X509Certificate
> cert
;
774 bool ok
= content::CertStore::GetInstance()->RetrieveCert(cert_id
, &cert
);
776 return ScopedJavaLocalRef
<jbyteArray
>();
778 // Convert the certificate and return it
779 std::string der_string
;
780 net::X509Certificate::GetDEREncoded(cert
->os_cert_handle(), &der_string
);
781 return base::android::ToJavaByteArray(env
,
782 reinterpret_cast<const uint8
*>(der_string
.data()), der_string
.length());
785 void AwContents::RequestNewHitTestDataAt(JNIEnv
* env
,
789 jfloat touch_major
) {
790 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
791 gfx::PointF
touch_center(x
, y
);
792 gfx::SizeF
touch_area(touch_major
, touch_major
);
793 render_view_host_ext_
->RequestNewHitTestDataAt(touch_center
, touch_area
);
796 void AwContents::UpdateLastHitTestData(JNIEnv
* env
, jobject obj
) {
797 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
798 if (!render_view_host_ext_
->HasNewHitTestData()) return;
800 const AwHitTestData
& data
= render_view_host_ext_
->GetLastHitTestData();
801 render_view_host_ext_
->MarkHitTestDataRead();
803 // Make sure to null the Java object if data is empty/invalid.
804 ScopedJavaLocalRef
<jstring
> extra_data_for_type
;
805 if (data
.extra_data_for_type
.length())
806 extra_data_for_type
= ConvertUTF8ToJavaString(
807 env
, data
.extra_data_for_type
);
809 ScopedJavaLocalRef
<jstring
> href
;
810 if (data
.href
.length())
811 href
= ConvertUTF16ToJavaString(env
, data
.href
);
813 ScopedJavaLocalRef
<jstring
> anchor_text
;
814 if (data
.anchor_text
.length())
815 anchor_text
= ConvertUTF16ToJavaString(env
, data
.anchor_text
);
817 ScopedJavaLocalRef
<jstring
> img_src
;
818 if (data
.img_src
.is_valid())
819 img_src
= ConvertUTF8ToJavaString(env
, data
.img_src
.spec());
821 Java_AwContents_updateHitTestData(env
,
824 extra_data_for_type
.obj(),
830 void AwContents::OnSizeChanged(JNIEnv
* env
, jobject obj
,
831 int w
, int h
, int ow
, int oh
) {
832 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
833 browser_view_renderer_
.OnSizeChanged(w
, h
);
836 void AwContents::SetViewVisibility(JNIEnv
* env
, jobject obj
, bool visible
) {
837 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
838 browser_view_renderer_
.SetViewVisibility(visible
);
841 void AwContents::SetWindowVisibility(JNIEnv
* env
, jobject obj
, bool visible
) {
842 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
843 browser_view_renderer_
.SetWindowVisibility(visible
);
846 void AwContents::SetIsPaused(JNIEnv
* env
, jobject obj
, bool paused
) {
847 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
848 browser_view_renderer_
.SetIsPaused(paused
);
849 ContentViewCore
* cvc
=
850 ContentViewCore::FromWebContents(web_contents_
.get());
852 cvc
->PauseOrResumeGeolocation(paused
);
856 void AwContents::OnAttachedToWindow(JNIEnv
* env
, jobject obj
, int w
, int h
) {
857 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
858 browser_view_renderer_
.OnAttachedToWindow(w
, h
);
861 void AwContents::OnDetachedFromWindow(JNIEnv
* env
, jobject obj
) {
862 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
863 browser_view_renderer_
.OnDetachedFromWindow();
866 void AwContents::DetachFunctorFromView() {
867 JNIEnv
* env
= AttachCurrentThread();
868 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
870 Java_AwContents_detachFunctorFromView(env
, obj
.obj());
873 base::android::ScopedJavaLocalRef
<jbyteArray
>
874 AwContents::GetOpaqueState(JNIEnv
* env
, jobject obj
) {
875 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
876 // Required optimization in WebViewClassic to not save any state if
877 // there has been no navigations.
878 if (!web_contents_
->GetController().GetEntryCount())
879 return ScopedJavaLocalRef
<jbyteArray
>();
882 if (!WriteToPickle(*web_contents_
, &pickle
)) {
883 return ScopedJavaLocalRef
<jbyteArray
>();
885 return base::android::ToJavaByteArray(env
,
886 reinterpret_cast<const uint8
*>(pickle
.data()), pickle
.size());
890 jboolean
AwContents::RestoreFromOpaqueState(
891 JNIEnv
* env
, jobject obj
, jbyteArray state
) {
892 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
893 // TODO(boliu): This copy can be optimized out if this is a performance
895 std::vector
<uint8
> state_vector
;
896 base::android::JavaByteArrayToByteVector(env
, state
, &state_vector
);
898 base::Pickle
pickle(reinterpret_cast<const char*>(state_vector
.data()),
899 state_vector
.size());
900 base::PickleIterator
iterator(pickle
);
902 return RestoreFromPickle(&iterator
, web_contents_
.get());
905 bool AwContents::OnDraw(JNIEnv
* env
,
908 jboolean is_hardware_accelerated
,
914 jint visible_bottom
) {
915 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
916 gfx::Vector2d
scroll(scroll_x
, scroll_y
);
917 browser_view_renderer_
.PrepareToDraw(
918 scroll
, gfx::Rect(visible_left
, visible_top
, visible_right
- visible_left
,
919 visible_bottom
- visible_top
));
920 if (is_hardware_accelerated
&& browser_view_renderer_
.attached_to_window() &&
921 !g_force_auxiliary_bitmap_rendering
) {
922 return browser_view_renderer_
.OnDrawHardware();
925 gfx::Size view_size
= browser_view_renderer_
.size();
926 if (view_size
.IsEmpty()) {
927 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_EmptySize",
928 TRACE_EVENT_SCOPE_THREAD
);
932 // TODO(hush): Right now webview size is passed in as the auxiliary bitmap
933 // size, which might hurt performace (only for software draws with auxiliary
934 // bitmap). For better performance, get global visible rect, transform it
935 // from screen space to view space, then intersect with the webview in
936 // viewspace. Use the resulting rect as the auxiliary bitmap.
937 scoped_ptr
<SoftwareCanvasHolder
> canvas_holder
= SoftwareCanvasHolder::Create(
938 canvas
, scroll
, view_size
, g_force_auxiliary_bitmap_rendering
);
939 if (!canvas_holder
|| !canvas_holder
->GetCanvas()) {
940 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_NoSoftwareCanvas",
941 TRACE_EVENT_SCOPE_THREAD
);
944 return browser_view_renderer_
.OnDrawSoftware(canvas_holder
->GetCanvas());
947 void AwContents::SetPendingWebContentsForPopup(
948 scoped_ptr
<content::WebContents
> pending
) {
949 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
950 if (pending_contents_
.get()) {
951 // TODO(benm): Support holding multiple pop up window requests.
952 LOG(WARNING
) << "Blocking popup window creation as an outstanding "
953 << "popup window is still pending.";
954 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, pending
.release());
957 pending_contents_
.reset(new AwContents(pending
.Pass()));
958 // Set dip_scale for pending contents, which is necessary for the later
959 // SynchronousCompositor and InputHandler setup.
960 pending_contents_
->SetDipScaleInternal(browser_view_renderer_
.dip_scale());
963 void AwContents::FocusFirstNode(JNIEnv
* env
, jobject obj
) {
964 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
965 web_contents_
->FocusThroughTabTraversal(false);
968 void AwContents::SetBackgroundColor(JNIEnv
* env
, jobject obj
, jint color
) {
969 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
970 render_view_host_ext_
->SetBackgroundColor(color
);
973 void AwContents::OnComputeScroll(JNIEnv
* env
,
975 jlong animation_time_millis
) {
976 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
977 browser_view_renderer_
.OnComputeScroll(
979 base::TimeDelta::FromMilliseconds(animation_time_millis
));
982 jlong
AwContents::ReleasePopupAwContents(JNIEnv
* env
, jobject obj
) {
983 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
984 return reinterpret_cast<intptr_t>(pending_contents_
.release());
987 gfx::Point
AwContents::GetLocationOnScreen() {
988 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
989 JNIEnv
* env
= AttachCurrentThread();
990 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
993 std::vector
<int> location
;
994 base::android::JavaIntArrayToIntVector(
996 Java_AwContents_getLocationOnScreen(env
, obj
.obj()).obj(),
998 return gfx::Point(location
[0], location
[1]);
1001 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value
) {
1002 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1003 JNIEnv
* env
= AttachCurrentThread();
1004 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1007 Java_AwContents_scrollContainerViewTo(
1008 env
, obj
.obj(), new_value
.x(), new_value
.y());
1011 void AwContents::UpdateScrollState(gfx::Vector2d max_scroll_offset
,
1012 gfx::SizeF contents_size_dip
,
1013 float page_scale_factor
,
1014 float min_page_scale_factor
,
1015 float max_page_scale_factor
) {
1016 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1017 JNIEnv
* env
= AttachCurrentThread();
1018 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1021 Java_AwContents_updateScrollState(env
,
1023 max_scroll_offset
.x(),
1024 max_scroll_offset
.y(),
1025 contents_size_dip
.width(),
1026 contents_size_dip
.height(),
1028 min_page_scale_factor
,
1029 max_page_scale_factor
);
1032 void AwContents::DidOverscroll(gfx::Vector2d overscroll_delta
,
1033 gfx::Vector2dF overscroll_velocity
) {
1034 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1035 JNIEnv
* env
= AttachCurrentThread();
1036 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1039 Java_AwContents_didOverscroll(env
, obj
.obj(), overscroll_delta
.x(),
1040 overscroll_delta
.y(), overscroll_velocity
.x(),
1041 overscroll_velocity
.y());
1044 void AwContents::SetDipScale(JNIEnv
* env
, jobject obj
, jfloat dip_scale
) {
1045 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1046 SetDipScaleInternal(dip_scale
);
1049 void AwContents::SetDipScaleInternal(float dip_scale
) {
1050 browser_view_renderer_
.SetDipScale(dip_scale
);
1053 void AwContents::ScrollTo(JNIEnv
* env
, jobject obj
, jint x
, jint y
) {
1054 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1055 browser_view_renderer_
.ScrollTo(gfx::Vector2d(x
, y
));
1058 void AwContents::SmoothScroll(JNIEnv
* env
,
1062 jlong duration_ms
) {
1063 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1065 float scale
= browser_view_renderer_
.dip_scale() *
1066 browser_view_renderer_
.page_scale_factor();
1067 render_view_host_ext_
->SmoothScroll(target_x
/ scale
, target_y
/ scale
,
1071 void AwContents::OnWebLayoutPageScaleFactorChanged(float page_scale_factor
) {
1072 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1073 JNIEnv
* env
= AttachCurrentThread();
1074 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1077 Java_AwContents_onWebLayoutPageScaleFactorChanged(env
, obj
.obj(),
1081 void AwContents::OnWebLayoutContentsSizeChanged(
1082 const gfx::Size
& contents_size
) {
1083 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1084 JNIEnv
* env
= AttachCurrentThread();
1085 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1088 Java_AwContents_onWebLayoutContentsSizeChanged(
1089 env
, obj
.obj(), contents_size
.width(), contents_size
.height());
1092 jlong
AwContents::CapturePicture(JNIEnv
* env
,
1096 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1097 return reinterpret_cast<intptr_t>(
1098 new AwPicture(browser_view_renderer_
.CapturePicture(width
, height
)));
1101 void AwContents::EnableOnNewPicture(JNIEnv
* env
,
1104 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1105 browser_view_renderer_
.EnableOnNewPicture(enabled
);
1109 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef
& java_ref
,
1111 ScopedJavaGlobalRef
<jobject
>* callback
,
1113 JNIEnv
* env
= AttachCurrentThread();
1114 ScopedJavaLocalRef
<jobject
> obj
= java_ref
.get(env
);
1117 Java_AwContents_invokeVisualStateCallback(
1118 env
, obj
.obj(), callback
->obj(), request_id
);
1122 void AwContents::InsertVisualStateCallback(
1123 JNIEnv
* env
, jobject obj
, long request_id
, jobject callback
) {
1124 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1125 ScopedJavaGlobalRef
<jobject
>* j_callback
= new ScopedJavaGlobalRef
<jobject
>();
1126 j_callback
->Reset(env
, callback
);
1127 web_contents_
->GetMainFrame()->InsertVisualStateCallback(
1128 base::Bind(&InvokeVisualStateCallback
, java_ref_
, request_id
,
1129 base::Owned(j_callback
)));
1132 void AwContents::ClearView(JNIEnv
* env
, jobject obj
) {
1133 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1134 browser_view_renderer_
.ClearView();
1137 void AwContents::SetExtraHeadersForUrl(JNIEnv
* env
, jobject obj
,
1138 jstring url
, jstring jextra_headers
) {
1139 std::string extra_headers
;
1141 extra_headers
= ConvertJavaStringToUTF8(env
, jextra_headers
);
1142 AwResourceContext
* resource_context
= static_cast<AwResourceContext
*>(
1143 AwBrowserContext::FromWebContents(web_contents_
.get())->
1144 GetResourceContext());
1145 resource_context
->SetExtraHeaders(GURL(ConvertJavaStringToUTF8(env
, url
)),
1149 void AwContents::SetJsOnlineProperty(JNIEnv
* env
,
1151 jboolean network_up
) {
1152 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1153 render_view_host_ext_
->SetJsOnlineProperty(network_up
);
1156 void AwContents::TrimMemory(JNIEnv
* env
,
1160 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1161 browser_view_renderer_
.TrimMemory(level
, visible
);
1164 // TODO(sgurun) add support for posting a frame whose name is known (only
1165 // main frame is supported at this time, see crbug.com/389721)
1166 void AwContents::PostMessageToFrame(JNIEnv
* env
, jobject obj
,
1167 jstring frame_name
, jstring message
, jstring target_origin
,
1168 jintArray sent_ports
) {
1170 // Use an empty source origin for android webview.
1171 base::string16 source_origin
;
1172 base::string16
j_target_origin(ConvertJavaStringToUTF16(env
, target_origin
));
1173 base::string16
j_message(ConvertJavaStringToUTF16(env
, message
));
1174 std::vector
<int> j_ports
;
1176 if (sent_ports
!= nullptr) {
1177 base::android::JavaIntArrayToIntVector(env
, sent_ports
, &j_ports
);
1178 BrowserThread::PostTask(
1181 base::Bind(&AwMessagePortServiceImpl::RemoveSentPorts
,
1182 base::Unretained(AwMessagePortServiceImpl::GetInstance()),
1185 std::vector
<content::TransferredMessagePort
> ports(j_ports
.size());
1186 for (size_t i
= 0; i
< j_ports
.size(); ++i
)
1187 ports
[i
].id
= j_ports
[i
];
1188 content::MessagePortProvider::PostMessageToFrame(web_contents_
.get(),
1195 scoped_refptr
<AwMessagePortMessageFilter
>
1196 AwContents::GetMessagePortMessageFilter() {
1197 // Create a message port message filter if necessary
1198 if (message_port_message_filter_
.get() == nullptr) {
1199 message_port_message_filter_
=
1200 new AwMessagePortMessageFilter(
1201 web_contents_
->GetMainFrame()->GetRoutingID());
1202 web_contents_
->GetRenderProcessHost()->AddFilter(
1203 message_port_message_filter_
.get());
1205 return message_port_message_filter_
;
1208 void AwContents::CreateMessageChannel(JNIEnv
* env
, jobject obj
,
1209 jobjectArray ports
) {
1211 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env
, ports
,
1212 GetMessagePortMessageFilter());
1215 void AwContents::GrantFileSchemeAccesstoChildProcess(JNIEnv
* env
, jobject obj
) {
1216 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
1217 web_contents_
->GetRenderProcessHost()->GetID(), url::kFileScheme
);
1220 void SetShouldDownloadFavicons(JNIEnv
* env
,
1221 const JavaParamRef
<jclass
>& jclazz
) {
1222 g_should_download_favicons
= true;
1225 } // namespace android_webview