Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Unified Diff: chrome/browser/android/js_result_handler.cc

Issue 10823340: [Android] Upstream Modal Dialogs functionality (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/js_result_handler.cc
diff --git a/chrome/browser/android/js_result_handler.cc b/chrome/browser/android/js_result_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70b1624588c16e197dc8d06d16b36c02bf985ad5
--- /dev/null
+++ b/chrome/browser/android/js_result_handler.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/js_result_handler.h"
+
+#include "base/android/jni_string.h"
+#include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
+#include "jni/JsResultHandler_jni.h"
+#include "content/public/browser/android/content_view_core.h"
+
+using base::android::ConvertJavaStringToUTF16;
+using content::ContentViewCore;
+
+bool RegisterJsResultHandler(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+void ConfirmJsResult(JNIEnv* env,
+ jobject obj,
+ jint dialogPointer,
+ jstring promptResult) {
+ JavaScriptAppModalDialog* dialog_ =
+ reinterpret_cast<JavaScriptAppModalDialog*>(dialogPointer);
+ string16 prompt_text;
+ if (promptResult) {
+ prompt_text = base::android::ConvertJavaStringToUTF16(
+ env,
+ promptResult);
+ }
+ dialog_->OnAccept(prompt_text, false);
+}
+
+void CancelJsResult(JNIEnv* env, jobject obj, jint dialogPointer) {
+ JavaScriptAppModalDialog* dialog_ =
+ reinterpret_cast<JavaScriptAppModalDialog*>(dialogPointer);
+ dialog_->OnCancel(false);
+}
+
+base::android::ScopedJavaLocalRef<jobject> createJsResultHandler(
+ JNIEnv* env,
+ AppModalDialog* dialog) {
+ return Java_JsResultHandler_create(env, reinterpret_cast<jint>(dialog));
+}
+
+void setJsResultHandledByNative(JNIEnv* env, jobject obj) {
+ Java_JsResultHandler_setHandledByNative(env, obj);
+}
+
+bool clientHasCalledConfirmOrCancel(JNIEnv* env, jobject obj) {
+ return Java_JsResultHandler_clientHasCalledConfirmOrCancel(env, obj);
+}

Powered by Google App Engine
This is Rietveld 408576698