Diff
Modified: trunk/Source/WebCore/ChangeLog (162113 => 162114)
--- trunk/Source/WebCore/ChangeLog 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebCore/ChangeLog 2014-01-16 06:42:39 UTC (rev 162114)
@@ -1,3 +1,27 @@
+2014-01-15 Benjamin Poulain <[email protected]>
+
+ Move user agent code to WebCore and unify some code between OS X and iOS
+ https://bugs.webkit.org/show_bug.cgi?id=127080
+
+ Reviewed by Sam Weinig.
+
+ Move the duplicated code from WebView and WebPageProxy to two files
+ in WebCore: UserAgentMac and UserAgentIOS.
+
+ * Configurations/WebCore.xcconfig:
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/ios/UserAgentIOS.mm: Added.
+ (WebCore::platformSystemRootDirectory):
+ (WebCore::osMarketingVersion):
+ (WebCore::standardUserAgentWithApplicationName):
+ * page/mac/UserAgent.h: Added.
+ * page/mac/UserAgentMac.mm: Added.
+ (WebCore::systemMarketingVersionForUserAgentString):
+ (WebCore::standardUserAgentWithApplicationName):
+ * platform/ios/WebCoreSystemInterfaceIOS.h:
+ * platform/ios/WebCoreSystemInterfaceIOS.mm:
+
2014-01-15 Sam Weinig <[email protected]>
Fix windows build.
Modified: trunk/Source/WebCore/Configurations/WebCore.xcconfig (162113 => 162114)
--- trunk/Source/WebCore/Configurations/WebCore.xcconfig 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebCore/Configurations/WebCore.xcconfig 2014-01-16 06:42:39 UTC (rev 162114)
@@ -112,6 +112,6 @@
_javascript_CORE_PRIVATE_HEADERS_engineering = $(BUILT_PRODUCTS_DIR)/_javascript_Core.framework/PrivateHeaders;
EXCLUDED_SOURCE_FILE_NAMES = $(EXCLUDED_SOURCE_FILE_NAMES_$(PLATFORM_NAME));
-EXCLUDED_SOURCE_FILE_NAMES_iphoneos = *.tiff *Cursor.png AccessibilityObjectMac.mm AXObjectCacheMac.mm ClipboardMac.mm ColorMac.mm Cursor.cpp CursorMac.mm EditorMac.mm EventHandlerMac.mm EventLoopMac.mm GeolocationServiceMac.mm GraphicsContext3DOpenGLES.cpp IconDatabase.cpp IconMac.mm KeyEventMac.mm KillRingMac.mm LocalCurrentGraphicsContext.mm MIMETypeRegistryMac.mm MediaPlayerPrivateQTKit.mm NSScrollerImpDetails.mm NetworkStateNotifierMac.cpp PasteboardMac.mm PlatformEventFactoryMac.mm PlatformMouseEventMac.mm PlatformPasteboardMac.mm PlatformScreenMac.mm PlatformSpeechSynthesizerMac.mm PluginMainThreadScheduler.cpp RunLoopMac.mm SSLKeyGeneratorMac.cpp ScrollingCoordinatorMac.mm ScrollingStateScrollingNodeMac.mm ScrollingTreeScrollingNodeMac.mm ScrollViewMac.mm ScrollbarThemeMac.mm SharedTimerMac.mm SoundMac.mm SystemTimeMac.cpp ThemeMac.mm ThreadCheck.mm WebAccessibilityObjectWrapperMac.mm WebCoreSystemInterface.mm WebCoreURLResponse.mm WebCoreView.m WebFontCache.mm WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm WheelEventMac.mm WidgetMac.mm mac/LayerPool.mm DisplayRefreshMonitorMac.cpp;
+EXCLUDED_SOURCE_FILE_NAMES_iphoneos = *.tiff *Cursor.png AccessibilityObjectMac.mm AXObjectCacheMac.mm ClipboardMac.mm ColorMac.mm Cursor.cpp CursorMac.mm EditorMac.mm EventHandlerMac.mm EventLoopMac.mm GeolocationServiceMac.mm GraphicsContext3DOpenGLES.cpp IconDatabase.cpp IconMac.mm KeyEventMac.mm KillRingMac.mm LocalCurrentGraphicsContext.mm MIMETypeRegistryMac.mm MediaPlayerPrivateQTKit.mm NSScrollerImpDetails.mm NetworkStateNotifierMac.cpp PasteboardMac.mm PlatformEventFactoryMac.mm PlatformMouseEventMac.mm PlatformPasteboardMac.mm PlatformScreenMac.mm PlatformSpeechSynthesizerMac.mm PluginMainThreadScheduler.cpp RunLoopMac.mm SSLKeyGeneratorMac.cpp ScrollingCoordinatorMac.mm ScrollingStateScrollingNodeMac.mm ScrollingTreeScrollingNodeMac.mm ScrollViewMac.mm ScrollbarThemeMac.mm SharedTimerMac.mm SoundMac.mm SystemTimeMac.cpp ThemeMac.mm ThreadCheck.mm UserAgentMac.mm WebAccessibilityObjectWrapperMac.mm WebCoreSystemInterface.mm WebCoreURLResponse.mm WebCoreView.m WebFontCache.mm WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm WheelEventMac.mm WidgetMac.mm mac/LayerPool.mm DisplayRefreshMonitorMac.cpp;
EXCLUDED_SOURCE_FILE_NAMES_iphonesimulator = $(EXCLUDED_SOURCE_FILE_NAMES_iphoneos);
EXCLUDED_SOURCE_FILE_NAMES_macosx = *IOS.h *IOS.cpp *IOS.mm JSTouch* JSGesture* DOMGesture* DOMTouch* KillRingNone.cpp WAKAppKitStubs.h WAKClipView.h WAKResponder.h WAKScrollView.h WAKView.h WAKViewPrivate.h WAKWindow.h WKContentObservation.h WKGraphics.h WKTypes.h WKUtilities.h WKView.h WKViewPrivate.h WebCoreThread.h WebCoreThreadMessage.h WebCoreThreadRun.h WebCoreThreadSystemInterface.h;
Modified: trunk/Source/WebCore/WebCore.exp.in (162113 => 162114)
--- trunk/Source/WebCore/WebCore.exp.in 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-01-16 06:42:39 UTC (rev 162114)
@@ -2084,6 +2084,7 @@
__ZN7WebCore35contextMenuItemTagShowSpellingPanelEb
__ZN7WebCore35contextMenuItemTagShowSubstitutionsEb
__ZN7WebCore35contextMenuItemTagSubstitutionsMenuEv
+__ZN7WebCore36standardUserAgentWithApplicationNameERKN3WTF6StringES3_
__ZN7WebCore37contextMenuItemTagTransformationsMenuEv
__ZN7WebCore38contextMenuItemTagWritingDirectionMenuEv
__ZN7WebCore42contextMenuItemTagCheckGrammarWithSpellingEv
@@ -2530,7 +2531,6 @@
_wkGetDeviceClass
_wkGetPlatformNameForNavigator
_wkGetScreenScaleFactor
-_wkGetUserAgent
_wkGetVendorNameForNavigator
_wkGetVerticalGlyphsForCharacters
_wkGetViewportScreenSize
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (162113 => 162114)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-01-16 06:42:39 UTC (rev 162114)
@@ -968,6 +968,9 @@
24F54EAD101FE914000AE741 /* ApplicationCacheHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 24F54EAB101FE914000AE741 /* ApplicationCacheHost.h */; settings = {ATTRIBUTES = (); }; };
2542F4DA1166C25A00E89A86 /* UserGestureIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */; };
2542F4DB1166C25A00E89A86 /* UserGestureIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 26255F0018878DFF0006E1FD /* UserAgentIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26255EFF18878DFF0006E1FD /* UserAgentIOS.mm */; };
+ 26255F0318878E110006E1FD /* UserAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 26255F0118878E110006E1FD /* UserAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 26255F0418878E110006E1FD /* UserAgentMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26255F0218878E110006E1FD /* UserAgentMac.mm */; };
265541391489811C000DFC5D /* KeyEventCodesIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 265541371489811C000DFC5D /* KeyEventCodesIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
2655413A1489811C000DFC5D /* KeyEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 265541381489811C000DFC5D /* KeyEventIOS.mm */; };
265541521489B233000DFC5D /* CursorIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2655414B1489AA2B000DFC5D /* CursorIOS.cpp */; };
@@ -7815,6 +7818,9 @@
2527CC9516BF95DD009DDAC0 /* PlatformSpeechSynthesisUtterance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSpeechSynthesisUtterance.cpp; sourceTree = "<group>"; };
2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserGestureIndicator.cpp; sourceTree = "<group>"; };
2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserGestureIndicator.h; sourceTree = "<group>"; };
+ 26255EFF18878DFF0006E1FD /* UserAgentIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserAgentIOS.mm; sourceTree = "<group>"; };
+ 26255F0118878E110006E1FD /* UserAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserAgent.h; sourceTree = "<group>"; };
+ 26255F0218878E110006E1FD /* UserAgentMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserAgentMac.mm; sourceTree = "<group>"; };
265541371489811C000DFC5D /* KeyEventCodesIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCodesIOS.h; path = ios/KeyEventCodesIOS.h; sourceTree = "<group>"; };
265541381489811C000DFC5D /* KeyEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventIOS.mm; path = ios/KeyEventIOS.mm; sourceTree = "<group>"; };
2655414B1489AA2B000DFC5D /* CursorIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CursorIOS.cpp; path = ios/CursorIOS.cpp; sourceTree = "<group>"; };
@@ -14633,6 +14639,7 @@
children = (
FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
+ 26255EFF18878DFF0006E1FD /* UserAgentIOS.mm */,
225A16B30D5C11E900090295 /* WebEventRegion.h */,
225A16B40D5C11E900090295 /* WebEventRegion.mm */,
);
@@ -17173,6 +17180,8 @@
93C09A7E0B064EEF005ABD4D /* EventHandlerMac.mm */,
1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */,
E1C2F2481533A2120083F974 /* SettingsMac.mm */,
+ 26255F0118878E110006E1FD /* UserAgent.h */,
+ 26255F0218878E110006E1FD /* UserAgentMac.mm */,
F587854C02DE375901EA4122 /* WebCoreFrameView.h */,
);
path = mac;
@@ -25937,6 +25946,7 @@
D086FE9809D53AAB005BC74D /* UnlinkCommand.h in Headers */,
F55B3DDE1251F12D003EF269 /* URLInputType.h in Headers */,
A72763BF16689BFB002FCACB /* UserActionElementSet.h in Headers */,
+ 26255F0318878E110006E1FD /* UserAgent.h in Headers */,
078E091717D14D1C00420AA1 /* MediaStreamRegistry.h in Headers */,
656581B209D14EE6000E61D7 /* UserAgentStyleSheets.h in Headers */,
003F1FEA11E6AB43008258D9 /* UserContentTypes.h in Headers */,
@@ -29182,6 +29192,8 @@
65DF326109D1E199000BE325 /* UserAgentStyleSheetsData.cpp in Sources */,
BCACF3BC1072921A00C0C8A3 /* UserContentURLPattern.cpp in Sources */,
FFDBC048183D27B700407109 /* LineWidth.cpp in Sources */,
+ 26255F0018878DFF0006E1FD /* UserAgentIOS.mm in Sources */,
+ 26255F0418878E110006E1FD /* UserAgentMac.mm in Sources */,
2542F4DA1166C25A00E89A86 /* UserGestureIndicator.cpp in Sources */,
BCDF317B11F8D683003C5BF8 /* UserTypingGestureIndicator.cpp in Sources */,
1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */,
Added: trunk/Source/WebCore/page/ios/UserAgentIOS.mm (0 => 162114)
--- trunk/Source/WebCore/page/ios/UserAgentIOS.mm (rev 0)
+++ trunk/Source/WebCore/page/ios/UserAgentIOS.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "UserAgent.h"
+
+#import <WebCoreSystemInterface.h>
+#import <wtf/NeverDestroyed.h>
+#import <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+static NSString *platformSystemRootDirectory()
+{
+#if PLATFORM(IOS_SIMULATOR)
+ const char *simulatorRoot = getenv("IPHONE_SIMULATOR_ROOT");
+ return [NSString stringWithUTF8String:(simulatorRoot ? simulatorRoot : "/")];
+#else
+ return @"/";
+#endif
+}
+
+static NSString *osMarketingVersion()
+{
+ RetainPtr<NSDictionary> systemInfo = [[NSDictionary alloc] initWithContentsOfFile:[platformSystemRootDirectory() stringByAppendingPathComponent:@"System/Library/CoreServices/SystemVersion.plist"]];
+ NSString *productVersion = [systemInfo objectForKey:@"ProductVersion"];
+ return !productVersion ? @"" : [productVersion stringByReplacingOccurrencesOfString:@"." withString:@"_"];
+}
+
+String standardUserAgentWithApplicationName(const String& applicationName, const String& webkitVersionString)
+{
+ if (CFStringRef overrideUserAgent = wkGetUserAgent())
+ return overrideUserAgent;
+
+ // Check to see if there is a user agent override for all WebKit clients.
+ CFPropertyListRef override = CFPreferencesCopyAppValue(CFSTR("UserAgent"), CFSTR("com.apple.WebFoundation"));
+ if (override) {
+ if (CFGetTypeID(override) == CFStringGetTypeID())
+ return static_cast<NSString *>(CFBridgingRelease(override));
+ CFRelease(override);
+ }
+
+ NSString *webKitVersion = webkitVersionString;
+ CFStringRef deviceName = wkGetDeviceName();
+ CFStringRef osNameForUserAgent = wkGetOSNameForUserAgent();
+ NSString *osMarketingVersionString = osMarketingVersion();
+ if (applicationName.isEmpty())
+ return [NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU %@ %@ like Mac OS X) AppleWebKit/%@ (KHTML, like Gecko)", deviceName, osNameForUserAgent, osMarketingVersionString, webKitVersion];
+ return [NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU %@ %@ like Mac OS X) AppleWebKit/%@ (KHTML, like Gecko) %@", deviceName, osNameForUserAgent, osMarketingVersionString, webKitVersion, static_cast<NSString *>(applicationName)];
+}
+
+} // namespace WebCore.
Added: trunk/Source/WebCore/page/mac/UserAgent.h (0 => 162114)
--- trunk/Source/WebCore/page/mac/UserAgent.h (rev 0)
+++ trunk/Source/WebCore/page/mac/UserAgent.h 2014-01-16 06:42:39 UTC (rev 162114)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UserAgent_h
+#define UserAgent_h
+
+#include <wtf/text/WTFString.h>
+
+@class NSBundle;
+
+namespace WebCore {
+String standardUserAgentWithApplicationName(const String& applicationName, const String& webkitVersionString);
+}
+
+#endif // UserAgentMac_h
Added: trunk/Source/WebCore/page/mac/UserAgentMac.mm (0 => 162114)
--- trunk/Source/WebCore/page/mac/UserAgentMac.mm (rev 0)
+++ trunk/Source/WebCore/page/mac/UserAgentMac.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "UserAgent.h"
+
+#import <WebCore/SystemVersionMac.h>
+#import <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+#if defined(__ppc__) || defined(__ppc64__)
+#define PROCESSOR "PPC"
+#elif defined(__i386__) || defined(__x86_64__)
+#define PROCESSOR "Intel"
+#else
+#error Unknown architecture
+#endif
+
+static NSString *systemMarketingVersionForUserAgentString()
+{
+ // Use underscores instead of dots because when we first added the Mac OS X version to the user agent string
+ // we were concerned about old DHTML libraries interpreting "4." as Netscape 4. That's no longer a concern for us
+ // but we're sticking with the underscores for compatibility with the format used by older versions of Safari.
+ return [systemMarketingVersion() stringByReplacingOccurrencesOfString:@"." withString:@"_"];
+}
+
+String standardUserAgentWithApplicationName(const String& applicationName, const String& webKitVersionString)
+{
+ String osVersion = systemMarketingVersionForUserAgentString();
+
+ if (applicationName.isEmpty())
+ return makeString("Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X ", osVersion, ") AppleWebKit/", webKitVersionString, " (KHTML, like Gecko)");
+ return makeString("Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X ", osVersion, ") AppleWebKit/", webKitVersionString, " (KHTML, like Gecko) ", applicationName);
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.h (162113 => 162114)
--- trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.h 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.h 2014-01-16 06:42:39 UTC (rev 162114)
@@ -68,6 +68,8 @@
}
extern CFStringRef (*wkGetUserAgent)(void);
+extern CFStringRef (*wkGetDeviceName)(void);
+extern CFStringRef (*wkGetOSNameForUserAgent)(void);
extern CFStringRef (*wkGetPlatformNameForNavigator)(void);
extern CFStringRef (*wkGetVendorNameForNavigator)(void);
Modified: trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm (162113 => 162114)
--- trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -139,5 +139,7 @@
#endif
CFStringRef (*wkGetUserAgent)(void);
+CFStringRef (*wkGetDeviceName)(void);
+CFStringRef (*wkGetOSNameForUserAgent)(void);
CFStringRef (*wkGetPlatformNameForNavigator)(void);
CFStringRef (*wkGetVendorNameForNavigator)(void);
Modified: trunk/Source/WebKit/mac/ChangeLog (162113 => 162114)
--- trunk/Source/WebKit/mac/ChangeLog 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit/mac/ChangeLog 2014-01-16 06:42:39 UTC (rev 162114)
@@ -1,3 +1,17 @@
+2014-01-15 Benjamin Poulain <[email protected]>
+
+ Move user agent code to WebCore and unify some code between OS X and iOS
+ https://bugs.webkit.org/show_bug.cgi?id=127080
+
+ Reviewed by Sam Weinig.
+
+ * WebCoreSupport/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface):
+ * WebView/WebView.mm:
+ (userVisibleWebKitVersionString):
+ (+[WebView _standardUserAgentWithApplicationName:]):
+ (-[WebView _setUIWebViewUserAgentWithBuildVersion:]):
+
2014-01-15 Joseph Pecoraro <[email protected]>
[iOS] Clean up REMOTE_INSPECTOR code in OpenSource after the iOS merge
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm (162113 => 162114)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -237,6 +237,8 @@
#if PLATFORM(IOS)
INIT(GetUserAgent);
+ INIT(GetDeviceName);
+ INIT(GetOSNameForUserAgent);
INIT(GetPlatformNameForNavigator);
INIT(GetVendorNameForNavigator);
#endif
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (162113 => 162114)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -168,9 +168,9 @@
#import <WebCore/SecurityPolicy.h>
#import <WebCore/Settings.h>
#import <WebCore/StyleProperties.h>
-#import <WebCore/SystemVersionMac.h>
#import <WebCore/TextResourceDecoder.h>
#import <WebCore/ThreadCheck.h>
+#import <WebCore/UserAgent.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebCore/WebCoreView.h>
#import <WebCore/Widget.h>
@@ -305,16 +305,6 @@
using namespace Inspector;
using namespace WebCore;
-#if defined(__ppc__) || defined(__ppc64__)
-#define PROCESSOR "PPC"
-#elif defined(__i386__) || defined(__x86_64__)
-#define PROCESSOR "Intel"
-#else
-#if !PLATFORM(IOS)
-#error Unknown architecture
-#endif
-#endif
-
#define FOR_EACH_RESPONDER_SELECTOR(macro) \
macro(alignCenter) \
macro(alignJustified) \
@@ -683,81 +673,25 @@
@implementation WebView (WebPrivate)
-#if !PLATFORM(IOS)
-static NSString *systemMarketingVersionForUserAgentString()
+static String userVisibleWebKitVersionString()
{
- // Use underscores instead of dots because when we first added the Mac OS X version to the user agent string
- // we were concerned about old DHTML libraries interpreting "4." as Netscape 4. That's no longer a concern for us
- // but we're sticking with the underscores for compatibility with the format used by older versions of Safari.
- return [systemMarketingVersion() stringByReplacingOccurrencesOfString:@"." withString:@"_"];
-}
-#endif
-
-static NSString *createUserVisibleWebKitVersionString()
-{
// If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
// string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
NSString *fullVersion = [[NSBundle bundleForClass:[WebView class]] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
if (nonDigitRange.location == NSNotFound && fullVersion.length > 3)
- return [[fullVersion substringFromIndex:fullVersion.length - 3] copy];
+ return [fullVersion substringFromIndex:fullVersion.length - 3];
if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
- return [[fullVersion substringFromIndex:nonDigitRange.location - 3] copy];
- return [fullVersion copy];
+ return [fullVersion substringFromIndex:nonDigitRange.location - 3];
+ return fullVersion;
}
-#if !PLATFORM(IOS)
+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName
{
- // Note: Do *not* move the initialization of osVersion nor webKitVersion into the declaration.
- // Garbage collection won't correctly mark the global variable in that case <rdar://problem/5733674>.
- static NSString *osVersion;
- static NSString *webKitVersion;
- if (!osVersion)
- osVersion = [systemMarketingVersionForUserAgentString() retain];
- if (!webKitVersion)
- webKitVersion = createUserVisibleWebKitVersionString();
- if ([applicationName length])
- return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X %@) AppleWebKit/%@ (KHTML, like Gecko) %@", osVersion, webKitVersion, applicationName];
- return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X %@) AppleWebKit/%@ (KHTML, like Gecko)", osVersion, webKitVersion];
+ return standardUserAgentWithApplicationName(applicationName, userVisibleWebKitVersionString());
}
-#else
-+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName osMarketingVersion:(NSString *)osMarketingVersion
-{
- // Check to see if there is a user agent override for all WebKit clients.
- CFPropertyListRef override = CFPreferencesCopyAppValue(CFSTR("UserAgent"), CFSTR("com.apple.WebFoundation"));
- if (override) {
- if (CFGetTypeID(override) == CFStringGetTypeID())
- return (NSString *)CFBridgingRelease(override);
- CFRelease(override);
- }
- static NSString *webKitVersion;
- if (!webKitVersion)
- webKitVersion = createUserVisibleWebKitVersionString();
- if ([applicationName length])
- return [NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU %@ %@ like Mac OS X) AppleWebKit/%@ (KHTML, like Gecko) %@", WKGetDeviceName(), WKGetOSNameForUserAgent(), osMarketingVersion, webKitVersion, applicationName];
- return [NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU %@ %@ like Mac OS X) AppleWebKit/%@ (KHTML, like Gecko)", WKGetDeviceName(), WKGetOSNameForUserAgent(), osMarketingVersion, webKitVersion];
-}
-
-+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName
-{
- static NSString *osMarketingVersion;
- if (!osMarketingVersion) {
-#if !PLATFORM(IOS_SIMULATOR)
- NSDictionary *systemInfo = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
-#else
- NSString *rootDirectory = [NSString stringWithUTF8String:WebKitPlatformSystemRootDirectory()];
- NSDictionary *systemInfo = [[NSDictionary alloc] initWithContentsOfFile:[rootDirectory stringByAppendingPathComponent:@"System/Library/CoreServices/SystemVersion.plist"]];
-#endif
- NSString *productVersion = [systemInfo objectForKey:@"ProductVersion"];
- // Due to <rdar://problem/3787996>, we must use something other than periods to delimit the marketing version. Using underscores to match Leopard's new convention.
- osMarketingVersion = !productVersion ? @"" : [[productVersion stringByReplacingOccurrencesOfString:@"." withString:@"_"] retain];
- [systemInfo release];
- }
- return [self _standardUserAgentWithApplicationName:applicationName osMarketingVersion:osMarketingVersion];
-}
-
+#if PLATFORM(IOS)
- (void)_setBrowserUserAgentProductVersion:(NSString *)productVersion buildVersion:(NSString *)buildVersion bundleVersion:(NSString *)bundleVersion
{
[self setApplicationNameForUserAgent:[NSString stringWithFormat:@"Version/%@ Mobile/%@ Safari/%@", productVersion, buildVersion, bundleVersion]];
@@ -767,7 +701,6 @@
{
[self setApplicationNameForUserAgent:[@"Mobile/" stringByAppendingString:buildVersion]];
}
-
#endif // PLATFORM(IOS)
+ (void)_reportException:(JSValueRef)exception inContext:(JSContextRef)context
Modified: trunk/Source/WebKit2/ChangeLog (162113 => 162114)
--- trunk/Source/WebKit2/ChangeLog 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit2/ChangeLog 2014-01-16 06:42:39 UTC (rev 162114)
@@ -1,3 +1,18 @@
+2014-01-15 Benjamin Poulain <[email protected]>
+
+ Move user agent code to WebCore and unify some code between OS X and iOS
+ https://bugs.webkit.org/show_bug.cgi?id=127080
+
+ Reviewed by Sam Weinig.
+
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::userVisibleWebKitVersionString):
+ (WebKit::WebPageProxy::standardUserAgent):
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::standardUserAgent):
+ * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface):
+
2014-01-15 Eunmi Lee <[email protected]>
[EFL][WK2] Use timestamp when event occurs for touch events.
Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (162113 => 162114)
--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -33,6 +33,7 @@
#import "WebPageMessages.h"
#import "WebProcessProxy.h"
#import <WebCore/NotImplemented.h>
+#import <WebCore/UserAgent.h>
#import <WebCore/SharedBuffer.h>
using namespace WebCore;
@@ -46,15 +47,22 @@
#endif
}
-String WebPageProxy::standardUserAgent(const String&)
+static String userVisibleWebKitVersionString()
{
- if (CFStringRef overrideUserAgent = WKGetUserAgent())
- return overrideUserAgent;
+ // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
+ // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
+ NSString *fullVersion = [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
+ NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
+ if (nonDigitRange.location == NSNotFound && fullVersion.length > 3)
+ return [fullVersion substringFromIndex:fullVersion.length - 3];
+ if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
+ return [fullVersion substringFromIndex:nonDigitRange.location - 3];
+ return fullVersion;
+}
- notImplemented();
-
- // Just return the iOS 7 user agent for now.
- return [NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU %@ 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B489 Safari/9537.53", WKGetDeviceName(), WKGetOSNameForUserAgent()];
+String WebPageProxy::standardUserAgent(const String& applicationName)
+{
+ return standardUserAgentWithApplicationName(applicationName, userVisibleWebKitVersionString());
}
void WebPageProxy::getIsSpeaking(bool&)
Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (162113 => 162114)
--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -43,8 +43,8 @@
#import <WebCore/DictationAlternative.h>
#import <WebCore/GraphicsLayer.h>
#import <WebCore/SharedBuffer.h>
-#import <WebCore/SystemVersionMac.h>
#import <WebCore/TextAlternativeWithRange.h>
+#import <WebCore/UserAgent.h>
#import <WebKitSystemInterface.h>
#import <mach-o/dyld.h>
#import <wtf/NeverDestroyed.h>
@@ -75,22 +75,6 @@
#endif
}
-#if defined(__ppc__) || defined(__ppc64__)
-#define PROCESSOR "PPC"
-#elif defined(__i386__) || defined(__x86_64__)
-#define PROCESSOR "Intel"
-#else
-#error Unknown architecture
-#endif
-
-static NSString *systemMarketingVersionForUserAgentString()
-{
- // Use underscores instead of dots because when we first added the Mac OS X version to the user agent string
- // we were concerned about old DHTML libraries interpreting "4." as Netscape 4. That's no longer a concern for us
- // but we're sticking with the underscores for compatibility with the format used by older versions of Safari.
- return [systemMarketingVersion() stringByReplacingOccurrencesOfString:@"." withString:@"_"];
-}
-
static String userVisibleWebKitVersionString()
{
// If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
@@ -106,12 +90,7 @@
String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
{
- static NeverDestroyed<String> osVersion(systemMarketingVersionForUserAgentString());
- static NeverDestroyed<String> webKitVersion(userVisibleWebKitVersionString());
-
- if (applicationNameForUserAgent.isEmpty())
- return makeString("Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X ", osVersion.get(), ") AppleWebKit/", webKitVersion.get(), " (KHTML, like Gecko)");
- return makeString("Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X ", osVersion.get(), ") AppleWebKit/", webKitVersion.get(), " (KHTML, like Gecko) ", applicationNameForUserAgent);
+ return standardUserAgentWithApplicationName(applicationNameForUserAgent, userVisibleWebKitVersionString());
}
void WebPageProxy::getIsSpeaking(bool& isSpeaking)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (162113 => 162114)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm 2014-01-16 05:27:16 UTC (rev 162113)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm 2014-01-16 06:42:39 UTC (rev 162114)
@@ -203,6 +203,14 @@
INIT(CGPathAddRoundedRect);
INIT(CFURLRequestAllowAllPostCaching);
+#if PLATFORM(IOS)
+ INIT(GetUserAgent);
+ INIT(GetDeviceName);
+ INIT(GetOSNameForUserAgent);
+ INIT(GetPlatformNameForNavigator);
+ INIT(GetVendorNameForNavigator);
+#endif
+
#if !PLATFORM(IOS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
INIT(NSElasticDeltaForTimeDelta);
INIT(NSElasticDeltaForReboundDelta);