diff options
author | eugenebut <eugenebut@chromium.org> | 2015-10-30 09:47:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-30 16:47:37 +0000 |
commit | 2de015203b33dfb0c040b0eaa4ce4c8fb52ade8a (patch) | |
tree | c606b63ecc35363ae27277f0b1ab89109e2e2b0b /ios/web | |
parent | 70eceecb80f82f7deea985549b52b97149ef9005 (diff) | |
download | chromium_src-2de015203b33dfb0c040b0eaa4ce4c8fb52ade8a.zip chromium_src-2de015203b33dfb0c040b0eaa4ce4c8fb52ade8a.tar.gz chromium_src-2de015203b33dfb0c040b0eaa4ce4c8fb52ade8a.tar.bz2 |
[ios] Removed DCHECK which prevents WKProcessPool manual creation.
That DCHECK was originally added to:
1.) Prevent issues with WKWebView cookie clearing on iOS8 (not supported
by WKWebView anymore).
2.) Ensure correct Modal Data Partitioning (postponed work).
BUG=537244
Review URL: https://codereview.chromium.org/1427003003
Cr-Commit-Position: refs/heads/master@{#357123}
Diffstat (limited to 'ios/web')
-rw-r--r-- | ios/web/web_state/ui/wk_web_view_configuration_provider.mm | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm index 030db07..cf776df 100644 --- a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm +++ b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm @@ -5,84 +5,14 @@ #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" #import <Foundation/Foundation.h> -#import <objc/runtime.h> #import <WebKit/WebKit.h> #include "base/ios/ios_util.h" #import "base/ios/weak_nsobject.h" #import "base/logging.h" -#import "ios/web/alloc_with_zone_interceptor.h" #include "ios/web/public/browser_state.h" #import "ios/web/web_state/js/page_script_util.h" #import "ios/web/web_state/ui/crw_wk_script_message_router.h" -#import "ios/web/web_state/web_view_internal_creation_util.h" - -#if !defined(NDEBUG) - -namespace { -BOOL gAllowWKProcessPoolCreation = NO; - -// By default WKProcessPool creation is not allowed by embedder to prevent -// issues with browsing data clearing. However some iOS system methods do create -// WKProcessPool inside, which is perfectly fine and should be allowed. This -// method whitelists given |klass| with given |selector|, so creation of -// WKProcessPool is allowed inside that selector call. This function currently -// supports Objective-C methods with up to 4 arguments and needs to be updated -// if support for more arguments is required. -void AllowWKProcessPoolCreation(Class klass, SEL selector) { - Method method = class_getInstanceMethod(klass, selector); - IMP originalImp = method_getImplementation(method); - IMP safeImp = imp_implementationWithBlock( - ^(id self, id arg1, id arg2, id arg3, id arg4) { - BOOL oldAllowWKProcessPoolCreation = gAllowWKProcessPoolCreation; - gAllowWKProcessPoolCreation = YES; - id result = originalImp(self, selector, arg1, arg2, arg3, arg4); - gAllowWKProcessPoolCreation = oldAllowWKProcessPoolCreation; - return result; - }); - - method_setImplementation(method, safeImp); -} -} - -@interface WKProcessPool (CRWAdditions) -@end - -@implementation WKProcessPool (CRWAdditions) - -+ (void)load { - id (^allocator)(Class klass, NSZone* zone) = ^id(Class klass, NSZone* zone) { - if (gAllowWKProcessPoolCreation || web::IsWebViewAllocInitAllowed()) { - return NSAllocateObject(klass, 0, zone); - } - // You have hit this because you are trying to create a WKProcessPool - // directly or indirectly (f.e. by creating WKWebViewConfiguration - // manually). Please use GetWebViewConfiguration() to get - // WKWebViewConfiguration object. - NOTREACHED(); - return nil; - }; - web::AddAllocWithZoneMethod([WKProcessPool class], allocator); - - if (!base::ios::IsRunningOnIOS9OrLater()) - return; - - // Make sure that WKWebsiteDataStore is allowed to create WKProcessPool for - // internal implementation purposes. - AllowWKProcessPoolCreation( - [WKWebsiteDataStore class], - @selector(fetchDataRecordsOfTypes:completionHandler:completionHandler:)); - AllowWKProcessPoolCreation( - [WKWebsiteDataStore class], - @selector(removeDataOfTypes:forDataRecords:completionHandler:)); - AllowWKProcessPoolCreation( - [WKWebsiteDataStore class], - @selector(removeDataOfTypes:modifiedSince:completionHandler:)); -} - -@end - -#endif // !defined(NDEBUG) namespace web { @@ -136,15 +66,6 @@ WKWebViewConfigurationProvider::GetWebViewConfiguration() { // setJavaScriptCanOpenWindowsAutomatically is required to support popups. [[configuration_ preferences] setJavaScriptCanOpenWindowsAutomatically:YES]; [[configuration_ userContentController] addUserScript:GetEarlyPageScript()]; -#if !defined(NDEBUG) - // Lazily load WKProcessPool. -[[WKProcessPool alloc] init] call is not - // allowed except when creating config object inside this class. - // Unmanaged creation of WKProcessPool may lead to issues with cookie - // clearing and Browsing Data Partitioning implementation. - gAllowWKProcessPoolCreation = YES; - CHECK([configuration_ processPool]); - gAllowWKProcessPoolCreation = NO; -#endif // !defined(NDEBUG) } // Prevent callers from changing the internals of configuration. return [[configuration_ copy] autorelease]; |