Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/DataReductionProxyInfoBar.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/DataReductionProxyInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/DataReductionProxyInfoBar.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4d1b2bcce8c30d587f078a8f7ea8300525c630e7 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/DataReductionProxyInfoBar.java |
| @@ -0,0 +1,52 @@ |
| +// 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.infobar; |
| + |
| +import android.content.Context; |
| +import android.content.Intent; |
| +import android.preference.PreferenceActivity; |
| + |
| +import org.chromium.content_public.browser.WebContents; |
| + |
| +/** |
| + * Generates an InfoBar for the data reduction proxy that contains a message and a link to the |
| + * data reduction proxy settings menu. |
| + */ |
| +public class DataReductionProxyInfoBar extends ConfirmInfoBar { |
| + private static String sSettingsClassName; |
| + private static String sDataReductionProxySettingsClassName; |
| + private static String sTitle; |
| + private static String sLinkText; |
| + |
| + public static void launch(WebContents webContents, |
|
aruslan
2014/07/15 23:14:28
nit: javadoc + why it is setting static variables.
bengr
2014/07/16 00:43:25
Done. The alternative was to pass this info to nat
|
| + String settingsClassName, |
| + String drpSettingsClassName, |
| + String title, |
| + String linkText) { |
| + sSettingsClassName = settingsClassName; |
| + sDataReductionProxySettingsClassName = drpSettingsClassName; |
| + sTitle = title; |
| + sLinkText = linkText; |
| + DataReductionProxyInfoBarDelegate.launch(webContents); |
| + } |
| + |
| + DataReductionProxyInfoBar(long nativeInfoBar, int iconDrawableId) { |
| + super(nativeInfoBar, null, iconDrawableId, sTitle, |
| + sLinkText, null, null); |
| + } |
| + |
| + @Override |
| + public void onLinkClicked() { |
| + Context context = getContext(); |
| + if (context == null) return; |
| + Intent intent = new Intent(Intent.ACTION_VIEW); |
| + intent.setClassName(context, sSettingsClassName); |
| + intent.setFlags( |
| + Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| + intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, |
| + sDataReductionProxySettingsClassName); |
| + context.startActivity(intent); |
| + } |
| +} |