Add UA string tags for Windows 64.
authorpkasting@chromium.org <pkasting@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2011 06:31:32 +0000 (06:31 +0000)
committerpkasting@chromium.org <pkasting@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2011 06:31:32 +0000 (06:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=55226

Reviewed by Ryosuke Niwa.

* StringsNotToBeLocalized.txt:
* platform/win/SystemInfo.cpp:
(WebCore::osVersionForUAString):
(WebCore::isWOW64):
(WebCore::processorArchitecture):
(WebCore::architectureTokenForUAString):
(WebCore::windowsVersionForUAString):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80693 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/StringsNotToBeLocalized.txt
Source/WebCore/platform/win/SystemInfo.cpp

index a4ec995..3d627b4 100644 (file)
@@ -1,5 +1,20 @@
 2011-03-09  Peter Kasting  <pkasting@google.com>
 
+        Reviewed by Ryosuke Niwa.
+
+        Add UA string tags for Windows 64.
+        https://bugs.webkit.org/show_bug.cgi?id=55226
+
+        * StringsNotToBeLocalized.txt:
+        * platform/win/SystemInfo.cpp:
+        (WebCore::osVersionForUAString):
+        (WebCore::isWOW64):
+        (WebCore::processorArchitecture):
+        (WebCore::architectureTokenForUAString):
+        (WebCore::windowsVersionForUAString):
+
+2011-03-09  Peter Kasting  <pkasting@google.com>
+
         Unreviewed, attempted build fix.
 
         * WebCore.pri: Try to update include path for Qt Windows build.
index bde82cb..d10a2e1 100644 (file)
@@ -99,6 +99,9 @@
 "://"
 ":/?#"
 "; "
+"; WOW64"
+"; Win64; x64"
+"; Win64; IA64"
 "<!"
 "<%@ %@>"
 "<?"
 "WebViewWindowClass"
 "WebWorkersPrivate"
 "Windows "
-"Windows CE"
-"Windows CE "
-"Windows CE .NET"
 "Windows 3.1"
 "Windows 95"
 "Windows 98"
 "Windows 98; Win 9x 4.90"
-"WinNT4.0"
+"Windows CE"
+"Windows CE "
+"Windows CE .NET"
 "Windows NT "
+"WinNT4.0"
 "WmvPlugin"
 "XSL"
 "XXXXXX-"
 "javascript:"
 "jpeg"
 "js"
+"kernel32.dll"
 "kioskmode"
 "ks_c_5601-1987"
 "kungfoo.tv.ecto"
index 54ffd9a..83d6d47 100644 (file)
@@ -86,7 +86,7 @@ WindowsVersion windowsVersion(int* major, int* minor)
     return version;
 }
 
-String windowsVersionForUAString()
+static String osVersionForUAString()
 {
     int major, minor;
     WindowsVersion version = windowsVersion(&major, &minor);
@@ -113,4 +113,65 @@ String windowsVersionForUAString()
     return makeString(familyName, String::number(major), '.', String::number(minor));
 }
 
+static bool isWOW64()
+{
+    static bool initialized = false;
+    static bool wow64 = false;
+
+    if (!initialized) {
+        initialized = true;
+        HMODULE kernel32Module = GetModuleHandleA("kernel32.dll");
+        if (!kernel32Module)
+            return wow64;
+        typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL);
+        IsWow64ProcessFunc isWOW64Process = reinterpret_cast<IsWow64ProcessFunc>(GetProcAddress(kernel32Module, "IsWow64Process"));
+        if (isWOW64Process) {
+            BOOL result = FALSE;
+            wow64 = isWOW64Process(GetCurrentProcess(), &result) && result;
+        }
+    }
+
+    return wow64;
+}
+
+static WORD processorArchitecture()
+{
+    static bool initialized = false;
+    static WORD architecture = PROCESSOR_ARCHITECTURE_INTEL;
+
+    if (!initialized) {
+        initialized = true;
+        HMODULE kernel32Module = GetModuleHandleA("kernel32.dll");
+        if (!kernel32Module)
+            return architecture;
+        typedef VOID (WINAPI* GetNativeSystemInfoFunc)(LPSYSTEM_INFO);
+        GetNativeSystemInfoFunc getNativeSystemInfo = reinterpret_cast<GetNativeSystemInfoFunc>(GetProcAddress(kernel32Module, "GetNativeSystemInfo"));
+        if (getNativeSystemInfo) {
+            SYSTEM_INFO systemInfo = {0};
+            getNativeSystemInfo(&systemInfo);
+            architecture = systemInfo.wProcessorArchitecture;
+        }
+    }
+
+    return architecture;
+}
+
+static String architectureTokenForUAString()
+{
+#if !OS(WINCE)
+    if (isWOW64())
+        return "; WOW64";
+    if (processorArchitecture() == PROCESSOR_ARCHITECTURE_AMD64)
+        return "; Win64; x64";
+    if (processorArchitecture() == PROCESSOR_ARCHITECTURE_IA64)
+        return "; Win64; IA64";
+#endif
+    return String();
+}
+
+String windowsVersionForUAString()
+{
+    return makeString(osVersionForUAString(), architectureTokenForUAString());
+}
+
 } // namespace WebCore