OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_client_bridge.h" | 5 #include "android_webview/native/aw_contents_client_bridge.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "android_webview/common/devtools_instrumentation.h" | 9 #include "android_webview/common/devtools_instrumentation.h" |
10 #include "android_webview/native/aw_contents.h" | 10 #include "android_webview/native/aw_contents.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // Tell the chromium message loop to not perform any tasks after the current | 356 // Tell the chromium message loop to not perform any tasks after the current |
357 // one - we want to make sure we return to Java cleanly without first making | 357 // one - we want to make sure we return to Java cleanly without first making |
358 // any new JNI calls. | 358 // any new JNI calls. |
359 base::MessageLoopForUI::current()->Abort(); | 359 base::MessageLoopForUI::current()->Abort(); |
360 // If we crashed we don't want to continue the navigation. | 360 // If we crashed we don't want to continue the navigation. |
361 return true; | 361 return true; |
362 } | 362 } |
363 return did_override; | 363 return did_override; |
364 } | 364 } |
365 | 365 |
| 366 void AwContentsClientBridge::NewDownload(const GURL& url, |
| 367 const std::string& user_agent, |
| 368 const std::string& content_disposition, |
| 369 const std::string& mime_type, |
| 370 int64_t content_length) { |
| 371 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 372 JNIEnv* env = AttachCurrentThread(); |
| 373 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 374 if (obj.is_null()) |
| 375 return; |
| 376 |
| 377 ScopedJavaLocalRef<jstring> jstring_url = |
| 378 ConvertUTF8ToJavaString(env, url.spec()); |
| 379 ScopedJavaLocalRef<jstring> jstring_user_agent = |
| 380 ConvertUTF8ToJavaString(env, user_agent); |
| 381 ScopedJavaLocalRef<jstring> jstring_content_disposition = |
| 382 ConvertUTF8ToJavaString(env, content_disposition); |
| 383 ScopedJavaLocalRef<jstring> jstring_mime_type = |
| 384 ConvertUTF8ToJavaString(env, mime_type); |
| 385 |
| 386 Java_AwContentsClientBridge_newDownload( |
| 387 env, obj, jstring_url, jstring_user_agent, jstring_content_disposition, |
| 388 jstring_mime_type, content_length); |
| 389 } |
| 390 |
366 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, | 391 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, |
367 const JavaRef<jobject>&, | 392 const JavaRef<jobject>&, |
368 int id, | 393 int id, |
369 const JavaRef<jstring>& prompt) { | 394 const JavaRef<jstring>& prompt) { |
370 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 395 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
371 content::JavaScriptDialogManager::DialogClosedCallback* callback = | 396 content::JavaScriptDialogManager::DialogClosedCallback* callback = |
372 pending_js_dialog_callbacks_.Lookup(id); | 397 pending_js_dialog_callbacks_.Lookup(id); |
373 if (!callback) { | 398 if (!callback) { |
374 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; | 399 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; |
375 return; | 400 return; |
(...skipping 28 matching lines...) Expand all Loading... |
404 pending_client_cert_request_delegates_.Remove(request_id); | 429 pending_client_cert_request_delegates_.Remove(request_id); |
405 | 430 |
406 delete delegate; | 431 delete delegate; |
407 } | 432 } |
408 | 433 |
409 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 434 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
410 return RegisterNativesImpl(env); | 435 return RegisterNativesImpl(env); |
411 } | 436 } |
412 | 437 |
413 } // namespace android_webview | 438 } // namespace android_webview |
OLD | NEW |