Changeset 262207 in webkit


Ignore:
Timestamp:
May 27, 2020 12:35:15 PM (4 years ago)
Author:
pvollan@apple.com
Message:

Unreviewed, reverting r260840.

This patch is no longer needed after preferences root cause
has been fixed.

Reverted changeset:

"[Cocoa] Global preferences are not accessible in the
WebContent process when CFPrefs direct mode is enabled"
https://bugs.webkit.org/show_bug.cgi?id=211075
https://trac.webkit.org/changeset/260840

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r262205 r262207  
     12020-05-27  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Unreviewed, reverting r260840.
     4
     5        This patch is no longer needed after preferences root cause
     6        has been fixed.
     7
     8        Reverted changeset:
     9
     10        "[Cocoa] Global preferences are not accessible in the
     11        WebContent process when CFPrefs direct mode is enabled"
     12        https://bugs.webkit.org/show_bug.cgi?id=211075
     13        https://trac.webkit.org/changeset/260840
     14
    1152020-05-27  Michael Catanzaro  <mcatanzaro@gnome.org>
    216
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r261479 r262207  
    189189#if ENABLE(CFPREFS_DIRECT_MODE)
    190190    encoder << preferencesExtensionHandles;
    191     encoder << encodedGlobalPreferences;
    192191#endif
    193192#endif
     
    528527        return false;
    529528    parameters.preferencesExtensionHandles = WTFMove(*preferencesExtensionHandles);
    530 
    531     Optional<String> encodedGlobalPreferences;
    532     decoder >> encodedGlobalPreferences;
    533     if (!encodedGlobalPreferences)
    534         return false;
    535     parameters.encodedGlobalPreferences = WTFMove(*encodedGlobalPreferences);
    536529#endif
    537530#endif
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r261479 r262207  
    228228#if ENABLE(CFPREFS_DIRECT_MODE)
    229229    Optional<SandboxExtension::HandleArray> preferencesExtensionHandles;
    230     String encodedGlobalPreferences;
    231230#endif
    232231#endif
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r261948 r262207  
    454454    }
    455455
    456 #if ENABLE(CFPREFS_DIRECT_MODE)
    457 #if PLATFORM(IOS_FAMILY)
     456#if ENABLE(CFPREFS_DIRECT_MODE) && PLATFORM(IOS_FAMILY)
    458457    if (_AXSApplicationAccessibilityEnabled())
    459458        parameters.preferencesExtensionHandles = SandboxExtension::createHandlesForMachLookup({ "com.apple.cfprefsd.agent"_s, "com.apple.cfprefsd.daemon"_s }, WTF::nullopt);
    460 #endif
    461 
    462     auto globalPreferencesDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr));
    463     static CFStringRef keys[] = {
    464         CFSTR("AppleLanguages"),
    465         CFSTR("AppleLanguagesSchemaVersion"),
    466         CFSTR("AppleLocale")
    467     };
    468     for (size_t i = 0; i < std::size(keys); ++i) {
    469         auto value = adoptCF(CFPreferencesCopyAppValue(keys[i], CFSTR("kCFPreferencesAnyApplication")));
    470         if (!value)
    471             continue;
    472         CFDictionaryAddValue(globalPreferencesDictionary.get(), keys[i], value.get());
    473     }
    474     if (CFDictionaryGetCount(globalPreferencesDictionary.get()) > 0) {
    475         NSError *e = nil;
    476         auto data = retainPtr([NSKeyedArchiver archivedDataWithRootObject:(__bridge NSMutableDictionary *)globalPreferencesDictionary.get() requiringSecureCoding:YES error:&e]);
    477         if (e) {
    478             ASSERT_NOT_REACHED();
    479             WTFLogAlways("Failed to archive global preferences dictionary with NSKeyedArchiver.");
    480         } else
    481             parameters.encodedGlobalPreferences = String([data base64EncodedStringWithOptions:0]);
    482     }
    483459#endif
    484460
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r261479 r262207  
    167167#endif
    168168
    169 #if ENABLE(CFPREFS_DIRECT_MODE)
    170 static void setGlobalPreferences(const String& encodedGlobalPreferences)
    171 {
    172     if (encodedGlobalPreferences.isEmpty())
    173         return;
    174 
    175     auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:encodedGlobalPreferences options:0]);
    176     if (!encodedData)
    177         return;
    178 
    179     NSError *err = nil;
    180     auto classes = [NSSet setWithArray:@[[NSString class], [NSNumber class], [NSDate class], [NSDictionary class], [NSArray class], [NSData class]]];
    181     id globalPreferencesDictionary = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:encodedData.get() error:&err];
    182     if (err) {
    183         ASSERT_NOT_REACHED();
    184         WTFLogAlways("Failed to unarchive global preferences dictionary with NSKeyedUnarchiver.");
    185         return;
    186     }
    187     [globalPreferencesDictionary enumerateKeysAndObjectsUsingBlock: ^(NSString *key, id value, BOOL* stop) {
    188         if (value)
    189             CFPreferencesSetAppValue(static_cast<CFStringRef>(key), static_cast<CFPropertyListRef>(value), CFSTR("kCFPreferencesAnyApplication"));
    190     }];
    191 }
    192 #endif
    193 
    194169void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
    195170{
    196 #if ENABLE(CFPREFS_DIRECT_MODE)
    197     setGlobalPreferences(parameters.encodedGlobalPreferences);
    198 #endif
    199 
    200171    // Map Launch Services database. This should be done as early as possible, as the mapping will fail
    201172    // if 'com.apple.lsd.mapdb' is being accessed before this.
     
    217188        ASSERT(String(uti.get()) = String(adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, CFSTR("text/html"), 0)).get()));
    218189    }
     190
    219191
    220192#if PLATFORM(IOS_FAMILY)
  • trunk/Tools/ChangeLog

    r262203 r262207  
     12020-05-27  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Unreviewed, reverting r260840.
     4
     5        This patch is no longer needed after preferences root cause
     6        has been fixed.
     7
     8        Reverted changeset:
     9
     10        "[Cocoa] Global preferences are not accessible in the
     11        WebContent process when CFPrefs direct mode is enabled"
     12        https://bugs.webkit.org/show_bug.cgi?id=211075
     13        https://trac.webkit.org/changeset/260840
     14
    1152020-05-27  Devin Rousso  <drousso@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm

    r260840 r262207  
    277277}
    278278
    279 TEST(WebKit, GlobalPreferences)
    280 {
    281     NSString *globalDomain = @"kCFPreferencesAnyApplication";
    282     NSString *globalKey = @"AppleLanguages";
    283 
    284     NSArray *languages = @[@"en-US", @"nb-US"];
    285 
    286     CFPreferencesSetAppValue(static_cast<CFStringRef>(globalKey), static_cast<CFArrayRef>(languages), static_cast<CFStringRef>(globalDomain));
    287 
    288     auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:globalDomain]);
    289     [userDefaults.get() setObject:languages forKey:globalKey];
    290 
    291     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
    292     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
    293     configuration.get().processPool = (WKProcessPool *)context.get();
    294     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
    295 
    296     auto preferenceValue = [&] {
    297         NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", globalDomain, globalKey];
    298         return [webView stringByEvaluatingJavaScript:js];
    299     };
    300 
    301     auto encodedString = preferenceValue();
    302     auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:encodedString options:0]);
    303     ASSERT_TRUE(encodedData);
    304     NSError *err = nil;
    305     auto object = retainPtr([NSKeyedUnarchiver unarchivedObjectOfClass:[NSObject class] fromData:encodedData.get() error:&err]);
    306     ASSERT_TRUE(!err);
    307     ASSERT_TRUE(object);
    308     ASSERT_TRUE([object isEqual:languages]);
    309 }
    310 
    311279#endif // WK_HAVE_C_SPI
Note: See TracChangeset for help on using the changeset viewer.