Commit bd1d07ad authored by Charles Harrison's avatar Charles Harrison Committed by Commit Bot

[subresource_filter] Add Learn more link on Android

This patch adds a "Learn more" link to the expanded infobar, which will
send users to a Chrome help page about the feature.

The page is not currently implemented, so until M61 hits stable the
link will be broken and just land on the support home page.

Bug: 689992
Change-Id: If7d85ad643ce872a48fb7538967886ffebd5fe8d
Reviewed-on: https://chromium-review.googlesource.com/541519Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarDan Alcantara <dfalcantara@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481631}
parent 41a571ab
......@@ -25,7 +25,7 @@ public class AdsBlockedInfoBar extends ConfirmInfoBar implements OnCheckedChange
private final String mOKButtonText;
private final String mReloadButtonText;
private final String mToggleText;
private boolean mShowExplanation;
private boolean mIsShowingExplanation;
private boolean mReloadIsToggled;
private ButtonCompat mButton;
......@@ -49,8 +49,10 @@ public class AdsBlockedInfoBar extends ConfirmInfoBar implements OnCheckedChange
@Override
public void createContent(InfoBarLayout layout) {
super.createContent(layout);
if (mShowExplanation) {
if (mIsShowingExplanation) {
layout.setMessage(mFollowUpMessage);
String learnMore = layout.getContext().getString(R.string.learn_more);
layout.appendMessageLinkText(learnMore);
setButtons(layout, mOKButtonText, null);
InfoBarControlLayout controlLayout = layout.addControlLayout();
......@@ -75,8 +77,13 @@ public class AdsBlockedInfoBar extends ConfirmInfoBar implements OnCheckedChange
@Override
public void onLinkClicked() {
mShowExplanation = true;
replaceView(createView());
// If we aren't already showing the explanation, clicking the link should expand to show the
// explanation. If we *are* already showing the explanation, clicking the link (which should
// change to Learn more) should take us to the help page.
if (!mIsShowingExplanation) {
mIsShowingExplanation = true;
replaceView(createView());
}
super.onLinkClicked();
}
......
......@@ -13,6 +13,7 @@
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h"
#include "components/strings/grit/components_strings.h"
#include "components/subresource_filter/core/browser/subresource_filter_constants.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -73,7 +74,24 @@ bool AdsBlockedInfobarDelegate::Cancel() {
return true;
}
GURL AdsBlockedInfobarDelegate::GetLinkURL() const {
DCHECK(infobar_expanded_);
return GURL(subresource_filter::kLearnMoreLink);
}
bool AdsBlockedInfobarDelegate::LinkClicked(WindowOpenDisposition disposition) {
ChromeSubresourceFilterClient::LogAction(kActionDetailsShown);
if (infobar_expanded_) {
DCHECK_EQ(disposition, WindowOpenDisposition::NEW_FOREGROUND_TAB);
infobar()->owner()->OpenURL(GetLinkURL(),
WindowOpenDisposition::NEW_FOREGROUND_TAB);
ChromeSubresourceFilterClient::LogAction(kActionClickedLearnMore);
} else {
ChromeSubresourceFilterClient::LogAction(kActionDetailsShown);
infobar_expanded_ = true;
}
// Returning false keeps the infobar up, which is the behavior we want in all
// cases. If the user is navigating via a new foreground tab we do not want
// the infobar going away on the tab (and therefore invoking our smart-hiding
// logic).
return false;
}
......@@ -34,11 +34,15 @@ class AdsBlockedInfobarDelegate : public ConfirmInfoBarDelegate {
int GetButtons() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
bool Cancel() override;
GURL GetLinkURL() const override;
bool LinkClicked(WindowOpenDisposition disposition) override;
private:
AdsBlockedInfobarDelegate();
// True when the infobar is in the expanded state.
bool infobar_expanded_ = false;
DISALLOW_COPY_AND_ASSIGN(AdsBlockedInfobarDelegate);
};
......
......@@ -56,6 +56,9 @@ constexpr char kActivationConsoleMessage[] =
constexpr char kDisallowSubframeConsoleMessage[] =
"Subresource filtering disallowed loading this resource, ";
constexpr char kLearnMoreLink[] =
"https://support.google.com/chrome/?p=blocked_ads";
} // namespace subresource_filter
#endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_CONSTANTS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment