Commit 64d11dea authored by aurimas@chromium.org's avatar aurimas@chromium.org

Cleaning up Android's Autofill call suggestionSelected.

Cleaning up Android's Autofill call suggestionSelected to remove unused
parameters from the function.

BUG=


Review URL: https://chromiumcodereview.appspot.com/11778043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175778 0039d316-1c4b-4281-b951-d872f2087c98
parent 32274ae8
...@@ -64,10 +64,8 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem ...@@ -64,10 +64,8 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
/** /**
* Handles the selection of an Autofill suggestion from an AutofillPopup. * Handles the selection of an Autofill suggestion from an AutofillPopup.
* @param listIndex The index of the selected Autofill suggestion. * @param listIndex The index of the selected Autofill suggestion.
* @param value The value of the selected Autofill suggestion.
* @param uniqueId The unique id of the selected Autofill suggestion.
*/ */
public void suggestionSelected(int listIndex, String value, int uniqueId); public void suggestionSelected(int listIndex);
} }
// ListPopupWindow needs an anchor view to determine it's size and position. We create a view // ListPopupWindow needs an anchor view to determine it's size and position. We create a view
...@@ -223,14 +221,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem ...@@ -223,14 +221,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
try { mAutofillCallback.suggestionSelected(position);
ListAdapter adapter = (ListAdapter) parent.getAdapter();
AutofillSuggestion data = (AutofillSuggestion) adapter.getItem(position);
mAutofillCallback.suggestionSelected(position, data.mName, data.mUniqueId);
} catch (ClassCastException e) {
Log.w("AutofillWindow", "error in onItemClick", e);
assert false;
}
} }
} }
...@@ -35,8 +35,8 @@ public class AutofillPopupGlue implements AutofillPopupDelegate{ ...@@ -35,8 +35,8 @@ public class AutofillPopupGlue implements AutofillPopupDelegate{
} }
@Override @Override
public void suggestionSelected(int listIndex, String value, int uniqueId) { public void suggestionSelected(int listIndex) {
nativeSuggestionSelected(mNativeAutofillPopup, listIndex, value, uniqueId); nativeSuggestionSelected(mNativeAutofillPopup, listIndex);
} }
/** /**
...@@ -84,6 +84,6 @@ public class AutofillPopupGlue implements AutofillPopupDelegate{ ...@@ -84,6 +84,6 @@ public class AutofillPopupGlue implements AutofillPopupDelegate{
private native void nativeDismissed(int nativeAutofillPopupViewAndroid); private native void nativeDismissed(int nativeAutofillPopupViewAndroid);
private native void nativeSuggestionSelected(int nativeAutofillPopupViewAndroid, private native void nativeSuggestionSelected(int nativeAutofillPopupViewAndroid,
int listIndex, String value, int uniqueId); int listIndex);
} }
\ No newline at end of file
...@@ -76,19 +76,15 @@ public class AutofillTest extends ChromiumTestShellTestBase { ...@@ -76,19 +76,15 @@ public class AutofillTest extends ChromiumTestShellTestBase {
private static final int CALLBACK_TIMEOUT_MS = 4000; private static final int CALLBACK_TIMEOUT_MS = 4000;
private static final int CHECK_INTERVAL_MS = 100; private static final int CHECK_INTERVAL_MS = 100;
private final AtomicBoolean mGotPopupSelection = new AtomicBoolean(false); private final AtomicBoolean mGotPopupSelection = new AtomicBoolean(false);
private Pair<String, Integer> mSelectedData = null; public int mListIndex = -1;
@Override @Override
public void suggestionSelected(int listIndex, String value, int uniqueId) { public void suggestionSelected(int listIndex) {
mSelectedData = new Pair<String, Integer>(value, uniqueId); mListIndex = listIndex;
mAutofillPopup.dismiss(); mAutofillPopup.dismiss();
mGotPopupSelection.set(true); mGotPopupSelection.set(true);
} }
public Pair<String, Integer> getSelectedData() {
return mSelectedData;
}
public boolean waitForCallback() throws InterruptedException { public boolean waitForCallback() throws InterruptedException {
return CriteriaHelper.pollForCriteria(new Criteria() { return CriteriaHelper.pollForCriteria(new Criteria() {
@Override @Override
...@@ -157,8 +153,6 @@ public class AutofillTest extends ChromiumTestShellTestBase { ...@@ -157,8 +153,6 @@ public class AutofillTest extends ChromiumTestShellTestBase {
touchCommon.singleClickViewRelative(mAutofillPopup.getListView(), 10, 10); touchCommon.singleClickViewRelative(mAutofillPopup.getListView(), 10, 10);
assertTrue(mMockAutofillCallback.waitForCallback()); assertTrue(mMockAutofillCallback.waitForCallback());
Pair<String, Integer> selected = mMockAutofillCallback.getSelectedData(); assertEquals(0, mMockAutofillCallback.mListIndex);
assertEquals(suggestions[0].mName, selected.first);
assertEquals(suggestions[0].mUniqueId, selected.second.intValue());
} }
} }
...@@ -80,9 +80,7 @@ void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { ...@@ -80,9 +80,7 @@ void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() {
void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env, void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env,
jobject obj, jobject obj,
jint list_index, jint list_index) {
jstring /*name*/,
jint /*identifier*/) {
controller_->AcceptSuggestion(list_index); controller_->AcceptSuggestion(list_index);
} }
......
...@@ -24,13 +24,8 @@ class AutofillPopupViewAndroid : public AutofillPopupView { ...@@ -24,13 +24,8 @@ class AutofillPopupViewAndroid : public AutofillPopupView {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Methods called from Java via JNI // Methods called from Java via JNI
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Called when an autofill item was selected. TODO(estade): remove |name| and // Called when an autofill item was selected.
// |unique_id|. void SuggestionSelected(JNIEnv* env, jobject obj, jint list_index);
void SuggestionSelected(JNIEnv* env,
jobject obj,
jint list_index,
jstring name,
jint unique_id);
void Dismissed(JNIEnv *env, jobject obj); void Dismissed(JNIEnv *env, jobject obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment