Commit 57722ec5 authored by estade's avatar estade Committed by Commit bot

Hook up autofill popup control elements

BUG=403597

Review URL: https://codereview.chromium.org/490193003

Cr-Commit-Position: refs/heads/master@{#292272}
parent d0aae185
...@@ -21,6 +21,9 @@ public abstract class ChromiumApplication extends ContentApplication { ...@@ -21,6 +21,9 @@ public abstract class ChromiumApplication extends ContentApplication {
@CalledByNative @CalledByNative
protected abstract void showSyncSettings(); protected abstract void showSyncSettings();
@CalledByNative
protected abstract void showAutofillSettings();
@CalledByNative @CalledByNative
protected abstract void showTermsOfServiceDialog(); protected abstract void showTermsOfServiceDialog();
......
...@@ -89,6 +89,10 @@ public class ChromeShellApplication extends ChromiumApplication { ...@@ -89,6 +89,10 @@ public class ChromeShellApplication extends ChromiumApplication {
protected void showSyncSettings() { protected void showSyncSettings() {
} }
@Override
protected void showAutofillSettings() {
}
@Override @Override
protected void showTermsOfServiceDialog() { protected void showTermsOfServiceDialog() {
} }
......
...@@ -29,6 +29,12 @@ void ChromiumApplication::ShowSyncSettings() { ...@@ -29,6 +29,12 @@ void ChromiumApplication::ShowSyncSettings() {
base::android::GetApplicationContext()); base::android::GetApplicationContext());
} }
void ChromiumApplication::ShowAutofillSettings() {
Java_ChromiumApplication_showAutofillSettings(
base::android::AttachCurrentThread(),
base::android::GetApplicationContext());
}
void ChromiumApplication::ShowTermsOfServiceDialog() { void ChromiumApplication::ShowTermsOfServiceDialog() {
Java_ChromiumApplication_showTermsOfServiceDialog( Java_ChromiumApplication_showTermsOfServiceDialog(
base::android::AttachCurrentThread(), base::android::AttachCurrentThread(),
......
...@@ -29,6 +29,9 @@ class ChromiumApplication { ...@@ -29,6 +29,9 @@ class ChromiumApplication {
// Opens the sync settings page. // Opens the sync settings page.
static void ShowSyncSettings(); static void ShowSyncSettings();
// Opens the autofill settings page.
static void ShowAutofillSettings();
// Shows a dialog with the terms of service. // Shows a dialog with the terms of service.
static void ShowTermsOfServiceDialog(); static void ShowTermsOfServiceDialog();
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/android/chromium_application.h"
#include "chrome/browser/ui/android/autofill/autofill_logger_android.h" #include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
#endif #endif
...@@ -90,7 +91,7 @@ PrefService* ChromeAutofillClient::GetPrefs() { ...@@ -90,7 +91,7 @@ PrefService* ChromeAutofillClient::GetPrefs() {
void ChromeAutofillClient::ShowAutofillSettings() { void ChromeAutofillClient::ShowAutofillSettings() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
NOTIMPLEMENTED(); chrome::android::ChromiumApplication::ShowAutofillSettings();
#else #else
Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
if (browser) if (browser)
......
...@@ -21,6 +21,10 @@ public class ChromeNativeTestApplication extends ChromiumApplication { ...@@ -21,6 +21,10 @@ public class ChromeNativeTestApplication extends ChromiumApplication {
protected void showSyncSettings() { protected void showSyncSettings() {
} }
@Override
protected void showAutofillSettings() {
}
@Override @Override
protected void showTermsOfServiceDialog() { protected void showTermsOfServiceDialog() {
} }
......
...@@ -31,16 +31,10 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On ...@@ -31,16 +31,10 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
PopupWindow.OnDismissListener { PopupWindow.OnDismissListener {
/** /**
* Constants defining types of Autofill suggestion entries. * The constant used to specify a separator in a list of Autofill suggestions.
* Has to be kept in sync with enum in WebAutofillClient.h * Has to be kept in sync with enum in WebAutofillClient.h
*
* Not supported: MenuItemIDWarningMessage, MenuItemIDClearForm, and
* MenuItemIDAutofillOptions.
*/ */
private static final int ITEM_ID_AUTOCOMPLETE_ENTRY = 0;
private static final int ITEM_ID_PASSWORD_ENTRY = -2;
private static final int ITEM_ID_SEPARATOR_ENTRY = -3; private static final int ITEM_ID_SEPARATOR_ENTRY = -3;
private static final int ITEM_ID_DATA_LIST_ENTRY = -6;
private final Context mContext; private final Context mContext;
private final AutofillPopupDelegate mAutofillCallback; private final AutofillPopupDelegate mAutofillCallback;
...@@ -90,14 +84,14 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On ...@@ -90,14 +84,14 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
ArrayList<DropdownItem> cleanedData = new ArrayList<DropdownItem>(); ArrayList<DropdownItem> cleanedData = new ArrayList<DropdownItem>();
HashSet<Integer> separators = new HashSet<Integer>(); HashSet<Integer> separators = new HashSet<Integer>();
for (int i = 0; i < suggestions.length; i++) { for (int i = 0; i < suggestions.length; i++) {
int itemId = suggestions[i].getUniqueId(); int itemId = suggestions[i].getSuggestionId();
if (itemId > 0 || itemId == ITEM_ID_AUTOCOMPLETE_ENTRY || if (itemId == ITEM_ID_SEPARATOR_ENTRY) {
itemId == ITEM_ID_PASSWORD_ENTRY || itemId == ITEM_ID_DATA_LIST_ENTRY) {
cleanedData.add(suggestions[i]);
} else if (itemId == ITEM_ID_SEPARATOR_ENTRY) {
separators.add(cleanedData.size()); separators.add(cleanedData.size());
} else {
cleanedData.add(suggestions[i]);
} }
} }
setAdapter(new DropdownAdapter(mContext, cleanedData, separators)); setAdapter(new DropdownAdapter(mContext, cleanedData, separators));
show(); show();
ApiCompatibilityUtils.setLayoutDirection(getListView(), ApiCompatibilityUtils.setLayoutDirection(getListView(),
......
...@@ -12,18 +12,18 @@ import org.chromium.ui.DropdownItem; ...@@ -12,18 +12,18 @@ import org.chromium.ui.DropdownItem;
public class AutofillSuggestion implements DropdownItem { public class AutofillSuggestion implements DropdownItem {
private final String mLabel; private final String mLabel;
private final String mSublabel; private final String mSublabel;
private final int mUniqueId; private final int mSuggestionId;
/** /**
* Constructs a Autofill suggestion container. * Constructs a Autofill suggestion container.
* @param name The name of the Autofill suggestion. * @param name The name of the Autofill suggestion.
* @param label The describing label of the Autofill suggestion. * @param label The describing label of the Autofill suggestion.
* @param uniqueId The unique id used to identify the Autofill suggestion. * @param suggestionId The type of suggestion.
*/ */
public AutofillSuggestion(String name, String label, int uniqueId) { public AutofillSuggestion(String name, String label, int suggestionId) {
mLabel = name; mLabel = name;
mSublabel = label; mSublabel = label;
mUniqueId = uniqueId; mSuggestionId = suggestionId;
} }
@Override @Override
...@@ -46,7 +46,7 @@ public class AutofillSuggestion implements DropdownItem { ...@@ -46,7 +46,7 @@ public class AutofillSuggestion implements DropdownItem {
return false; return false;
} }
public int getUniqueId() { public int getSuggestionId() {
return mUniqueId; return mSuggestionId;
} }
} }
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