| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if (ContentAutofillDriverFactory::FromWebContents(web_contents)) | 266 if (ContentAutofillDriverFactory::FromWebContents(web_contents)) |
| 267 return; | 267 return; |
| 268 | 268 |
| 269 AwAutofillClient::CreateForWebContents(web_contents); | 269 AwAutofillClient::CreateForWebContents(web_contents); |
| 270 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( | 270 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( |
| 271 web_contents, AwAutofillClient::FromWebContents(web_contents), | 271 web_contents, AwAutofillClient::FromWebContents(web_contents), |
| 272 base::android::GetDefaultLocale(), | 272 base::android::GetDefaultLocale(), |
| 273 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 273 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void AwContents::SetAwAutofillClient(jobject client) { | 276 void AwContents::SetAwAutofillClient(const JavaRef<jobject>& client) { |
| 277 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 277 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 278 JNIEnv* env = AttachCurrentThread(); | 278 JNIEnv* env = AttachCurrentThread(); |
| 279 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 279 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 280 if (obj.is_null()) | 280 if (obj.is_null()) |
| 281 return; | 281 return; |
| 282 Java_AwContents_setAwAutofillClient(env, obj, client); | 282 Java_AwContents_setAwAutofillClient(env, obj, client); |
| 283 } | 283 } |
| 284 | 284 |
| 285 AwContents::~AwContents() { | 285 AwContents::~AwContents() { |
| 286 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_.get())); | 286 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_.get())); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 base::Bind(&DocumentHasImagesCallback, j_message)); | 392 base::Bind(&DocumentHasImagesCallback, j_message)); |
| 393 } | 393 } |
| 394 | 394 |
| 395 namespace { | 395 namespace { |
| 396 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback, | 396 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback, |
| 397 const base::FilePath& path, | 397 const base::FilePath& path, |
| 398 int64_t size) { | 398 int64_t size) { |
| 399 JNIEnv* env = AttachCurrentThread(); | 399 JNIEnv* env = AttachCurrentThread(); |
| 400 // Android files are UTF8, so the path conversion below is safe. | 400 // Android files are UTF8, so the path conversion below is safe. |
| 401 Java_AwContents_generateMHTMLCallback( | 401 Java_AwContents_generateMHTMLCallback( |
| 402 env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, | 402 env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, *callback); |
| 403 callback->obj()); | |
| 404 } | 403 } |
| 405 } // namespace | 404 } // namespace |
| 406 | 405 |
| 407 void AwContents::GenerateMHTML(JNIEnv* env, | 406 void AwContents::GenerateMHTML(JNIEnv* env, |
| 408 const JavaParamRef<jobject>& obj, | 407 const JavaParamRef<jobject>& obj, |
| 409 const JavaParamRef<jstring>& jpath, | 408 const JavaParamRef<jstring>& jpath, |
| 410 const JavaParamRef<jobject>& callback) { | 409 const JavaParamRef<jobject>& callback) { |
| 411 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 410 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 412 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); | 411 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| 413 j_callback->Reset(env, callback); | 412 j_callback->Reset(env, callback); |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 | 1139 |
| 1141 namespace { | 1140 namespace { |
| 1142 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref, | 1141 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref, |
| 1143 jlong request_id, | 1142 jlong request_id, |
| 1144 ScopedJavaGlobalRef<jobject>* callback, | 1143 ScopedJavaGlobalRef<jobject>* callback, |
| 1145 bool result) { | 1144 bool result) { |
| 1146 JNIEnv* env = AttachCurrentThread(); | 1145 JNIEnv* env = AttachCurrentThread(); |
| 1147 ScopedJavaLocalRef<jobject> obj = java_ref.get(env); | 1146 ScopedJavaLocalRef<jobject> obj = java_ref.get(env); |
| 1148 if (obj.is_null()) | 1147 if (obj.is_null()) |
| 1149 return; | 1148 return; |
| 1150 Java_AwContents_invokeVisualStateCallback(env, obj, callback->obj(), | 1149 Java_AwContents_invokeVisualStateCallback(env, obj, *callback, request_id); |
| 1151 request_id); | |
| 1152 } | 1150 } |
| 1153 } // namespace | 1151 } // namespace |
| 1154 | 1152 |
| 1155 void AwContents::InsertVisualStateCallback( | 1153 void AwContents::InsertVisualStateCallback( |
| 1156 JNIEnv* env, | 1154 JNIEnv* env, |
| 1157 const JavaParamRef<jobject>& obj, | 1155 const JavaParamRef<jobject>& obj, |
| 1158 jlong request_id, | 1156 jlong request_id, |
| 1159 const JavaParamRef<jobject>& callback) { | 1157 const JavaParamRef<jobject>& callback) { |
| 1160 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1158 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1161 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); | 1159 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 int routing_id = new_host->GetRoutingID(); | 1292 int routing_id = new_host->GetRoutingID(); |
| 1295 // At this point, the current RVH may or may not contain a compositor. So | 1293 // At this point, the current RVH may or may not contain a compositor. So |
| 1296 // compositor_ may be nullptr, in which case | 1294 // compositor_ may be nullptr, in which case |
| 1297 // BrowserViewRenderer::DidInitializeCompositor() callback is time when the | 1295 // BrowserViewRenderer::DidInitializeCompositor() callback is time when the |
| 1298 // new compositor is constructed. | 1296 // new compositor is constructed. |
| 1299 browser_view_renderer_.SetActiveCompositorID( | 1297 browser_view_renderer_.SetActiveCompositorID( |
| 1300 CompositorID(process_id, routing_id)); | 1298 CompositorID(process_id, routing_id)); |
| 1301 } | 1299 } |
| 1302 | 1300 |
| 1303 } // namespace android_webview | 1301 } // namespace android_webview |
| OLD | NEW |