| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 PHISHING_PROCEED_CROSS_SITE, | 120 PHISHING_PROCEED_CROSS_SITE, |
| 121 MAX_DETAILED_ACTION | 121 MAX_DETAILED_ACTION |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 void RecordDetailedUserAction(DetailedDecision decision) { | 124 void RecordDetailedUserAction(DetailedDecision decision) { |
| 125 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", | 125 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", |
| 126 decision, | 126 decision, |
| 127 MAX_DETAILED_ACTION); | 127 MAX_DETAILED_ACTION); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Constants for the M37 Finch trial. | |
| 131 const char kV3StudyName[] = "MalwareInterstitialVersion"; | |
| 132 const char kCondV2[] = "V2"; | |
| 133 const char kCondV3[] = "V3"; | |
| 134 const char kCondV3Advice[] = "V3Advice"; | |
| 135 const char kCondV3Social[] = "V3Social"; | |
| 136 const char kCondV3NotRecommend[] = "V3NotRecommend"; | |
| 137 const char kCondV3History[] = "V3History"; | |
| 138 | |
| 139 // Default to V3 unless a flag or field trial says otherwise. Flags override | |
| 140 // field trial settings. | |
| 141 const char* GetTrialCondition() { | |
| 142 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 143 switches::kMalwareInterstitialV2)) { | |
| 144 return kCondV2; | |
| 145 } | |
| 146 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 147 switches::kMalwareInterstitialV3)) { | |
| 148 return kCondV3; | |
| 149 } | |
| 150 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 151 switches::kMalwareInterstitialV3Advice)) { | |
| 152 return kCondV3Advice; | |
| 153 } | |
| 154 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 155 switches::kMalwareInterstitialV3Social)) { | |
| 156 return kCondV3Social; | |
| 157 } | |
| 158 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 159 switches::kMalwareInterstitialV3NotRecommend)) { | |
| 160 return kCondV3NotRecommend; | |
| 161 } | |
| 162 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 163 switches::kMalwareInterstitialV3History)) { | |
| 164 return kCondV3History; | |
| 165 } | |
| 166 | |
| 167 // Make sure that the return value is one of the expected types instead of | |
| 168 // directly returning base::FieldTrialList::FindFullName. | |
| 169 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondV2) | |
| 170 return kCondV2; | |
| 171 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondV3) | |
| 172 return kCondV3; | |
| 173 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondV3Advice) | |
| 174 return kCondV3Advice; | |
| 175 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondV3Social) | |
| 176 return kCondV3Social; | |
| 177 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondV3NotRecommend) | |
| 178 return kCondV3NotRecommend; | |
| 179 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondV3History) | |
| 180 return kCondV3History; | |
| 181 return kCondV3; | |
| 182 } | |
| 183 | |
| 184 } // namespace | 130 } // namespace |
| 185 | 131 |
| 186 // static | 132 // static |
| 187 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 133 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
| 188 | 134 |
| 189 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 135 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
| 190 // don't leak it. | 136 // don't leak it. |
| 191 class SafeBrowsingBlockingPageFactoryImpl | 137 class SafeBrowsingBlockingPageFactoryImpl |
| 192 : public SafeBrowsingBlockingPageFactory { | 138 : public SafeBrowsingBlockingPageFactory { |
| 193 public: | 139 public: |
| 194 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 140 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 195 SafeBrowsingUIManager* ui_manager, | 141 SafeBrowsingUIManager* ui_manager, |
| 196 WebContents* web_contents, | 142 WebContents* web_contents, |
| 197 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 143 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 198 OVERRIDE { | 144 OVERRIDE { |
| 199 // Only use the V2 page if the interstitial is for a single malware or | 145 return new SafeBrowsingBlockingPage(ui_manager, web_contents, |
| 200 // phishing resource. | |
| 201 if ((GetTrialCondition() == kCondV2) && (unsafe_resources.size() == 1) && | |
| 202 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || | |
| 203 unsafe_resources[0].threat_type == | |
| 204 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || | |
| 205 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING || | |
| 206 unsafe_resources[0].threat_type == | |
| 207 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) { | |
| 208 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | |
| 209 unsafe_resources); | |
| 210 } | |
| 211 return new SafeBrowsingBlockingPageV3(ui_manager, web_contents, | |
| 212 unsafe_resources); | 146 unsafe_resources); |
| 213 } | 147 } |
| 214 | 148 |
| 215 private: | 149 private: |
| 216 friend struct base::DefaultLazyInstanceTraits< | 150 friend struct base::DefaultLazyInstanceTraits< |
| 217 SafeBrowsingBlockingPageFactoryImpl>; | 151 SafeBrowsingBlockingPageFactoryImpl>; |
| 218 | 152 |
| 219 SafeBrowsingBlockingPageFactoryImpl() { } | 153 SafeBrowsingBlockingPageFactoryImpl() { } |
| 220 | 154 |
| 221 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageFactoryImpl); | 155 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageFactoryImpl); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 // load, since they happen after the page is finished loading. | 791 // load, since they happen after the page is finished loading. |
| 858 if (unsafe_resources[0].threat_type == | 792 if (unsafe_resources[0].threat_type == |
| 859 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) { | 793 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) { |
| 860 return false; | 794 return false; |
| 861 } | 795 } |
| 862 | 796 |
| 863 // Otherwise, check the threat type. | 797 // Otherwise, check the threat type. |
| 864 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; | 798 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; |
| 865 } | 799 } |
| 866 | 800 |
| 867 SafeBrowsingBlockingPageV2::SafeBrowsingBlockingPageV2( | 801 std::string SafeBrowsingBlockingPage::GetHTMLContents() { |
| 868 SafeBrowsingUIManager* ui_manager, | |
| 869 WebContents* web_contents, | |
| 870 const UnsafeResourceList& unsafe_resources) | |
| 871 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { | |
| 872 } | |
| 873 | |
| 874 std::string SafeBrowsingBlockingPageV2::GetHTMLContents() { | |
| 875 // Load the HTML page and create the template components. | |
| 876 base::DictionaryValue strings; | |
| 877 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 878 std::string html; | |
| 879 | |
| 880 if (unsafe_resources_.empty()) { | |
| 881 NOTREACHED(); | |
| 882 return std::string(); | |
| 883 } | |
| 884 | |
| 885 if (unsafe_resources_.size() > 1) { | |
| 886 NOTREACHED(); | |
| 887 } else { | |
| 888 SBThreatType threat_type = unsafe_resources_[0].threat_type; | |
| 889 if (threat_type == SB_THREAT_TYPE_URL_MALWARE || | |
| 890 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) { | |
| 891 PopulateMalwareStringDictionary(&strings); | |
| 892 } else { // Phishing. | |
| 893 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING || | |
| 894 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | |
| 895 PopulatePhishingStringDictionary(&strings); | |
| 896 } | |
| 897 html = rb.GetRawDataResource(IDR_SAFE_BROWSING_MALWARE_BLOCK_V2). | |
| 898 as_string(); | |
| 899 } | |
| 900 interstitial_show_time_ = base::TimeTicks::Now(); | |
| 901 return webui::GetTemplatesHtml(html, &strings, "template-root"); | |
| 902 } | |
| 903 | |
| 904 void SafeBrowsingBlockingPageV2::PopulateStringDictionary( | |
| 905 base::DictionaryValue* strings, | |
| 906 const base::string16& title, | |
| 907 const base::string16& headline, | |
| 908 const base::string16& description1, | |
| 909 const base::string16& description2, | |
| 910 const base::string16& description3) { | |
| 911 strings->SetString("title", title); | |
| 912 strings->SetString("headLine", headline); | |
| 913 strings->SetString("description1", description1); | |
| 914 strings->SetString("description2", description2); | |
| 915 strings->SetString("description3", description3); | |
| 916 strings->SetBoolean("proceedDisabled", | |
| 917 IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); | |
| 918 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); | |
| 919 strings->SetBoolean("isPhishing", interstitial_type_ == TYPE_PHISHING); | |
| 920 | |
| 921 strings->SetString("back_button", | |
| 922 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); | |
| 923 strings->SetString("seeMore", l10n_util::GetStringUTF16( | |
| 924 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | |
| 925 strings->SetString("proceed", | |
| 926 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | |
| 927 webui::SetFontAndTextDirection(strings); | |
| 928 } | |
| 929 | |
| 930 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( | |
| 931 base::DictionaryValue* strings) { | |
| 932 NOTREACHED(); | |
| 933 } | |
| 934 | |
| 935 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( | |
| 936 base::DictionaryValue* strings) { | |
| 937 // Check to see if we're blocking the main page, or a sub-resource on the | |
| 938 // main page. | |
| 939 base::string16 headline, description1, description2, description3; | |
| 940 | |
| 941 | |
| 942 description3 = l10n_util::GetStringUTF16( | |
| 943 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3); | |
| 944 if (is_main_frame_load_blocked_) { | |
| 945 headline = l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE); | |
| 946 description1 = l10n_util::GetStringFUTF16( | |
| 947 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1, | |
| 948 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 949 base::UTF8ToUTF16(url_.host())); | |
| 950 description2 = l10n_util::GetStringUTF16( | |
| 951 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2); | |
| 952 strings->SetString("details", l10n_util::GetStringUTF16( | |
| 953 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS)); | |
| 954 } else { | |
| 955 headline = l10n_util::GetStringUTF16( | |
| 956 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE); | |
| 957 description1 = l10n_util::GetStringFUTF16( | |
| 958 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE, | |
| 959 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 960 base::UTF8ToUTF16(web_contents_->GetURL().host())); | |
| 961 description2 = l10n_util::GetStringFUTF16( | |
| 962 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE, | |
| 963 base::UTF8ToUTF16(url_.host())); | |
| 964 strings->SetString("details", l10n_util::GetStringFUTF16( | |
| 965 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS_SUBRESOURCE, | |
| 966 base::UTF8ToUTF16(url_.host()))); | |
| 967 } | |
| 968 | |
| 969 PopulateStringDictionary( | |
| 970 strings, | |
| 971 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE), | |
| 972 headline, | |
| 973 description1, | |
| 974 description2, | |
| 975 description3); | |
| 976 | |
| 977 if (!CanShowMalwareDetailsOption()) { | |
| 978 strings->SetBoolean(kDisplayCheckBox, false); | |
| 979 strings->SetString("confirm_text", std::string()); | |
| 980 strings->SetString(kBoxChecked, std::string()); | |
| 981 } else { | |
| 982 // Show the checkbox for sending malware details. | |
| 983 strings->SetBoolean(kDisplayCheckBox, true); | |
| 984 | |
| 985 std::string privacy_link = base::StringPrintf( | |
| 986 kPrivacyLinkHtml, | |
| 987 l10n_util::GetStringUTF8( | |
| 988 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str()); | |
| 989 | |
| 990 strings->SetString("confirm_text", | |
| 991 l10n_util::GetStringFUTF16( | |
| 992 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, | |
| 993 base::UTF8ToUTF16(privacy_link))); | |
| 994 Profile* profile = Profile::FromBrowserContext( | |
| 995 web_contents_->GetBrowserContext()); | |
| 996 if (profile->GetPrefs()->HasPrefPath( | |
| 997 prefs::kSafeBrowsingExtendedReportingEnabled)) { | |
| 998 reporting_checkbox_checked_ = | |
| 999 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | |
| 1000 } else if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled) || | |
| 1001 IsPrefEnabled(prefs::kSafeBrowsingDownloadFeedbackEnabled)) { | |
| 1002 reporting_checkbox_checked_ = true; | |
| 1003 } | |
| 1004 strings->SetString(kBoxChecked, | |
| 1005 reporting_checkbox_checked_ ? "yes" : std::string()); | |
| 1006 } | |
| 1007 | |
| 1008 strings->SetString("report_error", base::string16()); | |
| 1009 strings->SetString("learnMore", | |
| 1010 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | |
| 1011 } | |
| 1012 | |
| 1013 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary( | |
| 1014 base::DictionaryValue* strings) { | |
| 1015 PopulateStringDictionary( | |
| 1016 strings, | |
| 1017 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE), | |
| 1018 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE), | |
| 1019 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1, | |
| 1020 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
| 1021 base::UTF8ToUTF16(url_.host())), | |
| 1022 base::string16(), | |
| 1023 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION2)); | |
| 1024 | |
| 1025 strings->SetString("details", std::string()); | |
| 1026 strings->SetString("confirm_text", std::string()); | |
| 1027 strings->SetString(kBoxChecked, std::string()); | |
| 1028 strings->SetString( | |
| 1029 "report_error", | |
| 1030 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | |
| 1031 strings->SetBoolean(kDisplayCheckBox, false); | |
| 1032 strings->SetString("learnMore", | |
| 1033 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | |
| 1034 } | |
| 1035 | |
| 1036 SafeBrowsingBlockingPageV3::SafeBrowsingBlockingPageV3( | |
| 1037 SafeBrowsingUIManager* ui_manager, | |
| 1038 WebContents* web_contents, | |
| 1039 const UnsafeResourceList& unsafe_resources) | |
| 1040 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources), | |
| 1041 trial_condition_(GetTrialCondition()) { | |
| 1042 } | |
| 1043 | |
| 1044 std::string SafeBrowsingBlockingPageV3::GetHTMLContents() { | |
| 1045 DCHECK(!unsafe_resources_.empty()); | 802 DCHECK(!unsafe_resources_.empty()); |
| 1046 | 803 |
| 1047 // Fill in the shared values. | 804 // Fill in the shared values. |
| 1048 base::DictionaryValue load_time_data; | 805 base::DictionaryValue load_time_data; |
| 1049 webui::SetFontAndTextDirection(&load_time_data); | 806 webui::SetFontAndTextDirection(&load_time_data); |
| 1050 load_time_data.SetBoolean("ssl", false); | 807 load_time_data.SetBoolean("ssl", false); |
| 1051 load_time_data.SetString( | 808 load_time_data.SetString( |
| 1052 "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); | 809 "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); |
| 1053 load_time_data.SetString( | 810 load_time_data.SetString( |
| 1054 "openDetails", | 811 "openDetails", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1070 | 827 |
| 1071 interstitial_show_time_ = base::TimeTicks::Now(); | 828 interstitial_show_time_ = base::TimeTicks::Now(); |
| 1072 | 829 |
| 1073 base::StringPiece html( | 830 base::StringPiece html( |
| 1074 ResourceBundle::GetSharedInstance().GetRawDataResource( | 831 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 1075 IRD_SSL_INTERSTITIAL_V2_HTML)); | 832 IRD_SSL_INTERSTITIAL_V2_HTML)); |
| 1076 webui::UseVersion2 version; | 833 webui::UseVersion2 version; |
| 1077 return webui::GetI18nTemplateHtml(html, &load_time_data); | 834 return webui::GetI18nTemplateHtml(html, &load_time_data); |
| 1078 } | 835 } |
| 1079 | 836 |
| 1080 void SafeBrowsingBlockingPageV3::PopulateMalwareLoadTimeData( | 837 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData( |
| 1081 base::DictionaryValue* load_time_data) { | 838 base::DictionaryValue* load_time_data) { |
| 1082 load_time_data->SetString("trialCondition", trial_condition_); | |
| 1083 load_time_data->SetBoolean("phishing", false); | 839 load_time_data->SetBoolean("phishing", false); |
| 1084 load_time_data->SetString( | 840 load_time_data->SetString( |
| 1085 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); | 841 "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); |
| 1086 load_time_data->SetString( | 842 load_time_data->SetString( |
| 1087 "primaryParagraph", | 843 "primaryParagraph", |
| 1088 l10n_util::GetStringFUTF16( | 844 l10n_util::GetStringFUTF16( |
| 1089 IDS_MALWARE_V3_PRIMARY_PARAGRAPH, | 845 IDS_MALWARE_V3_PRIMARY_PARAGRAPH, |
| 1090 base::UTF8ToUTF16(url_.host()))); | 846 base::UTF8ToUTF16(url_.host()))); |
| 1091 if (trial_condition_ == kCondV3History) { | 847 load_time_data->SetString( |
| 1092 load_time_data->SetString( | 848 "explanationParagraph", |
| 1093 "explanationParagraph", | 849 is_main_frame_load_blocked_ ? |
| 1094 is_main_frame_load_blocked_ ? | 850 l10n_util::GetStringFUTF16( |
| 1095 l10n_util::GetStringFUTF16( | 851 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH, |
| 1096 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_HISTORY, | 852 base::UTF8ToUTF16(url_.host())) : |
| 1097 base::UTF8ToUTF16(url_.host())) : | 853 l10n_util::GetStringFUTF16( |
| 1098 l10n_util::GetStringFUTF16( | 854 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE, |
| 1099 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE_HISTORY, | 855 base::UTF8ToUTF16(web_contents_->GetURL().host()), |
| 1100 base::UTF8ToUTF16(web_contents_->GetURL().host()), | 856 base::UTF8ToUTF16(url_.host()))); |
| 1101 base::UTF8ToUTF16(url_.host()))); | 857 load_time_data->SetString( |
| 1102 } else if (trial_condition_ == kCondV3Advice) { | 858 "finalParagraph", |
| 1103 load_time_data->SetString( | 859 l10n_util::GetStringUTF16(IDS_MALWARE_V3_PROCEED_PARAGRAPH)); |
| 1104 "explanationParagraph", | |
| 1105 is_main_frame_load_blocked_ ? | |
| 1106 l10n_util::GetStringFUTF16( | |
| 1107 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_ADVICE, | |
| 1108 base::UTF8ToUTF16(url_.host())) : | |
| 1109 l10n_util::GetStringFUTF16( | |
| 1110 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE_ADVICE, | |
| 1111 base::UTF8ToUTF16(web_contents_->GetURL().host()), | |
| 1112 base::UTF8ToUTF16(url_.host()))); | |
| 1113 load_time_data->SetString( | |
| 1114 "adviceHeading", | |
| 1115 l10n_util::GetStringUTF16(IDS_MALWARE_V3_ADVICE_HEADING)); | |
| 1116 } else { | |
| 1117 load_time_data->SetString( | |
| 1118 "explanationParagraph", | |
| 1119 is_main_frame_load_blocked_ ? | |
| 1120 l10n_util::GetStringFUTF16( | |
| 1121 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH, | |
| 1122 base::UTF8ToUTF16(url_.host())) : | |
| 1123 l10n_util::GetStringFUTF16( | |
| 1124 IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE, | |
| 1125 base::UTF8ToUTF16(web_contents_->GetURL().host()), | |
| 1126 base::UTF8ToUTF16(url_.host()))); | |
| 1127 } | |
| 1128 if (trial_condition_ == kCondV3Social) { | |
| 1129 load_time_data->SetString( | |
| 1130 "finalParagraph", | |
| 1131 l10n_util::GetStringUTF16(IDS_MALWARE_V3_PROCEED_PARAGRAPH_SOCIAL)); | |
| 1132 } else if (trial_condition_ == kCondV3NotRecommend) { | |
| 1133 load_time_data->SetString( | |
| 1134 "finalParagraph", | |
| 1135 l10n_util::GetStringUTF16( | |
| 1136 IDS_MALWARE_V3_PROCEED_PARAGRAPH_NOT_RECOMMEND)); | |
| 1137 } else { | |
| 1138 load_time_data->SetString( | |
| 1139 "finalParagraph", | |
| 1140 l10n_util::GetStringUTF16(IDS_MALWARE_V3_PROCEED_PARAGRAPH)); | |
| 1141 } | |
| 1142 | 860 |
| 1143 load_time_data->SetBoolean(kDisplayCheckBox, CanShowMalwareDetailsOption()); | 861 load_time_data->SetBoolean(kDisplayCheckBox, CanShowMalwareDetailsOption()); |
| 1144 if (CanShowMalwareDetailsOption()) { | 862 if (CanShowMalwareDetailsOption()) { |
| 1145 std::string privacy_link = base::StringPrintf( | 863 std::string privacy_link = base::StringPrintf( |
| 1146 kPrivacyLinkHtml, | 864 kPrivacyLinkHtml, |
| 1147 l10n_util::GetStringUTF8( | 865 l10n_util::GetStringUTF8( |
| 1148 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str()); | 866 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); |
| 1149 load_time_data->SetString( | 867 load_time_data->SetString( |
| 1150 "optInLink", | 868 "optInLink", |
| 1151 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, | 869 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, |
| 1152 base::UTF8ToUTF16(privacy_link))); | 870 base::UTF8ToUTF16(privacy_link))); |
| 1153 Profile* profile = Profile::FromBrowserContext( | 871 Profile* profile = Profile::FromBrowserContext( |
| 1154 web_contents_->GetBrowserContext()); | 872 web_contents_->GetBrowserContext()); |
| 1155 if (profile->GetPrefs()->HasPrefPath( | 873 if (profile->GetPrefs()->HasPrefPath( |
| 1156 prefs::kSafeBrowsingExtendedReportingEnabled)) { | 874 prefs::kSafeBrowsingExtendedReportingEnabled)) { |
| 1157 reporting_checkbox_checked_ = | 875 reporting_checkbox_checked_ = |
| 1158 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | 876 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
| 1159 } else if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled) || | 877 } else if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled) || |
| 1160 IsPrefEnabled(prefs::kSafeBrowsingDownloadFeedbackEnabled)) { | 878 IsPrefEnabled(prefs::kSafeBrowsingDownloadFeedbackEnabled)) { |
| 1161 reporting_checkbox_checked_ = true; | 879 reporting_checkbox_checked_ = true; |
| 1162 } | 880 } |
| 1163 load_time_data->SetBoolean( | 881 load_time_data->SetBoolean( |
| 1164 kBoxChecked, reporting_checkbox_checked_); | 882 kBoxChecked, reporting_checkbox_checked_); |
| 1165 } | 883 } |
| 1166 } | 884 } |
| 1167 | 885 |
| 1168 void SafeBrowsingBlockingPageV3::PopulatePhishingLoadTimeData( | 886 void SafeBrowsingBlockingPage::PopulatePhishingLoadTimeData( |
| 1169 base::DictionaryValue* load_time_data) { | 887 base::DictionaryValue* load_time_data) { |
| 1170 load_time_data->SetString("trialCondition", std::string()); | |
| 1171 load_time_data->SetBoolean("phishing", true); | 888 load_time_data->SetBoolean("phishing", true); |
| 1172 load_time_data->SetString( | 889 load_time_data->SetString( |
| 1173 "heading", | 890 "heading", |
| 1174 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING)); | 891 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING)); |
| 1175 load_time_data->SetString( | 892 load_time_data->SetString( |
| 1176 "primaryParagraph", | 893 "primaryParagraph", |
| 1177 l10n_util::GetStringFUTF16( | 894 l10n_util::GetStringFUTF16( |
| 1178 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 895 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
| 1179 base::UTF8ToUTF16(url_.host()))); | 896 base::UTF8ToUTF16(url_.host()))); |
| 1180 load_time_data->SetString( | 897 load_time_data->SetString( |
| 1181 "explanationParagraph", | 898 "explanationParagraph", |
| 1182 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 899 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
| 1183 base::UTF8ToUTF16(url_.host()))); | 900 base::UTF8ToUTF16(url_.host()))); |
| 1184 load_time_data->SetString( | 901 load_time_data->SetString( |
| 1185 "finalParagraph", | 902 "finalParagraph", |
| 1186 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 903 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
| 1187 } | 904 } |
| OLD | NEW |