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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBar.java

Issue 24109002: [InfoBar] Upstram basic infobar flow for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@upstream_infobar_full
Patch Set: Fix License header in two more files Created 7 years, 3 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/infobar/ConfirmInfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBar.java
new file mode 100644
index 0000000000000000000000000000000000000000..71a90221505f4b014558f8250537be66cd0b166d
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBar.java
@@ -0,0 +1,77 @@
+// Copyright (c) 2013 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.infobar;
+
+import android.content.Context;
+
+/**
+ * An infobar that presents the user with 2 buttons (typically OK, Cancel).
+ */
+public class ConfirmInfoBar extends TwoButtonInfoBar {
+ // Message to prompt the user.
+ private final String mMessage;
+
+ // Typically set to "OK", or some other positive action.
+ private final String mPrimaryButtonText;
+
+ // Typically set to "Cancel", or some other negative action.
+ private final String mSecondaryButtonText;
+
+ // Listens for when either of the buttons is clicked.
+ private final InfoBarListeners.Confirm mConfirmListener;
+
+ public ConfirmInfoBar(InfoBarListeners.Confirm confirmListener, int backgroundType,
+ int iconDrawableId, String message, String primaryButtonText,
+ String secondaryButtonText) {
+ this(0, confirmListener, backgroundType, iconDrawableId, message, primaryButtonText,
+ secondaryButtonText);
+ }
+
+ public ConfirmInfoBar(int nativeInfoBar, InfoBarListeners.Confirm confirmListener,
+ int backgroundType, int iconDrawableId, String message, String primaryButtonText,
+ String secondaryButtonText) {
+ super(confirmListener, backgroundType, iconDrawableId);
+ mMessage = message;
+ mPrimaryButtonText = primaryButtonText;
+ mSecondaryButtonText = secondaryButtonText;
+ mConfirmListener = confirmListener;
+ setNativeInfoBar(nativeInfoBar);
+ }
+
+ @Override
+ public CharSequence getMessageText(Context context) {
+ return mMessage;
+ }
+
+ @Override
+ public String getPrimaryButtonText(Context context) {
+ return mPrimaryButtonText;
+ }
+
+ @Override
+ public String getSecondaryButtonText(Context context) {
+ return mSecondaryButtonText;
+ }
+
+ @Override
+ public void onButtonClicked(boolean isPrimaryButton) {
+ if (mConfirmListener != null) {
+ mConfirmListener.onConfirmInfoBarButtonClicked(this, isPrimaryButton);
+ }
+
+ if (mNativeInfoBarPtr != 0) {
+ int action = isPrimaryButton ? InfoBar.ACTION_TYPE_OK : InfoBar.ACTION_TYPE_CANCEL;
+ nativeOnButtonClicked(mNativeInfoBarPtr, action, "");
+ }
+ }
+
+ @Override
+ public void onCloseButtonClicked() {
+ if (mNativeInfoBarPtr != 0) {
+ nativeOnCloseButtonClicked(mNativeInfoBarPtr);
+ }
+ super.onCloseButtonClicked();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698