Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Begin work on the bundle parameter API
https://bugs.webkit.org/show_bug.cgi?id=130267

Reviewed by Dan Bernstein.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _objectForBundleParameter:]):
(-[WKProcessPool _setObject:forBundleParameter:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/WebContext.h:
(WebKit::WebContext::bundleParameters):
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::ensureBundleParameters):
(WebKit::WebContext::platformInitializeWebProcess):

Canonical link: https://commits.webkit.org/148249@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165660 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Mar 14, 2014
1 parent df66029 commit 0f3a2f4
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,24 @@
2014-03-14 Anders Carlsson <andersca@apple.com>

Begin work on the bundle parameter API
https://bugs.webkit.org/show_bug.cgi?id=130267

Reviewed by Dan Bernstein.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _objectForBundleParameter:]):
(-[WKProcessPool _setObject:forBundleParameter:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/WebContext.h:
(WebKit::WebContext::bundleParameters):
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::ensureBundleParameters):
(WebKit::WebContext::platformInitializeWebProcess):

2014-03-14 Alexey Proskuryakov <ap@apple.com>

[Mac] Sync extended attribute related rules with AppSandbox profile
Expand Down
16 changes: 16 additions & 0 deletions Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Expand Up @@ -26,6 +26,7 @@
#include "config.h"
#include "WebProcessCreationParameters.h"

#include "APIData.h"
#include "ArgumentCoders.h"

namespace WebKit {
Expand Down Expand Up @@ -110,6 +111,9 @@ void WebProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
encoder << shouldForceScreenFontSubstitution;
encoder << shouldEnableKerningAndLigaturesByDefault;
encoder << shouldEnableJIT;
encoder << !!bundleParameterData;
if (bundleParameterData)
encoder << bundleParameterData->dataReference();
#endif

#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Expand Down Expand Up @@ -235,6 +239,18 @@ bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProc
return false;
if (!decoder.decode(parameters.shouldEnableJIT))
return false;

bool hasBundleParameterData;
if (!decoder.decode(hasBundleParameterData))
return false;

if (hasBundleParameterData) {
IPC::DataReference dataReference;
if (!decoder.decode(dataReference))
return false;

parameters.bundleParameterData = API::Data::create(dataReference.data(), dataReference.size());
}
#endif

#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit2/Shared/WebProcessCreationParameters.h
Expand Up @@ -36,12 +36,17 @@

#if PLATFORM(COCOA)
#include "MachPort.h"

#endif

#if USE(SOUP)
#include "HTTPCookieAcceptPolicy.h"
#endif

namespace API {
class Data;
}

namespace IPC {
class ArgumentDecoder;
class ArgumentEncoder;
Expand Down Expand Up @@ -132,6 +137,9 @@ struct WebProcessCreationParameters {
bool shouldForceScreenFontSubstitution;
bool shouldEnableKerningAndLigaturesByDefault;
bool shouldEnableJIT;

RefPtr<API::Data> bundleParameterData;

#endif // PLATFORM(COCOA)

#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Expand Down
10 changes: 10 additions & 0 deletions Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm
Expand Up @@ -142,6 +142,16 @@ - (void)_setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
_context->supplement<WebKit::WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
}

- (id)_objectForBundleParameter:(NSString *)parameter
{
return [_context->bundleParameters() objectForKey:parameter];
}

- (void)_setObject:(id <NSCopying, NSSecureCoding>)object forBundleParameter:(NSString *)parameter
{
[_context->ensureBundleParameters() setObject:adoptNS([(NSObject *)object copy]).get() forKey:parameter];
}

@end

#endif // WK_API_ENABLED
3 changes: 3 additions & 0 deletions Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Expand Up @@ -32,6 +32,9 @@
- (void)_setAllowsSpecificHTTPSCertificate:(NSArray *)certificateChain forHost:(NSString *)host;
- (void)_setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy;

- (id)_objectForBundleParameter:(NSString *)parameter;
- (void)_setObject:(id <NSCopying, NSSecureCoding>)object forBundleParameter:(NSString *)parameter;

@end

#endif
8 changes: 8 additions & 0 deletions Source/WebKit2/UIProcess/WebContext.h
Expand Up @@ -62,6 +62,7 @@
#endif

#if PLATFORM(COCOA)
OBJC_CLASS NSMutableDictionary;
OBJC_CLASS NSObject;
OBJC_CLASS NSString;
#endif
Expand Down Expand Up @@ -332,6 +333,9 @@ class WebContext : public API::ObjectImpl<API::Object::Type::Context>, private I

#if PLATFORM(COCOA)
void updateProcessSuppressionState() const;

NSMutableDictionary *ensureBundleParameters();
NSMutableDictionary *bundleParameters() { return m_bundleParameters.get(); }
#endif

void setMemoryCacheDisabled(bool);
Expand Down Expand Up @@ -528,6 +532,10 @@ class WebContext : public API::ObjectImpl<API::Object::Type::Context>, private I
#endif

bool m_memoryCacheDisabled;

#if PLATFORM(COCOA)
RetainPtr<NSMutableDictionary> m_bundleParameters;
#endif
};

template<typename T>
Expand Down
33 changes: 32 additions & 1 deletion Source/WebKit2/UIProcess/mac/WebContextMac.mm
Expand Up @@ -49,7 +49,6 @@
#import "NetworkProcessProxy.h"
#endif


#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090

#if __has_include(<CFNetwork/CFURLProtocolPriv.h>)
Expand All @@ -61,6 +60,12 @@

#endif

#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1080
@interface NSKeyedArchiver (WKDetails)
- (void)setRequiresSecureCoding:(BOOL)b;
@end
#endif

using namespace WebCore;

NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory";
Expand Down Expand Up @@ -115,6 +120,14 @@ static void registerUserDefaultsIfNeeded()
#endif
}

NSMutableDictionary *WebContext::ensureBundleParameters()
{
if (!m_bundleParameters)
m_bundleParameters = adoptNS([[NSMutableDictionary alloc] init]);

return m_bundleParameters.get();
}

void WebContext::platformInitialize()
{
registerUserDefaultsIfNeeded();
Expand Down Expand Up @@ -182,6 +195,24 @@ static void registerUserDefaultsIfNeeded()
#if ENABLE(NETWORK_PROCESS)
}
#endif

if (m_bundleParameters) {
auto data = adoptNS([[NSMutableData alloc] init]);
auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] init]);

[keyedArchiver setRequiresSecureCoding:YES];

@try {
[keyedArchiver encodeObject:m_bundleParameters.get() forKey:@"parameters"];
[keyedArchiver finishEncoding];
} @catch (NSException *exception) {
LOG_ERROR("Failed to encode bundle parameters: %@", exception);
}

parameters.bundleParameterData = API::Data::createWithoutCopying((const unsigned char*)[data bytes], [data length], [] (unsigned char*, const void* data) {
[(NSData *)data release];
}, data.leakRef());
}
}

#if ENABLE(NETWORK_PROCESS)
Expand Down

0 comments on commit 0f3a2f4

Please sign in to comment.