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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java

Issue 606153002: [android] Password generation UI for android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unify default text color. Use integers instead of enums. Simplify delegate. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java
new file mode 100644
index 0000000000000000000000000000000000000000..96920878252c52a324b13c65634fba83c1b6d385
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java
@@ -0,0 +1,135 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.autofill;
+
+import android.app.Activity;
+import android.os.Handler;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+import org.chromium.ui.base.ViewAndroid;
+import org.chromium.ui.base.ViewAndroidDelegate;
+import org.chromium.ui.base.WindowAndroid;
+
+/**
+ * JNI call glue for password generation between native and Java objects.
+ */
+@JNINamespace("autofill")
+public class PasswordGenerationPopupBridge implements PasswordGenerationPopup.Delegate {
+ private final long mNativePasswordGenerationPopupViewAndroid;
+ private final PasswordGenerationPopup mPopup;
+
+ /**
+ * A convenience method for the constructor to be invoked from the native counterpart.
+ * @param nativePopup The pointer to the native counterpart.
+ * @param windowAndroid The browser window.
+ * @param containerViewDelegate Interface to acquire and release anchors.
+ */
+ @CalledByNative
+ private static PasswordGenerationPopupBridge create(long nativePopup,
+ WindowAndroid windowAndroid, ViewAndroid viewAndroid) {
+ return new PasswordGenerationPopupBridge(nativePopup, windowAndroid,
+ viewAndroid.getViewAndroidDelegate());
+ }
+
+ /**
+ * Builds the bridge between native and Java objects.
+ */
+ public PasswordGenerationPopupBridge(long nativePopup, WindowAndroid windowAndroid,
+ ViewAndroidDelegate containerViewDelegate) {
+ mNativePasswordGenerationPopupViewAndroid = nativePopup;
+ Activity activity = windowAndroid.getActivity().get();
+ if (activity == null) {
+ mPopup = null;
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ onDismissed();
+ }
+ });
+ } else {
+ mPopup = new PasswordGenerationPopup(activity, containerViewDelegate, this);
+ }
+ }
+
+ /**
+ * Sets the location and size of the popup anchor (password input field).
+ * @param x X coordinate.
+ * @param y Y coordinate.
+ * @param width The width of the anchor.
+ * @param height The height of the anchor.
+ */
+ @CalledByNative
+ private void setAnchorRect(float x, float y, float width, float height) {
+ if (mPopup != null) {
+ mPopup.setAnchorRect(x, y, width, height);
+ }
+ }
+
+ /**
+ * Shows a password generation popup with specified data.
+ * @param isRtl True if the popup should be RTL.
+ * @param mimiumWidth The minimum width for the popup.
+ * @param passwordDisplayed Whether the generated password should be displayed.
+ * @param password The auto-generated password to suggest.
+ * @param suggestionTitle The translated title of the suggestion part of the popup.
+ * @param explanationText The translated text that explains the popup.
+ * @param explanationTextLinkRangeStart The start of the range in the explanation text that
+ * should be a link to the saved passwords.
+ * @param explanationTextLinkRangeEnd The end of the range in the explanation text that should
+ * be a link to the saved passwords.
+ */
+ @CalledByNative
+ private void show(boolean isRtl, int minimumWidth, boolean passwordDisplayed, String password,
+ String suggestionTitle, String explanationText, int explanationTextLinkRangeStart,
+ int explanationTextLinkRangeEnd) {
+ if (mPopup != null) {
+ mPopup.show(new PasswordGeneration(isRtl, minimumWidth, passwordDisplayed, password,
+ suggestionTitle, explanationText, explanationTextLinkRangeStart,
+ explanationTextLinkRangeEnd));
+ }
+ }
+
+ /**
+ * Hides the password generation popup.
+ */
+ @CalledByNative
+ private void hide() {
+ if (mPopup != null) {
aurimas (slooooooooow) 2014/10/16 23:30:01 Its pretty short so you can make it one line like:
please use gerrit instead 2014/10/17 05:19:00 Done.
+ mPopup.dismiss();
+ }
+ }
+
+ /**
+ * Native call to open the "saved passwords" link.
+ */
+ @Override
+ public void onSavedPasswordsLinkClicked() {
+ nativeSavedPasswordsLinkClicked(mNativePasswordGenerationPopupViewAndroid);
+ }
+
+ private native void nativeSavedPasswordsLinkClicked(
+ long nativePasswordGenerationPopupViewAndroid);
+
+ /**
+ * Native call to inform the controller that the popup was hidden.
+ */
+ @Override
+ public void onDismissed() {
+ nativeDismissed(mNativePasswordGenerationPopupViewAndroid);
+ }
+
+ private native void nativeDismissed(long nativePasswordGenerationPopupViewAndroid);
+
+ /**
+ * Native call to handle the selection of the suggested password in the popup.
+ */
+ @Override
+ public void onPasswordSelected() {
+ nativePasswordSelected(mNativePasswordGenerationPopupViewAndroid);
+ }
+
+ private native void nativePasswordSelected(long nativePasswordGenerationPopupViewAndroid);
+}

Powered by Google App Engine
This is Rietveld 408576698