Title: [170653] trunk/Source/WebKit2
Revision
170653
Author
[email protected]
Date
2014-07-01 11:41:27 -0700 (Tue, 01 Jul 2014)

Log Message

[Cocoa] WebProcess doesn't follow localization of UI process when run as a service
https://bugs.webkit.org/show_bug.cgi?id=133126
<rdar://problem/13396515>

Patch by Alexey Proskuryakov.
Reviewed by Tim Horton.

* Configurations/WebContentService.Development.xcconfig:
* Configurations/WebContentService.xcconfig:
Figure out which of the two keys to use. CFBundleAllowMixedLocalizations was
a workaround before we got CFBundleFollowParentLocalization, and these cannot be
used together.

* UIProcess/Launcher/mac/ProcessLauncherMac.mm: (WebKit::connectToService): Set up
XPC bootstrap for CFBundle to use.

* WebKit2.xcodeproj/project.pbxproj: Added a script that applies the key to Info.plist.

* WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-OSX.plist:
* WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist:
* WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist:
* WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist:
Removed CFBundleAllowMixedLocalizations, we now add it programmatically.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170652 => 170653)


--- trunk/Source/WebKit2/ChangeLog	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-01 18:41:27 UTC (rev 170653)
@@ -1,3 +1,29 @@
+2014-07-01  Alexey Proskuryakov  <[email protected]>
+
+        [Cocoa] WebProcess doesn't follow localization of UI process when run as a service
+        https://bugs.webkit.org/show_bug.cgi?id=133126
+        <rdar://problem/13396515>
+
+        Patch by Alexey Proskuryakov.
+        Reviewed by Tim Horton.
+
+        * Configurations/WebContentService.Development.xcconfig:
+        * Configurations/WebContentService.xcconfig:
+        Figure out which of the two keys to use. CFBundleAllowMixedLocalizations was
+        a workaround before we got CFBundleFollowParentLocalization, and these cannot be
+        used together.
+
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm: (WebKit::connectToService): Set up
+        XPC bootstrap for CFBundle to use.
+
+        * WebKit2.xcodeproj/project.pbxproj: Added a script that applies the key to Info.plist.
+
+        * WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-OSX.plist:
+        * WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist:
+        * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist:
+        * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist:
+        Removed CFBundleAllowMixedLocalizations, we now add it programmatically.
+
 2014-07-01  Alex Christensen  <[email protected]>
 
         [iOS] Unreviewed build fix after r170640.

Modified: trunk/Source/WebKit2/Configurations/WebContentService.Development.xcconfig (170652 => 170653)


--- trunk/Source/WebKit2/Configurations/WebContentService.Development.xcconfig	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/Configurations/WebContentService.Development.xcconfig	2014-07-01 18:41:27 UTC (rev 170653)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+// Copyright (C) 2012-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
@@ -31,6 +31,14 @@
 INFOPLIST_FILE_iphoneos = WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist;
 INFOPLIST_FILE_iphonesimulator = $(INFOPLIST_FILE_iphoneos);
 
+BUNDLE_LOCALIZATION_KEY = $(BUNDLE_LOCALIZATION_KEY_$(PLATFORM_NAME));
+BUNDLE_LOCALIZATION_KEY_iphoneos = CFBundleFollowParentLocalization;
+BUNDLE_LOCALIZATION_KEY_iphonesimulator = CFBundleFollowParentLocalization;
+BUNDLE_LOCALIZATION_KEY_macosx = $(BUNDLE_LOCALIZATION_KEY_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
+BUNDLE_LOCALIZATION_KEY_macosx_1080 = CFBundleAllowMixedLocalizations;
+BUNDLE_LOCALIZATION_KEY_macosx_1090 = CFBundleAllowMixedLocalizations;
+BUNDLE_LOCALIZATION_KEY_macosx_101000 = CFBundleFollowParentLocalization;
+
 CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*] = Configurations/WebContent-iOS.entitlements
 
 OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_VERSIONED_FRAMEWORK_PATH) $(OTHER_LDFLAGS_$(PLATFORM_NAME));

Modified: trunk/Source/WebKit2/Configurations/WebContentService.xcconfig (170652 => 170653)


--- trunk/Source/WebKit2/Configurations/WebContentService.xcconfig	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/Configurations/WebContentService.xcconfig	2014-07-01 18:41:27 UTC (rev 170653)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+// Copyright (C) 2012-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
@@ -31,6 +31,14 @@
 INFOPLIST_FILE_iphoneos = WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist;
 INFOPLIST_FILE_iphonesimulator = $(INFOPLIST_FILE_iphoneos);
 
