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 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.view.LayoutInflater; | 10 import android.view.LayoutInflater; |
11 import android.view.View; | 11 import android.view.View; |
12 import android.view.ViewGroup; | 12 import android.view.ViewGroup; |
13 import android.widget.Button; | 13 import android.widget.Button; |
14 import android.widget.CheckBox; | 14 import android.widget.CheckBox; |
15 import android.widget.EditText; | 15 import android.widget.EditText; |
16 import android.widget.TextView; | 16 import android.widget.TextView; |
17 | 17 |
18 import org.chromium.base.CalledByNative; | 18 import org.chromium.base.CalledByNative; |
19 import org.chromium.content.app.AppResource; | 19 import org.chromium.content.app.AppResource; |
20 import org.chromium.content.browser.ContentViewCore; | 20 import org.chromium.ui.gfx.NativeWindow; |
21 | 21 |
22 public class JavascriptAppModalDialog { | 22 public class JavascriptAppModalDialog { |
23 private String mTitle; | 23 private String mTitle; |
24 private String mMessage; | 24 private String mMessage; |
25 private boolean mShouldShowSuppressCheckBox; | 25 private boolean mShouldShowSuppressCheckBox; |
26 private int mNativeDialogPointer; | 26 private int mNativeDialogPointer; |
27 private AlertDialog mDialog; | 27 private AlertDialog mDialog; |
28 | 28 |
29 private JavascriptAppModalDialog(String title, String message, | 29 private JavascriptAppModalDialog(String title, String message, |
30 boolean shouldShowSuppressCheckBox) { | 30 boolean shouldShowSuppressCheckBox) { |
(...skipping 22 matching lines...) Expand all Loading... |
53 } | 53 } |
54 | 54 |
55 @CalledByNative | 55 @CalledByNative |
56 public static JavascriptAppModalDialog createPromptDialog(String title, Stri
ng message, | 56 public static JavascriptAppModalDialog createPromptDialog(String title, Stri
ng message, |
57 boolean shouldShowSuppressCheckBox, String defaultPromptText) { | 57 boolean shouldShowSuppressCheckBox, String defaultPromptText) { |
58 return new JavascriptAppPromptDialog(title, message, shouldShowSuppressC
heckBox, | 58 return new JavascriptAppPromptDialog(title, message, shouldShowSuppressC
heckBox, |
59 defaultPromptText); | 59 defaultPromptText); |
60 } | 60 } |
61 | 61 |
62 @CalledByNative | 62 @CalledByNative |
63 void showJavascriptAppModalDialog(ContentViewCore contentViewCore, int nativ
eDialogPointer) { | 63 void showJavascriptAppModalDialog(NativeWindow window, int nativeDialogPoint
er) { |
64 assert contentViewCore != null; | 64 assert window != null; |
65 | 65 Context context = window.getActivity(); |
66 Context context = contentViewCore.getContext(); | |
67 | 66 |
68 // Cache the native dialog pointer so that we can use it to return the | 67 // Cache the native dialog pointer so that we can use it to return the |
69 // response. | 68 // response. |
70 mNativeDialogPointer = nativeDialogPointer; | 69 mNativeDialogPointer = nativeDialogPointer; |
71 | 70 |
72 LayoutInflater inflater = | 71 LayoutInflater inflater = |
73 (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATE
R_SERVICE); | 72 (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATE
R_SERVICE); |
74 | 73 |
75 assert AppResource.LAYOUT_JS_MODAL_DIALOG != 0; | 74 assert AppResource.LAYOUT_JS_MODAL_DIALOG != 0; |
76 ViewGroup dialogLayout = (ViewGroup) inflater.inflate(AppResource.LAYOUT
_JS_MODAL_DIALOG, | 75 ViewGroup dialogLayout = (ViewGroup) inflater.inflate(AppResource.LAYOUT
_JS_MODAL_DIALOG, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 237 } |
239 } | 238 } |
240 } | 239 } |
241 | 240 |
242 private native void nativeDidAcceptAppModalDialog(int nativeJavascriptAppMod
alDialogAndroid, | 241 private native void nativeDidAcceptAppModalDialog(int nativeJavascriptAppMod
alDialogAndroid, |
243 String prompt, boolean suppress); | 242 String prompt, boolean suppress); |
244 | 243 |
245 private native void nativeDidCancelAppModalDialog(int nativeJavascriptAppMod
alDialogAndroid, | 244 private native void nativeDidCancelAppModalDialog(int nativeJavascriptAppMod
alDialogAndroid, |
246 boolean suppress); | 245 boolean suppress); |
247 } | 246 } |
OLD | NEW |