OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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.autofill; | 5 package org.chromium.chrome.browser.autofill; |
6 | 6 |
7 import android.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
8 | 8 |
9 import org.chromium.base.CalledByNative; | 9 import org.chromium.base.CalledByNative; |
10 import org.chromium.base.JNINamespace; | 10 import org.chromium.base.JNINamespace; |
11 import org.chromium.chrome.browser.autofill.AutofillDialog.AutofillDialogDelegat
e; | 11 import org.chromium.chrome.browser.autofill.AutofillDialog.AutofillDialogDelegat
e; |
12 import org.chromium.ui.gfx.NativeWindow; | 12 import org.chromium.ui.gfx.NativeWindow; |
13 | 13 |
14 /** | 14 /** |
15 * JNI call glue for AutofillDialog C++ and Java objects. | 15 * JNI call glue for AutofillDialog C++ and Java objects. |
16 */ | 16 */ |
17 @JNINamespace("autofill") | 17 @JNINamespace("autofill") |
18 public class AutofillDialogGlue implements AutofillDialogDelegate { | 18 public class AutofillDialogGlue implements AutofillDialogDelegate { |
19 @SuppressWarnings("unused") | 19 @SuppressWarnings("unused") |
20 private final int mNativeDialogPopup; | 20 private final int mNativeDialogPopup; |
21 private AutofillDialog mAutofillDialog; | 21 private AutofillDialog mAutofillDialog; |
22 | 22 |
23 public AutofillDialogGlue(int nativeAutofillDialogViewAndroid, NativeWindow
nativeWindow) { | 23 public AutofillDialogGlue(int nativeAutofillDialogViewAndroid, NativeWindow
nativeWindow) { |
24 mNativeDialogPopup = nativeAutofillDialogViewAndroid; | 24 mNativeDialogPopup = nativeAutofillDialogViewAndroid; |
25 | 25 |
26 mAutofillDialog = new AutofillDialog(nativeWindow.getContext()); | 26 mAutofillDialog = new AutofillDialog(nativeWindow.getContext(), this); |
27 mAutofillDialog.show(); | 27 mAutofillDialog.show(); |
28 } | 28 } |
29 | 29 |
30 @CalledByNative | 30 @CalledByNative |
31 private static AutofillDialogGlue create(int nativeAutofillDialogViewAndroid
, | 31 private static AutofillDialogGlue create(int nativeAutofillDialogViewAndroid
, |
32 NativeWindow nativeWindow) { | 32 NativeWindow nativeWindow) { |
33 return new AutofillDialogGlue(nativeAutofillDialogViewAndroid, nativeWin
dow); | 33 return new AutofillDialogGlue(nativeAutofillDialogViewAndroid, nativeWin
dow); |
34 } | 34 } |
35 | 35 |
36 /** | 36 /** |
37 * Updates a section of Autofill dialog. | 37 * Updates a section of Autofill dialog. |
38 * @param section Section that needs to be updated. Should match one of the
values in | 38 * @param section Section that needs to be updated. Should match one of the
values in |
39 * {@link AutofillDialogConstants}. | 39 * {@link AutofillDialogConstants}. |
40 * @param visible Whether the section should be visible. | 40 * @param visible Whether the section should be visible. |
41 * @param dialogInputs Input fields of the currently selected menu item. | 41 * @param dialogInputs Input fields of the currently selected menu item. |
42 * @param menuItems Menu items for the section. | 42 * @param menuItems Menu items for the section. |
43 * @param selectedMenuItem The menu item that is currently selected or -1 ot
herwise. | 43 * @param selectedMenuItem The menu item that is currently selected or -1 ot
herwise. |
44 */ | 44 */ |
45 @CalledByNative | 45 @CalledByNative |
46 private void updateSection(int section, boolean visible, AutofillDialogField
[] dialogInputs, | 46 private void updateSection(int section, boolean visible, AutofillDialogField
[] dialogInputs, |
47 AutofillDialogMenuItem[] menuItems, int selectedMenuItem) { | 47 AutofillDialogMenuItem[] menuItems, int selectedMenuItem) { |
48 mAutofillDialog.updateSection(section, visible, dialogInputs, menuItems,
selectedMenuItem); | 48 mAutofillDialog.updateSection(section, visible, dialogInputs, menuItems,
selectedMenuItem); |
49 } | 49 } |
50 | 50 |
| 51 /** |
| 52 * Notifies the dialog that the underlying model is changed and all sections
will be updated. |
| 53 * @param fetchingIsActive If true, the data is being fetched and is not yet
available. |
| 54 */ |
| 55 private void modelChanged(boolean fetchingIsActive) { |
| 56 mAutofillDialog.modelChanged(fetchingIsActive); |
| 57 } |
| 58 |
| 59 /** |
| 60 * Updates the account chooser of Autofill dialog. |
| 61 * @param accountNames List of accounts to be shown. |
| 62 * @param selectedAccountIndex Index of the currently selected account. |
| 63 */ |
| 64 private void updateAccountChooser(String[] accountNames, int selectedAccount
Index) { |
| 65 mAutofillDialog.updateAccountChooserAndAddTitle(accountNames, selectedAc
countIndex); |
| 66 } |
| 67 |
51 @CalledByNative | 68 @CalledByNative |
52 private AutofillDialogField[] getSection(int section) { | 69 private AutofillDialogField[] getSection(int section) { |
53 return mAutofillDialog.getSection(section); | 70 return mAutofillDialog.getSection(section); |
54 } | 71 } |
55 | 72 |
56 @CalledByNative | 73 @CalledByNative |
57 private String getCvc() { | 74 private String getCvc() { |
58 return mAutofillDialog.getCvc(); | 75 return mAutofillDialog.getCvc(); |
59 } | 76 } |
60 | 77 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 182 |
166 private native void nativeItemSelected(int nativeAutofillDialogViewAndroid,
int section, | 183 private native void nativeItemSelected(int nativeAutofillDialogViewAndroid,
int section, |
167 int index); | 184 int index); |
168 private native void nativeAccountSelected(int nativeAutofillDialogViewAndroi
d, int index); | 185 private native void nativeAccountSelected(int nativeAutofillDialogViewAndroi
d, int index); |
169 private native void nativeEditingStart(int nativeAutofillDialogViewAndroid,
int section); | 186 private native void nativeEditingStart(int nativeAutofillDialogViewAndroid,
int section); |
170 private native void nativeEditingComplete(int nativeAutofillDialogViewAndroi
d, int section); | 187 private native void nativeEditingComplete(int nativeAutofillDialogViewAndroi
d, int section); |
171 private native void nativeEditingCancel(int nativeAutofillDialogViewAndroid,
int section); | 188 private native void nativeEditingCancel(int nativeAutofillDialogViewAndroid,
int section); |
172 private native void nativeDialogSubmit(int nativeAutofillDialogViewAndroid); | 189 private native void nativeDialogSubmit(int nativeAutofillDialogViewAndroid); |
173 private native void nativeDialogCancel(int nativeAutofillDialogViewAndroid); | 190 private native void nativeDialogCancel(int nativeAutofillDialogViewAndroid); |
174 } | 191 } |
OLD | NEW |