Changeset 275590 in webkit
- Timestamp:
- Apr 7, 2021 12:40:41 AM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r275587 r275590 1 2021-04-07 Stephan Szabo <stephan.szabo@sony.com> 2 3 [PlayStation] Provide a non-empty User Agent 4 https://bugs.webkit.org/show_bug.cgi?id=224216 5 6 Reviewed by Ross Kirsling. 7 8 Add non-empty implementation of User Agent code for port. 9 10 * platform/playstation/UserAgentPlayStation.cpp: 11 1 12 2021-04-06 Myles C. Maxfield <mmaxfield@apple.com> 2 13 -
trunk/Source/WebCore/platform/playstation/UserAgentPlayStation.cpp
r254526 r275590 1 1 /* 2 * Copyright (C) 20 18Sony Interactive Entertainment Inc.2 * Copyright (C) 2021 Sony Interactive Entertainment Inc. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "UserAgent.h" 28 28 29 #include <wtf/NeverDestroyed.h> 30 #include <wtf/URL.h> 31 #include <wtf/text/StringBuilder.h> 32 33 // WARNING! WARNING! WARNING! 34 // 35 // The user agent is ludicrously fragile. The most innocent change can 36 // and will break websites. Read the git log for this file and 37 // WebCore/platform/glib/UserAgentGLib.cpp carefully before changing 38 // user agent construction. You have been warned. 39 29 40 namespace WebCore { 30 41 31 String standardUserAgent(const String&, const String&)42 static String getSystemSoftwareName() 32 43 { 33 return emptyString(); 44 #if HAS_GETENV_NP 45 char buf[32]; 46 if (!getenv_np("SYSTEM_SOFTWARE_NAME", buf, sizeof(buf))) 47 return buf; 48 #endif 49 return "PlayStation"; 50 } 51 52 static String getSystemSoftwareVersion() 53 { 54 #if HAS_GETENV_NP 55 char buf[32]; 56 if (!getenv_np("SYSTEM_SOFTWARE_VERSION", buf, sizeof(buf))) 57 return buf; 58 #endif 59 return "0.00"; 60 } 61 62 static const String platformForUAString() 63 { 64 static NeverDestroyed<const String> uaSystemSoftwareName(getSystemSoftwareName()); 65 return uaSystemSoftwareName; 66 } 67 68 static const String platformVersionForUAString() 69 { 70 static NeverDestroyed<const String> uaSystemSoftwareVersion(getSystemSoftwareVersion()); 71 return uaSystemSoftwareVersion; 72 } 73 74 static constexpr const char* versionForUAString() 75 { 76 // https://bugs.webkit.org/show_bug.cgi?id=180365 77 return "605.1.15"; 78 } 79 80 static String buildUserAgentString() 81 { 82 StringBuilder uaString; 83 uaString.appendLiteral("Mozilla/5.0 "); 84 uaString.append('('); 85 86 uaString.appendLiteral("PlayStation; "); 87 88 uaString.append(platformForUAString()); 89 uaString.append('/'); 90 uaString.append(platformVersionForUAString()); 91 92 uaString.appendLiteral(") AppleWebKit/"); 93 uaString.append(versionForUAString()); 94 uaString.appendLiteral(" (KHTML, like Gecko) "); 95 96 // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See 97 // https://bugs.webkit.org/show_bug.cgi?id=133403 for details. 98 uaString.appendLiteral("Version/14.0 Safari/"); 99 uaString.append(versionForUAString()); 100 101 return uaString.toString(); 102 } 103 104 static const String standardUserAgentStatic() 105 { 106 static NeverDestroyed<const String> uaStatic(buildUserAgentString()); 107 return uaStatic; 108 } 109 110 String standardUserAgent(const String& applicationName, const String& applicationVersion) 111 { 112 // Create a default user agent string with a liberal interpretation of 113 // https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference 114 // 115 // Forming a functional user agent is really difficult. We must mention Safari, because some 116 // sites check for that when detecting WebKit browsers. Additionally some sites assume that 117 // browsers that are "Safari" but not running on OS X are the Safari iOS browser. Getting this 118 // wrong can cause sites to load the wrong JavaScript, CSS, or custom fonts. In some cases 119 // sites won't load resources at all. 120 if (applicationName.isEmpty()) 121 return standardUserAgentStatic(); 122 123 String finalApplicationVersion = applicationVersion; 124 if (finalApplicationVersion.isEmpty()) 125 finalApplicationVersion = versionForUAString(); 126 127 return makeString(standardUserAgentStatic(), ' ', applicationName, '/', finalApplicationVersion); 34 128 } 35 129 36 130 String standardUserAgentForURL(const URL&) 37 131 { 38 return emptyString();132 return standardUserAgentStatic(); 39 133 } 40 134
Note: See TracChangeset
for help on using the changeset viewer.