| 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 "chrome/browser/android/js_result_handler.h" |
| 6 |
| 7 #include "base/android/jni_string.h" |
| 8 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 9 #include "jni/JsResultHandler_jni.h" |
| 10 #include "content/public/browser/android/content_view_core.h" |
| 11 |
| 12 using base::android::ConvertJavaStringToUTF16; |
| 13 using content::ContentViewCore; |
| 14 |
| 15 bool RegisterJsResultHandler(JNIEnv* env) { |
| 16 return RegisterNativesImpl(env); |
| 17 } |
| 18 |
| 19 void ConfirmJsResult(JNIEnv* env, |
| 20 jobject obj, |
| 21 jint dialogPointer, |
| 22 jstring promptResult) { |
| 23 JavaScriptAppModalDialog* dialog_ = |
| 24 reinterpret_cast<JavaScriptAppModalDialog*>(dialogPointer); |
| 25 string16 prompt_text; |
| 26 if (promptResult) { |
| 27 prompt_text = base::android::ConvertJavaStringToUTF16( |
| 28 env, |
| 29 promptResult); |
| 30 } |
| 31 dialog_->OnAccept(prompt_text, false); |
| 32 } |
| 33 |
| 34 void CancelJsResult(JNIEnv* env, jobject obj, jint dialogPointer) { |
| 35 JavaScriptAppModalDialog* dialog_ = |
| 36 reinterpret_cast<JavaScriptAppModalDialog*>(dialogPointer); |
| 37 dialog_->OnCancel(false); |
| 38 } |
| 39 |
| 40 base::android::ScopedJavaLocalRef<jobject> createJsResultHandler( |
| 41 JNIEnv* env, |
| 42 AppModalDialog* dialog) { |
| 43 return Java_JsResultHandler_create(env, reinterpret_cast<jint>(dialog)); |
| 44 } |
| 45 |
| 46 void setJsResultHandledByNative(JNIEnv* env, jobject obj) { |
| 47 Java_JsResultHandler_setHandledByNative(env, obj); |
| 48 } |
| 49 |
| 50 bool clientHasCalledConfirmOrCancel(JNIEnv* env, jobject obj) { |
| 51 return Java_JsResultHandler_clientHasCalledConfirmOrCancel(env, obj); |
| 52 } |
| OLD | NEW |