From 81bc750723a18f21cd17d1b173cd2a4dda9cea6e Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 24 May 2011 11:24:40 +0100 Subject: Merge WebKit at r80534: Intial merge by Git Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61 --- Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp | 52 +++++------------------- 1 file changed, 10 insertions(+), 42 deletions(-) (limited to 'Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp') diff --git a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp index f70363c..186ad44 100644 --- a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp @@ -26,8 +26,8 @@ #include "config.h" #include "WebPageProxy.h" +#include "resource.h" #include -#include #include #include #include @@ -62,53 +62,21 @@ static String windowsVersion() static String userVisibleWebKitVersionString() { - String versionStr = "420+"; - void* data = 0; + LPWSTR buildNumberStringPtr; + if (!::LoadStringW(instanceHandle(), BUILD_NUMBER, reinterpret_cast(&buildNumberStringPtr), 0) || !buildNumberStringPtr) + return "534+"; - struct LANGANDCODEPAGE { - WORD wLanguage; - WORD wCodePage; - } *lpTranslate; - - TCHAR path[MAX_PATH]; - ::GetModuleFileName(instanceHandle(), path, WTF_ARRAY_LENGTH(path)); - DWORD handle; - DWORD versionSize = ::GetFileVersionInfoSize(path, &handle); - if (!versionSize) - goto exit; - data = fastMalloc(versionSize); - if (!data) - goto exit; - if (!::GetFileVersionInfo(path, 0, versionSize, data)) - goto exit; - UINT cbTranslate; - if (!::VerQueryValue(data, TEXT("\\VarFileInfo\\Translation"), (LPVOID*)&lpTranslate, &cbTranslate)) - goto exit; - TCHAR key[256]; - _stprintf_s(key, WTF_ARRAY_LENGTH(key), TEXT("\\StringFileInfo\\%04x%04x\\ProductVersion"), lpTranslate[0].wLanguage, lpTranslate[0].wCodePage); - LPCTSTR productVersion; - UINT productVersionLength; - if (!::VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&productVersion, &productVersionLength)) - goto exit; - versionStr = String(productVersion, productVersionLength - 1); - -exit: - if (data) - fastFree(data); - return versionStr; + return buildNumberStringPtr; } String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent) { - DEFINE_STATIC_LOCAL(String, osVersion, (windowsVersion())); - DEFINE_STATIC_LOCAL(String, webKitVersion, (userVisibleWebKitVersionString())); - - // FIXME: We should upate the user agent if the default language changes. - String language = defaultLanguage(); + DEFINE_STATIC_LOCAL(String, osVersion, (windowsVersion())); + DEFINE_STATIC_LOCAL(String, webKitVersion, (userVisibleWebKitVersionString())); - if (applicationNameForUserAgent.isEmpty()) - return makeString("Mozilla/5.0 (Windows; U; ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)"); - return makeString("Mozilla/5.0 (Windows; U; ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent); + if (applicationNameForUserAgent.isEmpty()) + return makeString("Mozilla/5.0 (", osVersion, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)"); + return makeString("Mozilla/5.0 (", osVersion, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent); } } // namespace WebKit -- cgit v1.1