Commit c06541da authored by Edward Jung's avatar Edward Jung Committed by Commit Bot

SafeBrowsing: Add SBErrorDisplayOptions.always_show_back_to_safety

Adding this option allows UI to set the visibility of the
'Back to safety' button.

Webview: Set to false, so the button would only be shown where
there is a page to go back to.
Chromium: option is always set to true so always show the
Back to safety button. Where there is no previous page,
the user is taken to the new tab page.

Bug: 760383
Change-Id: I8857b6bf2ff977c572f507f817bf815307453c13
Reviewed-on: https://chromium-review.googlesource.com/641435Reviewed-by: default avatarJialiu Lin <jialiul@chromium.org>
Reviewed-by: default avatarAdrienne Porter Felt <felt@chromium.org>
Reviewed-by: default avatarSelim Gurun <sgurun@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Commit-Queue: Edward Jung <edwardjung@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501227}
parent 6c0d8493
...@@ -98,6 +98,7 @@ void AwSafeBrowsingBlockingPage::ShowBlockingPage( ...@@ -98,6 +98,7 @@ void AwSafeBrowsingBlockingPage::ShowBlockingPage(
pref_service->GetBoolean( pref_service->GetBoolean(
::prefs::kSafeBrowsingProceedAnywayDisabled), ::prefs::kSafeBrowsingProceedAnywayDisabled),
false, // should_open_links_in_new_tab false, // should_open_links_in_new_tab
false, // always_show_back_to_safety
"cpn_safe_browsing_wv"); // help_center_article_link "cpn_safe_browsing_wv"); // help_center_article_link
ErrorUiType errorType = ErrorUiType errorType =
......
...@@ -79,6 +79,7 @@ class SafeBrowsingBlockingPageFactoryImpl ...@@ -79,6 +79,7 @@ class SafeBrowsingBlockingPageFactoryImpl
IsExtendedReportingEnabled(*prefs), IsScout(*prefs), IsExtendedReportingEnabled(*prefs), IsScout(*prefs),
is_proceed_anyway_disabled, is_proceed_anyway_disabled,
true, // should_open_links_in_new_tab true, // should_open_links_in_new_tab
true, // always_show_back_to_safety
kHelpCenterLink); kHelpCenterLink);
return new SafeBrowsingBlockingPage(ui_manager, web_contents, return new SafeBrowsingBlockingPage(ui_manager, web_contents,
......
...@@ -329,6 +329,7 @@ class TestSafeBrowsingBlockingPageFactory ...@@ -329,6 +329,7 @@ class TestSafeBrowsingBlockingPageFactory
IsExtendedReportingEnabled(*prefs), IsScout(*prefs), IsExtendedReportingEnabled(*prefs), IsScout(*prefs),
is_proceed_anyway_disabled, is_proceed_anyway_disabled,
true, // should_open_links_in_new_tab true, // should_open_links_in_new_tab
false, // check_can_go_back_to_safety
"cpn_safe_browsing" /* help_center_article_link */); "cpn_safe_browsing" /* help_center_article_link */);
return new TestSafeBrowsingBlockingPage(delegate, web_contents, return new TestSafeBrowsingBlockingPage(delegate, web_contents,
main_frame_url, unsafe_resources, main_frame_url, unsafe_resources,
......
...@@ -95,6 +95,7 @@ class TestSafeBrowsingBlockingPageFactory ...@@ -95,6 +95,7 @@ class TestSafeBrowsingBlockingPageFactory
IsExtendedReportingEnabled(*prefs), IsScout(*prefs), IsExtendedReportingEnabled(*prefs), IsScout(*prefs),
is_proceed_anyway_disabled, is_proceed_anyway_disabled,
true, // should_open_links_in_new_tab true, // should_open_links_in_new_tab
true, // always_show_back_to_safety
"cpn_safe_browsing" /* help_center_article_link */); "cpn_safe_browsing" /* help_center_article_link */);
return new TestSafeBrowsingBlockingPage(manager, web_contents, return new TestSafeBrowsingBlockingPage(manager, web_contents,
main_frame_url, unsafe_resources, main_frame_url, unsafe_resources,
...@@ -177,6 +178,7 @@ class TestSafeBrowsingBlockingQuietPageFactory ...@@ -177,6 +178,7 @@ class TestSafeBrowsingBlockingQuietPageFactory
IsExtendedReportingEnabled(*prefs), IsScout(*prefs), IsExtendedReportingEnabled(*prefs), IsScout(*prefs),
is_proceed_anyway_disabled, is_proceed_anyway_disabled,
true, // should_open_links_in_new_tab true, // should_open_links_in_new_tab
true, // always_show_back_to_safety
"cpn_safe_browsing" /* help_center_article_link */); "cpn_safe_browsing" /* help_center_article_link */);
return new TestSafeBrowsingBlockingPageQuiet( return new TestSafeBrowsingBlockingPageQuiet(
manager, web_contents, main_frame_url, unsafe_resources, manager, web_contents, main_frame_url, unsafe_resources,
......
...@@ -437,6 +437,7 @@ class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { ...@@ -437,6 +437,7 @@ class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage {
false, // is_scout_reporting_enabled false, // is_scout_reporting_enabled
false, // is_proceed_anyway_disabled false, // is_proceed_anyway_disabled
true, // should_open_links_in_new_tab true, // should_open_links_in_new_tab
true, // always_show_back_to_safety
"cpn_safe_browsing")) { // help_center_article_link "cpn_safe_browsing")) { // help_center_article_link
// Don't delay details at all for the unittest. // Don't delay details at all for the unittest.
SetThreatDetailsProceedDelayForTesting(0); SetThreatDetailsProceedDelayForTesting(0);
......
...@@ -80,6 +80,7 @@ BaseBlockingPage::CreateDefaultDisplayOptions( ...@@ -80,6 +80,7 @@ BaseBlockingPage::CreateDefaultDisplayOptions(
false, // is_scout false, // is_scout
false, // kSafeBrowsingProceedAnywayDisabled false, // kSafeBrowsingProceedAnywayDisabled
false, // should_open_links_in_new_tab false, // should_open_links_in_new_tab
true, // always_show_back_to_safety
"cpn_safe_browsing"); // help_center_article_link "cpn_safe_browsing"); // help_center_article_link
} }
......
...@@ -84,6 +84,7 @@ SBErrorOptions TriggerManager::GetSBErrorDisplayOptions( ...@@ -84,6 +84,7 @@ SBErrorOptions TriggerManager::GetSBErrorDisplayOptions(
IsScout(pref_service), IsScout(pref_service),
/*is_proceed_anyway_disabled=*/false, /*is_proceed_anyway_disabled=*/false,
/*should_open_links_in_new_tab=*/false, /*should_open_links_in_new_tab=*/false,
/*show_back_to_safety_button=*/true,
/*help_center_article_link=*/std::string()); /*help_center_article_link=*/std::string());
} }
......
...@@ -32,6 +32,7 @@ BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions( ...@@ -32,6 +32,7 @@ BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions(
bool is_scout_reporting_enabled, bool is_scout_reporting_enabled,
bool is_proceed_anyway_disabled, bool is_proceed_anyway_disabled,
bool should_open_links_in_new_tab, bool should_open_links_in_new_tab,
bool always_show_back_to_safety,
const std::string& help_center_article_link) const std::string& help_center_article_link)
: is_main_frame_load_blocked(is_main_frame_load_blocked), : is_main_frame_load_blocked(is_main_frame_load_blocked),
is_extended_reporting_opt_in_allowed( is_extended_reporting_opt_in_allowed(
...@@ -41,6 +42,7 @@ BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions( ...@@ -41,6 +42,7 @@ BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions(
is_scout_reporting_enabled(is_scout_reporting_enabled), is_scout_reporting_enabled(is_scout_reporting_enabled),
is_proceed_anyway_disabled(is_proceed_anyway_disabled), is_proceed_anyway_disabled(is_proceed_anyway_disabled),
should_open_links_in_new_tab(should_open_links_in_new_tab), should_open_links_in_new_tab(should_open_links_in_new_tab),
always_show_back_to_safety(always_show_back_to_safety),
help_center_article_link(help_center_article_link) {} help_center_article_link(help_center_article_link) {}
BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions( BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions(
...@@ -53,6 +55,7 @@ BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions( ...@@ -53,6 +55,7 @@ BaseSafeBrowsingErrorUI::SBErrorDisplayOptions::SBErrorDisplayOptions(
is_scout_reporting_enabled(other.is_scout_reporting_enabled), is_scout_reporting_enabled(other.is_scout_reporting_enabled),
is_proceed_anyway_disabled(other.is_proceed_anyway_disabled), is_proceed_anyway_disabled(other.is_proceed_anyway_disabled),
should_open_links_in_new_tab(other.should_open_links_in_new_tab), should_open_links_in_new_tab(other.should_open_links_in_new_tab),
always_show_back_to_safety(other.always_show_back_to_safety),
help_center_article_link(other.help_center_article_link) {} help_center_article_link(other.help_center_article_link) {}
} // security_interstitials } // security_interstitials
...@@ -33,6 +33,7 @@ class BaseSafeBrowsingErrorUI { ...@@ -33,6 +33,7 @@ class BaseSafeBrowsingErrorUI {
bool is_scout_reporting_enabled, bool is_scout_reporting_enabled,
bool is_proceed_anyway_disabled, bool is_proceed_anyway_disabled,
bool should_open_links_in_new_tab, bool should_open_links_in_new_tab,
bool always_show_back_to_safety,
const std::string& help_center_article_link); const std::string& help_center_article_link);
SBErrorDisplayOptions(const SBErrorDisplayOptions& other); SBErrorDisplayOptions(const SBErrorDisplayOptions& other);
...@@ -64,6 +65,12 @@ class BaseSafeBrowsingErrorUI { ...@@ -64,6 +65,12 @@ class BaseSafeBrowsingErrorUI {
// Indicates if links should use a new foreground tab or the current tab. // Indicates if links should use a new foreground tab or the current tab.
bool should_open_links_in_new_tab; bool should_open_links_in_new_tab;
// Indicates if the 'Back to safety' primary action button should always be
// shown. If the option is false, this button is shown only when there is
// a proper page to navigate back to. Chrome and Chromium builds should
// always set this option to true,
bool always_show_back_to_safety;
// The p= query parameter used when visiting the Help Center. If this is // The p= query parameter used when visiting the Help Center. If this is
// nullptr, then a default value will be used for the SafeBrowsing article. // nullptr, then a default value will be used for the SafeBrowsing article.
std::string help_center_article_link; std::string help_center_article_link;
...@@ -109,6 +116,10 @@ class BaseSafeBrowsingErrorUI { ...@@ -109,6 +116,10 @@ class BaseSafeBrowsingErrorUI {
return display_options_.should_open_links_in_new_tab; return display_options_.should_open_links_in_new_tab;
} }
bool always_show_back_to_safety() const {
return display_options_.always_show_back_to_safety;
}
const std::string& get_help_center_article_link() const { const std::string& get_help_center_article_link() const {
return display_options_.help_center_article_link; return display_options_.help_center_article_link;
} }
......
...@@ -94,7 +94,10 @@ void SafeBrowsingLoudErrorUI::PopulateStringsForHtml( ...@@ -94,7 +94,10 @@ void SafeBrowsingLoudErrorUI::PopulateStringsForHtml(
"primaryButtonText", "primaryButtonText",
l10n_util::GetStringUTF16(IDS_SAFEBROWSING_OVERRIDABLE_SAFETY_BUTTON)); l10n_util::GetStringUTF16(IDS_SAFEBROWSING_OVERRIDABLE_SAFETY_BUTTON));
load_time_data->SetBoolean("overridable", !is_proceed_anyway_disabled()); load_time_data->SetBoolean("overridable", !is_proceed_anyway_disabled());
load_time_data->SetBoolean("hide_primary_button", !controller()->CanGoBack());
load_time_data->SetBoolean(
"hide_primary_button",
always_show_back_to_safety() ? false : !controller()->CanGoBack());
switch (interstitial_reason()) { switch (interstitial_reason()) {
case BaseSafeBrowsingErrorUI::SB_REASON_MALWARE: case BaseSafeBrowsingErrorUI::SB_REASON_MALWARE:
......
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