Index: ios/web/web_state/ui/wk_web_view_configuration_provider.mm |
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 030db07fa67a829ab8ea8138ae2b1e8e5bb6d56f..cf776dfd6299b520ba453af20248e23485b2ec2c 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]; |