Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: components/safe_browsing/base_blocking_page.cc

Issue 2898593002: WebView: choose loud vs. quiet interstitial (Closed)
Patch Set: Update WebView test for behavior change Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing/base_blocking_page.cc
diff --git a/components/safe_browsing/base_blocking_page.cc b/components/safe_browsing/base_blocking_page.cc
index 6c1272f5f366e8591a016fcd2ca0f71ea0dbb23f..027874c364deff44e527a34584251b091a667e5c 100644
--- a/components/safe_browsing/base_blocking_page.cc
+++ b/components/safe_browsing/base_blocking_page.cc
@@ -9,10 +9,12 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
+#include "components/grit/components_resources.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/security_interstitials/content/security_interstitial_controller_client.h"
#include "components/security_interstitials/core/metrics_helper.h"
#include "components/security_interstitials/core/safe_browsing_loud_error_ui.h"
+#include "components/security_interstitials/core/safe_browsing_quiet_error_ui.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
@@ -21,6 +23,7 @@ using content::InterstitialPage;
using content::WebContents;
using security_interstitials::BaseSafeBrowsingErrorUI;
using security_interstitials::SafeBrowsingLoudErrorUI;
+using security_interstitials::SafeBrowsingQuietErrorUI;
using security_interstitials::SecurityInterstitialControllerClient;
namespace safe_browsing {
@@ -44,7 +47,8 @@ BaseBlockingPage::BaseBlockingPage(
const GURL& main_frame_url,
const UnsafeResourceList& unsafe_resources,
std::unique_ptr<SecurityInterstitialControllerClient> controller_client,
- const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options)
+ const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options,
+ ErrorUiType error_type)
: SecurityInterstitialPage(web_contents,
unsafe_resources[0].url,
std::move(controller_client)),
@@ -55,17 +59,29 @@ BaseBlockingPage::BaseBlockingPage(
? -1
: web_contents->GetController().GetLastCommittedEntryIndex()),
unsafe_resources_(unsafe_resources),
- sb_error_ui_(base::MakeUnique<SafeBrowsingLoudErrorUI>(
- unsafe_resources_[0].url,
- main_frame_url_,
- GetInterstitialReason(unsafe_resources_),
- display_options,
- ui_manager->app_locale(),
- base::Time::NowFromSystemTime(),
- controller())),
+ sb_error_ui_(error_type == ErrorUiType::LOUD
Jialiu Lin 2017/05/22 17:06:00 nit: construction list is supposed to be simple. H
Nate Fischer 2017/05/22 23:13:46 Done.
+ ? static_cast<std::unique_ptr<BaseSafeBrowsingErrorUI>>(
+ base::MakeUnique<SafeBrowsingLoudErrorUI>(
+ unsafe_resources_[0].url,
+ main_frame_url_,
+ GetInterstitialReason(unsafe_resources_),
+ display_options,
+ ui_manager->app_locale(),
+ base::Time::NowFromSystemTime(),
+ controller()))
+ : static_cast<std::unique_ptr<BaseSafeBrowsingErrorUI>>(
+ base::MakeUnique<SafeBrowsingQuietErrorUI>(
+ unsafe_resources_[0].url,
+ main_frame_url_,
+ GetInterstitialReason(unsafe_resources_),
+ display_options,
+ ui_manager->app_locale(),
+ base::Time::NowFromSystemTime(),
+ controller(),
+ error_type == ErrorUiType::QUIET_GIANT))),
proceeded_(false),
- threat_details_proceed_delay_ms_(kThreatDetailsProceedDelayMilliSeconds) {
-}
+ threat_details_proceed_delay_ms_(kThreatDetailsProceedDelayMilliSeconds),
+ error_type_(error_type) {}
BaseBlockingPage::~BaseBlockingPage() {}
@@ -105,7 +121,7 @@ void BaseBlockingPage::ShowBlockingPage(
ui_manager, web_contents, entry ? entry->GetURL() : GURL(),
unsafe_resources,
CreateControllerClient(web_contents, unsafe_resources, ui_manager),
- CreateDefaultDisplayOptions(unsafe_resources));
+ CreateDefaultDisplayOptions(unsafe_resources), ErrorUiType::LOUD);
blocking_page->Show();
}
}
@@ -350,4 +366,10 @@ BaseBlockingPage::CreateControllerClient(
ui_manager->app_locale(), ui_manager->default_safe_page());
}
+int BaseBlockingPage::GetHTMLTemplateId() {
+ return error_type_ == ErrorUiType::LOUD
+ ? IDR_SECURITY_INTERSTITIAL_HTML
+ : IDR_SECURITY_INTERSTITIAL_QUIET_HTML;
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698