// 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 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;

    /**
     * Launch a data reduction proxy {@link InfoBar} with the specified title and link
     * text. Clicking the link will open the specified settings page.
     * @param webContents The {@link WebContents} in which to open the {@link InfoBar}.
     * @param settingsClassName The settings class to open.
     * @param drpSettingsClassName The {@link PreferenceActivity} fragment to show.
     * @param title The text to display in the {@link InfoBar}.
     * @param linkText The text to display in the link in the {@link InfoBar}.
     * @param linkUrl The URL to be loaded when the link text is clicked.
     */
    public static void launch(WebContents webContents,
            String settingsClassName,
            String drpSettingsClassName,
            String title,
            String linkText,
            String linkUrl) {
        sSettingsClassName = settingsClassName;
        sDataReductionProxySettingsClassName = drpSettingsClassName;
        sTitle = title;
        sLinkText = linkText;
        DataReductionProxyInfoBarDelegate.launch(webContents, linkUrl);
    }

    /**
     * Callers should now pass a linkUrl, which is loaded when the user clicks on linkText. See
     * {@link #launch} above. See http://crbug.com/383988.
     */
    @Deprecated
    public static void launch(WebContents webContents,
            String settingsClassName,
            String drpSettingsClassName,
            String title,
            String linkText) {
        launch(webContents, settingsClassName, drpSettingsClassName, title, linkText, "");
    }

    DataReductionProxyInfoBar(long nativeInfoBar, int iconDrawableId) {
        super(nativeInfoBar, null, iconDrawableId, sTitle,
                sLinkText, null, null);
    }

    @Override
    public void createContent(InfoBarLayout layout) {
        layout.setButtons(sLinkText, null);
    }

    @Override
    public void onButtonClicked(boolean isPrimaryButton) {
        if (!isPrimaryButton) return;
        onLinkClicked();
    }
}

@@ -472,118 +472,8 @@
 r %7B%0A
-    private static String sSettingsClassName;%0A    private static String sDataReductionProxySettingsClassName;%0A
     
@@ -797,152 +797,8 @@
 r%7D.%0A
-     * @param settingsClassName The settings class to open.%0A     * @param drpSettingsClassName The %7B@link PreferenceActivity%7D fragment to show.%0A
     
@@ -1077,87 +1077,8 @@
 ts,%0A
-            String settingsClassName,%0A            String drpSettingsClassName,%0A
     
@@ -1162,125 +1162,8 @@
 ) %7B%0A
-        sSettingsClassName = settingsClassName;%0A        sDataReductionProxySettingsClassName = drpSettingsClassName;%0A
     
@@ -1310,179 +1310,99 @@
   * 
-Callers should now pass a linkUrl, which is loaded when the user clicks on linkText. See%0A     * %7B@link #launch%7D above. See http://crbug.com/383988.%0A     */%0A    @Deprecated
+Use the method above instead. TODO(newt): delete this once all callers are updated.%0A     */
 %0A   
@@ -1472,33 +1472,23 @@
  String 
-settingsClassName
+unused1
 ,%0A      
@@ -1500,36 +1500,23 @@
  String 
-drpSettingsClassName
+unused2
 ,%0A      
@@ -1562,16 +1562,44 @@
 linkText
+,%0A            String linkUrl
 ) %7B%0A    
@@ -1625,49 +1625,8 @@
 nts,
- settingsClassName, drpSettingsClassName,
  tit
@@ -1643,10 +1643,15 @@
 xt, 
-%22%22
+linkUrl
 );%0A 

Delete dead code in DataReductionProxyInfoBar.