Title: [274228] trunk
Revision
274228
Author
bfulg...@apple.com
Date
2021-03-10 12:09:30 -0800 (Wed, 10 Mar 2021)

Log Message

[Cocoa] Add additional bundle ID property to WKWebViewConfiguration
https://bugs.webkit.org/show_bug.cgi?id=222919
<rdar://problem/75013854>

Reviewed by Alex Christensen.

Source/WebKit:

Add an additional property to _WKWebsiteDataStoreConfiguration to help thread the correct bundle
ID of the driving application to lower levels of WebKit so that we can provide better messaging
when a remote service (e.g., Safari View Controller or ASWebAuthenticationSession) is used. Currently
we often lack context and have to report a generic "web content" message that doesn't help a user
understand which app is actually requesting the load.

We cannot use either of the existing bundle ID's for this purpose since we always indicate 'com.apple.Safari'
as the source application to ensure proper handling of web traffic in lower levels of the system Network stack,
and sourceApplicationSecondaryIdentifier is used for Apple Pay purposes and cannot be repurposed for this task.

This first patch adds the property. A follow-up patch will flesh out the implementation.

* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::attributedBundleIdentifier const):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
(-[_WKWebsiteDataStoreConfiguration setAttributedBundleIdentifier:]):
(-[_WKWebsiteDataStoreConfiguration attributedBundleIdentifier]):
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::platformSetNetworkParameters):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
(WebKit::WebsiteDataStoreConfiguration::copy):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::attributedBundleIdentifier const):
(WebKit::WebsiteDataStoreConfiguration::setAttributedBundleIdentifier):

Tools:

Update existing SettingNonPersistentDataStorePathsThrowsException test with new property.

* TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (274227 => 274228)


--- trunk/Source/WebKit/ChangeLog	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/ChangeLog	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,3 +1,43 @@
+2021-03-10  Brent Fulgham  <bfulg...@apple.com>
+
+        [Cocoa] Add additional bundle ID property to WKWebViewConfiguration
+        https://bugs.webkit.org/show_bug.cgi?id=222919
+        <rdar://problem/75013854>
+
+        Reviewed by Alex Christensen.
+
+        Add an additional property to _WKWebsiteDataStoreConfiguration to help thread the correct bundle
+        ID of the driving application to lower levels of WebKit so that we can provide better messaging
+        when a remote service (e.g., Safari View Controller or ASWebAuthenticationSession) is used. Currently
+        we often lack context and have to report a generic "web content" message that doesn't help a user
+        understand which app is actually requesting the load.
+
+        We cannot use either of the existing bundle ID's for this purpose since we always indicate 'com.apple.Safari'
+        as the source application to ensure proper handling of web traffic in lower levels of the system Network stack,
+        and sourceApplicationSecondaryIdentifier is used for Apple Pay purposes and cannot be repurposed for this task.
+
+        This first patch adds the property. A follow-up patch will flesh out the implementation.
+
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::encode const):
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * NetworkProcess/NetworkSessionCreationParameters.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::attributedBundleIdentifier const):
+        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
+        (-[_WKWebsiteDataStoreConfiguration setAttributedBundleIdentifier:]):
+        (-[_WKWebsiteDataStoreConfiguration attributedBundleIdentifier]):
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::platformSetNetworkParameters):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
+        (WebKit::WebsiteDataStoreConfiguration::copy):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
+        (WebKit::WebsiteDataStoreConfiguration::attributedBundleIdentifier const):
+        (WebKit::WebsiteDataStoreConfiguration::setAttributedBundleIdentifier):
+
 2021-03-09  Darin Adler  <da...@apple.com>
 
         [Cocoa] Make WebKit API Objective-C objects safe to release on non-main threads

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (274227 => 274228)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,6 +47,7 @@
     IPC::encode(encoder, proxyConfiguration.get());
     encoder << sourceApplicationBundleIdentifier;
     encoder << sourceApplicationSecondaryIdentifier;
+    encoder << attributedBundleIdentifier;
     encoder << shouldLogCookieInformation;
     encoder << httpProxy;
     encoder << httpsProxy;
@@ -120,6 +121,11 @@
     if (!sourceApplicationSecondaryIdentifier)
         return WTF::nullopt;
 
