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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set callback to DoNothing close to where it's used Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Implementation of the SafeBrowsingBlockingPage class. 5 // Implementation of the SafeBrowsingBlockingPage class.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const char kSbDiagnosticUrl[] = 61 const char kSbDiagnosticUrl[] =
62 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie nt=chromium"; 62 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie nt=chromium";
63 #endif 63 #endif
64 64
65 // URL for malware and phishing, V2. 65 // URL for malware and phishing, V2.
66 const char kLearnMoreMalwareUrlV2[] = 66 const char kLearnMoreMalwareUrlV2[] =
67 "https://www.google.com/transparencyreport/safebrowsing/"; 67 "https://www.google.com/transparencyreport/safebrowsing/";
68 const char kLearnMorePhishingUrlV2[] = 68 const char kLearnMorePhishingUrlV2[] =
69 "https://www.google.com/transparencyreport/safebrowsing/"; 69 "https://www.google.com/transparencyreport/safebrowsing/";
70 70
71 const char kPrivacyLinkHtml[] =
72 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); "
73 "return false;\" onmousedown=\"return false;\">%s</a>";
74
75 // After a malware interstitial where the user opted-in to the report 71 // After a malware interstitial where the user opted-in to the report
76 // but clicked "proceed anyway", we delay the call to 72 // but clicked "proceed anyway", we delay the call to
77 // MalwareDetails::FinishCollection() by this much time (in 73 // MalwareDetails::FinishCollection() by this much time (in
78 // milliseconds). 74 // milliseconds).
79 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; 75 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000;
80 76
81 // The commands returned by the page when the user performs an action. 77 // The commands returned by the page when the user performs an action.
82 const char kDoReportCommand[] = "doReport"; 78 const char kDoReportCommand[] = "doReport";
83 const char kDontReportCommand[] = "dontReport"; 79 const char kDontReportCommand[] = "dontReport";
84 const char kExpandedSeeMoreCommand[] = "expandedSeeMore"; 80 const char kExpandedSeeMoreCommand[] = "expandedSeeMore";
85 const char kLearnMoreCommand[] = "learnMore2"; 81 const char kLearnMoreCommand[] = "learnMore2";
86 const char kProceedCommand[] = "proceed"; 82 const char kProceedCommand[] = "proceed";
87 const char kShowDiagnosticCommand[] = "showDiagnostic"; 83 const char kShowDiagnosticCommand[] = "showDiagnostic";
88 const char kShowPrivacyCommand[] = "showPrivacy"; 84 const char kShowPrivacyCommand[] = "showPrivacy";
89 const char kTakeMeBackCommand[] = "takeMeBack"; 85 const char kTakeMeBackCommand[] = "takeMeBack";
90 86
91 // Other constants used to communicate with the JavaScript.
92 const char kBoxChecked[] = "boxchecked";
93 const char kDisplayCheckBox[] = "displaycheckbox";
94
95 // Constants for the Experience Sampling instrumentation. 87 // Constants for the Experience Sampling instrumentation.
96 const char kEventNameMalware[] = "safebrowsing_interstitial_"; 88 const char kEventNameMalware[] = "safebrowsing_interstitial_";
97 const char kEventNameHarmful[] = "harmful_interstitial_"; 89 const char kEventNameHarmful[] = "harmful_interstitial_";
98 const char kEventNamePhishing[] = "phishing_interstitial_"; 90 const char kEventNamePhishing[] = "phishing_interstitial_";
99 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; 91 const char kEventNameOther[] = "safebrowsing_other_interstitial_";
100 92
101 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> 93 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap>
102 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; 94 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER;
103 95
104 } // namespace 96 } // namespace
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 360 }
369 361
370 void SafeBrowsingBlockingPage::OverrideRendererPrefs( 362 void SafeBrowsingBlockingPage::OverrideRendererPrefs(
371 content::RendererPreferences* prefs) { 363 content::RendererPreferences* prefs) {
372 Profile* profile = Profile::FromBrowserContext( 364 Profile* profile = Profile::FromBrowserContext(
373 web_contents()->GetBrowserContext()); 365 web_contents()->GetBrowserContext());
374 renderer_preferences_util::UpdateFromSystemSettings( 366 renderer_preferences_util::UpdateFromSystemSettings(
375 prefs, profile, web_contents()); 367 prefs, profile, web_contents());
376 } 368 }
377 369
378 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) {
379 Profile* profile = Profile::FromBrowserContext(
380 web_contents()->GetBrowserContext());
381 PrefService* pref = profile->GetPrefs();
382 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report);
383 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report);
384 }
385
386 void SafeBrowsingBlockingPage::OnProceed() { 370 void SafeBrowsingBlockingPage::OnProceed() {
387 proceeded_ = true; 371 proceeded_ = true;
388 // Send the malware details, if we opted to. 372 // Send the malware details, if we opted to.
389 FinishMalwareDetails(malware_details_proceed_delay_ms_); 373 FinishMalwareDetails(malware_details_proceed_delay_ms_);
390 374
391 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); 375 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true);
392 376
393 // Check to see if some new notifications of unsafe resources have been 377 // Check to see if some new notifications of unsafe resources have been
394 // received while we were showing the interstitial. 378 // received while we were showing the interstitial.
395 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 379 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); 454 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled);
471 if (enabled) { 455 if (enabled) {
472 // Finish the malware details collection, send it over. 456 // Finish the malware details collection, send it over.
473 BrowserThread::PostDelayedTask( 457 BrowserThread::PostDelayedTask(
474 BrowserThread::IO, FROM_HERE, 458 BrowserThread::IO, FROM_HERE,
475 base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()), 459 base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()),
476 base::TimeDelta::FromMilliseconds(delay_ms)); 460 base::TimeDelta::FromMilliseconds(delay_ms));
477 } 461 }
478 } 462 }
479 463
480 bool SafeBrowsingBlockingPage::IsPrefEnabled(const char* pref) {
481 Profile* profile =
482 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
483 return profile->GetPrefs()->GetBoolean(pref);
484 }
485
486 // static 464 // static
487 void SafeBrowsingBlockingPage::NotifySafeBrowsingUIManager( 465 void SafeBrowsingBlockingPage::NotifySafeBrowsingUIManager(
488 SafeBrowsingUIManager* ui_manager, 466 SafeBrowsingUIManager* ui_manager,
489 const UnsafeResourceList& unsafe_resources, 467 const UnsafeResourceList& unsafe_resources,
490 bool proceed) { 468 bool proceed) {
491 BrowserThread::PostTask( 469 BrowserThread::PostTask(
492 BrowserThread::IO, FROM_HERE, 470 BrowserThread::IO, FROM_HERE,
493 base::Bind(&SafeBrowsingUIManager::OnBlockingPageDone, 471 base::Bind(&SafeBrowsingUIManager::OnBlockingPageDone,
494 ui_manager, unsafe_resources, proceed)); 472 ui_manager, unsafe_resources, proceed));
495 } 473 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 case SB_REASON_PHISHING: 595 case SB_REASON_PHISHING:
618 PopulatePhishingLoadTimeData(load_time_data); 596 PopulatePhishingLoadTimeData(load_time_data);
619 break; 597 break;
620 } 598 }
621 } 599 }
622 600
623 void SafeBrowsingBlockingPage::PopulateExtendedReportingOption( 601 void SafeBrowsingBlockingPage::PopulateExtendedReportingOption(
624 base::DictionaryValue* load_time_data) { 602 base::DictionaryValue* load_time_data) {
625 // Only show checkbox if !(HTTPS || incognito-mode). 603 // Only show checkbox if !(HTTPS || incognito-mode).
626 const bool show = CanShowMalwareDetailsOption(); 604 const bool show = CanShowMalwareDetailsOption();
627 load_time_data->SetBoolean(kDisplayCheckBox, show); 605 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show);
628 if (!show) 606 if (!show)
629 return; 607 return;
630 608
631 const std::string privacy_link = base::StringPrintf( 609 const std::string privacy_link = base::StringPrintf(
632 kPrivacyLinkHtml, 610 interstitials::kPrivacyLinkHtml,
633 l10n_util::GetStringUTF8( 611 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
634 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
635 load_time_data->SetString( 612 load_time_data->SetString(
636 "optInLink", 613 interstitials::kOptInLink,
637 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, 614 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
638 base::UTF8ToUTF16(privacy_link))); 615 base::UTF8ToUTF16(privacy_link)));
639 load_time_data->SetBoolean( 616 load_time_data->SetBoolean(
640 kBoxChecked, 617 interstitials::kBoxChecked,
641 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); 618 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled));
642 } 619 }
643 620
644 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData( 621 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData(
645 base::DictionaryValue* load_time_data) { 622 base::DictionaryValue* load_time_data) {
646 load_time_data->SetBoolean("phishing", false); 623 load_time_data->SetBoolean("phishing", false);
647 load_time_data->SetString( 624 load_time_data->SetString(
648 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); 625 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING));
649 load_time_data->SetString( 626 load_time_data->SetString(
650 "primaryParagraph", 627 "primaryParagraph",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 load_time_data->SetString( 681 load_time_data->SetString(
705 "explanationParagraph", 682 "explanationParagraph",
706 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, 683 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH,
707 GetFormattedHostName())); 684 GetFormattedHostName()));
708 load_time_data->SetString( 685 load_time_data->SetString(
709 "finalParagraph", 686 "finalParagraph",
710 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); 687 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH));
711 688
712 PopulateExtendedReportingOption(load_time_data); 689 PopulateExtendedReportingOption(load_time_data);
713 } 690 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698