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