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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 const char kNavigatedAwayMetaCommand[] = "closed"; | 108 const char kNavigatedAwayMetaCommand[] = "closed"; |
109 | 109 |
110 // Other constants used to communicate with the JavaScript. | 110 // Other constants used to communicate with the JavaScript. |
111 const char kBoxChecked[] = "boxchecked"; | 111 const char kBoxChecked[] = "boxchecked"; |
112 const char kDisplayCheckBox[] = "displaycheckbox"; | 112 const char kDisplayCheckBox[] = "displaycheckbox"; |
113 | 113 |
114 // Constants for the Experience Sampling instrumentation. | 114 // Constants for the Experience Sampling instrumentation. |
115 #if defined(ENABLE_EXTENSIONS) | 115 #if defined(ENABLE_EXTENSIONS) |
116 const char kEventNameMalware[] = "safebrowsing_interstitial_"; | 116 const char kEventNameMalware[] = "safebrowsing_interstitial_"; |
117 const char kEventNamePhishing[] = "phishing_interstitial_"; | 117 const char kEventNamePhishing[] = "phishing_interstitial_"; |
118 const char kEventNameMalwareAndPhishing[] = | |
119 "malware_and_phishing_interstitial_"; | |
120 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; | 118 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; |
121 #endif | 119 #endif |
122 | 120 |
123 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 121 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
124 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 122 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
125 | 123 |
126 // This enum is used for a histogram. Don't reorder, delete, or insert | 124 // This enum is used for a histogram. Don't reorder, delete, or insert |
127 // elements. New elements should be added before MAX_ACTION only. | 125 // elements. New elements should be added before MAX_ACTION only. |
128 enum DetailedDecision { | 126 enum DetailedDecision { |
129 MALWARE_SHOW_NEW_SITE = 0, | 127 MALWARE_SHOW_NEW_SITE = 0, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (threat_type == SB_THREAT_TYPE_URL_MALWARE || | 198 if (threat_type == SB_THREAT_TYPE_URL_MALWARE || |
201 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) { | 199 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) { |
202 malware = true; | 200 malware = true; |
203 } else { | 201 } else { |
204 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING || | 202 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING || |
205 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | 203 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); |
206 phishing = true; | 204 phishing = true; |
207 } | 205 } |
208 } | 206 } |
209 DCHECK(phishing || malware); | 207 DCHECK(phishing || malware); |
210 if (malware && phishing) | 208 if (malware) |
211 interstitial_type_ = TYPE_MALWARE_AND_PHISHING; | |
212 else if (malware) | |
213 interstitial_type_ = TYPE_MALWARE; | 209 interstitial_type_ = TYPE_MALWARE; |
214 else | 210 else |
215 interstitial_type_ = TYPE_PHISHING; | 211 interstitial_type_ = TYPE_PHISHING; |
216 | 212 |
217 RecordUserAction(SHOW); | 213 RecordUserAction(SHOW); |
218 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 214 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
219 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 215 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
220 Profile::EXPLICIT_ACCESS); | 216 Profile::EXPLICIT_ACCESS); |
221 if (history_service) { | 217 if (history_service) { |
222 history_service->GetVisibleVisitCountToHost( | 218 history_service->GetVisibleVisitCountToHost( |
(...skipping 20 matching lines...) Expand all Loading... |
243 malware_details_.get() == NULL && CanShowMalwareDetailsOption()) { | 239 malware_details_.get() == NULL && CanShowMalwareDetailsOption()) { |
244 malware_details_ = MalwareDetails::NewMalwareDetails( | 240 malware_details_ = MalwareDetails::NewMalwareDetails( |
245 ui_manager_, web_contents, unsafe_resources[0]); | 241 ui_manager_, web_contents, unsafe_resources[0]); |
246 } | 242 } |
247 | 243 |
248 #if defined(ENABLE_EXTENSIONS) | 244 #if defined(ENABLE_EXTENSIONS) |
249 // ExperienceSampling: Set up new sampling event for this interstitial. | 245 // ExperienceSampling: Set up new sampling event for this interstitial. |
250 // This needs to handle all types of warnings this interstitial can show. | 246 // This needs to handle all types of warnings this interstitial can show. |
251 std::string event_name; | 247 std::string event_name; |
252 switch (interstitial_type_) { | 248 switch (interstitial_type_) { |
253 case TYPE_MALWARE_AND_PHISHING: | |
254 event_name = kEventNameMalwareAndPhishing; | |
255 break; | |
256 case TYPE_MALWARE: | 249 case TYPE_MALWARE: |
257 event_name = kEventNameMalware; | 250 event_name = kEventNameMalware; |
258 break; | 251 break; |
259 case TYPE_PHISHING: | 252 case TYPE_PHISHING: |
260 event_name = kEventNamePhishing; | 253 event_name = kEventNamePhishing; |
261 break; | 254 break; |
262 default: | 255 default: |
263 event_name = kEventNameOther; | 256 event_name = kEventNameOther; |
264 break; | 257 break; |
265 } | 258 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 PHISHING_PROCEED, | 568 PHISHING_PROCEED, |
576 MALWARE_SHOW_ADVANCED, | 569 MALWARE_SHOW_ADVANCED, |
577 MULTIPLE_SHOW_ADVANCED, | 570 MULTIPLE_SHOW_ADVANCED, |
578 PHISHING_SHOW_ADVANCED, | 571 PHISHING_SHOW_ADVANCED, |
579 MAX_ACTION | 572 MAX_ACTION |
580 } histogram_action = MAX_ACTION; | 573 } histogram_action = MAX_ACTION; |
581 | 574 |
582 switch (event) { | 575 switch (event) { |
583 case SHOW: | 576 case SHOW: |
584 switch (interstitial_type_) { | 577 switch (interstitial_type_) { |
585 case TYPE_MALWARE_AND_PHISHING: | |
586 histogram_action = MULTIPLE_SHOW; | |
587 break; | |
588 case TYPE_MALWARE: | 578 case TYPE_MALWARE: |
589 histogram_action = MALWARE_SHOW; | 579 histogram_action = MALWARE_SHOW; |
590 break; | 580 break; |
591 case TYPE_PHISHING: | 581 case TYPE_PHISHING: |
592 histogram_action = PHISHING_SHOW; | 582 histogram_action = PHISHING_SHOW; |
593 break; | 583 break; |
594 } | 584 } |
595 break; | 585 break; |
596 case PROCEED: | 586 case PROCEED: |
597 switch (interstitial_type_) { | 587 switch (interstitial_type_) { |
598 case TYPE_MALWARE_AND_PHISHING: | |
599 histogram_action = MULTIPLE_PROCEED; | |
600 break; | |
601 case TYPE_MALWARE: | 588 case TYPE_MALWARE: |
602 histogram_action = MALWARE_PROCEED; | 589 histogram_action = MALWARE_PROCEED; |
603 break; | 590 break; |
604 case TYPE_PHISHING: | 591 case TYPE_PHISHING: |
605 histogram_action = PHISHING_PROCEED; | 592 histogram_action = PHISHING_PROCEED; |
606 break; | 593 break; |
607 } | 594 } |
608 break; | 595 break; |
609 case DONT_PROCEED: | 596 case DONT_PROCEED: |
610 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | 597 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { |
611 switch (interstitial_type_) { | 598 switch (interstitial_type_) { |
612 case TYPE_MALWARE_AND_PHISHING: | |
613 histogram_action = MULTIPLE_FORCED_DONT_PROCEED; | |
614 break; | |
615 case TYPE_MALWARE: | 599 case TYPE_MALWARE: |
616 histogram_action = MALWARE_FORCED_DONT_PROCEED; | 600 histogram_action = MALWARE_FORCED_DONT_PROCEED; |
617 break; | 601 break; |
618 case TYPE_PHISHING: | 602 case TYPE_PHISHING: |
619 histogram_action = PHISHING_FORCED_DONT_PROCEED; | 603 histogram_action = PHISHING_FORCED_DONT_PROCEED; |
620 break; | 604 break; |
621 } | 605 } |
622 } else { | 606 } else { |
623 switch (interstitial_type_) { | 607 switch (interstitial_type_) { |
624 case TYPE_MALWARE_AND_PHISHING: | |
625 histogram_action = MULTIPLE_DONT_PROCEED; | |
626 break; | |
627 case TYPE_MALWARE: | 608 case TYPE_MALWARE: |
628 histogram_action = MALWARE_DONT_PROCEED; | 609 histogram_action = MALWARE_DONT_PROCEED; |
629 break; | 610 break; |
630 case TYPE_PHISHING: | 611 case TYPE_PHISHING: |
631 histogram_action = PHISHING_DONT_PROCEED; | 612 histogram_action = PHISHING_DONT_PROCEED; |
632 break; | 613 break; |
633 } | 614 } |
634 } | 615 } |
635 break; | 616 break; |
636 case SHOW_ADVANCED: | 617 case SHOW_ADVANCED: |
637 switch (interstitial_type_) { | 618 switch (interstitial_type_) { |
638 case TYPE_MALWARE_AND_PHISHING: | |
639 histogram_action = MULTIPLE_SHOW_ADVANCED; | |
640 break; | |
641 case TYPE_MALWARE: | 619 case TYPE_MALWARE: |
642 histogram_action = MALWARE_SHOW_ADVANCED; | 620 histogram_action = MALWARE_SHOW_ADVANCED; |
643 break; | 621 break; |
644 case TYPE_PHISHING: | 622 case TYPE_PHISHING: |
645 histogram_action = PHISHING_SHOW_ADVANCED; | 623 histogram_action = PHISHING_SHOW_ADVANCED; |
646 break; | 624 break; |
647 } | 625 } |
648 break; | 626 break; |
649 default: | 627 default: |
650 NOTREACHED() << "Unexpected event: " << event; | 628 NOTREACHED() << "Unexpected event: " << event; |
651 } | 629 } |
652 if (histogram_action == MAX_ACTION) { | 630 if (histogram_action == MAX_ACTION) { |
653 NOTREACHED(); | 631 NOTREACHED(); |
654 } else { | 632 } else { |
655 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, | 633 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, |
656 MAX_ACTION); | 634 MAX_ACTION); |
657 } | 635 } |
658 | 636 |
659 if (event == PROCEED || event == DONT_PROCEED) { | 637 if (event == PROCEED || event == DONT_PROCEED) { |
660 if (num_visits_ == 0 && interstitial_type_ != TYPE_MALWARE_AND_PHISHING) { | 638 if (num_visits_ == 0) { |
661 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 639 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? |
662 MALWARE_SHOW_NEW_SITE : PHISHING_SHOW_NEW_SITE); | 640 MALWARE_SHOW_NEW_SITE : PHISHING_SHOW_NEW_SITE); |
663 if (event == PROCEED) { | 641 if (event == PROCEED) { |
664 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 642 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? |
665 MALWARE_PROCEED_NEW_SITE : PHISHING_PROCEED_NEW_SITE); | 643 MALWARE_PROCEED_NEW_SITE : PHISHING_PROCEED_NEW_SITE); |
666 } | 644 } |
667 } | 645 } |
668 if (unsafe_resources_[0].is_subresource && | 646 if (unsafe_resources_[0].is_subresource) { |
669 interstitial_type_ != TYPE_MALWARE_AND_PHISHING) { | |
670 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 647 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? |
671 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); | 648 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); |
672 if (event == PROCEED) { | 649 if (event == PROCEED) { |
673 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 650 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? |
674 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); | 651 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); |
675 } | 652 } |
676 } | 653 } |
677 } | 654 } |
678 } | 655 } |
679 | 656 |
680 void SafeBrowsingBlockingPage::RecordUserReactionTime( | 657 void SafeBrowsingBlockingPage::RecordUserReactionTime( |
681 const std::string& command) { | 658 const std::string& command) { |
682 if (interstitial_show_time_.is_null()) | 659 if (interstitial_show_time_.is_null()) |
683 return; // We already reported the user reaction time. | 660 return; // We already reported the user reaction time. |
684 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_; | 661 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_; |
685 DVLOG(1) << "User reaction time for command:" << command | 662 DVLOG(1) << "User reaction time for command:" << command |
686 << " on interstitial_type_:" << interstitial_type_ | 663 << " on interstitial_type_:" << interstitial_type_ |
687 << " warning took " << dt.InMilliseconds() << "ms"; | 664 << " warning took " << dt.InMilliseconds() << "ms"; |
688 bool recorded = true; | 665 bool recorded = true; |
689 if (interstitial_type_ == TYPE_MALWARE || | 666 if (interstitial_type_ == TYPE_MALWARE) { |
690 interstitial_type_ == TYPE_MALWARE_AND_PHISHING) { | |
691 // There are six ways in which the malware interstitial can go | 667 // There are six ways in which the malware interstitial can go |
692 // away. We handle all of them here but we group two together: closing the | 668 // away. We handle all of them here but we group two together: closing the |
693 // tag / browser window and clicking on the back button in the browser (not | 669 // tag / browser window and clicking on the back button in the browser (not |
694 // the big green button) are considered the same action. | 670 // the big green button) are considered the same action. |
695 if (command == kProceedCommand) { | 671 if (command == kProceedCommand) { |
696 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeProceed", dt); | 672 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeProceed", dt); |
697 } else if (command == kTakeMeBackCommand) { | 673 } else if (command == kTakeMeBackCommand) { |
698 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeTakeMeBack", dt); | 674 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeTakeMeBack", dt); |
699 } else if (command == kShowDiagnosticCommand) { | 675 } else if (command == kShowDiagnosticCommand) { |
700 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); | 676 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 916 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
941 base::UTF8ToUTF16(url_.host()))); | 917 base::UTF8ToUTF16(url_.host()))); |
942 load_time_data->SetString( | 918 load_time_data->SetString( |
943 "explanationParagraph", | 919 "explanationParagraph", |
944 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 920 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
945 base::UTF8ToUTF16(url_.host()))); | 921 base::UTF8ToUTF16(url_.host()))); |
946 load_time_data->SetString( | 922 load_time_data->SetString( |
947 "finalParagraph", | 923 "finalParagraph", |
948 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 924 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
949 } | 925 } |
OLD | NEW |