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/memory/memory_pressure_listener.h"
43 #include "base/message_loop/message_loop.h"
44 #include "base/pickle.h"
45 #include "base/strings/string16.h"
46 #include "base/supports_user_data.h"
47 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
48 #include "components/autofill/core/browser/autofill_manager.h"
49 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
50 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
51 #include "components/navigation_interception/intercept_navigation_delegate.h"
52 #include "content/public/browser/android/content_view_core.h"
53 #include "content/public/browser/android/synchronous_compositor.h"
54 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/cert_store.h"
56 #include "content/public/browser/favicon_status.h"
57 #include "content/public/browser/message_port_provider.h"
58 #include "content/public/browser/navigation_entry.h"
59 #include "content/public/browser/render_frame_host.h"
60 #include "content/public/browser/render_process_host.h"
61 #include "content/public/browser/render_view_host.h"
62 #include "content/public/browser/web_contents.h"
63 #include "content/public/common/message_port_types.h"
64 #include "content/public/common/renderer_preferences.h"
65 #include "content/public/common/ssl_status.h"
66 #include "jni/AwContents_jni.h"
67 #include "net/base/auth.h"
68 #include "net/cert/x509_certificate.h"
69 #include "third_party/skia/include/core/SkPicture.h"
70 #include "ui/gfx/android/java_bitmap.h"
71 #include "ui/gfx/geometry/rect_f.h"
72 #include "ui/gfx/geometry/size.h"
73 #include "ui/gfx/image/image.h"
75 struct AwDrawSWFunctionTable
;
77 using autofill::ContentAutofillDriverFactory
;
78 using autofill::AutofillManager
;
79 using base::android::AttachCurrentThread
;
80 using base::android::ConvertJavaStringToUTF16
;
81 using base::android::ConvertJavaStringToUTF8
;
82 using base::android::ConvertUTF16ToJavaString
;
83 using base::android::ConvertUTF8ToJavaString
;
84 using base::android::JavaRef
;
85 using base::android::ScopedJavaGlobalRef
;
86 using base::android::ScopedJavaLocalRef
;
87 using data_reduction_proxy::DataReductionProxySettings
;
88 using navigation_interception::InterceptNavigationDelegate
;
89 using content::BrowserThread
;
90 using content::ContentViewCore
;
91 using content::WebContents
;
94 static AwDrawGLFunction DrawGLFunction
;
95 static void DrawGLFunction(long view_context
,
96 AwDrawGLInfo
* draw_info
,
98 // |view_context| is the value that was returned from the java
99 // AwContents.onPrepareDrawGL; this cast must match the code there.
100 reinterpret_cast<android_webview::SharedRendererState
*>(view_context
)
105 namespace android_webview
{
109 bool g_should_download_favicons
= false;
111 bool g_force_auxiliary_bitmap_rendering
= false;
113 const void* kAwContentsUserDataKey
= &kAwContentsUserDataKey
;
115 class AwContentsUserData
: public base::SupportsUserData::Data
{
117 AwContentsUserData(AwContents
* ptr
) : contents_(ptr
) {}
119 static AwContents
* GetContents(WebContents
* web_contents
) {
122 AwContentsUserData
* data
= static_cast<AwContentsUserData
*>(
123 web_contents
->GetUserData(kAwContentsUserDataKey
));
124 return data
? data
->contents_
: NULL
;
128 AwContents
* contents_
;
131 base::subtle::Atomic32 g_instance_count
= 0;
133 void OnIoThreadClientReady(content::RenderFrameHost
* rfh
) {
134 int render_process_id
= rfh
->GetProcess()->GetID();
135 int render_frame_id
= rfh
->GetRoutingID();
136 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(
137 render_process_id
, render_frame_id
);
143 AwContents
* AwContents::FromWebContents(WebContents
* web_contents
) {
144 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
145 return AwContentsUserData::GetContents(web_contents
);
149 AwContents
* AwContents::FromID(int render_process_id
, int render_view_id
) {
150 const content::RenderViewHost
* rvh
=
151 content::RenderViewHost::FromID(render_process_id
, render_view_id
);
152 if (!rvh
) return NULL
;
153 content::WebContents
* web_contents
=
154 content::WebContents::FromRenderViewHost(rvh
);
155 if (!web_contents
) return NULL
;
156 return FromWebContents(web_contents
);
160 AwBrowserPermissionRequestDelegate
* AwBrowserPermissionRequestDelegate::FromID(
161 int render_process_id
, int render_frame_id
) {
162 AwContents
* aw_contents
= AwContents::FromWebContents(
163 content::WebContents::FromRenderFrameHost(
164 content::RenderFrameHost::FromID(render_process_id
,
166 return implicit_cast
<AwBrowserPermissionRequestDelegate
*>(aw_contents
);
169 AwContents::AwContents(scoped_ptr
<WebContents
> web_contents
)
170 : web_contents_(web_contents
.Pass()),
171 browser_view_renderer_(
173 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI
)),
174 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) {
175 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count
, 1);
176 icon_helper_
.reset(new IconHelper(web_contents_
.get()));
177 icon_helper_
->SetListener(this);
178 web_contents_
->SetUserData(android_webview::kAwContentsUserDataKey
,
179 new AwContentsUserData(this));
180 browser_view_renderer_
.RegisterWithWebContents(web_contents_
.get());
181 render_view_host_ext_
.reset(
182 new AwRenderViewHostExt(this, web_contents_
.get()));
184 permission_request_handler_
.reset(
185 new PermissionRequestHandler(this, web_contents_
.get()));
187 AwAutofillClient
* autofill_manager_delegate
=
188 AwAutofillClient::FromWebContents(web_contents_
.get());
189 InitDataReductionProxyIfNecessary();
190 if (autofill_manager_delegate
)
191 InitAutofillIfNecessary(autofill_manager_delegate
->GetSaveFormData());
192 content::SynchronousCompositor::SetClientForWebContents(
193 web_contents_
.get(), &browser_view_renderer_
);
196 void AwContents::SetJavaPeers(JNIEnv
* env
,
199 jobject web_contents_delegate
,
200 jobject contents_client_bridge
,
201 jobject io_thread_client
,
202 jobject intercept_navigation_delegate
) {
203 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
204 // The |aw_content| param is technically spurious as it duplicates |obj| but
205 // is passed over anyway to make the binding more explicit.
206 java_ref_
= JavaObjectWeakGlobalRef(env
, aw_contents
);
208 web_contents_delegate_
.reset(
209 new AwWebContentsDelegate(env
, web_contents_delegate
));
210 web_contents_
->SetDelegate(web_contents_delegate_
.get());
212 contents_client_bridge_
.reset(
213 new AwContentsClientBridge(env
, contents_client_bridge
));
214 AwContentsClientBridgeBase::Associate(web_contents_
.get(),
215 contents_client_bridge_
.get());
217 AwContentsIoThreadClientImpl::Associate(
218 web_contents_
.get(), ScopedJavaLocalRef
<jobject
>(env
, io_thread_client
));
220 InterceptNavigationDelegate::Associate(
222 make_scoped_ptr(new InterceptNavigationDelegate(
223 env
, intercept_navigation_delegate
)));
225 // Finally, having setup the associations, release any deferred requests
226 web_contents_
->ForEachFrame(base::Bind(&OnIoThreadClientReady
));
229 void AwContents::SetSaveFormData(bool enabled
) {
230 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
231 InitAutofillIfNecessary(enabled
);
232 // We need to check for the existence, since autofill_manager_delegate
233 // may not be created when the setting is false.
234 if (AwAutofillClient::FromWebContents(web_contents_
.get())) {
235 AwAutofillClient::FromWebContents(web_contents_
.get())->
236 SetSaveFormData(enabled
);
240 void AwContents::InitDataReductionProxyIfNecessary() {
241 AwBrowserContext
* browser_context
=
242 AwBrowserContext::FromWebContents(web_contents_
.get());
243 browser_context
->CreateUserPrefServiceIfNecessary();
246 void AwContents::InitAutofillIfNecessary(bool enabled
) {
247 // Do not initialize if the feature is not enabled.
250 // Check if the autofill driver factory already exists.
251 content::WebContents
* web_contents
= web_contents_
.get();
252 if (ContentAutofillDriverFactory::FromWebContents(web_contents
))
255 AwBrowserContext::FromWebContents(web_contents
)->
256 CreateUserPrefServiceIfNecessary();
257 AwAutofillClient::CreateForWebContents(web_contents
);
258 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
259 web_contents
, AwAutofillClient::FromWebContents(web_contents
),
260 base::android::GetDefaultLocale(),
261 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER
);
264 void AwContents::SetAwAutofillClient(jobject client
) {
265 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
266 JNIEnv
* env
= AttachCurrentThread();
267 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
270 Java_AwContents_setAwAutofillClient(env
, obj
.obj(), client
);
273 AwContents::~AwContents() {
274 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_
.get()));
275 content::SynchronousCompositor::SetClientForWebContents(web_contents_
.get(),
277 web_contents_
->RemoveUserData(kAwContentsUserDataKey
);
278 if (find_helper_
.get())
279 find_helper_
->SetListener(NULL
);
280 if (icon_helper_
.get())
281 icon_helper_
->SetListener(NULL
);
282 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count
, -1);
283 // When the last WebView is destroyed free all discardable memory allocated by
284 // Chromium, because the app process may continue to run for a long time
285 // without ever using another WebView.
286 if (base::subtle::NoBarrier_Load(&g_instance_count
) == 0) {
287 base::MemoryPressureListener::NotifyMemoryPressure(
288 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL
);
292 base::android::ScopedJavaLocalRef
<jobject
>
293 AwContents::GetWebContents(JNIEnv
* env
, jobject obj
) {
294 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
295 DCHECK(web_contents_
);
297 return base::android::ScopedJavaLocalRef
<jobject
>();
299 return web_contents_
->GetJavaWebContents();
302 void AwContents::Destroy(JNIEnv
* env
, jobject obj
) {
307 static jlong
Init(JNIEnv
* env
, jclass
, jobject browser_context
) {
308 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather
309 // than hard-code the default instance lookup here.
310 scoped_ptr
<WebContents
> web_contents(content::WebContents::Create(
311 content::WebContents::CreateParams(AwBrowserContext::GetDefault())));
312 // Return an 'uninitialized' instance; most work is deferred until the
313 // subsequent SetJavaPeers() call.
314 return reinterpret_cast<intptr_t>(new AwContents(web_contents
.Pass()));
317 static void SetForceAuxiliaryBitmapRendering(
320 jboolean force_auxiliary_bitmap_rendering
) {
321 g_force_auxiliary_bitmap_rendering
= force_auxiliary_bitmap_rendering
;
324 static void SetAwDrawSWFunctionTable(JNIEnv
* env
, jclass
,
325 jlong function_table
) {
326 RasterHelperSetAwDrawSWFunctionTable(
327 reinterpret_cast<AwDrawSWFunctionTable
*>(function_table
));
330 static void SetAwDrawGLFunctionTable(JNIEnv
* env
, jclass
,
331 jlong function_table
) {
334 static jlong
GetAwDrawGLFunction(JNIEnv
* env
, jclass
) {
335 return reinterpret_cast<intptr_t>(&DrawGLFunction
);
339 jint
GetNativeInstanceCount(JNIEnv
* env
, jclass
) {
340 return base::subtle::NoBarrier_Load(&g_instance_count
);
343 jlong
AwContents::GetAwDrawGLViewContext(JNIEnv
* env
, jobject obj
) {
344 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
345 return reinterpret_cast<intptr_t>(
346 browser_view_renderer_
.GetAwDrawGLViewContext());
350 void DocumentHasImagesCallback(const ScopedJavaGlobalRef
<jobject
>& message
,
352 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(),
358 void AwContents::DocumentHasImages(JNIEnv
* env
, jobject obj
, jobject message
) {
359 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
360 ScopedJavaGlobalRef
<jobject
> j_message
;
361 j_message
.Reset(env
, message
);
362 render_view_host_ext_
->DocumentHasImages(
363 base::Bind(&DocumentHasImagesCallback
, j_message
));
367 void GenerateMHTMLCallback(ScopedJavaGlobalRef
<jobject
>* callback
,
368 const base::FilePath
& path
, int64 size
) {
369 JNIEnv
* env
= AttachCurrentThread();
370 // Android files are UTF8, so the path conversion below is safe.
371 Java_AwContents_generateMHTMLCallback(
373 ConvertUTF8ToJavaString(env
, path
.AsUTF8Unsafe()).obj(),
374 size
, callback
->obj());
378 void AwContents::GenerateMHTML(JNIEnv
* env
, jobject obj
,
379 jstring jpath
, jobject callback
) {
380 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
381 ScopedJavaGlobalRef
<jobject
>* j_callback
= new ScopedJavaGlobalRef
<jobject
>();
382 j_callback
->Reset(env
, callback
);
383 base::FilePath
target_path(ConvertJavaStringToUTF8(env
, jpath
));
384 web_contents_
->GenerateMHTML(
386 base::Bind(&GenerateMHTMLCallback
, base::Owned(j_callback
), target_path
));
389 void AwContents::CreatePdfExporter(JNIEnv
* env
,
391 jobject pdfExporter
) {
393 new AwPdfExporter(env
,
395 web_contents_
.get()));
398 bool AwContents::OnReceivedHttpAuthRequest(const JavaRef
<jobject
>& handler
,
399 const std::string
& host
,
400 const std::string
& realm
) {
401 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
402 JNIEnv
* env
= AttachCurrentThread();
403 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
407 ScopedJavaLocalRef
<jstring
> jhost
= ConvertUTF8ToJavaString(env
, host
);
408 ScopedJavaLocalRef
<jstring
> jrealm
= ConvertUTF8ToJavaString(env
, realm
);
409 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
410 "onReceivedHttpAuthRequest");
411 Java_AwContents_onReceivedHttpAuthRequest(env
, obj
.obj(), handler
.obj(),
412 jhost
.obj(), jrealm
.obj());
416 void AwContents::SetOffscreenPreRaster(bool enabled
) {
417 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
418 browser_view_renderer_
.SetOffscreenPreRaster(enabled
);
421 void AwContents::AddVisitedLinks(JNIEnv
* env
,
423 jobjectArray jvisited_links
) {
424 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
425 std::vector
<base::string16
> visited_link_strings
;
426 base::android::AppendJavaStringArrayToStringVector(
427 env
, jvisited_links
, &visited_link_strings
);
429 std::vector
<GURL
> visited_link_gurls
;
430 std::vector
<base::string16
>::const_iterator itr
;
431 for (itr
= visited_link_strings
.begin(); itr
!= visited_link_strings
.end();
433 visited_link_gurls
.push_back(GURL(*itr
));
436 AwBrowserContext::FromWebContents(web_contents_
.get())
437 ->AddVisitedURLs(visited_link_gurls
);
440 bool RegisterAwContents(JNIEnv
* env
) {
441 return RegisterNativesImpl(env
);
446 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef
& java_ref
,
447 const GURL
& origin
) {
448 JNIEnv
* env
= AttachCurrentThread();
449 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref
.get(env
);
451 ScopedJavaLocalRef
<jstring
> j_origin(
452 ConvertUTF8ToJavaString(env
, origin
.spec()));
453 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
454 "onGeolocationPermissionsShowPrompt");
455 Java_AwContents_onGeolocationPermissionsShowPrompt(env
,
461 void ShowGeolocationPromptHelper(const JavaObjectWeakGlobalRef
& java_ref
,
462 const GURL
& origin
) {
463 JNIEnv
* env
= AttachCurrentThread();
464 if (java_ref
.get(env
).obj()) {
465 content::BrowserThread::PostTask(
466 content::BrowserThread::UI
,
468 base::Bind(&ShowGeolocationPromptHelperTask
,
474 } // anonymous namespace
476 void AwContents::ShowGeolocationPrompt(const GURL
& requesting_frame
,
477 base::Callback
<void(bool)> callback
) {
478 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
480 GURL origin
= requesting_frame
.GetOrigin();
481 bool show_prompt
= pending_geolocation_prompts_
.empty();
482 pending_geolocation_prompts_
.push_back(OriginCallback(origin
, callback
));
484 ShowGeolocationPromptHelper(java_ref_
, origin
);
489 void AwContents::InvokeGeolocationCallback(JNIEnv
* env
,
493 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
494 if (pending_geolocation_prompts_
.empty()) {
495 LOG(WARNING
) << "Response for this geolocation request has been received."
496 << " Ignoring subsequent responses";
500 GURL
callback_origin(base::android::ConvertJavaStringToUTF16(env
, origin
));
501 if (callback_origin
.GetOrigin() ==
502 pending_geolocation_prompts_
.front().first
) {
503 pending_geolocation_prompts_
.front().second
.Run(value
);
504 pending_geolocation_prompts_
.pop_front();
505 if (!pending_geolocation_prompts_
.empty()) {
506 ShowGeolocationPromptHelper(java_ref_
,
507 pending_geolocation_prompts_
.front().first
);
510 LOG(WARNING
) << "Response for this geolocation request has been received."
511 << " Ignoring subsequent responses";
515 void AwContents::HideGeolocationPrompt(const GURL
& origin
) {
516 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
517 bool removed_current_outstanding_callback
= false;
518 std::list
<OriginCallback
>::iterator it
= pending_geolocation_prompts_
.begin();
519 while (it
!= pending_geolocation_prompts_
.end()) {
520 if ((*it
).first
== origin
.GetOrigin()) {
521 if (it
== pending_geolocation_prompts_
.begin()) {
522 removed_current_outstanding_callback
= true;
524 it
= pending_geolocation_prompts_
.erase(it
);
530 if (removed_current_outstanding_callback
) {
531 JNIEnv
* env
= AttachCurrentThread();
532 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
534 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
535 "onGeolocationPermissionsHidePrompt");
536 Java_AwContents_onGeolocationPermissionsHidePrompt(env
, j_ref
.obj());
538 if (!pending_geolocation_prompts_
.empty()) {
539 ShowGeolocationPromptHelper(java_ref_
,
540 pending_geolocation_prompts_
.front().first
);
545 void AwContents::OnPermissionRequest(
546 base::android::ScopedJavaLocalRef
<jobject
> j_request
,
547 AwPermissionRequest
* request
) {
548 DCHECK(!j_request
.is_null());
551 JNIEnv
* env
= AttachCurrentThread();
552 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
553 if (j_ref
.is_null()) {
554 permission_request_handler_
->CancelRequest(request
->GetOrigin(),
555 request
->GetResources());
559 Java_AwContents_onPermissionRequest(env
, j_ref
.obj(), j_request
.obj());
562 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest
* request
) {
563 JNIEnv
* env
= AttachCurrentThread();
564 ScopedJavaLocalRef
<jobject
> j_request
= request
->GetJavaObject();
565 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
566 if (j_request
.is_null() || j_ref
.is_null())
569 Java_AwContents_onPermissionRequestCanceled(
570 env
, j_ref
.obj(), j_request
.obj());
573 void AwContents::PreauthorizePermission(
578 permission_request_handler_
->PreauthorizePermission(
579 GURL(base::android::ConvertJavaStringToUTF8(env
, origin
)), resources
);
582 void AwContents::RequestProtectedMediaIdentifierPermission(
584 const base::Callback
<void(bool)>& callback
) {
585 permission_request_handler_
->SendRequest(
586 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
587 origin
, AwPermissionRequest::ProtectedMediaId
, callback
)));
590 void AwContents::CancelProtectedMediaIdentifierPermissionRequests(
591 const GURL
& origin
) {
592 permission_request_handler_
->CancelRequest(
593 origin
, AwPermissionRequest::ProtectedMediaId
);
596 void AwContents::RequestGeolocationPermission(
598 const base::Callback
<void(bool)>& callback
) {
599 JNIEnv
* env
= AttachCurrentThread();
600 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
604 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env
, obj
.obj())) {
605 ShowGeolocationPrompt(origin
, callback
);
608 permission_request_handler_
->SendRequest(
609 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
610 origin
, AwPermissionRequest::Geolocation
, callback
)));
613 void AwContents::CancelGeolocationPermissionRequests(const GURL
& origin
) {
614 JNIEnv
* env
= AttachCurrentThread();
615 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
619 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env
, obj
.obj())) {
620 HideGeolocationPrompt(origin
);
623 permission_request_handler_
->CancelRequest(
624 origin
, AwPermissionRequest::Geolocation
);
627 void AwContents::RequestMIDISysexPermission(
629 const base::Callback
<void(bool)>& callback
) {
630 permission_request_handler_
->SendRequest(
631 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
632 origin
, AwPermissionRequest::MIDISysex
, callback
)));
635 void AwContents::CancelMIDISysexPermissionRequests(const GURL
& origin
) {
636 permission_request_handler_
->CancelRequest(
637 origin
, AwPermissionRequest::AwPermissionRequest::MIDISysex
);
640 void AwContents::FindAllAsync(JNIEnv
* env
, jobject obj
, jstring search_string
) {
641 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
642 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env
, search_string
));
645 void AwContents::FindNext(JNIEnv
* env
, jobject obj
, jboolean forward
) {
646 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
647 GetFindHelper()->FindNext(forward
);
650 void AwContents::ClearMatches(JNIEnv
* env
, jobject obj
) {
651 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
652 GetFindHelper()->ClearMatches();
655 void AwContents::ClearCache(
658 jboolean include_disk_files
) {
659 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
660 render_view_host_ext_
->ClearCache();
662 if (include_disk_files
) {
663 RemoveHttpDiskCache(web_contents_
->GetBrowserContext(),
664 web_contents_
->GetRoutingID());
668 FindHelper
* AwContents::GetFindHelper() {
669 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
670 if (!find_helper_
.get()) {
671 find_helper_
.reset(new FindHelper(web_contents_
.get()));
672 find_helper_
->SetListener(this);
674 return find_helper_
.get();
677 void AwContents::OnFindResultReceived(int active_ordinal
,
680 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
681 JNIEnv
* env
= AttachCurrentThread();
682 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
686 Java_AwContents_onFindResultReceived(
687 env
, obj
.obj(), active_ordinal
, match_count
, finished
);
690 bool AwContents::ShouldDownloadFavicon(const GURL
& icon_url
) {
691 return g_should_download_favicons
;
694 void AwContents::OnReceivedIcon(const GURL
& icon_url
, const SkBitmap
& bitmap
) {
695 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
696 JNIEnv
* env
= AttachCurrentThread();
697 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
701 content::NavigationEntry
* entry
=
702 web_contents_
->GetController().GetLastCommittedEntry();
705 entry
->GetFavicon().valid
= true;
706 entry
->GetFavicon().url
= icon_url
;
707 entry
->GetFavicon().image
= gfx::Image::CreateFrom1xBitmap(bitmap
);
710 Java_AwContents_onReceivedIcon(
711 env
, obj
.obj(), gfx::ConvertToJavaBitmap(&bitmap
).obj());
714 void AwContents::OnReceivedTouchIconUrl(const std::string
& url
,
716 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
717 JNIEnv
* env
= AttachCurrentThread();
718 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
722 Java_AwContents_onReceivedTouchIconUrl(
723 env
, obj
.obj(), ConvertUTF8ToJavaString(env
, url
).obj(), precomposed
);
726 bool AwContents::RequestDrawGL(bool wait_for_completion
) {
727 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
728 JNIEnv
* env
= AttachCurrentThread();
729 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
732 return Java_AwContents_requestDrawGL(env
, obj
.obj(), wait_for_completion
);
735 void AwContents::PostInvalidate() {
736 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
737 JNIEnv
* env
= AttachCurrentThread();
738 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
740 Java_AwContents_postInvalidateOnAnimation(env
, obj
.obj());
743 void AwContents::OnNewPicture() {
744 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
745 JNIEnv
* env
= AttachCurrentThread();
746 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
747 if (!obj
.is_null()) {
748 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
750 Java_AwContents_onNewPicture(env
, obj
.obj());
754 base::android::ScopedJavaLocalRef
<jbyteArray
> AwContents::GetCertificate(
757 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
758 content::NavigationEntry
* entry
=
759 web_contents_
->GetController().GetLastCommittedEntry();
761 return ScopedJavaLocalRef
<jbyteArray
>();
762 // Get the certificate
763 int cert_id
= entry
->GetSSL().cert_id
;
764 scoped_refptr
<net::X509Certificate
> cert
;
765 bool ok
= content::CertStore::GetInstance()->RetrieveCert(cert_id
, &cert
);
767 return ScopedJavaLocalRef
<jbyteArray
>();
769 // Convert the certificate and return it
770 std::string der_string
;
771 net::X509Certificate::GetDEREncoded(cert
->os_cert_handle(), &der_string
);
772 return base::android::ToJavaByteArray(env
,
773 reinterpret_cast<const uint8
*>(der_string
.data()), der_string
.length());
776 void AwContents::RequestNewHitTestDataAt(JNIEnv
* env
,
780 jfloat touch_major
) {
781 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
782 gfx::PointF
touch_center(x
, y
);
783 gfx::SizeF
touch_area(touch_major
, touch_major
);
784 render_view_host_ext_
->RequestNewHitTestDataAt(touch_center
, touch_area
);
787 void AwContents::UpdateLastHitTestData(JNIEnv
* env
, jobject obj
) {
788 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
789 if (!render_view_host_ext_
->HasNewHitTestData()) return;
791 const AwHitTestData
& data
= render_view_host_ext_
->GetLastHitTestData();
792 render_view_host_ext_
->MarkHitTestDataRead();
794 // Make sure to null the Java object if data is empty/invalid.
795 ScopedJavaLocalRef
<jstring
> extra_data_for_type
;
796 if (data
.extra_data_for_type
.length())
797 extra_data_for_type
= ConvertUTF8ToJavaString(
798 env
, data
.extra_data_for_type
);
800 ScopedJavaLocalRef
<jstring
> href
;
801 if (data
.href
.length())
802 href
= ConvertUTF16ToJavaString(env
, data
.href
);
804 ScopedJavaLocalRef
<jstring
> anchor_text
;
805 if (data
.anchor_text
.length())
806 anchor_text
= ConvertUTF16ToJavaString(env
, data
.anchor_text
);
808 ScopedJavaLocalRef
<jstring
> img_src
;
809 if (data
.img_src
.is_valid())
810 img_src
= ConvertUTF8ToJavaString(env
, data
.img_src
.spec());
812 Java_AwContents_updateHitTestData(env
,
815 extra_data_for_type
.obj(),
821 void AwContents::OnSizeChanged(JNIEnv
* env
, jobject obj
,
822 int w
, int h
, int ow
, int oh
) {
823 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
824 browser_view_renderer_
.OnSizeChanged(w
, h
);
827 void AwContents::SetViewVisibility(JNIEnv
* env
, jobject obj
, bool visible
) {
828 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
829 browser_view_renderer_
.SetViewVisibility(visible
);
832 void AwContents::SetWindowVisibility(JNIEnv
* env
, jobject obj
, bool visible
) {
833 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
834 browser_view_renderer_
.SetWindowVisibility(visible
);
837 void AwContents::SetIsPaused(JNIEnv
* env
, jobject obj
, bool paused
) {
838 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
839 browser_view_renderer_
.SetIsPaused(paused
);
840 ContentViewCore
* cvc
=
841 ContentViewCore::FromWebContents(web_contents_
.get());
843 cvc
->PauseOrResumeGeolocation(paused
);
847 void AwContents::OnAttachedToWindow(JNIEnv
* env
, jobject obj
, int w
, int h
) {
848 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
849 browser_view_renderer_
.OnAttachedToWindow(w
, h
);
852 void AwContents::OnDetachedFromWindow(JNIEnv
* env
, jobject obj
) {
853 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
854 browser_view_renderer_
.OnDetachedFromWindow();
857 void AwContents::DetachFunctorFromView() {
858 JNIEnv
* env
= AttachCurrentThread();
859 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
861 Java_AwContents_detachFunctorFromView(env
, obj
.obj());
864 base::android::ScopedJavaLocalRef
<jbyteArray
>
865 AwContents::GetOpaqueState(JNIEnv
* env
, jobject obj
) {
866 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
867 // Required optimization in WebViewClassic to not save any state if
868 // there has been no navigations.
869 if (!web_contents_
->GetController().GetEntryCount())
870 return ScopedJavaLocalRef
<jbyteArray
>();
873 if (!WriteToPickle(*web_contents_
, &pickle
)) {
874 return ScopedJavaLocalRef
<jbyteArray
>();
876 return base::android::ToJavaByteArray(env
,
877 reinterpret_cast<const uint8
*>(pickle
.data()), pickle
.size());
881 jboolean
AwContents::RestoreFromOpaqueState(
882 JNIEnv
* env
, jobject obj
, jbyteArray state
) {
883 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
884 // TODO(boliu): This copy can be optimized out if this is a performance
886 std::vector
<uint8
> state_vector
;
887 base::android::JavaByteArrayToByteVector(env
, state
, &state_vector
);
889 base::Pickle
pickle(reinterpret_cast<const char*>(state_vector
.data()),
890 state_vector
.size());
891 base::PickleIterator
iterator(pickle
);
893 return RestoreFromPickle(&iterator
, web_contents_
.get());
896 bool AwContents::OnDraw(JNIEnv
* env
,
899 jboolean is_hardware_accelerated
,
905 jint visible_bottom
) {
906 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
907 gfx::Vector2d
scroll(scroll_x
, scroll_y
);
908 browser_view_renderer_
.PrepareToDraw(
909 scroll
, gfx::Rect(visible_left
, visible_top
, visible_right
- visible_left
,
910 visible_bottom
- visible_top
));
911 if (is_hardware_accelerated
&& browser_view_renderer_
.attached_to_window() &&
912 !g_force_auxiliary_bitmap_rendering
) {
913 return browser_view_renderer_
.OnDrawHardware();
916 gfx::Size view_size
= browser_view_renderer_
.size();
917 if (view_size
.IsEmpty()) {
918 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_EmptySize",
919 TRACE_EVENT_SCOPE_THREAD
);
923 // TODO(hush): Right now webview size is passed in as the auxiliary bitmap
924 // size, which might hurt performace (only for software draws with auxiliary
925 // bitmap). For better performance, get global visible rect, transform it
926 // from screen space to view space, then intersect with the webview in
927 // viewspace. Use the resulting rect as the auxiliary bitmap.
928 scoped_ptr
<SoftwareCanvasHolder
> canvas_holder
= SoftwareCanvasHolder::Create(
929 canvas
, scroll
, view_size
, g_force_auxiliary_bitmap_rendering
);
930 if (!canvas_holder
|| !canvas_holder
->GetCanvas()) {
931 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_EmptySize",
932 TRACE_EVENT_SCOPE_THREAD
);
935 return browser_view_renderer_
.OnDrawSoftware(canvas_holder
->GetCanvas());
938 void AwContents::SetPendingWebContentsForPopup(
939 scoped_ptr
<content::WebContents
> pending
) {
940 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
941 if (pending_contents_
.get()) {
942 // TODO(benm): Support holding multiple pop up window requests.
943 LOG(WARNING
) << "Blocking popup window creation as an outstanding "
944 << "popup window is still pending.";
945 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, pending
.release());
948 pending_contents_
.reset(new AwContents(pending
.Pass()));
949 // Set dip_scale for pending contents, which is necessary for the later
950 // SynchronousCompositor and InputHandler setup.
951 pending_contents_
->SetDipScaleInternal(browser_view_renderer_
.dip_scale());
954 void AwContents::FocusFirstNode(JNIEnv
* env
, jobject obj
) {
955 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
956 web_contents_
->FocusThroughTabTraversal(false);
959 void AwContents::SetBackgroundColor(JNIEnv
* env
, jobject obj
, jint color
) {
960 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
961 render_view_host_ext_
->SetBackgroundColor(color
);
964 void AwContents::OnComputeScroll(JNIEnv
* env
,
966 jlong animation_time_millis
) {
967 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
968 browser_view_renderer_
.OnComputeScroll(
970 base::TimeDelta::FromMilliseconds(animation_time_millis
));
973 jlong
AwContents::ReleasePopupAwContents(JNIEnv
* env
, jobject obj
) {
974 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
975 return reinterpret_cast<intptr_t>(pending_contents_
.release());
978 gfx::Point
AwContents::GetLocationOnScreen() {
979 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
980 JNIEnv
* env
= AttachCurrentThread();
981 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
984 std::vector
<int> location
;
985 base::android::JavaIntArrayToIntVector(
987 Java_AwContents_getLocationOnScreen(env
, obj
.obj()).obj(),
989 return gfx::Point(location
[0], location
[1]);
992 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value
) {
993 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
994 JNIEnv
* env
= AttachCurrentThread();
995 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
998 Java_AwContents_scrollContainerViewTo(
999 env
, obj
.obj(), new_value
.x(), new_value
.y());
1002 bool AwContents::IsSmoothScrollingActive() const {
1003 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1004 JNIEnv
* env
= AttachCurrentThread();
1005 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1008 return Java_AwContents_isSmoothScrollingActive(env
, obj
.obj());
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::OnWebLayoutPageScaleFactorChanged(float page_scale_factor
) {
1059 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1060 JNIEnv
* env
= AttachCurrentThread();
1061 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1064 Java_AwContents_onWebLayoutPageScaleFactorChanged(env
, obj
.obj(),
1068 void AwContents::OnWebLayoutContentsSizeChanged(
1069 const gfx::Size
& contents_size
) {
1070 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1071 JNIEnv
* env
= AttachCurrentThread();
1072 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1075 Java_AwContents_onWebLayoutContentsSizeChanged(
1076 env
, obj
.obj(), contents_size
.width(), contents_size
.height());
1079 jlong
AwContents::CapturePicture(JNIEnv
* env
,
1083 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1084 return reinterpret_cast<intptr_t>(
1085 new AwPicture(browser_view_renderer_
.CapturePicture(width
, height
)));
1088 void AwContents::EnableOnNewPicture(JNIEnv
* env
,
1091 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1092 browser_view_renderer_
.EnableOnNewPicture(enabled
);
1096 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef
& java_ref
,
1098 ScopedJavaGlobalRef
<jobject
>* callback
,
1100 JNIEnv
* env
= AttachCurrentThread();
1101 ScopedJavaLocalRef
<jobject
> obj
= java_ref
.get(env
);
1104 Java_AwContents_invokeVisualStateCallback(
1105 env
, obj
.obj(), callback
->obj(), request_id
);
1109 void AwContents::InsertVisualStateCallback(
1110 JNIEnv
* env
, jobject obj
, long request_id
, jobject callback
) {
1111 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1112 ScopedJavaGlobalRef
<jobject
>* j_callback
= new ScopedJavaGlobalRef
<jobject
>();
1113 j_callback
->Reset(env
, callback
);
1114 web_contents_
->GetMainFrame()->InsertVisualStateCallback(
1115 base::Bind(&InvokeVisualStateCallback
, java_ref_
, request_id
,
1116 base::Owned(j_callback
)));
1119 void AwContents::ClearView(JNIEnv
* env
, jobject obj
) {
1120 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1121 browser_view_renderer_
.ClearView();
1124 void AwContents::SetExtraHeadersForUrl(JNIEnv
* env
, jobject obj
,
1125 jstring url
, jstring jextra_headers
) {
1126 std::string extra_headers
;
1128 extra_headers
= ConvertJavaStringToUTF8(env
, jextra_headers
);
1129 AwResourceContext
* resource_context
= static_cast<AwResourceContext
*>(
1130 AwBrowserContext::FromWebContents(web_contents_
.get())->
1131 GetResourceContext());
1132 resource_context
->SetExtraHeaders(GURL(ConvertJavaStringToUTF8(env
, url
)),
1136 void AwContents::SetJsOnlineProperty(JNIEnv
* env
,
1138 jboolean network_up
) {
1139 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1140 render_view_host_ext_
->SetJsOnlineProperty(network_up
);
1143 void AwContents::TrimMemory(JNIEnv
* env
,
1147 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1148 browser_view_renderer_
.TrimMemory(level
, visible
);
1151 // TODO(sgurun) add support for posting a frame whose name is known (only
1152 // main frame is supported at this time, see crbug.com/389721)
1153 void AwContents::PostMessageToFrame(JNIEnv
* env
, jobject obj
,
1154 jstring frame_name
, jstring message
, jstring target_origin
,
1155 jintArray sent_ports
) {
1157 // Use an empty source origin for android webview.
1158 base::string16 source_origin
;
1159 base::string16
j_target_origin(ConvertJavaStringToUTF16(env
, target_origin
));
1160 base::string16
j_message(ConvertJavaStringToUTF16(env
, message
));
1161 std::vector
<int> j_ports
;
1163 if (sent_ports
!= nullptr) {
1164 base::android::JavaIntArrayToIntVector(env
, sent_ports
, &j_ports
);
1165 BrowserThread::PostTask(
1168 base::Bind(&AwMessagePortServiceImpl::RemoveSentPorts
,
1169 base::Unretained(AwMessagePortServiceImpl::GetInstance()),
1172 std::vector
<content::TransferredMessagePort
> ports(j_ports
.size());
1173 for (size_t i
= 0; i
< j_ports
.size(); ++i
)
1174 ports
[i
].id
= j_ports
[i
];
1175 content::MessagePortProvider::PostMessageToFrame(web_contents_
.get(),
1182 scoped_refptr
<AwMessagePortMessageFilter
>
1183 AwContents::GetMessagePortMessageFilter() {
1184 // Create a message port message filter if necessary
1185 if (message_port_message_filter_
.get() == nullptr) {
1186 message_port_message_filter_
=
1187 new AwMessagePortMessageFilter(
1188 web_contents_
->GetMainFrame()->GetRoutingID());
1189 web_contents_
->GetRenderProcessHost()->AddFilter(
1190 message_port_message_filter_
.get());
1192 return message_port_message_filter_
;
1195 void AwContents::CreateMessageChannel(JNIEnv
* env
, jobject obj
,
1196 jobjectArray ports
) {
1198 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env
, ports
,
1199 GetMessagePortMessageFilter());
1202 void SetShouldDownloadFavicons(JNIEnv
* env
, jclass jclazz
) {
1203 g_should_download_favicons
= true;
1206 } // namespace android_webview