[Cocoa] WebProcess doesn't follow localization of UI process when run as a service
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jul 2014 18:41:27 +0000 (18:41 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jul 2014 18:41:27 +0000 (18:41 +0000)
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.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/WebContentService.Development.xcconfig
Source/WebKit2/Configurations/WebContentService.xcconfig
Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-OSX.plist
Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/Info-iOS.plist
Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist
Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist

index e4c25fe..c2657c4 100644 (file)
@@ -1,3 +1,29 @@
+2014-07-01  Alexey Proskuryakov  <ap@apple.com>
+
+        [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  <achristensen@webkit.org>
 
         [iOS] Unreviewed build fix after r170640.
index 67918e1..28671b8 100644 (file)
@@ -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_macosx = WebProcess/EntryPoint/mac/XPCService/WebContentService.D
 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));
index ceebe5d..dbbd7ba 100644 (file)
@@ -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_macosx = WebProcess/EntryPoint/mac/XPCService/WebContentService/I
 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));
index 36c9961..70d8481 100644 (file)
@@ -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>
 #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 @@ static void connectToService(const ProcessLauncher::LaunchOptions& launchOptions
     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 @@ static void connectToService(const ProcessLauncher::LaunchOptions& launchOptions
     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]);
index 7be4ef0..0eb6e64 100644 (file)
                                BC3DE46215A91763008D26FC /* Sources */,
                                BCDC308D15FDB99A006B6695 /* Frameworks */,
                                BC3DE46415A91763008D26FC /* Resources */,
+                               E19C7DDB194A5E9100F1866F /* Add CFBundle Localization Info.plist Key */,
                        );
                        buildRules = (
                        );
                                BCAE9DE5160C097400A33217 /* Sources */,
                                BCAE9DE6160C097400A33217 /* Frameworks */,
                                BCAE9DE7160C097400A33217 /* Resources */,
+                               E19C7DDA194A4C9500F1866F /* Add CFBundle Localization Info.plist Key */,
                        );
                        buildRules = (
                        );
                        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 */
index cf6eb55..a3ceb3a 100644 (file)
@@ -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>
index de6d542..df35da1 100644 (file)
@@ -22,8 +22,6 @@
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>${BUNDLE_VERSION}</string>
-       <key>CFBundleAllowMixedLocalizations</key>
-       <true/>
        <key>LSFileQuarantineEnabled</key>
        <true/>
        <key>WebKitEntryPoint</key>
index 90d350b..01ca3c1 100644 (file)
@@ -28,8 +28,6 @@
        <string>NSApplication</string>
        <key>WebKitEntryPoint</key>
        <string>WebContentServiceInitializer</string>
-       <key>CFBundleAllowMixedLocalizations</key>
-       <true/>
        <key>LSUIElement</key>
        <true/>
        <key>NSSupportsAutomaticGraphicsSwitching</key>
index bbeba01..c65d27f 100644 (file)
@@ -35,8 +35,6 @@
                <key>_MultipleInstances</key>
                <true/>
        </dict>
-       <key>CFBundleAllowMixedLocalizations</key>
-       <true/>
        <key>UIBackgroundModes</key>
        <array>
                <string>audio</string>