| 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 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/renderer_preferences_util.h" | 28 #include "chrome/browser/renderer_preferences_util.h" |
| 29 #include "chrome/browser/safe_browsing/threat_details.h" | 29 #include "chrome/browser/safe_browsing/threat_details.h" |
| 30 #include "chrome/browser/safe_browsing/ui_manager.h" | 30 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
| 35 #include "components/google/core/browser/google_util.h" | 35 #include "components/google/core/browser/google_util.h" |
| 36 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
| 37 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 37 #include "components/security_interstitials/core/common_string_util.h" | 38 #include "components/security_interstitials/core/common_string_util.h" |
| 38 #include "components/security_interstitials/core/controller_client.h" | 39 #include "components/security_interstitials/core/controller_client.h" |
| 39 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 40 #include "content/public/browser/interstitial_page.h" | 41 #include "content/public/browser/interstitial_page.h" |
| 41 #include "content/public/browser/navigation_controller.h" | 42 #include "content/public/browser/navigation_controller.h" |
| 42 #include "content/public/browser/navigation_entry.h" | 43 #include "content/public/browser/navigation_entry.h" |
| 43 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
| 44 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| 45 #include "content/public/common/renderer_preferences.h" | 46 #include "content/public/common/renderer_preferences.h" |
| 46 #include "net/base/escape.h" | 47 #include "net/base/escape.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 400 } |
| 400 } | 401 } |
| 401 | 402 |
| 402 void SafeBrowsingBlockingPage::FinishThreatDetails(int64_t delay_ms, | 403 void SafeBrowsingBlockingPage::FinishThreatDetails(int64_t delay_ms, |
| 403 bool did_proceed, | 404 bool did_proceed, |
| 404 int num_visits) { | 405 int num_visits) { |
| 405 if (threat_details_.get() == NULL) | 406 if (threat_details_.get() == NULL) |
| 406 return; // Not all interstitials have threat details (eg., incognito mode). | 407 return; // Not all interstitials have threat details (eg., incognito mode). |
| 407 | 408 |
| 408 const bool enabled = | 409 const bool enabled = |
| 409 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled) && | 410 IsExtendedReportingEnabled(*profile()->GetPrefs()) && |
| 410 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed); | 411 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed); |
| 411 if (!enabled) | 412 if (!enabled) |
| 412 return; | 413 return; |
| 413 | 414 |
| 414 controller()->metrics_helper()->RecordUserInteraction( | 415 controller()->metrics_helper()->RecordUserInteraction( |
| 415 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); | 416 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| 416 // Finish the malware details collection, send it over. | 417 // Finish the malware details collection, send it over. |
| 417 BrowserThread::PostDelayedTask( | 418 BrowserThread::PostDelayedTask( |
| 418 BrowserThread::IO, FROM_HERE, | 419 BrowserThread::IO, FROM_HERE, |
| 419 base::Bind(&ThreatDetails::FinishCollection, threat_details_, | 420 base::Bind(&ThreatDetails::FinishCollection, threat_details_, |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 const std::string privacy_link = base::StringPrintf( | 684 const std::string privacy_link = base::StringPrintf( |
| 684 security_interstitials::kPrivacyLinkHtml, | 685 security_interstitials::kPrivacyLinkHtml, |
| 685 security_interstitials::CMD_OPEN_REPORTING_PRIVACY, | 686 security_interstitials::CMD_OPEN_REPORTING_PRIVACY, |
| 686 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); | 687 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); |
| 687 load_time_data->SetString( | 688 load_time_data->SetString( |
| 688 security_interstitials::kOptInLink, | 689 security_interstitials::kOptInLink, |
| 689 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, | 690 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, |
| 690 base::UTF8ToUTF16(privacy_link))); | 691 base::UTF8ToUTF16(privacy_link))); |
| 691 load_time_data->SetBoolean( | 692 load_time_data->SetBoolean( |
| 692 security_interstitials::kBoxChecked, | 693 security_interstitials::kBoxChecked, |
| 693 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); | 694 IsExtendedReportingEnabled(*profile()->GetPrefs())); |
| 694 } | 695 } |
| 695 | 696 |
| 696 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData( | 697 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData( |
| 697 base::DictionaryValue* load_time_data) { | 698 base::DictionaryValue* load_time_data) { |
| 698 load_time_data->SetBoolean("phishing", false); | 699 load_time_data->SetBoolean("phishing", false); |
| 699 load_time_data->SetString( | 700 load_time_data->SetString( |
| 700 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); | 701 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); |
| 701 load_time_data->SetString( | 702 load_time_data->SetString( |
| 702 "primaryParagraph", | 703 "primaryParagraph", |
| 703 l10n_util::GetStringFUTF16( | 704 l10n_util::GetStringFUTF16( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 l10n_util::GetStringFUTF16(IDS_PHISHING_V4_EXPLANATION_PARAGRAPH, | 757 l10n_util::GetStringFUTF16(IDS_PHISHING_V4_EXPLANATION_PARAGRAPH, |
| 757 GetFormattedHostName())); | 758 GetFormattedHostName())); |
| 758 load_time_data->SetString( | 759 load_time_data->SetString( |
| 759 "finalParagraph", | 760 "finalParagraph", |
| 760 l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH)); | 761 l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH)); |
| 761 | 762 |
| 762 PopulateExtendedReportingOption(load_time_data); | 763 PopulateExtendedReportingOption(load_time_data); |
| 763 } | 764 } |
| 764 | 765 |
| 765 } // namespace safe_browsing | 766 } // namespace safe_browsing |
| OLD | NEW |