Remove 'RemoveTrailingSeparators' function from SimpleMenuModel
[chromium-blink-merge.git] / chrome / browser / safe_browsing / safe_browsing_blocking_page.cc
blob73b45a3944270fd246e8baccc52d35c9850c22d9
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Implementation of the SafeBrowsingBlockingPage class.
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
9 #include <string>
11 #include "base/bind.h"
12 #include "base/command_line.h"
13 #include "base/i18n/rtl.h"
14 #include "base/lazy_instance.h"
15 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h"
18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_piece.h"
20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h"
23 #include "base/values.h"
24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/renderer_preferences_util.h"
27 #include "chrome/browser/safe_browsing/malware_details.h"
28 #include "chrome/browser/safe_browsing/ui_manager.h"
29 #include "chrome/browser/tab_contents/tab_util.h"
30 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h"
33 #include "chrome/grit/generated_resources.h"
34 #include "chrome/grit/locale_settings.h"
35 #include "components/google/core/browser/google_util.h"
36 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/interstitial_page.h"
38 #include "content/public/browser/navigation_controller.h"
39 #include "content/public/browser/user_metrics.h"
40 #include "content/public/browser/web_contents.h"
41 #include "content/public/common/renderer_preferences.h"
42 #include "grit/browser_resources.h"
43 #include "net/base/escape.h"
44 #include "ui/base/l10n/l10n_util.h"
46 using base::UserMetricsAction;
47 using content::BrowserThread;
48 using content::InterstitialPage;
49 using content::OpenURLParams;
50 using content::Referrer;
51 using content::WebContents;
53 namespace {
55 // For malware interstitial pages, we link the problematic URL to Google's
56 // diagnostic page.
57 #if defined(GOOGLE_CHROME_BUILD)
58 const char kSbDiagnosticUrl[] =
59 "https://www.google.com/safebrowsing/diagnostic?site=%s&client=googlechrome";
60 #else
61 const char kSbDiagnosticUrl[] =
62 "https://www.google.com/safebrowsing/diagnostic?site=%s&client=chromium";
63 #endif
65 // URL for malware and phishing, V2.
66 const char kLearnMoreMalwareUrlV2[] =
67 "https://www.google.com/transparencyreport/safebrowsing/";
68 const char kLearnMorePhishingUrlV2[] =
69 "https://www.google.com/transparencyreport/safebrowsing/";
71 // After a malware interstitial where the user opted-in to the report
72 // but clicked "proceed anyway", we delay the call to
73 // MalwareDetails::FinishCollection() by this much time (in
74 // milliseconds).
75 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000;
77 // Constants for the Experience Sampling instrumentation.
78 const char kEventNameMalware[] = "safebrowsing_interstitial_";
79 const char kEventNameHarmful[] = "harmful_interstitial_";
80 const char kEventNamePhishing[] = "phishing_interstitial_";
81 const char kEventNameOther[] = "safebrowsing_other_interstitial_";
83 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap>
84 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER;
86 } // namespace
88 // static
89 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL;
91 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we
92 // don't leak it.
93 class SafeBrowsingBlockingPageFactoryImpl
94 : public SafeBrowsingBlockingPageFactory {
95 public:
96 SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
97 SafeBrowsingUIManager* ui_manager,
98 WebContents* web_contents,
99 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources)
100 override {
101 return new SafeBrowsingBlockingPage(ui_manager, web_contents,
102 unsafe_resources);
105 private:
106 friend struct base::DefaultLazyInstanceTraits<
107 SafeBrowsingBlockingPageFactoryImpl>;
109 SafeBrowsingBlockingPageFactoryImpl() { }
111 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageFactoryImpl);
114 static base::LazyInstance<SafeBrowsingBlockingPageFactoryImpl>
115 g_safe_browsing_blocking_page_factory_impl = LAZY_INSTANCE_INITIALIZER;
117 // static
118 content::InterstitialPageDelegate::TypeID
119 SafeBrowsingBlockingPage::kTypeForTesting =
120 &SafeBrowsingBlockingPage::kTypeForTesting;
122 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
123 SafeBrowsingUIManager* ui_manager,
124 WebContents* web_contents,
125 const UnsafeResourceList& unsafe_resources)
126 : SecurityInterstitialPage(web_contents, unsafe_resources[0].url),
127 malware_details_proceed_delay_ms_(
128 kMalwareDetailsProceedDelayMilliSeconds),
129 ui_manager_(ui_manager),
130 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)),
131 unsafe_resources_(unsafe_resources),
132 proceeded_(false) {
133 bool malware = false;
134 bool harmful = false;
135 bool phishing = false;
136 for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
137 iter != unsafe_resources_.end(); ++iter) {
138 const UnsafeResource& resource = *iter;
139 SBThreatType threat_type = resource.threat_type;
140 if (threat_type == SB_THREAT_TYPE_URL_MALWARE ||
141 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) {
142 malware = true;
143 } else if (threat_type == SB_THREAT_TYPE_URL_UNWANTED) {
144 harmful = true;
145 } else {
146 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING ||
147 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL);
148 phishing = true;
151 DCHECK(phishing || malware || harmful);
152 if (malware)
153 interstitial_reason_ = SB_REASON_MALWARE;
154 else if (harmful)
155 interstitial_reason_ = SB_REASON_HARMFUL;
156 else
157 interstitial_reason_ = SB_REASON_PHISHING;
159 // This must be done after calculating |interstitial_reason_| above.
160 // Use same prefix for UMA as for Rappor.
161 set_metrics_helper(new SecurityInterstitialMetricsHelper(
162 web_contents, request_url(), GetMetricPrefix(), GetMetricPrefix(),
163 SecurityInterstitialMetricsHelper::REPORT_RAPPOR,
164 GetSamplingEventName()));
165 metrics_helper()->RecordUserDecision(SecurityInterstitialMetricsHelper::SHOW);
166 metrics_helper()->RecordUserInteraction(
167 SecurityInterstitialMetricsHelper::TOTAL_VISITS);
168 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
169 metrics_helper()->RecordUserDecision(
170 SecurityInterstitialMetricsHelper::PROCEEDING_DISABLED);
173 if (!is_main_frame_load_blocked_) {
174 navigation_entry_index_to_remove_ =
175 web_contents->GetController().GetLastCommittedEntryIndex();
176 } else {
177 navigation_entry_index_to_remove_ = -1;
180 // Start computing malware details. They will be sent only
181 // if the user opts-in on the blocking page later.
182 // If there's more than one malicious resources, it means the user
183 // clicked through the first warning, so we don't prepare additional
184 // reports.
185 if (unsafe_resources.size() == 1 &&
186 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE &&
187 malware_details_.get() == NULL && CanShowMalwareDetailsOption()) {
188 malware_details_ = MalwareDetails::NewMalwareDetails(
189 ui_manager_, web_contents, unsafe_resources[0]);
193 bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() {
194 return (!web_contents()->GetBrowserContext()->IsOffTheRecord() &&
195 web_contents()->GetURL().SchemeIs(url::kHttpScheme) &&
196 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed));
199 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
202 void SafeBrowsingBlockingPage::CommandReceived(const std::string& page_cmd) {
203 if (page_cmd == "\"pageLoadComplete\"") {
204 // content::WaitForRenderFrameReady sends this message when the page
205 // load completes. Ignore it.
206 return;
209 int command = 0;
210 bool retval = base::StringToInt(page_cmd, &command);
211 DCHECK(retval) << page_cmd;
213 switch (command) {
214 case CMD_DO_REPORT: {
215 // User enabled SB Extended Reporting via the checkbox.
216 SetReportingPreference(true);
217 break;
219 case CMD_DONT_REPORT: {
220 // User disabled SB Extended Reporting via the checkbox.
221 SetReportingPreference(false);
222 break;
224 case CMD_OPEN_HELP_CENTER: {
225 // User pressed "Learn more".
226 metrics_helper()->RecordUserInteraction(
227 SecurityInterstitialMetricsHelper::SHOW_LEARN_MORE);
228 GURL learn_more_url(
229 interstitial_reason_ == SB_REASON_PHISHING ?
230 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2);
231 learn_more_url = google_util::AppendGoogleLocaleParam(
232 learn_more_url, g_browser_process->GetApplicationLocale());
233 OpenURLParams params(learn_more_url,
234 Referrer(),
235 CURRENT_TAB,
236 ui::PAGE_TRANSITION_LINK,
237 false);
238 web_contents()->OpenURL(params);
239 break;
241 case CMD_OPEN_REPORTING_PRIVACY: {
242 // User pressed on the SB Extended Reporting "privacy policy" link.
243 OpenExtendedReportingPrivacyPolicy();
244 break;
246 case CMD_PROCEED: {
247 // User pressed on the button to proceed.
248 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
249 metrics_helper()->RecordUserDecision(
250 SecurityInterstitialMetricsHelper::PROCEED);
251 interstitial_page()->Proceed();
252 // |this| has been deleted after Proceed() returns.
253 break;
255 // If the user can't proceed, fall through to CMD_DONT_PROCEED.
257 case CMD_DONT_PROCEED: {
258 // User pressed on the button to return to safety.
259 // Don't record the user action here because there are other ways of
260 // triggering DontProceed, like clicking the back button.
261 if (is_main_frame_load_blocked_) {
262 // If the load is blocked, we want to close the interstitial and discard
263 // the pending entry.
264 interstitial_page()->DontProceed();
265 // |this| has been deleted after DontProceed() returns.
266 break;
269 // Otherwise the offending entry has committed, and we need to go back or
270 // to a safe page. We will close the interstitial when that page commits.
271 if (web_contents()->GetController().CanGoBack()) {
272 web_contents()->GetController().GoBack();
273 } else {
274 web_contents()->GetController().LoadURL(
275 GURL(chrome::kChromeUINewTabURL),
276 content::Referrer(),
277 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
278 std::string());
280 break;
282 case CMD_OPEN_DIAGNOSTIC: {
283 // User wants to see why this page is blocked.
284 // TODO(felt): element_index will always be 0. See crbug.com/464732
285 size_t element_index = 0;
286 const UnsafeResource& unsafe_resource = unsafe_resources_[element_index];
287 std::string bad_url_spec = unsafe_resource.url.spec();
288 metrics_helper()->RecordUserInteraction(
289 SecurityInterstitialMetricsHelper::SHOW_DIAGNOSTIC);
290 std::string diagnostic =
291 base::StringPrintf(kSbDiagnosticUrl,
292 net::EscapeQueryParamValue(bad_url_spec, true).c_str());
293 GURL diagnostic_url(diagnostic);
294 diagnostic_url = google_util::AppendGoogleLocaleParam(
295 diagnostic_url, g_browser_process->GetApplicationLocale());
296 DCHECK(unsafe_resource.threat_type == SB_THREAT_TYPE_URL_MALWARE ||
297 unsafe_resource.threat_type ==
298 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL ||
299 unsafe_resource.threat_type == SB_THREAT_TYPE_URL_UNWANTED);
300 OpenURLParams params(
301 diagnostic_url, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_LINK,
302 false);
303 web_contents()->OpenURL(params);
304 break;
306 case CMD_SHOW_MORE_SECTION: {
307 // User has opened up the hidden text.
308 metrics_helper()->RecordUserInteraction(
309 SecurityInterstitialMetricsHelper::SHOW_ADVANCED);
310 break;
315 void SafeBrowsingBlockingPage::OverrideRendererPrefs(
316 content::RendererPreferences* prefs) {
317 Profile* profile = Profile::FromBrowserContext(
318 web_contents()->GetBrowserContext());
319 renderer_preferences_util::UpdateFromSystemSettings(
320 prefs, profile, web_contents());
323 void SafeBrowsingBlockingPage::OnProceed() {
324 proceeded_ = true;
325 // Send the malware details, if we opted to.
326 FinishMalwareDetails(malware_details_proceed_delay_ms_);
328 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true);
330 // Check to see if some new notifications of unsafe resources have been
331 // received while we were showing the interstitial.
332 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
333 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents());
334 SafeBrowsingBlockingPage* blocking_page = NULL;
335 if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
336 // Build an interstitial for all the unsafe resources notifications.
337 // Don't show it now as showing an interstitial while an interstitial is
338 // already showing would cause DontProceed() to be invoked.
339 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_,
340 web_contents(),
341 iter->second);
342 unsafe_resource_map->erase(iter);
345 // Now that this interstitial is gone, we can show the new one.
346 if (blocking_page)
347 blocking_page->Show();
350 content::InterstitialPageDelegate::TypeID
351 SafeBrowsingBlockingPage::GetTypeForTesting() const {
352 return SafeBrowsingBlockingPage::kTypeForTesting;
355 bool SafeBrowsingBlockingPage::ShouldCreateNewNavigation() const {
356 return is_main_frame_load_blocked_;
359 void SafeBrowsingBlockingPage::OnDontProceed() {
360 // We could have already called Proceed(), in which case we must not notify
361 // the SafeBrowsingUIManager again, as the client has been deleted.
362 if (proceeded_)
363 return;
365 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
366 metrics_helper()->RecordUserDecision(
367 SecurityInterstitialMetricsHelper::DONT_PROCEED);
370 // Send the malware details, if we opted to.
371 FinishMalwareDetails(0); // No delay
373 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false);
375 // The user does not want to proceed, clear the queued unsafe resources
376 // notifications we received while the interstitial was showing.
377 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
378 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents());
379 if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
380 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false);
381 unsafe_resource_map->erase(iter);
384 // We don't remove the navigation entry if the tab is being destroyed as this
385 // would trigger a navigation that would cause trouble as the render view host
386 // for the tab has by then already been destroyed. We also don't delete the
387 // current entry if it has been committed again, which is possible on a page
388 // that had a subresource warning.
389 int last_committed_index =
390 web_contents()->GetController().GetLastCommittedEntryIndex();
391 if (navigation_entry_index_to_remove_ != -1 &&
392 navigation_entry_index_to_remove_ != last_committed_index &&
393 !web_contents()->IsBeingDestroyed()) {
394 CHECK(web_contents()->GetController().RemoveEntryAtIndex(
395 navigation_entry_index_to_remove_));
396 navigation_entry_index_to_remove_ = -1;
400 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) {
401 if (malware_details_.get() == NULL)
402 return; // Not all interstitials have malware details (eg phishing).
403 DCHECK_EQ(interstitial_reason_, SB_REASON_MALWARE);
405 const bool enabled =
406 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled) &&
407 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed);
408 if (!enabled)
409 return;
411 metrics_helper()->RecordUserInteraction(
412 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED);
413 // Finish the malware details collection, send it over.
414 BrowserThread::PostDelayedTask(
415 BrowserThread::IO, FROM_HERE,
416 base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()),
417 base::TimeDelta::FromMilliseconds(delay_ms));
420 // static
421 void SafeBrowsingBlockingPage::NotifySafeBrowsingUIManager(
422 SafeBrowsingUIManager* ui_manager,
423 const UnsafeResourceList& unsafe_resources,
424 bool proceed) {
425 BrowserThread::PostTask(
426 BrowserThread::IO, FROM_HERE,
427 base::Bind(&SafeBrowsingUIManager::OnBlockingPageDone,
428 ui_manager, unsafe_resources, proceed));
431 // static
432 SafeBrowsingBlockingPage::UnsafeResourceMap*
433 SafeBrowsingBlockingPage::GetUnsafeResourcesMap() {
434 return g_unsafe_resource_map.Pointer();
437 // static
438 SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage(
439 SafeBrowsingUIManager* ui_manager,
440 WebContents* web_contents,
441 const UnsafeResource& unsafe_resource) {
442 std::vector<UnsafeResource> resources;
443 resources.push_back(unsafe_resource);
444 // Set up the factory if this has not been done already (tests do that
445 // before this method is called).
446 if (!factory_)
447 factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer();
448 return factory_->CreateSafeBrowsingPage(ui_manager, web_contents, resources);
451 // static
452 void SafeBrowsingBlockingPage::ShowBlockingPage(
453 SafeBrowsingUIManager* ui_manager,
454 const UnsafeResource& unsafe_resource) {
455 DVLOG(1) << __FUNCTION__ << " " << unsafe_resource.url.spec();
456 WebContents* web_contents = tab_util::GetWebContentsByID(
457 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id);
459 InterstitialPage* interstitial =
460 InterstitialPage::GetInterstitialPage(web_contents);
461 if (interstitial && !unsafe_resource.is_subresource) {
462 // There is already an interstitial showing and we are about to display a
463 // new one for the main frame. Just hide the current one, it is now
464 // irrelevent
465 interstitial->DontProceed();
466 interstitial = NULL;
469 if (!interstitial) {
470 // There are no interstitial currently showing in that tab, go ahead and
471 // show this interstitial.
472 SafeBrowsingBlockingPage* blocking_page =
473 CreateBlockingPage(ui_manager, web_contents, unsafe_resource);
474 blocking_page->Show();
475 return;
478 // This is an interstitial for a page's resource, let's queue it.
479 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
480 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource);
483 // static
484 bool SafeBrowsingBlockingPage::IsMainPageLoadBlocked(
485 const UnsafeResourceList& unsafe_resources) {
486 // Client-side phishing detection interstitials never block the main frame
487 // load, since they happen after the page is finished loading.
488 if (unsafe_resources[0].threat_type ==
489 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) {
490 return false;
493 // Otherwise, check the threat type.
494 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource;
497 std::string SafeBrowsingBlockingPage::GetMetricPrefix() const {
498 switch (interstitial_reason_) {
499 case SB_REASON_MALWARE:
500 return "malware";
501 case SB_REASON_HARMFUL:
502 return "harmful";
503 case SB_REASON_PHISHING:
504 return "phishing";
506 NOTREACHED();
507 return std::string();
510 std::string SafeBrowsingBlockingPage::GetSamplingEventName() const {
511 switch (interstitial_reason_) {
512 case SB_REASON_MALWARE:
513 return kEventNameMalware;
514 case SB_REASON_HARMFUL:
515 return kEventNameHarmful;
516 case SB_REASON_PHISHING:
517 return kEventNamePhishing;
518 default:
519 return kEventNameOther;
523 void SafeBrowsingBlockingPage::PopulateInterstitialStrings(
524 base::DictionaryValue* load_time_data) {
525 CHECK(load_time_data);
526 CHECK(!unsafe_resources_.empty());
528 load_time_data->SetString("type", "SAFEBROWSING");
529 load_time_data->SetString(
530 "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE));
531 load_time_data->SetString(
532 "openDetails",
533 l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_OPEN_DETAILS_BUTTON));
534 load_time_data->SetString(
535 "closeDetails",
536 l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_CLOSE_DETAILS_BUTTON));
537 load_time_data->SetString(
538 "primaryButtonText",
539 l10n_util::GetStringUTF16(IDS_SAFEBROWSING_OVERRIDABLE_SAFETY_BUTTON));
540 load_time_data->SetBoolean(
541 "overridable",
542 !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
544 switch (interstitial_reason_) {
545 case SB_REASON_MALWARE:
546 PopulateMalwareLoadTimeData(load_time_data);
547 break;
548 case SB_REASON_HARMFUL:
549 PopulateHarmfulLoadTimeData(load_time_data);
550 break;
551 case SB_REASON_PHISHING:
552 PopulatePhishingLoadTimeData(load_time_data);
553 break;
557 void SafeBrowsingBlockingPage::PopulateExtendedReportingOption(
558 base::DictionaryValue* load_time_data) {
559 // Only show checkbox if !(HTTPS || incognito-mode).
560 const bool show = CanShowMalwareDetailsOption();
561 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show);
562 if (!show)
563 return;
565 const std::string privacy_link = base::StringPrintf(
566 interstitials::kPrivacyLinkHtml, CMD_OPEN_REPORTING_PRIVACY,
567 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
568 load_time_data->SetString(
569 interstitials::kOptInLink,
570 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
571 base::UTF8ToUTF16(privacy_link)));
572 load_time_data->SetBoolean(
573 interstitials::kBoxChecked,
574 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled));
577 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData(
578 base::DictionaryValue* load_time_data) {
579 load_time_data->SetBoolean("phishing", false);
580 load_time_data->SetString(
581 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING));
582 load_time_data->SetString(
583 "primaryParagraph",
584 l10n_util::GetStringFUTF16(
585 IDS_MALWARE_V3_PRIMARY_PARAGRAPH,
586 GetFormattedHostName()));
587 load_time_data->SetString(
588 "explanationParagraph",
589 is_main_frame_load_blocked_ ?
590 l10n_util::GetStringFUTF16(
591 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH,
592 GetFormattedHostName()) :
593 l10n_util::GetStringFUTF16(
594 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE,
595 base::UTF8ToUTF16(web_contents()->GetURL().host()),
596 GetFormattedHostName()));
597 load_time_data->SetString(
598 "finalParagraph",
599 l10n_util::GetStringUTF16(IDS_MALWARE_V3_PROCEED_PARAGRAPH));
601 PopulateExtendedReportingOption(load_time_data);
604 void SafeBrowsingBlockingPage::PopulateHarmfulLoadTimeData(
605 base::DictionaryValue* load_time_data) {
606 load_time_data->SetBoolean("phishing", false);
607 load_time_data->SetString(
608 "heading", l10n_util::GetStringUTF16(IDS_HARMFUL_V3_HEADING));
609 load_time_data->SetString(
610 "primaryParagraph",
611 l10n_util::GetStringFUTF16(
612 IDS_HARMFUL_V3_PRIMARY_PARAGRAPH,
613 GetFormattedHostName()));
614 load_time_data->SetString(
615 "explanationParagraph",
616 l10n_util::GetStringFUTF16(
617 IDS_HARMFUL_V3_EXPLANATION_PARAGRAPH,
618 GetFormattedHostName()));
619 load_time_data->SetString(
620 "finalParagraph",
621 l10n_util::GetStringUTF16(IDS_HARMFUL_V3_PROCEED_PARAGRAPH));
623 PopulateExtendedReportingOption(load_time_data);
626 void SafeBrowsingBlockingPage::PopulatePhishingLoadTimeData(
627 base::DictionaryValue* load_time_data) {
628 load_time_data->SetBoolean("phishing", true);
629 load_time_data->SetString(
630 "heading",
631 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING));
632 load_time_data->SetString(
633 "primaryParagraph",
634 l10n_util::GetStringFUTF16(
635 IDS_PHISHING_V3_PRIMARY_PARAGRAPH,
636 GetFormattedHostName()));
637 load_time_data->SetString(
638 "explanationParagraph",
639 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH,
640 GetFormattedHostName()));
641 load_time_data->SetString(
642 "finalParagraph",
643 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH));
645 PopulateExtendedReportingOption(load_time_data);