+    Optional<String> attributedBundleIdentifier;
+    decoder >> attributedBundleIdentifier;
+    if (!attributedBundleIdentifier)
+        return WTF::nullopt;
+    
     Optional<bool> shouldLogCookieInformation;
     decoder >> shouldLogCookieInformation;
     if (!shouldLogCookieInformation)
@@ -295,6 +301,7 @@
         , WTFMove(proxyConfiguration)
         , WTFMove(*sourceApplicationBundleIdentifier)
         , WTFMove(*sourceApplicationSecondaryIdentifier)
+        , WTFMove(*attributedBundleIdentifier)
         , WTFMove(*shouldLogCookieInformation)
         , WTFMove(*httpProxy)
         , WTFMove(*httpsProxy)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (274227 => 274228)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -60,6 +60,7 @@
     RetainPtr<CFDictionaryRef> proxyConfiguration;
     String sourceApplicationBundleIdentifier;
     String sourceApplicationSecondaryIdentifier;
+    String attributedBundleIdentifier;
     bool shouldLogCookieInformation { false };
     URL httpProxy;
     URL httpsProxy;

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (274227 => 274228)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -75,6 +75,7 @@
     const String& boundInterfaceIdentifier() const;
     const String& sourceApplicationBundleIdentifier() const;
     const String& sourceApplicationSecondaryIdentifier() const;
+    const String& attributedBundleIdentifier() const;
 #if PLATFORM(IOS_FAMILY)
     const String& dataConnectionServiceType() const;
 #endif
@@ -147,6 +148,7 @@
     String m_boundInterfaceIdentifier;
     String m_sourceApplicationBundleIdentifier;
     String m_sourceApplicationSecondaryIdentifier;
+    String m_attributedBundleIdentifier;
     RetainPtr<CFDictionaryRef> m_proxyConfiguration;
     RetainPtr<DMFWebsitePolicyMonitor> m_deviceManagementPolicyMonitor;
     bool m_deviceManagementRestrictionsEnabled { false };

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (274227 => 274228)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1148,6 +1148,11 @@
     return m_sourceApplicationSecondaryIdentifier;
 }
 
+const String& NetworkSessionCocoa::attributedBundleIdentifier() const
+{
+    return m_attributedBundleIdentifier;
+}
+
 #if PLATFORM(IOS_FAMILY)
 const String& NetworkSessionCocoa::dataConnectionServiceType() const
 {
@@ -1222,6 +1227,7 @@
     , m_boundInterfaceIdentifier(parameters.boundInterfaceIdentifier)
     , m_sourceApplicationBundleIdentifier(parameters.sourceApplicationBundleIdentifier)
     , m_sourceApplicationSecondaryIdentifier(parameters.sourceApplicationSecondaryIdentifier)
+    , m_attributedBundleIdentifier(parameters.attributedBundleIdentifier)
     , m_proxyConfiguration(parameters.proxyConfiguration)
     , m_shouldLogCookieInformation(parameters.shouldLogCookieInformation)
     , m_fastServerTrustEvaluationEnabled(parameters.fastServerTrustEvaluationEnabled)

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h (274227 => 274228)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +39,7 @@
 // These properties apply to both persistent and non-persistent data stores.
 @property (nonatomic, nullable, copy) NSString *sourceApplicationBundleIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 @property (nonatomic, nullable, copy) NSString *sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+@property (nonatomic, nullable, copy) NSString *attributedBundleIdentifier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, nullable, copy, setter=setHTTPProxy:) NSURL *httpProxy WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 @property (nonatomic, nullable, copy, setter=setHTTPSProxy:) NSURL *httpsProxy WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 @property (nonatomic) BOOL deviceManagementRestrictionsEnabled WK_API_AVAILABLE(macos(10.15), ios(13.0));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm (274227 => 274228)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -242,6 +242,16 @@
     _configuration->setSourceApplicationSecondaryIdentifier(identifier);
 }
 
