Chromium Code Reviews| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 64 |
| 65 static const char* const kSbReportPhishingErrorUrl = | 65 static const char* const kSbReportPhishingErrorUrl = |
| 66 "http://www.google.com/safebrowsing/report_error/"; | 66 "http://www.google.com/safebrowsing/report_error/"; |
| 67 | 67 |
| 68 // URL for the "Learn more" link on the multi threat malware blocking page. | 68 // URL for the "Learn more" link on the multi threat malware blocking page. |
| 69 static const char* const kLearnMoreMalwareUrl = | 69 static const char* const kLearnMoreMalwareUrl = |
| 70 "https://www.google.com/support/bin/answer.py?answer=45449&topic=360" | 70 "https://www.google.com/support/bin/answer.py?answer=45449&topic=360" |
| 71 "&sa=X&oi=malwarewarninglink&resnum=1&ct=help"; | 71 "&sa=X&oi=malwarewarninglink&resnum=1&ct=help"; |
| 72 static const char* const kLearnMoreMalwareUrlV2 = | 72 static const char* const kLearnMoreMalwareUrlV2 = |
| 73 "https://www.google.com/goodtoknow/online-safety/malware/"; | 73 "https://www.google.com/goodtoknow/online-safety/malware/"; |
| 74 static const char* const kLearnMorePhishingUrlV2 = | |
| 75 "https://www.google.com/goodtoknow/online-safety/phishing/"; | |
| 74 | 76 |
| 75 // URL for the "Learn more" link on the phishing blocking page. | 77 // URL for the "Learn more" link on the phishing blocking page. |
| 76 static const char* const kLearnMorePhishingUrl = | 78 static const char* const kLearnMorePhishingUrl = |
| 77 "https://www.google.com/support/bin/answer.py?answer=106318"; | 79 "https://www.google.com/support/bin/answer.py?answer=106318"; |
| 78 | 80 |
| 79 static const char* const kSbDiagnosticHtml = | 81 static const char* const kSbDiagnosticHtml = |
| 80 "<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" " | 82 "<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" " |
| 81 "onmousedown=\"return false;\">%s</a>"; | 83 "onmousedown=\"return false;\">%s</a>"; |
| 82 | 84 |
| 83 static const char* const kPLinkHtml = | 85 static const char* const kPLinkHtml = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 | 122 |
| 121 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 123 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
| 122 // don't leak it. | 124 // don't leak it. |
| 123 class SafeBrowsingBlockingPageFactoryImpl | 125 class SafeBrowsingBlockingPageFactoryImpl |
| 124 : public SafeBrowsingBlockingPageFactory { | 126 : public SafeBrowsingBlockingPageFactory { |
| 125 public: | 127 public: |
| 126 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 128 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 127 SafeBrowsingService* service, | 129 SafeBrowsingService* service, |
| 128 WebContents* web_contents, | 130 WebContents* web_contents, |
| 129 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { | 131 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { |
| 130 // Only do the trial if the interstitial is for a single malware resource, | 132 // Only do the trial if the interstitial is for a single malware or |
| 131 // the other types of interstitials have not been updated to V2 yet. | 133 // phishing resource, the multi-threat interstitial has not been updated to |
| 134 // V2 yet. | |
| 132 if (unsafe_resources.size() == 1 && | 135 if (unsafe_resources.size() == 1 && |
| 133 unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE) { | 136 (unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE || |
| 137 unsafe_resources[0].threat_type == | |
| 138 SafeBrowsingService::URL_PHISHING)) { | |
| 134 if (base::FieldTrialList::FindFullName("SBInterstitial") == "V2") { | 139 if (base::FieldTrialList::FindFullName("SBInterstitial") == "V2") { |
| 135 DVLOG(1) << "In V2 group."; | 140 DVLOG(1) << "In V2 group."; |
| 136 return new SafeBrowsingBlockingPageV2(service, web_contents, | 141 return new SafeBrowsingBlockingPageV2(service, web_contents, |
| 137 unsafe_resources); | 142 unsafe_resources); |
| 138 } | 143 } |
| 139 DVLOG(1) << "In V1 group."; | 144 DVLOG(1) << "In V1 group."; |
| 140 } | 145 } |
| 141 return new SafeBrowsingBlockingPageV1(service, web_contents, | 146 return new SafeBrowsingBlockingPageV1(service, web_contents, |
| 142 unsafe_resources); | 147 unsafe_resources); |
| 143 } | 148 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 return; | 264 return; |
| 260 } | 265 } |
| 261 | 266 |
| 262 if (command == kLearnMoreCommandV2) { | 267 if (command == kLearnMoreCommandV2) { |
| 263 // User pressed "Learn more". | 268 // User pressed "Learn more". |
| 264 GURL url; | 269 GURL url; |
| 265 SafeBrowsingService::UrlCheckResult threat_type = | 270 SafeBrowsingService::UrlCheckResult threat_type = |
| 266 unsafe_resources_[0].threat_type; | 271 unsafe_resources_[0].threat_type; |
| 267 if (threat_type == SafeBrowsingService::URL_MALWARE) { | 272 if (threat_type == SafeBrowsingService::URL_MALWARE) { |
| 268 url = google_util::AppendGoogleLocaleParam(GURL(kLearnMoreMalwareUrlV2)); | 273 url = google_util::AppendGoogleLocaleParam(GURL(kLearnMoreMalwareUrlV2)); |
| 274 } else if (threat_type == SafeBrowsingService::URL_PHISHING || | |
| 275 threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { | |
| 276 url = google_util::AppendGoogleLocaleParam(GURL(kLearnMorePhishingUrlV2)); | |
| 269 } else { | 277 } else { |
| 270 NOTREACHED(); | 278 NOTREACHED(); |
| 271 } | 279 } |
| 272 | 280 |
| 273 OpenURLParams params( | 281 OpenURLParams params( |
| 274 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 282 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 275 web_contents_->OpenURL(params); | 283 web_contents_->OpenURL(params); |
| 276 return; | 284 return; |
| 277 } | 285 } |
| 278 | 286 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); | 663 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); |
| 656 } else if (command == kTakeMeBackCommand) { | 664 } else if (command == kTakeMeBackCommand) { |
| 657 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); | 665 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); |
| 658 } else if (command == kShowDiagnosticCommand) { | 666 } else if (command == kShowDiagnosticCommand) { |
| 659 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); | 667 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); |
| 660 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 668 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
| 661 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); | 669 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); |
| 662 } else if (command == kNavigatedAwayMetaCommand) { | 670 } else if (command == kNavigatedAwayMetaCommand) { |
| 663 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); | 671 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); |
| 664 } else if (command == kExpandedSeeMore) { | 672 } else if (command == kExpandedSeeMore) { |
| 665 // TODO(mattm): Add histogram for this when we implement V2 of the | 673 // Only record the expanded histogram once per display of the |
| 666 // phishing interstitial. | 674 // interstitial. |
| 667 NOTREACHED(); | 675 if (has_expanded_see_more_section_) |
| 676 return; | |
|
Dan Beam
2012/09/13 04:54:26
nit: \n here IMO
mattm
2012/09/13 20:12:07
Done.
| |
| 677 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", | |
| 678 dt); | |
| 679 has_expanded_see_more_section_ = true; | |
| 680 // Expanding the "See More" section doesn't finish the interstitial, so | |
| 681 // don't mark the reaction time as recorded. | |
| 668 recorded = false; | 682 recorded = false; |
| 669 } else { | 683 } else { |
| 670 recorded = false; | 684 recorded = false; |
| 671 } | 685 } |
| 672 } | 686 } |
| 673 if (recorded) // Making sure we don't double-count reaction times. | 687 if (recorded) // Making sure we don't double-count reaction times. |
| 674 interstitial_show_time_ = base::TimeTicks(); // Resets the show time. | 688 interstitial_show_time_ = base::TimeTicks(); // Resets the show time. |
| 675 } | 689 } |
| 676 | 690 |
| 677 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { | 691 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1020 return std::string(); | 1034 return std::string(); |
| 1021 } | 1035 } |
| 1022 | 1036 |
| 1023 if (unsafe_resources_.size() > 1) { | 1037 if (unsafe_resources_.size() > 1) { |
| 1024 NOTREACHED(); | 1038 NOTREACHED(); |
| 1025 } else { | 1039 } else { |
| 1026 SafeBrowsingService::UrlCheckResult threat_type = | 1040 SafeBrowsingService::UrlCheckResult threat_type = |
| 1027 unsafe_resources_[0].threat_type; | 1041 unsafe_resources_[0].threat_type; |
| 1028 if (threat_type == SafeBrowsingService::URL_MALWARE) { | 1042 if (threat_type == SafeBrowsingService::URL_MALWARE) { |
| 1029 PopulateMalwareStringDictionary(&strings); | 1043 PopulateMalwareStringDictionary(&strings); |
| 1030 html = rb.GetRawDataResource( | |
| 1031 IDR_SAFE_BROWSING_MALWARE_BLOCK_V2, | |
| 1032 ui::SCALE_FACTOR_NONE).as_string(); | |
| 1033 } else { // Phishing. | 1044 } else { // Phishing. |
| 1034 DCHECK(threat_type == SafeBrowsingService::URL_PHISHING || | 1045 DCHECK(threat_type == SafeBrowsingService::URL_PHISHING || |
| 1035 threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL); | 1046 threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL); |
| 1036 NOTREACHED(); | 1047 PopulatePhishingStringDictionary(&strings); |
| 1037 } | 1048 } |
| 1049 html = rb.GetRawDataResource(IDR_SAFE_BROWSING_MALWARE_BLOCK_V2, | |
| 1050 ui::SCALE_FACTOR_NONE).as_string(); | |
| 1038 } | 1051 } |
| 1039 interstitial_show_time_ = base::TimeTicks::Now(); | 1052 interstitial_show_time_ = base::TimeTicks::Now(); |
| 1040 return jstemplate_builder::GetTemplatesHtml(html, &strings, "template-root"); | 1053 return jstemplate_builder::GetTemplatesHtml(html, &strings, "template-root"); |
| 1041 } | 1054 } |
| 1042 | 1055 |
| 1043 void SafeBrowsingBlockingPageV2::PopulateStringDictionary( | 1056 void SafeBrowsingBlockingPageV2::PopulateStringDictionary( |
| 1044 DictionaryValue* strings, | 1057 DictionaryValue* strings, |
| 1045 const string16& title, | 1058 const string16& title, |
| 1046 const string16& headline, | 1059 const string16& headline, |
| 1047 const string16& description1, | 1060 const string16& description1, |
| 1048 const string16& description2, | 1061 const string16& description2, |
| 1049 const string16& description3) { | 1062 const string16& description3) { |
| 1050 strings->SetString("title", title); | 1063 strings->SetString("title", title); |
| 1051 strings->SetString("headLine", headline); | 1064 strings->SetString("headLine", headline); |
| 1052 strings->SetString("description1", description1); | 1065 strings->SetString("description1", description1); |
| 1053 strings->SetString("description2", description2); | 1066 strings->SetString("description2", description2); |
| 1054 strings->SetString("description3", description3); | 1067 strings->SetString("description3", description3); |
| 1055 strings->SetBoolean("proceedDisabled", | 1068 strings->SetBoolean("proceedDisabled", |
| 1056 IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); | 1069 IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); |
| 1057 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); | 1070 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); |
| 1071 strings->SetBoolean("isPhishing", interstitial_type_ == TYPE_PHISHING); | |
| 1058 | 1072 |
| 1059 strings->SetString("back_button", | 1073 strings->SetString("back_button", |
| 1060 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); | 1074 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); |
| 1061 strings->SetString("seeMore", l10n_util::GetStringUTF16( | 1075 strings->SetString("seeMore", l10n_util::GetStringUTF16( |
| 1062 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | 1076 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); |
| 1077 strings->SetString("proceed", | |
| 1078 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | |
| 1063 | 1079 |
| 1064 ChromeURLDataManager::DataSource::SetFontAndTextDirection(strings); | 1080 ChromeURLDataManager::DataSource::SetFontAndTextDirection(strings); |
| 1065 } | 1081 } |
| 1066 | 1082 |
| 1067 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( | 1083 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( |
| 1068 DictionaryValue* strings) { | 1084 DictionaryValue* strings) { |
| 1069 NOTREACHED(); | 1085 NOTREACHED(); |
| 1070 } | 1086 } |
| 1071 | 1087 |
| 1072 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( | 1088 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1131 strings->SetString("confirm_text", | 1147 strings->SetString("confirm_text", |
| 1132 l10n_util::GetStringFUTF16( | 1148 l10n_util::GetStringFUTF16( |
| 1133 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, | 1149 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, |
| 1134 UTF8ToUTF16(privacy_link))); | 1150 UTF8ToUTF16(privacy_link))); |
| 1135 if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled)) | 1151 if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled)) |
| 1136 strings->SetString(kBoxChecked, "yes"); | 1152 strings->SetString(kBoxChecked, "yes"); |
| 1137 else | 1153 else |
| 1138 strings->SetString(kBoxChecked, ""); | 1154 strings->SetString(kBoxChecked, ""); |
| 1139 } | 1155 } |
| 1140 | 1156 |
| 1141 strings->SetString("proceed", | 1157 strings->SetString("report_error", string16()); |
| 1142 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | |
| 1143 strings->SetString("learnMore", | 1158 strings->SetString("learnMore", |
| 1144 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | 1159 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); |
| 1145 } | 1160 } |
| 1146 | 1161 |
| 1147 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary( | 1162 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary( |
| 1148 DictionaryValue* strings) { | 1163 DictionaryValue* strings) { |
| 1149 NOTREACHED(); | 1164 PopulateStringDictionary( |
| 1165 strings, | |
| 1166 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE), | |
| 1167 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE), | |
| 1168 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1, | |
| 1169 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 1170 UTF8ToUTF16(url_.host())), | |
| 1171 string16(), | |
| 1172 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION2)); | |
| 1173 | |
| 1174 strings->SetString("details", ""); | |
|
Dan Beam
2012/09/13 04:54:26
what are these empty strings about?
mattm
2012/09/13 20:12:07
Since we use the same html for both malware and ph
Dan Beam
2012/09/14 21:27:10
ahhh, I understand
| |
| 1175 strings->SetString("confirm_text", ""); | |
| 1176 strings->SetString(kBoxChecked, ""); | |
| 1177 strings->SetString("report_error", | |
| 1178 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | |
| 1179 strings->SetBoolean(kDisplayCheckBox, false); | |
| 1180 strings->SetString("learnMore", | |
| 1181 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | |
| 1150 } | 1182 } |
| OLD | NEW |