+BUNDLE_LOCALIZATION_KEY = $(BUNDLE_LOCALIZATION_KEY_$(PLATFORM_NAME));
+BUNDLE_LOCALIZATION_KEY_iphoneos = CFBundleFollowParentLocalization;
+BUNDLE_LOCALIZATION_KEY_iphonesimulator = CFBundleFollowParentLocalization;
+BUNDLE_LOCALIZATION_KEY_macosx = $(BUNDLE_LOCALIZATION_KEY_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
+BUNDLE_LOCALIZATION_KEY_macosx_1080 = CFBundleAllowMixedLocalizations;
+BUNDLE_LOCALIZATION_KEY_macosx_1090 = CFBundleAllowMixedLocalizations;
+BUNDLE_LOCALIZATION_KEY_macosx_101000 = CFBundleFollowParentLocalization;
+
 CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*] = Configurations/WebContent-iOS.entitlements
 
 OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_VERSIONED_FRAMEWORK_PATH) $(OTHER_LDFLAGS_$(PLATFORM_NAME));

Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (170652 => 170653)


--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2014-07-01 18:41:27 UTC (rev 170653)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -29,6 +29,7 @@
 #import "DynamicLinkerEnvironmentExtractor.h"
 #import "EnvironmentVariables.h"
 #import "WebKitSystemInterface.h"
+#import <WebCore/SoftLinking.h>
 #import <crt_externs.h>
 #import <mach-o/dyld.h>
 #import <mach/machine.h>
@@ -44,12 +45,25 @@
 #import <wtf/text/WTFString.h>
 #import <xpc/xpc.h>
 
+#if __has_include(<xpc/private.h>)
+#import <xpc/private.h>
+#endif
+
 // FIXME: We should be doing this another way.
 extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, uint64_t);
 
 extern "C" void xpc_connection_set_instance(xpc_connection_t, uuid_t);
 extern "C" void xpc_dictionary_set_mach_send(xpc_object_t, const char*, mach_port_t);
 
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+extern "C" void xpc_connection_set_bootstrap(xpc_connection_t connection, xpc_object_t bootstrap);
+
+// FIXME: Soft linking is temporary, make this into a regular function call once this function is available everywhere we need.
+SOFT_LINK_FRAMEWORK(CoreFoundation)
+SOFT_LINK_OPTIONAL(CoreFoundation, _CFBundleSetupXPCBootstrap, void, unused, (xpc_object_t))
+
+#endif
+
 namespace WebKit {
 
 namespace {
@@ -191,6 +205,19 @@
     auto connection = IPC::adoptXPC(xpc_connection_create(serviceName(launchOptions, forDevelopment), 0));
     xpc_connection_set_instance(connection.get(), instanceUUID->uuid);
 
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+    // Inherit UI process localization. It can be different from child process default localization:
+    // 1. When the application and system frameworks simply have different localized resources available, we should match the application.
+    // 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
+    // 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
+    RetainPtr<CFStringRef> localization = adoptCF(WKCopyCFLocalizationPreferredName(0));
+    if (localization && _CFBundleSetupXPCBootstrapPtr()) {
+        auto initializationMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+        _CFBundleSetupXPCBootstrapPtr()(initializationMessage.get());
+        xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
+    }
+#endif
+
     // XPC requires having an event handler, even if it is not used.
     xpc_connection_set_event_handler(connection.get(), ^(xpc_object_t event) { });
     xpc_connection_resume(connection.get());
@@ -211,6 +238,7 @@
     NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
     CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
 
+    // FIXME: Switch to xpc_connection_set_bootstrap once it's available everywhere we need.
     auto bootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
     xpc_dictionary_set_string(bootstrapMessage.get(), "message-name", "bootstrap");
     xpc_dictionary_set_string(bootstrapMessage.get(), "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit"] executablePath] fileSystemRepresentation]);

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (170652 => 170653)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-07-01 18:41:27 UTC (rev 170653)
@@ -8017,6 +8017,7 @@
 				BC3DE46215A91763008D26FC /* Sources */,
 				BCDC308D15FDB99A006B6695 /* Frameworks */,
 				BC3DE46415A91763008D26FC /* Resources */,
+				E19C7DDB194A5E9100F1866F /* Add CFBundle Localization Info.plist Key */,
 			);
 			buildRules = (
 			);
@@ -8125,6 +8126,7 @@
 				BCAE9DE5160C097400A33217 /* Sources */,
 				BCAE9DE6160C097400A33217 /* Frameworks */,
 				BCAE9DE7160C097400A33217 /* Resources */,
+				E19C7DDA194A4C9500F1866F /* Add CFBundle Localization Info.plist Key */,
 			);
 			buildRules = (
 			);
@@ -8624,6 +8626,36 @@
 			shellPath = /bin/sh;
 			shellScript = "mkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit2\"\ncd \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit2\"\n\nexport WebKit2=\"${SRCROOT}\"\n\nif [ ! $CC ]; then\n    export CC=\"`xcrun -find clang`\"\nfi\n\nif [ \"${ACTION}\" = \"build\" -o \"${ACTION}\" = \"install\" -o \"${ACTION}\" = \"installhdrs\" ]; then\n    make --no-builtin-rules -f \"${WebKit2}/DerivedSources.make\" -j `/usr/sbin/sysctl -n hw.activecpu` SDKROOT=${SDKROOT}\nfi\n";
 		};
