| 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 "android_webview/common/devtools_instrumentation.h" | 7 #include "android_webview/common/devtools_instrumentation.h" |
| 8 #include "android_webview/native/aw_contents.h" | 8 #include "android_webview/native/aw_contents.h" |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 ScopedJavaLocalRef<jstring> jurl( | 333 ScopedJavaLocalRef<jstring> jurl( |
| 334 ConvertUTF8ToJavaString(env, origin_url.spec())); | 334 ConvertUTF8ToJavaString(env, origin_url.spec())); |
| 335 ScopedJavaLocalRef<jstring> jmessage( | 335 ScopedJavaLocalRef<jstring> jmessage( |
| 336 ConvertUTF16ToJavaString(env, message_text)); | 336 ConvertUTF16ToJavaString(env, message_text)); |
| 337 | 337 |
| 338 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsBeforeUnload"); | 338 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsBeforeUnload"); |
| 339 Java_AwContentsClientBridge_handleJsBeforeUnload( | 339 Java_AwContentsClientBridge_handleJsBeforeUnload( |
| 340 env, obj.obj(), jurl.obj(), jmessage.obj(), callback_id); | 340 env, obj.obj(), jurl.obj(), jmessage.obj(), callback_id); |
| 341 } | 341 } |
| 342 | 342 |
| 343 bool AwContentsClientBridge::ShouldOverrideUrlLoading(const base::string16& url, | |
| 344 bool has_user_gesture, | |
| 345 bool is_redirect, | |
| 346 bool is_main_frame) { | |
| 347 JNIEnv* env = AttachCurrentThread(); | |
| 348 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 349 if (obj.is_null()) | |
| 350 return false; | |
| 351 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url); | |
| 352 devtools_instrumentation::ScopedEmbedderCallbackTask( | |
| 353 "shouldOverrideUrlLoading"); | |
| 354 return Java_AwContentsClientBridge_shouldOverrideUrlLoading( | |
| 355 env, obj.obj(), jurl.obj(), has_user_gesture, is_redirect, is_main_frame); | |
| 356 } | |
| 357 | |
| 358 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, | 343 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, |
| 359 jobject, | 344 jobject, |
| 360 int id, | 345 int id, |
| 361 jstring prompt) { | 346 jstring prompt) { |
| 362 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 347 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 363 content::JavaScriptDialogManager::DialogClosedCallback* callback = | 348 content::JavaScriptDialogManager::DialogClosedCallback* callback = |
| 364 pending_js_dialog_callbacks_.Lookup(id); | 349 pending_js_dialog_callbacks_.Lookup(id); |
| 365 if (!callback) { | 350 if (!callback) { |
| 366 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; | 351 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; |
| 367 return; | 352 return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 394 pending_client_cert_request_delegates_.Remove(request_id); | 379 pending_client_cert_request_delegates_.Remove(request_id); |
| 395 | 380 |
| 396 delete delegate; | 381 delete delegate; |
| 397 } | 382 } |
| 398 | 383 |
| 399 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 384 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 400 return RegisterNativesImpl(env); | 385 return RegisterNativesImpl(env); |
| 401 } | 386 } |
| 402 | 387 |
| 403 } // namespace android_webview | 388 } // namespace android_webview |
| OLD | NEW |