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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.infobar;
6
7 import android.content.Context;
8
9 /**
10 * An infobar that presents the user with 2 buttons (typically OK, Cancel).
11 */
12 public class ConfirmInfoBar extends TwoButtonInfoBar {
13 // Message to prompt the user.
14 private final String mMessage;
15
16 // Typically set to "OK", or some other positive action.
17 private final String mPrimaryButtonText;
18
19 // Typically set to "Cancel", or some other negative action.
20 private final String mSecondaryButtonText;
21
22 // Listens for when either of the buttons is clicked.
23 private final InfoBarListeners.Confirm mConfirmListener;
24
25 public ConfirmInfoBar(InfoBarListeners.Confirm confirmListener, int backgrou ndType,
26 int iconDrawableId, String message, String primaryButtonText,
27 String secondaryButtonText) {
28 this(0, confirmListener, backgroundType, iconDrawableId, message, primar yButtonText,
29 secondaryButtonText);
30 }
31
32 public ConfirmInfoBar(int nativeInfoBar, InfoBarListeners.Confirm confirmLis tener,
33 int backgroundType, int iconDrawableId, String message, String prima ryButtonText,
34 String secondaryButtonText) {
35 super(confirmListener, backgroundType, iconDrawableId);
36 mMessage = message;
37 mPrimaryButtonText = primaryButtonText;
38 mSecondaryButtonText = secondaryButtonText;
39 mConfirmListener = confirmListener;
40 setNativeInfoBar(nativeInfoBar);
41 }
42
43 @Override
44 public CharSequence getMessageText(Context context) {
45 return mMessage;
46 }
47
48 @Override
49 public String getPrimaryButtonText(Context context) {
50 return mPrimaryButtonText;
51 }
52
53 @Override
54 public String getSecondaryButtonText(Context context) {
55 return mSecondaryButtonText;
56 }
57
58 @Override
59 public void onButtonClicked(boolean isPrimaryButton) {
60 if (mConfirmListener != null) {
61 mConfirmListener.onConfirmInfoBarButtonClicked(this, isPrimaryButton );
62 }
63
64 if (mNativeInfoBarPtr != 0) {
65 int action = isPrimaryButton ? InfoBar.ACTION_TYPE_OK : InfoBar.ACTI ON_TYPE_CANCEL;
66 nativeOnButtonClicked(mNativeInfoBarPtr, action, "");
67 }
68 }
69
70 @Override
71 public void onCloseButtonClicked() {
72 if (mNativeInfoBarPtr != 0) {
73 nativeOnCloseButtonClicked(mNativeInfoBarPtr);
74 }
75 super.onCloseButtonClicked();
76 }
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698