1 // Copyright 2014 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 org.chromium.content_public.browser.WebContents; 8 9 /** 10 * Generates an InfoBar for the data reduction proxy that contains a message and a link to the 11 * data reduction proxy settings menu. 12 */ 13 public class DataReductionProxyInfoBar extends ConfirmInfoBar { 14 private static String sSettingsClassName; 15 private static String sDataReductionProxySettingsClassName; 16 private static String sTitle; 17 private static String sLinkText; 18 19 /** 20 * Launch a data reduction proxy {@link InfoBar} with the specified title and link 21 * text. Clicking the link will open the specified settings page. 22 * @param webContents The {@link WebContents} in which to open the {@link InfoBar}. 23 * @param settingsClassName The settings class to open. 24 * @param drpSettingsClassName The {@link PreferenceActivity} fragment to show. 25 * @param title The text to display in the {@link InfoBar}. 26 * @param linkText The text to display in the link in the {@link InfoBar}. 27 * @param linkUrl The URL to be loaded when the link text is clicked. 28 */ 29 public static void launch(WebContents webContents, 30 String settingsClassName, 31 String drpSettingsClassName, 32 String title, 33 String linkText, 34 String linkUrl) { 35 sSettingsClassName = settingsClassName; 36 sDataReductionProxySettingsClassName = drpSettingsClassName; 37 sTitle = title; 38 sLinkText = linkText; 39 DataReductionProxyInfoBarDelegate.launch(webContents, linkUrl); 40 } 41 42 /** 43 * Callers should now pass a linkUrl, which is loaded when the user clicks on linkText. See 44 * {@link #launch} above. See http://crbug.com/383988. 45 */ 46 @Deprecated 47 public static void launch(WebContents webContents, 48 String settingsClassName, 49 String drpSettingsClassName, 50 String title, 51 String linkText) { 52 launch(webContents, settingsClassName, drpSettingsClassName, title, linkText, ""); 53 } 54 55 DataReductionProxyInfoBar(long nativeInfoBar, int iconDrawableId) { 56 super(nativeInfoBar, null, iconDrawableId, sTitle, 57 sLinkText, null, null); 58 } 59 60 @Override 61 public void createContent(InfoBarLayout layout) { 62 layout.setButtons(sLinkText, null); 63 } 64 65 @Override 66 public void onButtonClicked(boolean isPrimaryButton) { 67 if (!isPrimaryButton) return; 68 onLinkClicked(); 69 } 70 } 71