+- (void)setAttributedBundleIdentifier:(NSString *)identifier
+{
+    _configuration->setAttributedBundleIdentifier(identifier);
+}
+
+- (NSString *)attributedBundleIdentifier
+{
+    return _configuration->attributedBundleIdentifier();
+}
+
 - (NSURL *)applicationCacheDirectory
 {
     return [NSURL fileURLWithPath:_configuration->applicationCacheDirectory() isDirectory:YES];

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (274227 => 274228)


--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -167,6 +167,7 @@
     parameters.networkSessionParameters.proxyConfiguration = configuration().proxyConfiguration();
     parameters.networkSessionParameters.sourceApplicationBundleIdentifier = configuration().sourceApplicationBundleIdentifier();
     parameters.networkSessionParameters.sourceApplicationSecondaryIdentifier = configuration().sourceApplicationSecondaryIdentifier();
+    parameters.networkSessionParameters.attributedBundleIdentifier = configuration().attributedBundleIdentifier();
     parameters.networkSessionParameters.shouldLogCookieInformation = shouldLogCookieInformation;
     parameters.networkSessionParameters.httpProxy = WTFMove(httpProxy);
     parameters.networkSessionParameters.httpsProxy = WTFMove(httpsProxy);

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp (274227 => 274228)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -77,6 +77,7 @@
     copy->m_cookieStorageFile = this->m_cookieStorageFile;
     copy->m_sourceApplicationBundleIdentifier = this->m_sourceApplicationBundleIdentifier;
     copy->m_sourceApplicationSecondaryIdentifier = this->m_sourceApplicationSecondaryIdentifier;
+    copy->m_attributedBundleIdentifier = this->m_attributedBundleIdentifier;
     copy->m_httpProxy = this->m_httpProxy;
     copy->m_httpsProxy = this->m_httpsProxy;
     copy->m_deviceManagementRestrictionsEnabled = this->m_deviceManagementRestrictionsEnabled;

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h (274227 => 274228)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -133,6 +133,9 @@
     const String& sourceApplicationSecondaryIdentifier() const { return m_sourceApplicationSecondaryIdentifier; }
     void setSourceApplicationSecondaryIdentifier(String&& identifier) { m_sourceApplicationSecondaryIdentifier = WTFMove(identifier); }
 
+    const String& attributedBundleIdentifier() const { return m_attributedBundleIdentifier; }
+    void setAttributedBundleIdentifier(String&& identifier) { m_attributedBundleIdentifier = WTFMove(identifier); }
+    
     const URL& httpProxy() const { return m_httpProxy; }
     void setHTTPProxy(URL&& proxy) { m_httpProxy = WTFMove(proxy); }
 
@@ -194,6 +197,7 @@
     String m_cookieStorageFile;
     String m_sourceApplicationBundleIdentifier;
     String m_sourceApplicationSecondaryIdentifier;
+    String m_attributedBundleIdentifier;
     String m_boundInterfaceIdentifier;
     String m_dataConnectionServiceType;
     URL m_httpProxy;

Modified: trunk/Tools/ChangeLog (274227 => 274228)


--- trunk/Tools/ChangeLog	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Tools/ChangeLog	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,3 +1,16 @@
+2021-03-10  Brent Fulgham  <bfulg...@apple.com>
+
+        [Cocoa] Add additional bundle ID property to WKWebViewConfiguration
+        https://bugs.webkit.org/show_bug.cgi?id=222919
+        <rdar://problem/75013854>
+
+        Reviewed by Alex Christensen.
+
+        Update existing SettingNonPersistentDataStorePathsThrowsException test with new property.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
+        (TestWebKitAPI::TEST):
+
 2021-03-10  Sam Sneddon  <gsnedd...@apple.com>
 
         Adding Python type annotations to test_expectations.py

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm (274227 => 274228)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm	2021-03-10 19:58:31 UTC (rev 274227)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm	2021-03-10 20:09:30 UTC (rev 274228)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -267,6 +267,7 @@
     [configuration setHTTPSProxy:[NSURL URLWithString:@"https://www.apple.com/"]];
     [configuration setSourceApplicationBundleIdentifier:@"com.apple.Safari"];
     [configuration setSourceApplicationSecondaryIdentifier:@"com.apple.Safari"];
+    [configuration setAttributedBundleIdentifier:@"com.apple.Safari"];
 }
 
 TEST(WKWebsiteDataStore, FetchNonPersistentWebStorage)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to