OLD | NEW |
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 Loading... |
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 28 matching lines...) Expand all Loading... |
133 g_safe_browsing_blocking_page_factory_impl = LAZY_INSTANCE_INITIALIZER; | 125 g_safe_browsing_blocking_page_factory_impl = LAZY_INSTANCE_INITIALIZER; |
134 | 126 |
135 // static | 127 // static |
136 const void* SafeBrowsingBlockingPage::kTypeForTesting = | 128 const void* SafeBrowsingBlockingPage::kTypeForTesting = |
137 &SafeBrowsingBlockingPage::kTypeForTesting; | 129 &SafeBrowsingBlockingPage::kTypeForTesting; |
138 | 130 |
139 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( | 131 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( |
140 SafeBrowsingUIManager* ui_manager, | 132 SafeBrowsingUIManager* ui_manager, |
141 WebContents* web_contents, | 133 WebContents* web_contents, |
142 const UnsafeResourceList& unsafe_resources) | 134 const UnsafeResourceList& unsafe_resources) |
143 : SecurityInterstitialPage(web_contents, unsafe_resources[0].url), | 135 : SecurityInterstitialPageWithExtendedReporting(web_contents, |
| 136 unsafe_resources[0].url), |
144 malware_details_proceed_delay_ms_( | 137 malware_details_proceed_delay_ms_( |
145 kMalwareDetailsProceedDelayMilliSeconds), | 138 kMalwareDetailsProceedDelayMilliSeconds), |
146 ui_manager_(ui_manager), | 139 ui_manager_(ui_manager), |
147 report_loop_(NULL), | 140 report_loop_(NULL), |
148 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)), | 141 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)), |
149 unsafe_resources_(unsafe_resources), | 142 unsafe_resources_(unsafe_resources), |
150 proceeded_(false) { | 143 proceeded_(false) { |
151 bool malware = false; | 144 bool malware = false; |
152 bool harmful = false; | 145 bool harmful = false; |
153 bool phishing = false; | 146 bool phishing = false; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 360 } |
368 | 361 |
369 void SafeBrowsingBlockingPage::OverrideRendererPrefs( | 362 void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
370 content::RendererPreferences* prefs) { | 363 content::RendererPreferences* prefs) { |
371 Profile* profile = Profile::FromBrowserContext( | 364 Profile* profile = Profile::FromBrowserContext( |
372 web_contents()->GetBrowserContext()); | 365 web_contents()->GetBrowserContext()); |
373 renderer_preferences_util::UpdateFromSystemSettings( | 366 renderer_preferences_util::UpdateFromSystemSettings( |
374 prefs, profile, web_contents()); | 367 prefs, profile, web_contents()); |
375 } | 368 } |
376 | 369 |
377 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { | |
378 Profile* profile = Profile::FromBrowserContext( | |
379 web_contents()->GetBrowserContext()); | |
380 PrefService* pref = profile->GetPrefs(); | |
381 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); | |
382 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); | |
383 } | |
384 | |
385 void SafeBrowsingBlockingPage::OnProceed() { | 370 void SafeBrowsingBlockingPage::OnProceed() { |
386 proceeded_ = true; | 371 proceeded_ = true; |
387 // Send the malware details, if we opted to. | 372 // Send the malware details, if we opted to. |
388 FinishMalwareDetails(malware_details_proceed_delay_ms_); | 373 FinishMalwareDetails(malware_details_proceed_delay_ms_); |
389 | 374 |
390 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); | 375 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); |
391 | 376 |
392 // 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 |
393 // received while we were showing the interstitial. | 378 // received while we were showing the interstitial. |
394 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 379 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); | 453 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); |
469 if (enabled) { | 454 if (enabled) { |
470 // Finish the malware details collection, send it over. | 455 // Finish the malware details collection, send it over. |
471 BrowserThread::PostDelayedTask( | 456 BrowserThread::PostDelayedTask( |
472 BrowserThread::IO, FROM_HERE, | 457 BrowserThread::IO, FROM_HERE, |
473 base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()), | 458 base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()), |
474 base::TimeDelta::FromMilliseconds(delay_ms)); | 459 base::TimeDelta::FromMilliseconds(delay_ms)); |
475 } | 460 } |
476 } | 461 } |
477 | 462 |
478 bool SafeBrowsingBlockingPage::IsPrefEnabled(const char* pref) { | |
479 Profile* profile = | |
480 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | |
481 return profile->GetPrefs()->GetBoolean(pref); | |
482 } | |
483 | |
484 // static | 463 // static |
485 void SafeBrowsingBlockingPage::NotifySafeBrowsingUIManager( | 464 void SafeBrowsingBlockingPage::NotifySafeBrowsingUIManager( |
486 SafeBrowsingUIManager* ui_manager, | 465 SafeBrowsingUIManager* ui_manager, |
487 const UnsafeResourceList& unsafe_resources, | 466 const UnsafeResourceList& unsafe_resources, |
488 bool proceed) { | 467 bool proceed) { |
489 BrowserThread::PostTask( | 468 BrowserThread::PostTask( |
490 BrowserThread::IO, FROM_HERE, | 469 BrowserThread::IO, FROM_HERE, |
491 base::Bind(&SafeBrowsingUIManager::OnBlockingPageDone, | 470 base::Bind(&SafeBrowsingUIManager::OnBlockingPageDone, |
492 ui_manager, unsafe_resources, proceed)); | 471 ui_manager, unsafe_resources, proceed)); |
493 } | 472 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 load_time_data->SetString( | 681 load_time_data->SetString( |
703 "explanationParagraph", | 682 "explanationParagraph", |
704 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 683 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
705 GetFormattedHostName())); | 684 GetFormattedHostName())); |
706 load_time_data->SetString( | 685 load_time_data->SetString( |
707 "finalParagraph", | 686 "finalParagraph", |
708 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 687 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
709 | 688 |
710 PopulateExtendedReportingOption(load_time_data); | 689 PopulateExtendedReportingOption(load_time_data); |
711 } | 690 } |
OLD | NEW |