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 std::string g_locale
;
115 const void* kAwContentsUserDataKey
= &kAwContentsUserDataKey
;
117 class AwContentsUserData
: public base::SupportsUserData::Data
{
119 AwContentsUserData(AwContents
* ptr
) : contents_(ptr
) {}
121 static AwContents
* GetContents(WebContents
* web_contents
) {
124 AwContentsUserData
* data
= static_cast<AwContentsUserData
*>(
125 web_contents
->GetUserData(kAwContentsUserDataKey
));
126 return data
? data
->contents_
: NULL
;
130 AwContents
* contents_
;
133 base::subtle::Atomic32 g_instance_count
= 0;
135 void OnIoThreadClientReady(content::RenderFrameHost
* rfh
) {
136 int render_process_id
= rfh
->GetProcess()->GetID();
137 int render_frame_id
= rfh
->GetRoutingID();
138 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(
139 render_process_id
, render_frame_id
);
145 AwContents
* AwContents::FromWebContents(WebContents
* web_contents
) {
146 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
147 return AwContentsUserData::GetContents(web_contents
);
151 AwContents
* AwContents::FromID(int render_process_id
, int render_view_id
) {
152 const content::RenderViewHost
* rvh
=
153 content::RenderViewHost::FromID(render_process_id
, render_view_id
);
154 if (!rvh
) return NULL
;
155 content::WebContents
* web_contents
=
156 content::WebContents::FromRenderViewHost(rvh
);
157 if (!web_contents
) return NULL
;
158 return FromWebContents(web_contents
);
162 void SetLocale(JNIEnv
* env
, jclass
, jstring locale
) {
163 g_locale
= ConvertJavaStringToUTF8(env
, locale
);
167 std::string
AwContents::GetLocale() {
172 AwBrowserPermissionRequestDelegate
* AwBrowserPermissionRequestDelegate::FromID(
173 int render_process_id
, int render_frame_id
) {
174 AwContents
* aw_contents
= AwContents::FromWebContents(
175 content::WebContents::FromRenderFrameHost(
176 content::RenderFrameHost::FromID(render_process_id
,
178 return implicit_cast
<AwBrowserPermissionRequestDelegate
*>(aw_contents
);
181 AwContents::AwContents(scoped_ptr
<WebContents
> web_contents
)
182 : web_contents_(web_contents
.Pass()),
183 browser_view_renderer_(
185 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI
)),
186 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) {
187 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count
, 1);
188 icon_helper_
.reset(new IconHelper(web_contents_
.get()));
189 icon_helper_
->SetListener(this);
190 web_contents_
->SetUserData(android_webview::kAwContentsUserDataKey
,
191 new AwContentsUserData(this));
192 browser_view_renderer_
.RegisterWithWebContents(web_contents_
.get());
193 render_view_host_ext_
.reset(
194 new AwRenderViewHostExt(this, web_contents_
.get()));
196 permission_request_handler_
.reset(
197 new PermissionRequestHandler(this, web_contents_
.get()));
199 AwAutofillClient
* autofill_manager_delegate
=
200 AwAutofillClient::FromWebContents(web_contents_
.get());
201 InitDataReductionProxyIfNecessary();
202 if (autofill_manager_delegate
)
203 InitAutofillIfNecessary(autofill_manager_delegate
->GetSaveFormData());
204 content::SynchronousCompositor::SetClientForWebContents(
205 web_contents_
.get(), &browser_view_renderer_
);
208 void AwContents::SetJavaPeers(JNIEnv
* env
,
211 jobject web_contents_delegate
,
212 jobject contents_client_bridge
,
213 jobject io_thread_client
,
214 jobject intercept_navigation_delegate
) {
215 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
216 // The |aw_content| param is technically spurious as it duplicates |obj| but
217 // is passed over anyway to make the binding more explicit.
218 java_ref_
= JavaObjectWeakGlobalRef(env
, aw_contents
);
220 web_contents_delegate_
.reset(
221 new AwWebContentsDelegate(env
, web_contents_delegate
));
222 web_contents_
->SetDelegate(web_contents_delegate_
.get());
224 contents_client_bridge_
.reset(
225 new AwContentsClientBridge(env
, contents_client_bridge
));
226 AwContentsClientBridgeBase::Associate(web_contents_
.get(),
227 contents_client_bridge_
.get());
229 AwContentsIoThreadClientImpl::Associate(
230 web_contents_
.get(), ScopedJavaLocalRef
<jobject
>(env
, io_thread_client
));
232 InterceptNavigationDelegate::Associate(
234 make_scoped_ptr(new InterceptNavigationDelegate(
235 env
, intercept_navigation_delegate
)));
237 // Finally, having setup the associations, release any deferred requests
238 web_contents_
->ForEachFrame(base::Bind(&OnIoThreadClientReady
));
241 void AwContents::SetSaveFormData(bool enabled
) {
242 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
243 InitAutofillIfNecessary(enabled
);
244 // We need to check for the existence, since autofill_manager_delegate
245 // may not be created when the setting is false.
246 if (AwAutofillClient::FromWebContents(web_contents_
.get())) {
247 AwAutofillClient::FromWebContents(web_contents_
.get())->
248 SetSaveFormData(enabled
);
252 void AwContents::InitDataReductionProxyIfNecessary() {
253 AwBrowserContext
* browser_context
=
254 AwBrowserContext::FromWebContents(web_contents_
.get());
255 browser_context
->CreateUserPrefServiceIfNecessary();
258 void AwContents::InitAutofillIfNecessary(bool enabled
) {
259 // Do not initialize if the feature is not enabled.
262 // Check if the autofill driver factory already exists.
263 content::WebContents
* web_contents
= web_contents_
.get();
264 if (ContentAutofillDriverFactory::FromWebContents(web_contents
))
267 AwBrowserContext::FromWebContents(web_contents
)->
268 CreateUserPrefServiceIfNecessary();
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
, jclass
, jobject browser_context
) {
320 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather
321 // than hard-code the default instance lookup here.
322 scoped_ptr
<WebContents
> web_contents(content::WebContents::Create(
323 content::WebContents::CreateParams(AwBrowserContext::GetDefault())));
324 // Return an 'uninitialized' instance; most work is deferred until the
325 // subsequent SetJavaPeers() call.
326 return reinterpret_cast<intptr_t>(new AwContents(web_contents
.Pass()));
329 static void SetForceAuxiliaryBitmapRendering(
332 jboolean force_auxiliary_bitmap_rendering
) {
333 g_force_auxiliary_bitmap_rendering
= force_auxiliary_bitmap_rendering
;
336 static void SetAwDrawSWFunctionTable(JNIEnv
* env
, jclass
,
337 jlong function_table
) {
338 RasterHelperSetAwDrawSWFunctionTable(
339 reinterpret_cast<AwDrawSWFunctionTable
*>(function_table
));
342 static void SetAwDrawGLFunctionTable(JNIEnv
* env
, jclass
,
343 jlong function_table
) {
346 static jlong
GetAwDrawGLFunction(JNIEnv
* env
, jclass
) {
347 return reinterpret_cast<intptr_t>(&DrawGLFunction
);
351 jint
GetNativeInstanceCount(JNIEnv
* env
, jclass
) {
352 return base::subtle::NoBarrier_Load(&g_instance_count
);
355 jlong
AwContents::GetAwDrawGLViewContext(JNIEnv
* env
, jobject obj
) {
356 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
357 return reinterpret_cast<intptr_t>(
358 browser_view_renderer_
.GetAwDrawGLViewContext());
362 void DocumentHasImagesCallback(const ScopedJavaGlobalRef
<jobject
>& message
,
364 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(),
370 void AwContents::DocumentHasImages(JNIEnv
* env
, jobject obj
, jobject message
) {
371 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
372 ScopedJavaGlobalRef
<jobject
> j_message
;
373 j_message
.Reset(env
, message
);
374 render_view_host_ext_
->DocumentHasImages(
375 base::Bind(&DocumentHasImagesCallback
, j_message
));
379 void GenerateMHTMLCallback(ScopedJavaGlobalRef
<jobject
>* callback
,
380 const base::FilePath
& path
, int64 size
) {
381 JNIEnv
* env
= AttachCurrentThread();
382 // Android files are UTF8, so the path conversion below is safe.
383 Java_AwContents_generateMHTMLCallback(
385 ConvertUTF8ToJavaString(env
, path
.AsUTF8Unsafe()).obj(),
386 size
, callback
->obj());
390 void AwContents::GenerateMHTML(JNIEnv
* env
, jobject obj
,
391 jstring jpath
, jobject callback
) {
392 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
393 ScopedJavaGlobalRef
<jobject
>* j_callback
= new ScopedJavaGlobalRef
<jobject
>();
394 j_callback
->Reset(env
, callback
);
395 base::FilePath
target_path(ConvertJavaStringToUTF8(env
, jpath
));
396 web_contents_
->GenerateMHTML(
398 base::Bind(&GenerateMHTMLCallback
, base::Owned(j_callback
), target_path
));
401 void AwContents::CreatePdfExporter(JNIEnv
* env
,
403 jobject pdfExporter
) {
405 new AwPdfExporter(env
,
407 web_contents_
.get()));
410 bool AwContents::OnReceivedHttpAuthRequest(const JavaRef
<jobject
>& handler
,
411 const std::string
& host
,
412 const std::string
& realm
) {
413 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
414 JNIEnv
* env
= AttachCurrentThread();
415 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
419 ScopedJavaLocalRef
<jstring
> jhost
= ConvertUTF8ToJavaString(env
, host
);
420 ScopedJavaLocalRef
<jstring
> jrealm
= ConvertUTF8ToJavaString(env
, realm
);
421 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
422 "onReceivedHttpAuthRequest");
423 Java_AwContents_onReceivedHttpAuthRequest(env
, obj
.obj(), handler
.obj(),
424 jhost
.obj(), jrealm
.obj());
428 void AwContents::SetOffscreenPreRaster(bool enabled
) {
429 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
430 browser_view_renderer_
.SetOffscreenPreRaster(enabled
);
433 void AwContents::AddVisitedLinks(JNIEnv
* env
,
435 jobjectArray jvisited_links
) {
436 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
437 std::vector
<base::string16
> visited_link_strings
;
438 base::android::AppendJavaStringArrayToStringVector(
439 env
, jvisited_links
, &visited_link_strings
);
441 std::vector
<GURL
> visited_link_gurls
;
442 std::vector
<base::string16
>::const_iterator itr
;
443 for (itr
= visited_link_strings
.begin(); itr
!= visited_link_strings
.end();
445 visited_link_gurls
.push_back(GURL(*itr
));
448 AwBrowserContext::FromWebContents(web_contents_
.get())
449 ->AddVisitedURLs(visited_link_gurls
);
452 bool RegisterAwContents(JNIEnv
* env
) {
453 return RegisterNativesImpl(env
);
458 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef
& java_ref
,
459 const GURL
& origin
) {
460 JNIEnv
* env
= AttachCurrentThread();
461 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref
.get(env
);
463 ScopedJavaLocalRef
<jstring
> j_origin(
464 ConvertUTF8ToJavaString(env
, origin
.spec()));
465 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
466 "onGeolocationPermissionsShowPrompt");
467 Java_AwContents_onGeolocationPermissionsShowPrompt(env
,
473 void ShowGeolocationPromptHelper(const JavaObjectWeakGlobalRef
& java_ref
,
474 const GURL
& origin
) {
475 JNIEnv
* env
= AttachCurrentThread();
476 if (java_ref
.get(env
).obj()) {
477 content::BrowserThread::PostTask(
478 content::BrowserThread::UI
,
480 base::Bind(&ShowGeolocationPromptHelperTask
,
486 } // anonymous namespace
488 void AwContents::ShowGeolocationPrompt(const GURL
& requesting_frame
,
489 base::Callback
<void(bool)> callback
) {
490 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
492 GURL origin
= requesting_frame
.GetOrigin();
493 bool show_prompt
= pending_geolocation_prompts_
.empty();
494 pending_geolocation_prompts_
.push_back(OriginCallback(origin
, callback
));
496 ShowGeolocationPromptHelper(java_ref_
, origin
);
501 void AwContents::InvokeGeolocationCallback(JNIEnv
* env
,
505 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
506 if (pending_geolocation_prompts_
.empty())
509 GURL
callback_origin(base::android::ConvertJavaStringToUTF16(env
, origin
));
510 if (callback_origin
.GetOrigin() ==
511 pending_geolocation_prompts_
.front().first
) {
512 pending_geolocation_prompts_
.front().second
.Run(value
);
513 pending_geolocation_prompts_
.pop_front();
514 if (!pending_geolocation_prompts_
.empty()) {
515 ShowGeolocationPromptHelper(java_ref_
,
516 pending_geolocation_prompts_
.front().first
);
521 void AwContents::HideGeolocationPrompt(const GURL
& origin
) {
522 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
523 bool removed_current_outstanding_callback
= false;
524 std::list
<OriginCallback
>::iterator it
= pending_geolocation_prompts_
.begin();
525 while (it
!= pending_geolocation_prompts_
.end()) {
526 if ((*it
).first
== origin
.GetOrigin()) {
527 if (it
== pending_geolocation_prompts_
.begin()) {
528 removed_current_outstanding_callback
= true;
530 it
= pending_geolocation_prompts_
.erase(it
);
536 if (removed_current_outstanding_callback
) {
537 JNIEnv
* env
= AttachCurrentThread();
538 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
540 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
541 "onGeolocationPermissionsHidePrompt");
542 Java_AwContents_onGeolocationPermissionsHidePrompt(env
, j_ref
.obj());
544 if (!pending_geolocation_prompts_
.empty()) {
545 ShowGeolocationPromptHelper(java_ref_
,
546 pending_geolocation_prompts_
.front().first
);
551 void AwContents::OnPermissionRequest(
552 base::android::ScopedJavaLocalRef
<jobject
> j_request
,
553 AwPermissionRequest
* request
) {
554 DCHECK(!j_request
.is_null());
557 JNIEnv
* env
= AttachCurrentThread();
558 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
559 if (j_ref
.is_null()) {
560 permission_request_handler_
->CancelRequest(request
->GetOrigin(),
561 request
->GetResources());
565 Java_AwContents_onPermissionRequest(env
, j_ref
.obj(), j_request
.obj());
568 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest
* request
) {
569 JNIEnv
* env
= AttachCurrentThread();
570 ScopedJavaLocalRef
<jobject
> j_request
= request
->GetJavaObject();
571 ScopedJavaLocalRef
<jobject
> j_ref
= java_ref_
.get(env
);
572 if (j_request
.is_null() || j_ref
.is_null())
575 Java_AwContents_onPermissionRequestCanceled(
576 env
, j_ref
.obj(), j_request
.obj());
579 void AwContents::PreauthorizePermission(
584 permission_request_handler_
->PreauthorizePermission(
585 GURL(base::android::ConvertJavaStringToUTF8(env
, origin
)), resources
);
588 void AwContents::RequestProtectedMediaIdentifierPermission(
590 const base::Callback
<void(bool)>& callback
) {
591 permission_request_handler_
->SendRequest(
592 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
593 origin
, AwPermissionRequest::ProtectedMediaId
, callback
)));
596 void AwContents::CancelProtectedMediaIdentifierPermissionRequests(
597 const GURL
& origin
) {
598 permission_request_handler_
->CancelRequest(
599 origin
, AwPermissionRequest::ProtectedMediaId
);
602 void AwContents::RequestGeolocationPermission(
604 const base::Callback
<void(bool)>& callback
) {
605 JNIEnv
* env
= AttachCurrentThread();
606 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
610 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env
, obj
.obj())) {
611 ShowGeolocationPrompt(origin
, callback
);
614 permission_request_handler_
->SendRequest(
615 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
616 origin
, AwPermissionRequest::Geolocation
, callback
)));
619 void AwContents::CancelGeolocationPermissionRequests(const GURL
& origin
) {
620 JNIEnv
* env
= AttachCurrentThread();
621 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
625 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env
, obj
.obj())) {
626 HideGeolocationPrompt(origin
);
629 permission_request_handler_
->CancelRequest(
630 origin
, AwPermissionRequest::Geolocation
);
633 void AwContents::RequestMIDISysexPermission(
635 const base::Callback
<void(bool)>& callback
) {
636 permission_request_handler_
->SendRequest(
637 scoped_ptr
<AwPermissionRequestDelegate
>(new SimplePermissionRequest(
638 origin
, AwPermissionRequest::MIDISysex
, callback
)));
641 void AwContents::CancelMIDISysexPermissionRequests(const GURL
& origin
) {
642 permission_request_handler_
->CancelRequest(
643 origin
, AwPermissionRequest::AwPermissionRequest::MIDISysex
);
646 void AwContents::FindAllAsync(JNIEnv
* env
, jobject obj
, jstring search_string
) {
647 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
648 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env
, search_string
));
651 void AwContents::FindNext(JNIEnv
* env
, jobject obj
, jboolean forward
) {
652 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
653 GetFindHelper()->FindNext(forward
);
656 void AwContents::ClearMatches(JNIEnv
* env
, jobject obj
) {
657 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
658 GetFindHelper()->ClearMatches();
661 void AwContents::ClearCache(
664 jboolean include_disk_files
) {
665 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
666 render_view_host_ext_
->ClearCache();
668 if (include_disk_files
) {
669 RemoveHttpDiskCache(web_contents_
->GetBrowserContext(),
670 web_contents_
->GetRoutingID());
674 FindHelper
* AwContents::GetFindHelper() {
675 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
676 if (!find_helper_
.get()) {
677 find_helper_
.reset(new FindHelper(web_contents_
.get()));
678 find_helper_
->SetListener(this);
680 return find_helper_
.get();
683 void AwContents::OnFindResultReceived(int active_ordinal
,
686 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
687 JNIEnv
* env
= AttachCurrentThread();
688 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
692 Java_AwContents_onFindResultReceived(
693 env
, obj
.obj(), active_ordinal
, match_count
, finished
);
696 bool AwContents::ShouldDownloadFavicon(const GURL
& icon_url
) {
697 return g_should_download_favicons
;
700 void AwContents::OnReceivedIcon(const GURL
& icon_url
, const SkBitmap
& bitmap
) {
701 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
702 JNIEnv
* env
= AttachCurrentThread();
703 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
707 content::NavigationEntry
* entry
=
708 web_contents_
->GetController().GetLastCommittedEntry();
711 entry
->GetFavicon().valid
= true;
712 entry
->GetFavicon().url
= icon_url
;
713 entry
->GetFavicon().image
= gfx::Image::CreateFrom1xBitmap(bitmap
);
716 Java_AwContents_onReceivedIcon(
717 env
, obj
.obj(), gfx::ConvertToJavaBitmap(&bitmap
).obj());
720 void AwContents::OnReceivedTouchIconUrl(const std::string
& url
,
722 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
723 JNIEnv
* env
= AttachCurrentThread();
724 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
728 Java_AwContents_onReceivedTouchIconUrl(
729 env
, obj
.obj(), ConvertUTF8ToJavaString(env
, url
).obj(), precomposed
);
732 bool AwContents::RequestDrawGL(bool wait_for_completion
) {
733 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
734 JNIEnv
* env
= AttachCurrentThread();
735 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
738 return Java_AwContents_requestDrawGL(env
, obj
.obj(), wait_for_completion
);
741 void AwContents::PostInvalidate() {
742 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
743 JNIEnv
* env
= AttachCurrentThread();
744 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
746 Java_AwContents_postInvalidateOnAnimation(env
, obj
.obj());
749 void AwContents::OnNewPicture() {
750 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
751 JNIEnv
* env
= AttachCurrentThread();
752 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
753 if (!obj
.is_null()) {
754 devtools_instrumentation::ScopedEmbedderCallbackTask
embedder_callback(
756 Java_AwContents_onNewPicture(env
, obj
.obj());
760 base::android::ScopedJavaLocalRef
<jbyteArray
> AwContents::GetCertificate(
763 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
764 content::NavigationEntry
* entry
=
765 web_contents_
->GetController().GetLastCommittedEntry();
767 return ScopedJavaLocalRef
<jbyteArray
>();
768 // Get the certificate
769 int cert_id
= entry
->GetSSL().cert_id
;
770 scoped_refptr
<net::X509Certificate
> cert
;
771 bool ok
= content::CertStore::GetInstance()->RetrieveCert(cert_id
, &cert
);
773 return ScopedJavaLocalRef
<jbyteArray
>();
775 // Convert the certificate and return it
776 std::string der_string
;
777 net::X509Certificate::GetDEREncoded(cert
->os_cert_handle(), &der_string
);
778 return base::android::ToJavaByteArray(env
,
779 reinterpret_cast<const uint8
*>(der_string
.data()), der_string
.length());
782 void AwContents::RequestNewHitTestDataAt(JNIEnv
* env
,
786 jfloat touch_major
) {
787 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
788 gfx::PointF
touch_center(x
, y
);
789 gfx::SizeF
touch_area(touch_major
, touch_major
);
790 render_view_host_ext_
->RequestNewHitTestDataAt(touch_center
, touch_area
);
793 void AwContents::UpdateLastHitTestData(JNIEnv
* env
, jobject obj
) {
794 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
795 if (!render_view_host_ext_
->HasNewHitTestData()) return;
797 const AwHitTestData
& data
= render_view_host_ext_
->GetLastHitTestData();
798 render_view_host_ext_
->MarkHitTestDataRead();
800 // Make sure to null the Java object if data is empty/invalid.
801 ScopedJavaLocalRef
<jstring
> extra_data_for_type
;
802 if (data
.extra_data_for_type
.length())
803 extra_data_for_type
= ConvertUTF8ToJavaString(
804 env
, data
.extra_data_for_type
);
806 ScopedJavaLocalRef
<jstring
> href
;
807 if (data
.href
.length())
808 href
= ConvertUTF16ToJavaString(env
, data
.href
);
810 ScopedJavaLocalRef
<jstring
> anchor_text
;
811 if (data
.anchor_text
.length())
812 anchor_text
= ConvertUTF16ToJavaString(env
, data
.anchor_text
);
814 ScopedJavaLocalRef
<jstring
> img_src
;
815 if (data
.img_src
.is_valid())
816 img_src
= ConvertUTF8ToJavaString(env
, data
.img_src
.spec());
818 Java_AwContents_updateHitTestData(env
,
821 extra_data_for_type
.obj(),
827 void AwContents::OnSizeChanged(JNIEnv
* env
, jobject obj
,
828 int w
, int h
, int ow
, int oh
) {
829 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
830 browser_view_renderer_
.OnSizeChanged(w
, h
);
833 void AwContents::SetViewVisibility(JNIEnv
* env
, jobject obj
, bool visible
) {
834 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
835 browser_view_renderer_
.SetViewVisibility(visible
);
838 void AwContents::SetWindowVisibility(JNIEnv
* env
, jobject obj
, bool visible
) {
839 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
840 browser_view_renderer_
.SetWindowVisibility(visible
);
843 void AwContents::SetIsPaused(JNIEnv
* env
, jobject obj
, bool paused
) {
844 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
845 browser_view_renderer_
.SetIsPaused(paused
);
846 ContentViewCore
* cvc
=
847 ContentViewCore::FromWebContents(web_contents_
.get());
849 cvc
->PauseOrResumeGeolocation(paused
);
853 void AwContents::OnAttachedToWindow(JNIEnv
* env
, jobject obj
, int w
, int h
) {
854 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
855 browser_view_renderer_
.OnAttachedToWindow(w
, h
);
858 void AwContents::OnDetachedFromWindow(JNIEnv
* env
, jobject obj
) {
859 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
860 browser_view_renderer_
.OnDetachedFromWindow();
863 void AwContents::DetachFunctorFromView() {
864 JNIEnv
* env
= AttachCurrentThread();
865 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
867 Java_AwContents_detachFunctorFromView(env
, obj
.obj());
870 base::android::ScopedJavaLocalRef
<jbyteArray
>
871 AwContents::GetOpaqueState(JNIEnv
* env
, jobject obj
) {
872 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
873 // Required optimization in WebViewClassic to not save any state if
874 // there has been no navigations.
875 if (!web_contents_
->GetController().GetEntryCount())
876 return ScopedJavaLocalRef
<jbyteArray
>();
879 if (!WriteToPickle(*web_contents_
, &pickle
)) {
880 return ScopedJavaLocalRef
<jbyteArray
>();
882 return base::android::ToJavaByteArray(env
,
883 reinterpret_cast<const uint8
*>(pickle
.data()), pickle
.size());
887 jboolean
AwContents::RestoreFromOpaqueState(
888 JNIEnv
* env
, jobject obj
, jbyteArray state
) {
889 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
890 // TODO(boliu): This copy can be optimized out if this is a performance
892 std::vector
<uint8
> state_vector
;
893 base::android::JavaByteArrayToByteVector(env
, state
, &state_vector
);
895 base::Pickle
pickle(reinterpret_cast<const char*>(state_vector
.data()),
896 state_vector
.size());
897 base::PickleIterator
iterator(pickle
);
899 return RestoreFromPickle(&iterator
, web_contents_
.get());
902 bool AwContents::OnDraw(JNIEnv
* env
,
905 jboolean is_hardware_accelerated
,
911 jint visible_bottom
) {
912 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
913 gfx::Vector2d
scroll(scroll_x
, scroll_y
);
914 browser_view_renderer_
.PrepareToDraw(
915 scroll
, gfx::Rect(visible_left
, visible_top
, visible_right
- visible_left
,
916 visible_bottom
- visible_top
));
917 if (is_hardware_accelerated
&& browser_view_renderer_
.attached_to_window() &&
918 !g_force_auxiliary_bitmap_rendering
) {
919 return browser_view_renderer_
.OnDrawHardware();
922 gfx::Size view_size
= browser_view_renderer_
.size();
923 if (view_size
.IsEmpty()) {
924 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_EmptySize",
925 TRACE_EVENT_SCOPE_THREAD
);
929 // TODO(hush): Right now webview size is passed in as the auxiliary bitmap
930 // size, which might hurt performace (only for software draws with auxiliary
931 // bitmap). For better performance, get global visible rect, transform it
932 // from screen space to view space, then intersect with the webview in
933 // viewspace. Use the resulting rect as the auxiliary bitmap.
934 scoped_ptr
<SoftwareCanvasHolder
> canvas_holder
= SoftwareCanvasHolder::Create(
935 canvas
, scroll
, view_size
, g_force_auxiliary_bitmap_rendering
);
936 if (!canvas_holder
|| !canvas_holder
->GetCanvas()) {
937 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_EmptySize",
938 TRACE_EVENT_SCOPE_THREAD
);
941 return browser_view_renderer_
.OnDrawSoftware(canvas_holder
->GetCanvas());
944 void AwContents::SetPendingWebContentsForPopup(
945 scoped_ptr
<content::WebContents
> pending
) {
946 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
947 if (pending_contents_
.get()) {
948 // TODO(benm): Support holding multiple pop up window requests.
949 LOG(WARNING
) << "Blocking popup window creation as an outstanding "
950 << "popup window is still pending.";
951 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, pending
.release());
954 pending_contents_
.reset(new AwContents(pending
.Pass()));
955 // Set dip_scale for pending contents, which is necessary for the later
956 // SynchronousCompositor and InputHandler setup.
957 pending_contents_
->SetDipScaleInternal(browser_view_renderer_
.dip_scale());
960 void AwContents::FocusFirstNode(JNIEnv
* env
, jobject obj
) {
961 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
962 web_contents_
->FocusThroughTabTraversal(false);
965 void AwContents::SetBackgroundColor(JNIEnv
* env
, jobject obj
, jint color
) {
966 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
967 render_view_host_ext_
->SetBackgroundColor(color
);
970 void AwContents::OnComputeScroll(JNIEnv
* env
,
972 jlong animation_time_millis
) {
973 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
974 browser_view_renderer_
.OnComputeScroll(
976 base::TimeDelta::FromMilliseconds(animation_time_millis
));
979 jlong
AwContents::ReleasePopupAwContents(JNIEnv
* env
, jobject obj
) {
980 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
981 return reinterpret_cast<intptr_t>(pending_contents_
.release());
984 gfx::Point
AwContents::GetLocationOnScreen() {
985 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
986 JNIEnv
* env
= AttachCurrentThread();
987 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
990 std::vector
<int> location
;
991 base::android::JavaIntArrayToIntVector(
993 Java_AwContents_getLocationOnScreen(env
, obj
.obj()).obj(),
995 return gfx::Point(location
[0], location
[1]);
998 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value
) {
999 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1000 JNIEnv
* env
= AttachCurrentThread();
1001 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1004 Java_AwContents_scrollContainerViewTo(
1005 env
, obj
.obj(), new_value
.x(), new_value
.y());
1008 bool AwContents::IsSmoothScrollingActive() const {
1009 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1010 JNIEnv
* env
= AttachCurrentThread();
1011 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1014 return Java_AwContents_isSmoothScrollingActive(env
, obj
.obj());
1017 void AwContents::UpdateScrollState(gfx::Vector2d max_scroll_offset
,
1018 gfx::SizeF contents_size_dip
,
1019 float page_scale_factor
,
1020 float min_page_scale_factor
,
1021 float max_page_scale_factor
) {
1022 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1023 JNIEnv
* env
= AttachCurrentThread();
1024 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1027 Java_AwContents_updateScrollState(env
,
1029 max_scroll_offset
.x(),
1030 max_scroll_offset
.y(),
1031 contents_size_dip
.width(),
1032 contents_size_dip
.height(),
1034 min_page_scale_factor
,
1035 max_page_scale_factor
);
1038 void AwContents::DidOverscroll(gfx::Vector2d overscroll_delta
,
1039 gfx::Vector2dF overscroll_velocity
) {
1040 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1041 JNIEnv
* env
= AttachCurrentThread();
1042 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1045 Java_AwContents_didOverscroll(env
, obj
.obj(), overscroll_delta
.x(),
1046 overscroll_delta
.y(), overscroll_velocity
.x(),
1047 overscroll_velocity
.y());
1050 void AwContents::SetDipScale(JNIEnv
* env
, jobject obj
, jfloat dip_scale
) {
1051 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1052 SetDipScaleInternal(dip_scale
);
1055 void AwContents::SetDipScaleInternal(float dip_scale
) {
1056 browser_view_renderer_
.SetDipScale(dip_scale
);
1059 void AwContents::ScrollTo(JNIEnv
* env
, jobject obj
, jint x
, jint y
) {
1060 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1061 browser_view_renderer_
.ScrollTo(gfx::Vector2d(x
, y
));
1064 void AwContents::OnWebLayoutPageScaleFactorChanged(float page_scale_factor
) {
1065 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1066 JNIEnv
* env
= AttachCurrentThread();
1067 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1070 Java_AwContents_onWebLayoutPageScaleFactorChanged(env
, obj
.obj(),
1074 void AwContents::OnWebLayoutContentsSizeChanged(
1075 const gfx::Size
& contents_size
) {
1076 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1077 JNIEnv
* env
= AttachCurrentThread();
1078 ScopedJavaLocalRef
<jobject
> obj
= java_ref_
.get(env
);
1081 Java_AwContents_onWebLayoutContentsSizeChanged(
1082 env
, obj
.obj(), contents_size
.width(), contents_size
.height());
1085 jlong
AwContents::CapturePicture(JNIEnv
* env
,
1089 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1090 return reinterpret_cast<intptr_t>(
1091 new AwPicture(browser_view_renderer_
.CapturePicture(width
, height
)));
1094 void AwContents::EnableOnNewPicture(JNIEnv
* env
,
1097 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1098 browser_view_renderer_
.EnableOnNewPicture(enabled
);
1102 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef
& java_ref
,
1104 ScopedJavaGlobalRef
<jobject
>* callback
,
1106 JNIEnv
* env
= AttachCurrentThread();
1107 ScopedJavaLocalRef
<jobject
> obj
= java_ref
.get(env
);
1110 Java_AwContents_invokeVisualStateCallback(
1111 env
, obj
.obj(), callback
->obj(), request_id
);
1115 void AwContents::InsertVisualStateCallback(
1116 JNIEnv
* env
, jobject obj
, long request_id
, jobject callback
) {
1117 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1118 ScopedJavaGlobalRef
<jobject
>* j_callback
= new ScopedJavaGlobalRef
<jobject
>();
1119 j_callback
->Reset(env
, callback
);
1120 web_contents_
->GetMainFrame()->InsertVisualStateCallback(
1121 base::Bind(&InvokeVisualStateCallback
, java_ref_
, request_id
,
1122 base::Owned(j_callback
)));
1125 void AwContents::ClearView(JNIEnv
* env
, jobject obj
) {
1126 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1127 browser_view_renderer_
.ClearView();
1130 void AwContents::SetExtraHeadersForUrl(JNIEnv
* env
, jobject obj
,
1131 jstring url
, jstring jextra_headers
) {
1132 std::string extra_headers
;
1134 extra_headers
= ConvertJavaStringToUTF8(env
, jextra_headers
);
1135 AwResourceContext
* resource_context
= static_cast<AwResourceContext
*>(
1136 AwBrowserContext::FromWebContents(web_contents_
.get())->
1137 GetResourceContext());
1138 resource_context
->SetExtraHeaders(GURL(ConvertJavaStringToUTF8(env
, url
)),
1142 void AwContents::SetJsOnlineProperty(JNIEnv
* env
,
1144 jboolean network_up
) {
1145 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1146 render_view_host_ext_
->SetJsOnlineProperty(network_up
);
1149 void AwContents::TrimMemory(JNIEnv
* env
,
1153 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1154 browser_view_renderer_
.TrimMemory(level
, visible
);
1157 // TODO(sgurun) add support for posting a frame whose name is known (only
1158 // main frame is supported at this time, see crbug.com/389721)
1159 void AwContents::PostMessageToFrame(JNIEnv
* env
, jobject obj
,
1160 jstring frame_name
, jstring message
, jstring target_origin
,
1161 jintArray sent_ports
) {
1163 // Use an empty source origin for android webview.
1164 base::string16 source_origin
;
1165 base::string16
j_target_origin(ConvertJavaStringToUTF16(env
, target_origin
));
1166 base::string16
j_message(ConvertJavaStringToUTF16(env
, message
));
1167 std::vector
<int> j_ports
;
1169 if (sent_ports
!= nullptr) {
1170 base::android::JavaIntArrayToIntVector(env
, sent_ports
, &j_ports
);
1171 BrowserThread::PostTask(
1174 base::Bind(&AwMessagePortServiceImpl::RemoveSentPorts
,
1175 base::Unretained(AwMessagePortServiceImpl::GetInstance()),
1178 std::vector
<content::TransferredMessagePort
> ports(j_ports
.size());
1179 for (size_t i
= 0; i
< j_ports
.size(); ++i
)
1180 ports
[i
].id
= j_ports
[i
];
1181 content::MessagePortProvider::PostMessageToFrame(web_contents_
.get(),
1188 scoped_refptr
<AwMessagePortMessageFilter
>
1189 AwContents::GetMessagePortMessageFilter() {
1190 // Create a message port message filter if necessary
1191 if (message_port_message_filter_
.get() == nullptr) {
1192 message_port_message_filter_
=
1193 new AwMessagePortMessageFilter(
1194 web_contents_
->GetMainFrame()->GetRoutingID());
1195 web_contents_
->GetRenderProcessHost()->AddFilter(
1196 message_port_message_filter_
.get());
1198 return message_port_message_filter_
;
1201 void AwContents::CreateMessageChannel(JNIEnv
* env
, jobject obj
,
1202 jobjectArray ports
) {
1204 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env
, ports
,
1205 GetMessagePortMessageFilter());
1208 void SetShouldDownloadFavicons(JNIEnv
* env
, jclass jclazz
) {
1209 g_should_download_favicons
= true;
1212 } // namespace android_webview