|
33 | 33 | #import <wtf/StdLibExtras.h> |
34 | 34 | #import <wtf/text/MakeString.h> |
35 | 35 |
|
| 36 | +NSString * const SSBProviderGoogle = @"SSBProviderGoogle"; |
| 37 | +NSString * const SSBProviderTencent = @"SSBProviderTencent"; |
| 38 | +NSString * const SSBProviderApple = @"SSBProviderApple"; |
| 39 | + |
36 | 40 | namespace WebKit { |
37 | 41 |
|
38 | 42 | #if HAVE(SAFE_BROWSING) |
39 | 43 |
|
40 | 44 | static String malwareDetailsBase(SSBServiceLookupResult *result) |
41 | 45 | { |
42 | | -#if HAVE(SAFE_BROWSING_RESULT_DETAILS) |
43 | 46 | return result.malwareDetailsBaseURLString; |
44 | | -#else |
45 | | - if ([result.provider isEqualToString:SSBProviderTencent]) |
46 | | - return "https://www.urlsec.qq.com/check.html?tpl=safari"_s; |
47 | | - return "https://google.com/safebrowsing/diagnostic?tpl=safari"_s; |
48 | | -#endif |
49 | 47 | } |
50 | 48 |
|
51 | 49 | static NSURL *learnMoreURL(SSBServiceLookupResult *result) |
52 | 50 | { |
53 | | -#if HAVE(SAFE_BROWSING_RESULT_DETAILS) |
54 | 51 | return result.learnMoreURL; |
55 | | -#else |
56 | | - if ([result.provider isEqualToString:SSBProviderTencent]) |
57 | | - return [NSURL URLWithString:@"https://www.urlsec.qq.com/standard/s1.html?tpl=safari"]; |
58 | | - return [NSURL URLWithString:@"https://www.google.com/support/bin/answer.py?answer=106318"]; |
59 | | -#endif |
60 | 52 | } |
61 | 53 |
|
62 | 54 | static String reportAnErrorBase(SSBServiceLookupResult *result) |
63 | 55 | { |
64 | | -#if HAVE(SAFE_BROWSING_RESULT_DETAILS) |
65 | 56 | return result.reportAnErrorBaseURLString; |
66 | | -#else |
67 | | - if ([result.provider isEqualToString:SSBProviderTencent]) |
68 | | - return "https://www.urlsec.qq.com/complain.html?tpl=safari"_s; |
69 | | - return "https://www.google.com/safebrowsing/report_error/?tpl=safari"_s; |
70 | | -#endif |
71 | 57 | } |
72 | 58 |
|
73 | | -static String localizedProvider(SSBServiceLookupResult *result) |
| 59 | +static String localizedProviderDisplayName(SSBServiceLookupResult *result) |
74 | 60 | { |
75 | | -#if HAVE(SAFE_BROWSING_RESULT_DETAILS) |
76 | 61 | return result.localizedProviderDisplayName; |
77 | | -#else |
78 | | - if ([result.provider isEqualToString:SSBProviderTencent]) |
79 | | - return WEB_UI_NSSTRING(@"Tencent Safe Browsing", "Tencent Safe Browsing"); |
80 | | - return WEB_UI_NSSTRING(@"Google Safe Browsing", "Google Safe Browsing"); |
81 | | -#endif |
| 62 | +} |
| 63 | + |
| 64 | +static String localizedProviderShortName(SSBServiceLookupResult *result) |
| 65 | +{ |
| 66 | + if ([result respondsToSelector:@selector(localizedProviderShortName)]) |
| 67 | + return result.localizedProviderShortName; |
| 68 | + if ([result.provider isEqual:SSBProviderGoogle]) |
| 69 | + return "Google"_s; |
| 70 | + if ([result.provider isEqual:SSBProviderTencent]) |
| 71 | + return "Tencent"_s; |
| 72 | + if ([result.provider isEqual:SSBProviderApple]) |
| 73 | + return "Apple"_s; |
| 74 | + ASSERT_NOT_REACHED(); |
| 75 | + return ""_s; |
82 | 76 | } |
83 | 77 |
|
84 | 78 |
|
@@ -151,20 +145,22 @@ static void addLinkAndReplace(NSMutableAttributedString *string, NSString *toRep |
151 | 145 | if (result.isPhishing) { |
152 | 146 | NSString *phishingDescription = WEB_UI_NSSTRING(@"Warnings are shown for websites that have been reported as deceptive. Deceptive websites try to trick you into believing they are legitimate websites you trust.", "Phishing warning description"); |
153 | 147 | NSString *learnMore = WEB_UI_NSSTRING(@"Learn more…", "Action from safe browsing warning"); |
154 | | - NSString *phishingActions = WEB_UI_NSSTRING(@"If you believe this website is safe, you can %report-an-error%. Or, if you understand the risks involved, you can %bypass-link%.", "Phishing warning description"); |
| 148 | + NSString *phishingActions = WEB_UI_NSSTRING(@"This website was reported as deceptive by %provider-display-name%. If you believe this website is safe, you can %report-an-error% to %provider%. Or, if you understand the risks involved, you can %bypass-link%.", "Phishing warning description"); |
155 | 149 | NSString *reportAnError = WEB_UI_NSSTRING(@"report an error", "Action from safe browsing warning"); |
156 | 150 | NSString *visitUnsafeWebsite = WEB_UI_NSSTRING(@"visit this unsafe website", "Action from safe browsing warning"); |
157 | 151 |
|
158 | 152 | auto attributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@\n\n%@", phishingDescription, learnMore, phishingActions]]); |
159 | 153 | addLinkAndReplace(attributedString.get(), learnMore, learnMore, learnMoreURL(result)); |
| 154 | + replace(attributedString.get(), @"%provider-display-name%", localizedProviderDisplayName(result)); |
| 155 | + replace(attributedString.get(), @"%provider%", localizedProviderShortName(result)); |
160 | 156 | addLinkAndReplace(attributedString.get(), @"%report-an-error%", reportAnError, reportAnErrorURL(url, result)); |
161 | 157 | addLinkAndReplace(attributedString.get(), @"%bypass-link%", visitUnsafeWebsite, BrowsingWarning::visitUnsafeWebsiteSentinel()); |
162 | 158 | return attributedString.autorelease(); |
163 | 159 | } |
164 | 160 |
|
165 | 161 | auto malwareOrUnwantedSoftwareDetails = [&] (NSString *description, NSString *statusStringToReplace, bool confirmMalware) { |
166 | 162 | auto malwareDescription = adoptNS([[NSMutableAttributedString alloc] initWithString:description]); |
167 | | - replace(malwareDescription.get(), @"%safeBrowsingProvider%", localizedProvider(result)); |
| 163 | + replace(malwareDescription.get(), @"%safeBrowsingProvider%", localizedProviderDisplayName(result)); |
168 | 164 | auto statusLink = adoptNS([[NSMutableAttributedString alloc] initWithString:WEB_UI_NSSTRING(@"the status of “%site%”", "Part of malware description")]); |
169 | 165 | replace(statusLink.get(), @"%site%", url.host().toString()); |
170 | 166 | addLinkAndReplace(malwareDescription.get(), statusStringToReplace, [statusLink string], malwareDetailsURL(url, result)); |
|
0 commit comments