+		E19C7DDA194A4C9500F1866F /* Add CFBundle Localization Info.plist Key */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+			);
+			name = "Add CFBundle Localization Info.plist Key";
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "/usr/libexec/PlistBuddy -c \"Print :$BUNDLE_LOCALIZATION_KEY\" $TARGET_BUILD_DIR/$INFOPLIST_PATH >/dev/null 2>/dev/null\nif [[ $? != 0 ]]; then\n    echo \"Updating the Info.plist key\"\n    /usr/libexec/PlistBuddy -c \"Delete :CFBundleAllowMixedLocalizations\" $TARGET_BUILD_DIR/$INFOPLIST_PATH 2>/dev/null\n    /usr/libexec/PlistBuddy -c \"Delete :CFBundleFollowParentLocalization\" $TARGET_BUILD_DIR/$INFOPLIST_PATH 2>/dev/null\n    /usr/libexec/PlistBuddy -c \"Add :$BUNDLE_LOCALIZATION_KEY bool true\" $TARGET_BUILD_DIR/$INFOPLIST_PATH\n    echo \"Done\"\nfi\n";
+			showEnvVarsInLog = 0;
+		};
+		E19C7DDB194A5E9100F1866F /* Add CFBundle Localization Info.plist Key */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+			);
+			name = "Add CFBundle Localization Info.plist Key";
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "/usr/libexec/PlistBuddy -c \"Print :$BUNDLE_LOCALIZATION_KEY\" $TARGET_BUILD_DIR/$INFOPLIST_PATH >/dev/null 2>/dev/null\nif [[ $? != 0 ]]; then\n    echo \"Updating the Info.plist key\"\n    /usr/libexec/PlistBuddy -c \"Delete :CFBundleAllowMixedLocalizations\" $TARGET_BUILD_DIR/$INFOPLIST_PATH 2>/dev/null\n    /usr/libexec/PlistBuddy -c \"Delete :CFBundleFollowParentLocalization\" $TARGET_BUILD_DIR/$INFOPLIST_PATH 2>/dev/null\n    /usr/libexec/PlistBuddy -c \"Add :$BUNDLE_LOCALIZATION_KEY bool true\" $TARGET_BUILD_DIR/$INFOPLIST_PATH\n    echo \"Done\"\nfi\n";
+			showEnvVarsInLog = 0;
+		};
 /* End PBXShellScriptBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */

Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist (170652 => 170653)


--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist	2014-07-01 18:41:27 UTC (rev 170653)
@@ -28,8 +28,6 @@
 	<string>NSApplication</string>
 	<key>WebKitEntryPoint</key>
 	<string>WebContentServiceInitializer</string>
-	<key>CFBundleAllowMixedLocalizations</key>
-	<true/>
 	<key>LSUIElement</key>
 	<true/>
 	<key>NSSupportsAutomaticGraphicsSwitching</key>

Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist (170652 => 170653)


--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist	2014-07-01 18:41:27 UTC (rev 170653)
@@ -35,8 +35,6 @@
 		<key>_MultipleInstances</key>
 		<true/>
 	</dict>
-	<key>CFBundleAllowMixedLocalizations</key>
-	<true/>
 	<key>UIBackgroundModes</key>
 	<array>
 		<string>audio</string>

Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-OSX.plist (170652 => 170653)


--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-OSX.plist	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-OSX.plist	2014-07-01 18:41:27 UTC (rev 170653)
@@ -22,8 +22,6 @@
 	<string>????</string>
 	<key>CFBundleVersion</key>
 	<string>${BUNDLE_VERSION}</string>
-	<key>CFBundleAllowMixedLocalizations</key>
-	<true/>
 	<key>LSFileQuarantineEnabled</key>
 	<true/>
 	<key>NSPrincipalClass</key>
@@ -36,6 +34,8 @@
 	<true/>
 	<key>NSSupportsAppNap</key>
 	<true/>
+	<key>NSMainNibFile</key>
+	<string>WebContentProcess</string>
 	<key>XPCService</key>
 	<dict>
 		<key>JoinExistingSession</key>
@@ -47,7 +47,5 @@
 		<key>_MultipleInstances</key>
 		<true/>
 	</dict>
-	<key>NSMainNibFile</key>
-	<string>WebContentProcess</string>
 </dict>
 </plist>

Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist (170652 => 170653)


--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist	2014-07-01 18:29:53 UTC (rev 170652)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist	2014-07-01 18:41:27 UTC (rev 170653)
@@ -22,8 +22,6 @@
 	<string>????</string>
 	<key>CFBundleVersion</key>
 	<string>${BUNDLE_VERSION}</string>
-	<key>CFBundleAllowMixedLocalizations</key>
-	<true/>
 	<key>LSFileQuarantineEnabled</key>
 	<true/>
 	<key>WebKitEntryPoint</key>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to