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

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

Issue 756333003: Prompt for unmasking Wallet credit card on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge conflicts Created 6 years, 1 month 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/InstrumentUnmaskBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java
new file mode 100644
index 0000000000000000000000000000000000000000..567e3daad375224e47e60e0e86eb97ed38e7fce0
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java
@@ -0,0 +1,73 @@
+// 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.autofill.InstrumentUnmaskPrompt;
+import org.chromium.ui.autofill.InstrumentUnmaskPrompt.InstrumentUnmaskPromptDelegate;
+import org.chromium.ui.base.WindowAndroid;
+
+/**
+* JNI call glue for InstrumentUnmaskPrompt C++ and Java objects.
+*/
+@JNINamespace("autofill")
+public class InstrumentUnmaskBridge implements InstrumentUnmaskPromptDelegate {
+ private final long mNativeInstrumentUnmaskPromptViewAndroid;
+ private final InstrumentUnmaskPrompt mInstrumentUnmaskPrompt;
+
+ public InstrumentUnmaskBridge(long nativeInstrumentUnmaskPromptViewAndroid,
+ WindowAndroid windowAndroid) {
+ mNativeInstrumentUnmaskPromptViewAndroid = nativeInstrumentUnmaskPromptViewAndroid;
+ Activity activity = windowAndroid.getActivity().get();
+ if (activity == null) {
+ mInstrumentUnmaskPrompt = null;
+ // Clean up the native counterpart. This is posted to allow the native counterpart
+ // to fully finish the construction of this glue object before we attempt to delete it.
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ dismissed(new String());
+ }
+ });
+ } else {
+ mInstrumentUnmaskPrompt = new InstrumentUnmaskPrompt(activity, this);
+ }
+ }
+
+ @CalledByNative
+ private static InstrumentUnmaskBridge create(long nativeUnmaskPrompt,
+ WindowAndroid windowAndroid) {
+ return new InstrumentUnmaskBridge(nativeUnmaskPrompt, windowAndroid);
+ }
+
+ @Override
+ public void dismissed(String response) {
+ nativePromptDismissed(mNativeInstrumentUnmaskPromptViewAndroid, response);
+ }
+
+ /**
+ * Hides the Autofill Popup and removes its anchor from the ContainerView.
+ */
+ @CalledByNative
+ private void hide() {
+ if (mInstrumentUnmaskPrompt != null) mInstrumentUnmaskPrompt.hide();
+ }
+
+ /**
+ * Shows an Autofill popup with specified suggestions.
+ * @param suggestions Autofill suggestions to be displayed.
+ */
+ @CalledByNative
+ private void show() {
+ if (mInstrumentUnmaskPrompt != null) mInstrumentUnmaskPrompt.show();
+ }
+
+ private native void nativePromptDismissed(long nativeInstrumentUnmaskPromptViewAndroid,
+ String response);
+}

Powered by Google App Engine
This is Rietveld 408576698