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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | |
| 12 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "base/values.h" | 23 #include "base/values.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/google/google_util.h" | 25 #include "chrome/browser/google/google_util.h" |
| 25 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/renderer_preferences_util.h" | 28 #include "chrome/browser/renderer_preferences_util.h" |
| 28 #include "chrome/browser/safe_browsing/malware_details.h" | 29 #include "chrome/browser/safe_browsing/malware_details.h" |
| 29 #include "chrome/browser/safe_browsing/ui_manager.h" | 30 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 30 #include "chrome/browser/tab_contents/tab_util.h" | 31 #include "chrome/browser/tab_contents/tab_util.h" |
| 32 #include "chrome/common/chrome_switches.h" | |
| 31 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 33 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/interstitial_page.h" | 36 #include "content/public/browser/interstitial_page.h" |
| 35 #include "content/public/browser/navigation_controller.h" | 37 #include "content/public/browser/navigation_controller.h" |
| 36 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
| 37 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 38 #include "grit/browser_resources.h" | 40 #include "grit/browser_resources.h" |
| 39 #include "grit/chromium_strings.h" | 41 #include "grit/chromium_strings.h" |
| 40 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " | 88 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " |
| 87 "return false;\" onmousedown=\"return false;\">%s</a>"; | 89 "return false;\" onmousedown=\"return false;\">%s</a>"; |
| 88 | 90 |
| 89 // After a malware interstitial where the user opted-in to the report | 91 // After a malware interstitial where the user opted-in to the report |
| 90 // but clicked "proceed anyway", we delay the call to | 92 // but clicked "proceed anyway", we delay the call to |
| 91 // MalwareDetails::FinishCollection() by this much time (in | 93 // MalwareDetails::FinishCollection() by this much time (in |
| 92 // milliseconds). | 94 // milliseconds). |
| 93 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; | 95 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; |
| 94 | 96 |
| 95 // The commands returned by the page when the user performs an action. | 97 // The commands returned by the page when the user performs an action. |
| 96 const char kShowDiagnosticCommand[] = "showDiagnostic"; | 98 const char kDoReportCommand[] = "doReport"; |
| 97 const char kReportErrorCommand[] = "reportError"; | 99 const char kDontReportCommand[] = "dontReport"; |
| 100 const char kExpandedSeeMoreCommand[] = "expandedSeeMore"; | |
| 98 const char kLearnMoreCommand[] = "learnMore"; | 101 const char kLearnMoreCommand[] = "learnMore"; |
| 99 const char kLearnMoreCommandV2[] = "learnMore2"; | 102 const char kLearnMoreCommandV2[] = "learnMore2"; |
| 103 const char kProceedCommand[] = "proceed"; | |
| 104 const char kReportErrorCommand[] = "reportError"; | |
| 105 const char kShowDiagnosticCommand[] = "showDiagnostic"; | |
| 100 const char kShowPrivacyCommand[] = "showPrivacy"; | 106 const char kShowPrivacyCommand[] = "showPrivacy"; |
| 101 const char kProceedCommand[] = "proceed"; | |
| 102 const char kTakeMeBackCommand[] = "takeMeBack"; | 107 const char kTakeMeBackCommand[] = "takeMeBack"; |
| 103 const char kDoReportCommand[] = "doReport"; | |
| 104 const char kDontReportCommand[] = "dontReport"; | |
| 105 const char kDisplayCheckBox[] = "displaycheckbox"; | |
| 106 const char kBoxChecked[] = "boxchecked"; | |
| 107 const char kExpandedSeeMore[] = "expandedSeeMore"; | |
| 108 // Special command that we use when the user navigated away from the | 108 // Special command that we use when the user navigated away from the |
| 109 // page. E.g., closed the tab or the window. This is only used by | 109 // page. E.g., closed the tab or the window. This is only used by |
| 110 // RecordUserReactionTime. | 110 // RecordUserReactionTime. |
| 111 const char kNavigatedAwayMetaCommand[] = "closed"; | 111 const char kNavigatedAwayMetaCommand[] = "closed"; |
| 112 | 112 |
| 113 // Other constants used to communicate with the JavaScript. | |
| 114 const char kBoxChecked[] = "boxchecked"; | |
| 115 const char kDisplayCheckBox[] = "displaycheckbox"; | |
| 116 | |
| 113 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 117 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
| 114 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 118 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
| 115 | 119 |
| 116 // These are the conditions for the summer 2013 Finch experiment. | 120 // These are the conditions for the summer 2013 Finch experiment. |
| 117 // TODO(felt): Get rid of these now that experiment has ended. | 121 // TODO(felt): Get rid of these now that experiment has ended. |
| 118 const char kMalwareStudyName[] = "InterstitialMalware310"; | 122 const char kMalwareStudyName[] = "InterstitialMalware310"; |
| 119 const char kPhishingStudyName[] = "InterstitialPhishing564"; | 123 const char kPhishingStudyName[] = "InterstitialPhishing564"; |
| 120 const char kCond7MalwareFearMsg[] = "cond7MalwareFearMsg"; | 124 const char kCond7MalwareFearMsg[] = "cond7MalwareFearMsg"; |
| 121 const char kCond8PhishingFearMsg[] = "cond8PhishingFearMsg"; | 125 const char kCond8PhishingFearMsg[] = "cond8PhishingFearMsg"; |
| 122 const char kCond9MalwareCollabMsg[] = "cond9MalwareCollabMsg"; | 126 const char kCond9MalwareCollabMsg[] = "cond9MalwareCollabMsg"; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 139 PHISHING_PROCEED_CROSS_SITE, | 143 PHISHING_PROCEED_CROSS_SITE, |
| 140 MAX_DETAILED_ACTION | 144 MAX_DETAILED_ACTION |
| 141 }; | 145 }; |
| 142 | 146 |
| 143 void RecordDetailedUserAction(DetailedDecision decision) { | 147 void RecordDetailedUserAction(DetailedDecision decision) { |
| 144 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", | 148 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", |
| 145 decision, | 149 decision, |
| 146 MAX_DETAILED_ACTION); | 150 MAX_DETAILED_ACTION); |
| 147 } | 151 } |
| 148 | 152 |
| 153 bool Version3Enabled() { | |
| 154 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 155 switches::kMalwareInterstitialVersionV3)) { | |
| 156 return true; | |
| 157 } | |
| 158 if (base::FieldTrialList::FindFullName("MalwareInterstitialVersion") | |
|
mattm
2014/06/10 23:37:09
Doesn't the trial have to be initialized somewhere
felt
2014/06/11 00:12:09
No, this works, I have been testing with it. The i
| |
| 159 == "V3") { | |
|
mattm
2014/06/10 23:37:09
should be a constant?
felt
2014/06/11 00:12:09
Sure.
| |
| 160 return true; | |
| 161 } | |
| 162 return false; | |
| 163 } | |
| 164 | |
| 165 class SafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPage { | |
| 166 public: | |
| 167 SafeBrowsingBlockingPageV3(SafeBrowsingUIManager* ui_manager, | |
| 168 content::WebContents* web_contents, | |
| 169 const UnsafeResourceList& unsafe_resources); | |
| 170 | |
| 171 // InterstitialPageDelegate method: | |
| 172 virtual std::string GetHTMLContents() OVERRIDE; | |
| 173 | |
| 174 private: | |
| 175 // Fills the passed dictionary with the values to be passed to the template | |
| 176 // when creating the HTML. | |
| 177 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); | |
| 178 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); | |
| 179 | |
| 180 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV3); | |
| 181 }; | |
| 182 | |
| 149 } // namespace | 183 } // namespace |
| 150 | 184 |
| 151 // static | 185 // static |
| 152 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 186 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
| 153 | 187 |
| 154 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 188 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
| 155 // don't leak it. | 189 // don't leak it. |
| 156 class SafeBrowsingBlockingPageFactoryImpl | 190 class SafeBrowsingBlockingPageFactoryImpl |
| 157 : public SafeBrowsingBlockingPageFactory { | 191 : public SafeBrowsingBlockingPageFactory { |
| 158 public: | 192 public: |
| 159 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 193 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 160 SafeBrowsingUIManager* ui_manager, | 194 SafeBrowsingUIManager* ui_manager, |
| 161 WebContents* web_contents, | 195 WebContents* web_contents, |
| 162 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 196 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 163 OVERRIDE { | 197 OVERRIDE { |
| 164 // Only use the V2 page if the interstitial is for a single malware or | 198 // Only use the V2 page if the interstitial is for a single malware or |
| 165 // phishing resource, the multi-threat interstitial has not been updated to | 199 // phishing resource, the multi-threat interstitial has not been updated to |
| 166 // V2 yet. | 200 // V2 yet. |
| 167 if (unsafe_resources.size() == 1 && | 201 if (unsafe_resources.size() == 1 && |
| 168 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || | 202 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || |
| 169 unsafe_resources[0].threat_type == | 203 unsafe_resources[0].threat_type == |
| 170 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || | 204 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || |
| 171 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING || | 205 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING || |
| 172 unsafe_resources[0].threat_type == | 206 unsafe_resources[0].threat_type == |
| 173 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) { | 207 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) { |
| 174 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | 208 if (Version3Enabled()) { |
| 175 unsafe_resources); | 209 return new SafeBrowsingBlockingPageV3(ui_manager, web_contents, |
| 210 unsafe_resources); | |
| 211 } else { | |
| 212 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | |
| 213 unsafe_resources); | |
| 214 } | |
| 176 } | 215 } |
| 177 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, | 216 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, |
| 178 unsafe_resources); | 217 unsafe_resources); |
| 179 } | 218 } |
| 180 | 219 |
| 181 private: | 220 private: |
| 182 friend struct base::DefaultLazyInstanceTraits< | 221 friend struct base::DefaultLazyInstanceTraits< |
| 183 SafeBrowsingBlockingPageFactoryImpl>; | 222 SafeBrowsingBlockingPageFactoryImpl>; |
| 184 | 223 |
| 185 SafeBrowsingBlockingPageFactoryImpl() { } | 224 SafeBrowsingBlockingPageFactoryImpl() { } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 SB_THREAT_TYPE_URL_MALWARE || | 462 SB_THREAT_TYPE_URL_MALWARE || |
| 424 unsafe_resources_[element_index].threat_type == | 463 unsafe_resources_[element_index].threat_type == |
| 425 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); | 464 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); |
| 426 OpenURLParams params( | 465 OpenURLParams params( |
| 427 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, | 466 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, |
| 428 false); | 467 false); |
| 429 web_contents_->OpenURL(params); | 468 web_contents_->OpenURL(params); |
| 430 return; | 469 return; |
| 431 } | 470 } |
| 432 | 471 |
| 433 if (command == kExpandedSeeMore) { | 472 if (command == kExpandedSeeMoreCommand) { |
| 434 // User expanded the "see more info" section of the page. We don't actually | 473 // User expanded the "see more info" section of the page. We don't actually |
| 435 // do any action based on this, it's just so that RecordUserReactionTime can | 474 // do any action based on this, it's just so that RecordUserReactionTime can |
| 436 // track it. | 475 // track it. |
| 437 return; | 476 return; |
| 438 } | 477 } |
| 439 | 478 |
| 440 NOTREACHED() << "Unexpected command: " << command; | 479 NOTREACHED() << "Unexpected command: " << command; |
| 441 } | 480 } |
| 442 | 481 |
| 443 void SafeBrowsingBlockingPage::OverrideRendererPrefs( | 482 void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 } else if (command == kShowDiagnosticCommand) { | 745 } else if (command == kShowDiagnosticCommand) { |
| 707 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); | 746 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); |
| 708 } else if (command == kShowPrivacyCommand) { | 747 } else if (command == kShowPrivacyCommand) { |
| 709 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy", | 748 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy", |
| 710 dt); | 749 dt); |
| 711 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 750 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
| 712 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", | 751 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", |
| 713 dt); | 752 dt); |
| 714 } else if (command == kNavigatedAwayMetaCommand) { | 753 } else if (command == kNavigatedAwayMetaCommand) { |
| 715 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); | 754 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); |
| 716 } else if (command == kExpandedSeeMore) { | 755 } else if (command == kExpandedSeeMoreCommand) { |
| 717 // Only record the expanded histogram once per display of the | 756 // Only record the expanded histogram once per display of the |
| 718 // interstitial. | 757 // interstitial. |
| 719 if (has_expanded_see_more_section_) | 758 if (has_expanded_see_more_section_) |
| 720 return; | 759 return; |
| 721 RecordUserAction(SHOW_ADVANCED); | 760 RecordUserAction(SHOW_ADVANCED); |
| 722 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", | 761 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", |
| 723 dt); | 762 dt); |
| 724 has_expanded_see_more_section_ = true; | 763 has_expanded_see_more_section_ = true; |
| 725 // Expanding the "See More" section doesn't finish the interstitial, so | 764 // Expanding the "See More" section doesn't finish the interstitial, so |
| 726 // don't mark the reaction time as recorded. | 765 // don't mark the reaction time as recorded. |
| 727 recorded = false; | 766 recorded = false; |
| 728 } else { | 767 } else { |
| 729 recorded = false; | 768 recorded = false; |
| 730 } | 769 } |
| 731 } else { | 770 } else { |
| 732 // Same as above but for phishing warnings. | 771 // Same as above but for phishing warnings. |
| 733 if (command == kProceedCommand) { | 772 if (command == kProceedCommand) { |
| 734 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); | 773 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); |
| 735 } else if (command == kTakeMeBackCommand) { | 774 } else if (command == kTakeMeBackCommand) { |
| 736 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); | 775 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); |
| 737 } else if (command == kShowDiagnosticCommand) { | 776 } else if (command == kShowDiagnosticCommand) { |
| 738 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); | 777 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); |
| 739 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 778 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
| 740 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); | 779 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); |
| 741 } else if (command == kNavigatedAwayMetaCommand) { | 780 } else if (command == kNavigatedAwayMetaCommand) { |
| 742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); | 781 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); |
| 743 } else if (command == kExpandedSeeMore) { | 782 } else if (command == kExpandedSeeMoreCommand) { |
| 744 // Only record the expanded histogram once per display of the | 783 // Only record the expanded histogram once per display of the |
| 745 // interstitial. | 784 // interstitial. |
| 746 if (has_expanded_see_more_section_) | 785 if (has_expanded_see_more_section_) |
| 747 return; | 786 return; |
| 748 RecordUserAction(SHOW_ADVANCED); | 787 RecordUserAction(SHOW_ADVANCED); |
| 749 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", | 788 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", |
| 750 dt); | 789 dt); |
| 751 has_expanded_see_more_section_ = true; | 790 has_expanded_see_more_section_ = true; |
| 752 // Expanding the "See More" section doesn't finish the interstitial, so | 791 // Expanding the "See More" section doesn't finish the interstitial, so |
| 753 // don't mark the reaction time as recorded. | 792 // don't mark the reaction time as recorded. |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str()); | 1195 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str()); |
| 1157 | 1196 |
| 1158 strings->SetString("confirm_text", | 1197 strings->SetString("confirm_text", |
| 1159 l10n_util::GetStringFUTF16( | 1198 l10n_util::GetStringFUTF16( |
| 1160 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, | 1199 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, |
| 1161 base::UTF8ToUTF16(privacy_link))); | 1200 base::UTF8ToUTF16(privacy_link))); |
| 1162 if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled)) | 1201 if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled)) |
| 1163 strings->SetString(kBoxChecked, "yes"); | 1202 strings->SetString(kBoxChecked, "yes"); |
| 1164 else | 1203 else |
| 1165 strings->SetString(kBoxChecked, std::string()); | 1204 strings->SetString(kBoxChecked, std::string()); |
| 1166 } | 1205 } |
|
mattm
2014/06/10 23:37:09
Is it intentional that the new page doesn't show t
felt
2014/06/11 00:12:09
Yes, the designers were still deciding where to pu
| |
| 1167 | 1206 |
| 1168 strings->SetString("report_error", base::string16()); | 1207 strings->SetString("report_error", base::string16()); |
| 1169 strings->SetString("learnMore", | 1208 strings->SetString("learnMore", |
| 1170 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | 1209 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); |
| 1171 } | 1210 } |
| 1172 | 1211 |
| 1173 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary( | 1212 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary( |
| 1174 base::DictionaryValue* strings) { | 1213 base::DictionaryValue* strings) { |
| 1175 PopulateStringDictionary( | 1214 PopulateStringDictionary( |
| 1176 strings, | 1215 strings, |
| 1177 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE), | 1216 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE), |
| 1178 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE), | 1217 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE), |
| 1179 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1, | 1218 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1, |
| 1180 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 1219 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| 1181 base::UTF8ToUTF16(url_.host())), | 1220 base::UTF8ToUTF16(url_.host())), |
| 1182 base::string16(), | 1221 base::string16(), |
| 1183 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION2)); | 1222 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION2)); |
| 1184 | 1223 |
| 1185 strings->SetString("details", std::string()); | 1224 strings->SetString("details", std::string()); |
| 1186 strings->SetString("confirm_text", std::string()); | 1225 strings->SetString("confirm_text", std::string()); |
| 1187 strings->SetString(kBoxChecked, std::string()); | 1226 strings->SetString(kBoxChecked, std::string()); |
| 1188 strings->SetString( | 1227 strings->SetString( |
| 1189 "report_error", | 1228 "report_error", |
| 1190 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | 1229 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); |
| 1191 strings->SetBoolean(kDisplayCheckBox, false); | 1230 strings->SetBoolean(kDisplayCheckBox, false); |
| 1192 strings->SetString("learnMore", | 1231 strings->SetString("learnMore", |
| 1193 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | 1232 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); |
| 1194 } | 1233 } |
| 1234 | |
| 1235 SafeBrowsingBlockingPageV3::SafeBrowsingBlockingPageV3( | |
| 1236 SafeBrowsingUIManager* ui_manager, | |
| 1237 WebContents* web_contents, | |
| 1238 const UnsafeResourceList& unsafe_resources) | |
| 1239 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { | |
| 1240 } | |
| 1241 | |
| 1242 std::string SafeBrowsingBlockingPageV3::GetHTMLContents() { | |
| 1243 if (unsafe_resources_.empty() || unsafe_resources_.size() > 1) { | |
| 1244 // TODO(felt): Implement new multi-threat interstitial. crbug.com/160336 | |
| 1245 NOTIMPLEMENTED(); | |
| 1246 return std::string(); | |
| 1247 } | |
| 1248 | |
| 1249 // Fill in the shared values. | |
| 1250 base::DictionaryValue load_time_data; | |
| 1251 webui::SetFontAndTextDirection(&load_time_data); | |
| 1252 load_time_data.SetBoolean("ssl", false); | |
| 1253 load_time_data.SetString( | |
| 1254 "openDetails", | |
| 1255 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | |
| 1256 load_time_data.SetString( | |
| 1257 "closeDetails", | |
| 1258 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | |
| 1259 load_time_data.SetString( | |
| 1260 "primaryButtonText", | |
| 1261 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | |
| 1262 load_time_data.SetString( | |
| 1263 "proceedText", | |
| 1264 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | |
| 1265 load_time_data.SetBoolean( | |
| 1266 "overridable", | |
| 1267 !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); | |
| 1268 | |
| 1269 // Fill in the values that are specific to malware or phishing. | |
| 1270 SBThreatType threat_type = unsafe_resources_[0].threat_type; | |
| 1271 switch (threat_type) { | |
| 1272 case SB_THREAT_TYPE_URL_MALWARE: | |
| 1273 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: | |
| 1274 PopulateMalwareLoadTimeData(&load_time_data); | |
| 1275 break; | |
| 1276 case SB_THREAT_TYPE_URL_PHISHING: | |
| 1277 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: | |
| 1278 PopulatePhishingLoadTimeData(&load_time_data); | |
| 1279 break; | |
| 1280 case SB_THREAT_TYPE_SAFE: | |
| 1281 case SB_THREAT_TYPE_BINARY_MALWARE_URL: | |
| 1282 case SB_THREAT_TYPE_EXTENSION: | |
| 1283 NOTREACHED(); | |
| 1284 } | |
| 1285 | |
| 1286 interstitial_show_time_ = base::TimeTicks::Now(); | |
| 1287 | |
| 1288 base::StringPiece html( | |
| 1289 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 1290 IRD_SSL_INTERSTITIAL_V2_HTML)); | |
| 1291 webui::UseVersion2 version; | |
| 1292 return webui::GetI18nTemplateHtml(html, &load_time_data); | |
| 1293 } | |
| 1294 | |
| 1295 void SafeBrowsingBlockingPageV3::PopulateMalwareLoadTimeData( | |
| 1296 base::DictionaryValue* load_time_data) { | |
| 1297 load_time_data->SetBoolean("phishing", false); | |
| 1298 load_time_data->SetString( | |
| 1299 "tabTitle", | |
| 1300 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE)); | |
| 1301 load_time_data->SetString( | |
| 1302 "heading", | |
| 1303 l10n_util::GetStringUTF16(is_main_frame_load_blocked_ ? | |
| 1304 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE : | |
| 1305 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE)); | |
| 1306 load_time_data->SetString( | |
| 1307 "primaryParagraph", | |
| 1308 l10n_util::GetStringFUTF16( | |
| 1309 is_main_frame_load_blocked_ ? | |
| 1310 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1 : | |
| 1311 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE, | |
| 1312 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 1313 base::UTF8ToUTF16(is_main_frame_load_blocked_ ? | |
| 1314 url_.host() : web_contents_->GetURL().host()))); | |
| 1315 load_time_data->SetString( | |
| 1316 "secondParagraph", | |
| 1317 is_main_frame_load_blocked_ ? | |
| 1318 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2) : | |
| 1319 l10n_util::GetStringFUTF16( | |
| 1320 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE, | |
| 1321 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 1322 base::UTF8ToUTF16(url_.host()))); | |
| 1323 load_time_data->SetString( | |
| 1324 "thirdParagraph", | |
| 1325 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3)); | |
| 1326 load_time_data->SetString( | |
| 1327 "detailsText", | |
| 1328 is_main_frame_load_blocked_ ? | |
| 1329 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DETAILS) : | |
| 1330 l10n_util::GetStringFUTF16( | |
| 1331 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS_SUBRESOURCE, | |
| 1332 base::UTF8ToUTF16(url_.host()))); | |
| 1333 } | |
| 1334 | |
| 1335 void SafeBrowsingBlockingPageV3::PopulatePhishingLoadTimeData( | |
| 1336 base::DictionaryValue* load_time_data) { | |
| 1337 load_time_data->SetBoolean("phishing", true); | |
| 1338 load_time_data->SetString( | |
| 1339 "tabTitle", | |
| 1340 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE)); | |
| 1341 load_time_data->SetString( | |
| 1342 "heading", | |
| 1343 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE)); | |
| 1344 load_time_data->SetString( | |
| 1345 "primaryParagraph", | |
| 1346 l10n_util::GetStringFUTF16( | |
| 1347 IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1, | |
| 1348 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 1349 base::UTF8ToUTF16(url_.host()))); | |
| 1350 load_time_data->SetString( | |
| 1351 "secondParagraph", | |
| 1352 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2)); | |
|
mattm
2014/06/10 23:37:08
is MALWARE here intentional?
felt
2014/06/11 00:12:09
No, good catch.
| |
| 1353 load_time_data->SetString( | |
| 1354 "detailsText", | |
| 1355 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | |
| 1356 } | |
| OLD | NEW |