Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/SubresourceFilterExperimentalInfoBar.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/SubresourceFilterExperimentalInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/SubresourceFilterExperimentalInfoBar.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ad03424b9e6df6139462b09aae89c7155c1bddd8 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/SubresourceFilterExperimentalInfoBar.java |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2017 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.base.annotations.CalledByNative; |
| +import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.ResourceId; |
| + |
| +/** |
| + * After user proceed through Safe Browsing warning interstitials that are displayed when the site |
| + * ahead contains deceptive embedded content, the infobar appears, it explains the user that some |
| + * subresources were filtered and presents the "Detals" link. If the link is pressed full infobar |
| + * with detailed text and the action buttons appears, it gives the user an ability to reload the |
| + * page with the content we've blocked previously. |
| + */ |
| +public class SubresourceFilterExperimentalInfoBar extends ConfirmInfoBar { |
| + private final String mMessage; |
| + private final String mFollowUpMessage; |
| + private final String mOKButtonText; |
| + private final String mReloadButtonText; |
| + private Boolean mShowExplanation; |
|
gone
2017/03/24 21:16:13
use a regular boolean instead of Boolean
melandory
2017/03/28 13:43:26
Done.
|
| + |
| + @CalledByNative |
| + private static InfoBar show(int enumeratedIconId, String message, String oKButtonText, |
| + String reloadButtonText, String followUpMessage) { |
| + return new SubresourceFilterExperimentalInfoBar( |
| + ResourceId.mapToDrawableId(enumeratedIconId), message, oKButtonText, |
| + reloadButtonText, followUpMessage); |
| + } |
| + |
| + private SubresourceFilterExperimentalInfoBar(int iconDrawbleId, String message, |
| + String oKButtonText, String reloadButtonText, String followUpMessage) { |
| + super(iconDrawbleId, null, message, null, null, null); //, oKButtonText, reloadButtonText); |
| + mFollowUpMessage = followUpMessage; |
| + mMessage = message; |
| + mOKButtonText = oKButtonText; |
| + mReloadButtonText = reloadButtonText; |
| + mShowExplanation = false; |
|
gone
2017/03/24 21:16:13
this is false by default in Java
melandory
2017/03/28 13:43:26
Done.
|
| + } |
| + |
| + @Override |
| + public void createContent(InfoBarLayout layout) { |
| + super.createContent(layout); |
| + if (mShowExplanation) { |
| + layout.setMessage(mFollowUpMessage); |
| + setButtons(layout, mOKButtonText, mReloadButtonText); |
| + |
|
gone
2017/03/24 21:16:13
nit: remove extra newline
melandory
2017/03/28 13:43:26
Done.
|
| + } else { |
| + String link = layout.getContext().getString(R.string.subresource_filter_details_link); |
| + layout.setMessage(mMessage); |
| + layout.setMessageLinkText(link); |
| + } |
| + } |
| + |
| + @Override |
| + public void onLinkClicked() { |
| + mShowExplanation = true; |
| + replaceView(createView()); |
| + } |
| +} |