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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 // page. E.g., closed the tab or the window. This is only used by | 112 // page. E.g., closed the tab or the window. This is only used by |
| 113 // RecordUserReactionTime. | 113 // RecordUserReactionTime. |
| 114 static const char* const kNavigatedAwayMetaCommand = "closed"; | 114 static const char* const kNavigatedAwayMetaCommand = "closed"; |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 117 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
| 118 | 118 |
| 119 static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 119 static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
| 120 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 120 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
| 121 | 121 |
| 122 namespace { | |
| 123 | |
| 124 // These are the conditions for the summer 2013 Finch experiment. | |
| 125 const char kMalwareStudyName[] = "InterstitialMalware310"; | |
| 126 const char kPhishingStudyName[] = "InterstitialPhishing564"; | |
| 127 const char kCond1MalwareControl[] = "cond1MalwareControl"; | |
| 128 const char kCond2MalwareNoBrand[] = "cond2MalwareNoBrand"; | |
| 129 const char kCond3PhishingControl[] = "cond3PhishingControl"; | |
| 130 const char kCond4PhishingNoBrand[] = "cond4PhishingNoBrand"; | |
| 131 const char kCond5MalwareOneStep[] = "cond5MalwareOneStep"; | |
| 132 const char kCond6PhishingOneStep[] = "cond6PhishingOneStep"; | |
| 133 const char kCond7MalwareFearMsg[] = "cond7MalwareFearMsg"; | |
| 134 const char kCond8PhishingFearMsg[] = "cond8PhishingFearMsg"; | |
| 135 const char kCond9MalwareCollabMsg[] = "cond9MalwareCollabMsg"; | |
| 136 const char kCond10PhishingCollabMsg[] = "cond10PhishingCollabMsg"; | |
| 137 const char kCond11MalwareQuestion[] = "cond11MalwareQuestion"; | |
| 138 const char kCond12PhishingQuestion[] = "cond12PhishingQuestion"; | |
| 139 const char kCond13MalwareGoBack[] = "cond13MalwareGoBack"; | |
| 140 const char kCond14PhishingGoBack[] = "cond14PhishingGoBack"; | |
| 141 | |
| 142 } // namespace | |
| 143 | |
| 144 | |
| 122 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 145 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
| 123 // don't leak it. | 146 // don't leak it. |
| 124 class SafeBrowsingBlockingPageFactoryImpl | 147 class SafeBrowsingBlockingPageFactoryImpl |
| 125 : public SafeBrowsingBlockingPageFactory { | 148 : public SafeBrowsingBlockingPageFactory { |
| 126 public: | 149 public: |
| 127 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 150 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 128 SafeBrowsingUIManager* ui_manager, | 151 SafeBrowsingUIManager* ui_manager, |
| 129 WebContents* web_contents, | 152 WebContents* web_contents, |
| 130 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 153 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 131 OVERRIDE { | 154 OVERRIDE { |
| 132 // Only do the trial if the interstitial is for a single malware or | 155 // Only use the V2 page if the interstitial is for a single malware or |
| 133 // phishing resource, the multi-threat interstitial has not been updated to | 156 // phishing resource, the multi-threat interstitial has not been updated to |
| 134 // V2 yet. | 157 // V2 yet. |
| 135 if (unsafe_resources.size() == 1 && | 158 if (unsafe_resources.size() == 1 && |
| 136 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || | 159 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || |
| 137 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { | 160 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { |
| 138 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | 161 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, |
| 139 unsafe_resources); | 162 unsafe_resources); |
| 140 } | 163 } |
| 141 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, | 164 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, |
| 142 unsafe_resources); | 165 unsafe_resources); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 DCHECK(unsafe_resources_[element_index].threat_type == | 394 DCHECK(unsafe_resources_[element_index].threat_type == |
| 372 SB_THREAT_TYPE_URL_MALWARE); | 395 SB_THREAT_TYPE_URL_MALWARE); |
| 373 OpenURLParams params( | 396 OpenURLParams params( |
| 374 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, | 397 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, |
| 375 false); | 398 false); |
| 376 web_contents_->OpenURL(params); | 399 web_contents_->OpenURL(params); |
| 377 return; | 400 return; |
| 378 } | 401 } |
| 379 | 402 |
| 380 if (command == kExpandedSeeMore) { | 403 if (command == kExpandedSeeMore) { |
| 404 if (!has_expanded_see_more_section_) // Toggled in RecordUserReactionTime. | |
| 405 RecordUserAction(SHOW_ADVANCED); | |
|
mattm
2013/05/03 23:25:45
Is this ever triggered? RecordUserReactionTime is
felt
2013/05/03 23:44:49
You're right. I moved the call.
On 2013/05/03 23:
| |
| 381 // User expanded the "see more info" section of the page. We don't actually | 406 // User expanded the "see more info" section of the page. We don't actually |
| 382 // do any action based on this, it's just so that RecordUserReactionTime can | 407 // do any action based on this, it's just so that RecordUserReactionTime can |
| 383 // track it. | 408 // track it. |
| 384 return; | 409 return; |
| 385 } | 410 } |
| 386 | 411 |
| 387 NOTREACHED() << "Unexpected command: " << command; | 412 NOTREACHED() << "Unexpected command: " << command; |
| 388 } | 413 } |
| 389 | 414 |
| 390 void SafeBrowsingBlockingPage::OverrideRendererPrefs( | 415 void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 MALWARE_FORCED_DONT_PROCEED, | 501 MALWARE_FORCED_DONT_PROCEED, |
| 477 MALWARE_PROCEED, | 502 MALWARE_PROCEED, |
| 478 MULTIPLE_SHOW, | 503 MULTIPLE_SHOW, |
| 479 MULTIPLE_DONT_PROCEED, | 504 MULTIPLE_DONT_PROCEED, |
| 480 MULTIPLE_FORCED_DONT_PROCEED, | 505 MULTIPLE_FORCED_DONT_PROCEED, |
| 481 MULTIPLE_PROCEED, | 506 MULTIPLE_PROCEED, |
| 482 PHISHING_SHOW, | 507 PHISHING_SHOW, |
| 483 PHISHING_DONT_PROCEED, | 508 PHISHING_DONT_PROCEED, |
| 484 PHISHING_FORCED_DONT_PROCEED, | 509 PHISHING_FORCED_DONT_PROCEED, |
| 485 PHISHING_PROCEED, | 510 PHISHING_PROCEED, |
| 511 MALWARE_SHOW_ADVANCED, | |
| 512 MULTIPLE_SHOW_ADVANCED, | |
| 513 PHISHING_SHOW_ADVANCED, | |
| 486 MAX_ACTION | 514 MAX_ACTION |
| 487 } histogram_action = MAX_ACTION; | 515 } histogram_action = MAX_ACTION; |
| 488 | 516 |
| 489 switch (event) { | 517 switch (event) { |
| 490 case SHOW: | 518 case SHOW: |
| 491 switch (interstitial_type_) { | 519 switch (interstitial_type_) { |
| 492 case TYPE_MALWARE_AND_PHISHING: | 520 case TYPE_MALWARE_AND_PHISHING: |
| 493 histogram_action = MULTIPLE_SHOW; | 521 histogram_action = MULTIPLE_SHOW; |
| 494 break; | 522 break; |
| 495 case TYPE_MALWARE: | 523 case TYPE_MALWARE: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 break; | 561 break; |
| 534 case TYPE_MALWARE: | 562 case TYPE_MALWARE: |
| 535 histogram_action = MALWARE_DONT_PROCEED; | 563 histogram_action = MALWARE_DONT_PROCEED; |
| 536 break; | 564 break; |
| 537 case TYPE_PHISHING: | 565 case TYPE_PHISHING: |
| 538 histogram_action = PHISHING_DONT_PROCEED; | 566 histogram_action = PHISHING_DONT_PROCEED; |
| 539 break; | 567 break; |
| 540 } | 568 } |
| 541 } | 569 } |
| 542 break; | 570 break; |
| 571 case SHOW_ADVANCED: | |
| 572 switch (interstitial_type_) { | |
| 573 case TYPE_MALWARE_AND_PHISHING: | |
| 574 histogram_action = MULTIPLE_SHOW_ADVANCED; | |
| 575 break; | |
| 576 case TYPE_MALWARE: | |
| 577 histogram_action = MALWARE_SHOW_ADVANCED; | |
| 578 break; | |
| 579 case TYPE_PHISHING: | |
| 580 histogram_action = PHISHING_SHOW_ADVANCED; | |
| 581 break; | |
| 582 } | |
| 583 break; | |
| 543 default: | 584 default: |
| 544 NOTREACHED() << "Unexpected event: " << event; | 585 NOTREACHED() << "Unexpected event: " << event; |
| 545 } | 586 } |
| 546 if (histogram_action == MAX_ACTION) { | 587 if (histogram_action == MAX_ACTION) { |
| 547 NOTREACHED(); | 588 NOTREACHED(); |
| 548 } else { | 589 } else { |
| 549 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, | 590 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, |
| 550 MAX_ACTION); | 591 MAX_ACTION); |
| 551 } | 592 } |
| 552 | 593 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 void SafeBrowsingBlockingPageV1::PopulatePhishingStringDictionary( | 925 void SafeBrowsingBlockingPageV1::PopulatePhishingStringDictionary( |
| 885 DictionaryValue* strings) { | 926 DictionaryValue* strings) { |
| 886 NOTREACHED(); | 927 NOTREACHED(); |
| 887 } | 928 } |
| 888 | 929 |
| 889 SafeBrowsingBlockingPageV2::SafeBrowsingBlockingPageV2( | 930 SafeBrowsingBlockingPageV2::SafeBrowsingBlockingPageV2( |
| 890 SafeBrowsingUIManager* ui_manager, | 931 SafeBrowsingUIManager* ui_manager, |
| 891 WebContents* web_contents, | 932 WebContents* web_contents, |
| 892 const UnsafeResourceList& unsafe_resources) | 933 const UnsafeResourceList& unsafe_resources) |
| 893 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { | 934 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { |
| 935 if (unsafe_resources_[0].threat_type == SB_THREAT_TYPE_URL_MALWARE) { | |
| 936 trialCondition_ = | |
| 937 base::FieldTrialList::FindFullName(kMalwareStudyName); | |
| 938 } else if (unsafe_resources_[0].threat_type == | |
| 939 SB_THREAT_TYPE_URL_PHISHING || | |
| 940 unsafe_resources_[0].threat_type == | |
| 941 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) { | |
| 942 trialCondition_ = | |
| 943 base::FieldTrialList::FindFullName(kPhishingStudyName); | |
| 944 } | |
| 894 } | 945 } |
| 895 | 946 |
| 896 std::string SafeBrowsingBlockingPageV2::GetHTMLContents() { | 947 std::string SafeBrowsingBlockingPageV2::GetHTMLContents() { |
| 897 // Load the HTML page and create the template components. | 948 // Load the HTML page and create the template components. |
| 898 DictionaryValue strings; | 949 DictionaryValue strings; |
| 899 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 950 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 900 std::string html; | 951 std::string html; |
| 901 | 952 |
| 902 if (unsafe_resources_.empty()) { | 953 if (unsafe_resources_.empty()) { |
| 903 NOTREACHED(); | 954 NOTREACHED(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); | 992 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); |
| 942 strings->SetBoolean("isPhishing", interstitial_type_ == TYPE_PHISHING); | 993 strings->SetBoolean("isPhishing", interstitial_type_ == TYPE_PHISHING); |
| 943 | 994 |
| 944 strings->SetString("back_button", | 995 strings->SetString("back_button", |
| 945 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); | 996 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); |
| 946 strings->SetString("seeMore", l10n_util::GetStringUTF16( | 997 strings->SetString("seeMore", l10n_util::GetStringUTF16( |
| 947 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | 998 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); |
| 948 strings->SetString("proceed", | 999 strings->SetString("proceed", |
| 949 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | 1000 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); |
| 950 | 1001 |
| 1002 // Field trial | |
| 1003 strings->SetString("trialType", trialCondition_); | |
| 1004 if (trialCondition_ == kCond7MalwareFearMsg) { | |
| 1005 strings->SetString("headLine", | |
| 1006 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_FEAR_HEADLINE)); | |
| 1007 } else if (trialCondition_ == kCond8PhishingFearMsg) { | |
| 1008 strings->SetString("headLine", | |
| 1009 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_FEAR_HEADLINE)); | |
| 1010 } else if (trialCondition_ == kCond9MalwareCollabMsg) { | |
| 1011 strings->SetString("headLine", | |
| 1012 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_COLLAB_HEADLINE)); | |
| 1013 } else if (trialCondition_ == kCond10PhishingCollabMsg) { | |
| 1014 strings->SetString("headLine", | |
| 1015 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_COLLAB_HEADLINE)); | |
| 1016 } else if (trialCondition_ == kCond11MalwareQuestion) { | |
| 1017 strings->SetString("headLine", | |
| 1018 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_QUESTION_HEADLINE)); | |
| 1019 } else if (trialCondition_ == kCond12PhishingQuestion) { | |
| 1020 strings->SetString("headLine", | |
| 1021 l10n_util::GetStringUTF16( | |
| 1022 IDS_SAFE_BROWSING_PHISHING_QUESTION_HEADLINE)); | |
| 1023 } else if (trialCondition_ == kCond13MalwareGoBack) { | |
| 1024 strings->SetString("headLine", | |
| 1025 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_HEADLINE)); | |
| 1026 } else if (trialCondition_ == kCond14PhishingGoBack) { | |
| 1027 strings->SetString("headLine", | |
| 1028 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_BACK_HEADLINE)); | |
| 1029 } | |
| 1030 | |
| 951 webui::SetFontAndTextDirection(strings); | 1031 webui::SetFontAndTextDirection(strings); |
| 952 } | 1032 } |
| 953 | 1033 |
| 954 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( | 1034 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( |
| 955 DictionaryValue* strings) { | 1035 DictionaryValue* strings) { |
| 956 NOTREACHED(); | 1036 NOTREACHED(); |
| 957 } | 1037 } |
| 958 | 1038 |
| 959 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( | 1039 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( |
| 960 DictionaryValue* strings) { | 1040 DictionaryValue* strings) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 strings->SetString("details", std::string()); | 1125 strings->SetString("details", std::string()); |
| 1046 strings->SetString("confirm_text", std::string()); | 1126 strings->SetString("confirm_text", std::string()); |
| 1047 strings->SetString(kBoxChecked, std::string()); | 1127 strings->SetString(kBoxChecked, std::string()); |
| 1048 strings->SetString( | 1128 strings->SetString( |
| 1049 "report_error", | 1129 "report_error", |
| 1050 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | 1130 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); |
| 1051 strings->SetBoolean(kDisplayCheckBox, false); | 1131 strings->SetBoolean(kDisplayCheckBox, false); |
| 1052 strings->SetString("learnMore", | 1132 strings->SetString("learnMore", |
| 1053 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | 1133 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); |
| 1054 } | 1134 } |
| OLD | NEW |