Commit 4c506633 authored by Ioana Pandele's avatar Ioana Pandele Committed by Commit Bot

Remove temporary accessory wiring through the generation popup bridge

This is a temporary wiring that is no longer needed once crrev.com/c/1097478 lands.

Bug: 835234
Change-Id: I0acc8816724dbc523755327f46515fbdcba4fde6
Reviewed-on: https://chromium-review.googlesource.com/1110227Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569608}
parent 75ae75c4
...@@ -10,20 +10,12 @@ import android.view.View; ...@@ -10,20 +10,12 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import org.chromium.base.Callback;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryCoordinator;
import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData;
import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.Action;
import org.chromium.ui.DropdownPopupWindow; import org.chromium.ui.DropdownPopupWindow;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import javax.annotation.Nullable;
/** /**
* JNI call glue for password generation between native and Java objects. * JNI call glue for password generation between native and Java objects.
*/ */
...@@ -35,11 +27,6 @@ public class PasswordGenerationPopupBridge ...@@ -35,11 +27,6 @@ public class PasswordGenerationPopupBridge
private final Context mContext; private final Context mContext;
private final DropdownPopupWindow mPopup; private final DropdownPopupWindow mPopup;
private final View mAnchorView; private final View mAnchorView;
private final KeyboardAccessoryData.PropertyProvider<Action> mActionProvider =
new KeyboardAccessoryData.PropertyProvider<>();
private @Nullable Action mKeyboardAccessoryAction;
private final @Nullable KeyboardAccessoryCoordinator mKeyboardAccessory;
/** /**
* A convenience method for the constructor to be invoked from the native counterpart. * A convenience method for the constructor to be invoked from the native counterpart.
* @param anchorView View anchored for popup. * @param anchorView View anchored for popup.
...@@ -66,17 +53,10 @@ public class PasswordGenerationPopupBridge ...@@ -66,17 +53,10 @@ public class PasswordGenerationPopupBridge
// mContext could've been garbage collected. // mContext could've been garbage collected.
if (mContext == null) { if (mContext == null) {
mPopup = null; mPopup = null;
mKeyboardAccessory = null;
// Prevent destroying the native counterpart when it's about to derefence its own // Prevent destroying the native counterpart when it's about to derefence its own
// members in UpdateBoundsAndRedrawPopup(). // members in UpdateBoundsAndRedrawPopup().
new Handler().post(this::onDismiss); new Handler().post(this::onDismiss);
} else { } else {
if (mContext instanceof ChromeActivity) {
mKeyboardAccessory = ((ChromeActivity) mContext).getKeyboardAccessory();
mKeyboardAccessory.registerActionListProvider(mActionProvider);
} else {
mKeyboardAccessory = null;
}
mPopup = new DropdownPopupWindow(mContext, anchorView); mPopup = new DropdownPopupWindow(mContext, anchorView);
mPopup.setOnItemClickListener(this); mPopup.setOnItemClickListener(this);
mPopup.setOnDismissListener(this); mPopup.setOnDismissListener(this);
...@@ -130,13 +110,6 @@ public class PasswordGenerationPopupBridge ...@@ -130,13 +110,6 @@ public class PasswordGenerationPopupBridge
String suggestionTitle, String explanationText, int explanationTextLinkRangeStart, String suggestionTitle, String explanationText, int explanationTextLinkRangeStart,
int explanationTextLinkRangeEnd) { int explanationTextLinkRangeEnd) {
if (mPopup != null) { if (mPopup != null) {
// If an action can be shown in the popup, provide the same in the accessory or sheet.
if (providesGenerationAction() && mKeyboardAccessoryAction == null) {
// TODO(ioanap): Move these lines to a new native call or even a separate bridge.
createGeneratePasswordAction(suggestionTitle, this::onActionTriggered);
mActionProvider.notifyObservers(new Action[] {mKeyboardAccessoryAction});
// Don't return for now. We want to have both mechanisms in place initially.
}
float anchorWidth = mAnchorView.getLayoutParams().width; float anchorWidth = mAnchorView.getLayoutParams().width;
assert anchorWidth > 0; assert anchorWidth > 0;
PasswordGenerationAdapter adapter = new PasswordGenerationAdapter(mContext, this, PasswordGenerationAdapter adapter = new PasswordGenerationAdapter(mContext, this,
...@@ -166,22 +139,4 @@ public class PasswordGenerationPopupBridge ...@@ -166,22 +139,4 @@ public class PasswordGenerationPopupBridge
private void hide() { private void hide() {
if (mPopup != null) mPopup.dismiss(); if (mPopup != null) mPopup.dismiss();
} }
}
private void onActionTriggered(Action action) { \ No newline at end of file
assert action == mKeyboardAccessoryAction;
nativePasswordSelected(mNativePasswordGenerationPopupViewAndroid);
// TODO(ioanap): Create and use this call instead to start the ModalDialog flow:
// nativePasswordGenerationRequested(mNativePasswordGenerationPopupViewAndroid);
}
private boolean providesGenerationAction() {
return mKeyboardAccessory != null && ChromeFeatureList.isInitialized()
&& (ChromeFeatureList.isEnabled(ChromeFeatureList.PASSWORDS_KEYBOARD_ACCESSORY)
|| ChromeFeatureList.isEnabled(ChromeFeatureList.EXPERIMENTAL_UI));
}
private void createGeneratePasswordAction(String caption, Callback<Action> delegate) {
assert mKeyboardAccessoryAction == null : "Accessory Action should only be created once!";
mKeyboardAccessoryAction = new Action(caption, delegate);
}
}
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