OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #include "android_webview/native/js_result_handler.h" |
| 6 |
| 7 #include "base/android/jni_string.h" |
| 8 #include "jni/JsResultHandler_jni.h" |
| 9 #include "content/public/browser/javascript_dialogs.h" |
| 10 #include "content/public/browser/android/content_view_core.h" |
| 11 |
| 12 using base::android::ConvertJavaStringToUTF16; |
| 13 using content::ContentViewCore; |
| 14 |
| 15 namespace android_webview { |
| 16 |
| 17 void ConfirmJsResult(JNIEnv* env, |
| 18 jobject obj, |
| 19 jint dialogPointer, |
| 20 jstring promptResult) { |
| 21 content::JavaScriptDialogCreator::DialogClosedCallback* dialog_ = |
| 22 reinterpret_cast<content::JavaScriptDialogCreator::DialogClosedCallback*>( |
| 23 dialogPointer); |
| 24 string16 prompt_text; |
| 25 if (promptResult) { |
| 26 prompt_text = ConvertJavaStringToUTF16(env, promptResult); |
| 27 } |
| 28 dialog_->Run(true,prompt_text); |
| 29 } |
| 30 |
| 31 void CancelJsResult(JNIEnv* env, jobject obj, jint dialogPointer) { |
| 32 content::JavaScriptDialogCreator::DialogClosedCallback* dialog_ = |
| 33 reinterpret_cast<content::JavaScriptDialogCreator::DialogClosedCallback*>( |
| 34 dialogPointer); |
| 35 dialog_->Run(false, string16()); |
| 36 } |
| 37 |
| 38 base::android::ScopedJavaLocalRef<jobject> createJsResultHandler( |
| 39 JNIEnv* env, |
| 40 const content::JavaScriptDialogCreator::DialogClosedCallback* dialog) { |
| 41 return Java_JsResultHandler_create(env, reinterpret_cast<jint>(dialog)); |
| 42 } |
| 43 |
| 44 bool RegisterJsResultHandler(JNIEnv* env) { |
| 45 return RegisterNativesImpl(env); |
| 46 } |
| 47 |
| 48 } // namespace android_webview |
OLD | NEW |