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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupGlue.java

Issue 14018004: [Android] Refactor NativeView to be able to use it for AutofillDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.autofill; 5 package org.chromium.chrome.browser.autofill;
6 6
7 import org.chromium.base.CalledByNative; 7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace; 8 import org.chromium.base.JNINamespace;
9 import org.chromium.chrome.browser.autofill.AutofillPopup.AutofillPopupDelegate; 9 import org.chromium.chrome.browser.autofill.AutofillPopup.AutofillPopupDelegate;
10 import org.chromium.content.browser.ContainerViewDelegate; 10 import org.chromium.ui.ViewAndroid;
11 import org.chromium.ui.ViewAndroidDelegate;
11 import org.chromium.ui.WindowAndroid; 12 import org.chromium.ui.WindowAndroid;
12 13
13 /** 14 /**
14 * JNI call glue for AutofillExternalDelagate C++ and Java objects. 15 * JNI call glue for AutofillExternalDelagate C++ and Java objects.
15 */ 16 */
16 @JNINamespace("autofill") 17 @JNINamespace("autofill")
17 public class AutofillPopupGlue implements AutofillPopupDelegate{ 18 public class AutofillPopupGlue implements AutofillPopupDelegate{
18 private final int mNativeAutofillPopup; 19 private final int mNativeAutofillPopup;
19 private final AutofillPopup mAutofillPopup; 20 private final AutofillPopup mAutofillPopup;
20 21
21 public AutofillPopupGlue(int nativeAutofillPopupViewAndroid, WindowAndroid n ativeWindow, 22 public AutofillPopupGlue(int nativeAutofillPopupViewAndroid, WindowAndroid w indowAndroid,
22 ContainerViewDelegate containerViewDelegate) { 23 ViewAndroidDelegate containerViewDelegate) {
23 mNativeAutofillPopup = nativeAutofillPopupViewAndroid; 24 mNativeAutofillPopup = nativeAutofillPopupViewAndroid;
24 mAutofillPopup = new AutofillPopup(nativeWindow.getContext(), containerV iewDelegate, this); 25 mAutofillPopup = new AutofillPopup(windowAndroid.getContext(), container ViewDelegate, this);
25 } 26 }
26 27
27 @CalledByNative 28 @CalledByNative
28 private static AutofillPopupGlue create(int nativeAutofillPopupViewAndroid, 29 private static AutofillPopupGlue create(int nativeAutofillPopupViewAndroid,
29 WindowAndroid nativeWindow, ContainerViewDelegate containerViewDeleg ate) { 30 WindowAndroid windowAndroid, ViewAndroid viewAndroid) {
30 return new AutofillPopupGlue(nativeAutofillPopupViewAndroid, nativeWindo w, 31 return new AutofillPopupGlue(nativeAutofillPopupViewAndroid, windowAndro id,
31 containerViewDelegate); 32 viewAndroid.getViewAndroidDelegate());
32 } 33 }
33 34
34 @Override 35 @Override
35 public void requestHide() { 36 public void requestHide() {
36 nativeRequestHide(mNativeAutofillPopup); 37 nativeRequestHide(mNativeAutofillPopup);
37 } 38 }
38 39
39 @Override 40 @Override
40 public void suggestionSelected(int listIndex) { 41 public void suggestionSelected(int listIndex) {
41 nativeSuggestionSelected(mNativeAutofillPopup, listIndex); 42 nativeSuggestionSelected(mNativeAutofillPopup, listIndex);
(...skipping 21 matching lines...) Expand all
63 * @param x X coordinate. 64 * @param x X coordinate.
64 * @param y Y coordinate. 65 * @param y Y coordinate.
65 * @param width The width of the anchor. 66 * @param width The width of the anchor.
66 * @param height The height of the anchor. 67 * @param height The height of the anchor.
67 */ 68 */
68 @CalledByNative 69 @CalledByNative
69 private void setAnchorRect(float x, float y, float width, float height) { 70 private void setAnchorRect(float x, float y, float width, float height) {
70 mAutofillPopup.setAnchorRect(x, y, width, height); 71 mAutofillPopup.setAnchorRect(x, y, width, height);
71 } 72 }
72 73
74 // Helper methods for AutofillSuggestion
75
76 @CalledByNative
77 private static AutofillSuggestion[] createAutofillSuggestionArray(int size) {
78 return new AutofillSuggestion[size];
79 }
80
73 /** 81 /**
74 * Creates an Autofill Suggestion object with specified name and label. 82 * @param array AutofillSuggestion array that should get a new suggestion ad ded.
83 * @param index Index in the array where to place a new suggestion.
75 * @param name Name of the suggestion. 84 * @param name Name of the suggestion.
76 * @param label Label of the suggestion. 85 * @param label Label of the suggestion.
77 * @param uniqueId Unique suggestion id. 86 * @param uniqueId Unique suggestion id.
78 * @return The AutofillSuggestion object with the specified data.
79 */ 87 */
80 @CalledByNative 88 @CalledByNative
81 private static AutofillSuggestion createAutofillSuggestion(String name, Stri ng label, 89 private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
82 int uniqueId) { 90 String name, String label, int uniqueId) {
83 return new AutofillSuggestion(name, label, uniqueId); 91 array[index] = new AutofillSuggestion(name, label, uniqueId);
84 } 92 }
85 93
86 private native void nativeRequestHide(int nativeAutofillPopupViewAndroid); 94 private native void nativeRequestHide(int nativeAutofillPopupViewAndroid);
87 private native void nativeSuggestionSelected(int nativeAutofillPopupViewAndr oid, 95 private native void nativeSuggestionSelected(int nativeAutofillPopupViewAndr oid,
88 int listIndex); 96 int listIndex);
89 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698