| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/android/javascript_app_modal_dialog_android.h" | 5 #include "chrome/browser/ui/android/javascript_app_modal_dialog_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 | |
| 11 #include "chrome/browser/browser_process.h" | |
| 12 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" | 10 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" |
| 13 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h" | 11 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 14 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/javascript_message_type.h" | 14 #include "content/public/common/javascript_message_type.h" |
| 17 #include "jni/JavascriptAppModalDialog_jni.h" | 15 #include "jni/JavascriptAppModalDialog_jni.h" |
| 18 #include "ui/base/android/window_android.h" | 16 #include "ui/base/android/window_android.h" |
| 19 | 17 |
| 20 using base::android::AttachCurrentThread; | 18 using base::android::AttachCurrentThread; |
| 21 using base::android::ConvertUTF16ToJavaString; | 19 using base::android::ConvertUTF16ToJavaString; |
| 22 using base::android::ScopedJavaGlobalRef; | 20 using base::android::ScopedJavaGlobalRef; |
| 23 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
| 24 using content::BrowserThread; | 22 using content::BrowserThread; |
| 25 | 23 |
| 26 // static | |
| 27 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( | |
| 28 JavaScriptAppModalDialog* dialog, | |
| 29 gfx::NativeWindow parent_window) { | |
| 30 return new JavascriptAppModalDialogAndroid(AttachCurrentThread(), | |
| 31 dialog, parent_window); | |
| 32 } | |
| 33 | |
| 34 JavascriptAppModalDialogAndroid::JavascriptAppModalDialogAndroid( | 24 JavascriptAppModalDialogAndroid::JavascriptAppModalDialogAndroid( |
| 35 JNIEnv* env, | 25 JNIEnv* env, |
| 36 JavaScriptAppModalDialog* dialog, | 26 JavaScriptAppModalDialog* dialog, |
| 37 gfx::NativeWindow parent) | 27 gfx::NativeWindow parent) |
| 38 : dialog_(dialog), | 28 : dialog_(dialog), |
| 39 parent_jobject_weak_ref_(env, parent->GetJavaObject().obj()) { | 29 parent_jobject_weak_ref_(env, parent->GetJavaObject().obj()) { |
| 40 } | 30 } |
| 41 | 31 |
| 42 int JavascriptAppModalDialogAndroid::GetAppModalDialogButtons() const { | 32 int JavascriptAppModalDialogAndroid::GetAppModalDialogButtons() const { |
| 43 NOTIMPLEMENTED(); | 33 NOTIMPLEMENTED(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 148 |
| 159 JavascriptAppModalDialogAndroid::~JavascriptAppModalDialogAndroid() { | 149 JavascriptAppModalDialogAndroid::~JavascriptAppModalDialogAndroid() { |
| 160 // In case the dialog is still displaying, tell it to close itself. | 150 // In case the dialog is still displaying, tell it to close itself. |
| 161 // This can happen if you trigger a dialog but close the Tab before it's | 151 // This can happen if you trigger a dialog but close the Tab before it's |
| 162 // shown, and then accept the dialog. | 152 // shown, and then accept the dialog. |
| 163 if (!dialog_jobject_.is_null()) { | 153 if (!dialog_jobject_.is_null()) { |
| 164 JNIEnv* env = AttachCurrentThread(); | 154 JNIEnv* env = AttachCurrentThread(); |
| 165 Java_JavascriptAppModalDialog_dismiss(env, dialog_jobject_.obj()); | 155 Java_JavascriptAppModalDialog_dismiss(env, dialog_jobject_.obj()); |
| 166 } | 156 } |
| 167 } | 157 } |
| OLD | NEW |