From c1d9ac78dee7c9efca1e5ac9ef351ff1b2e2090c Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 12 Feb 2020 14:32:29 +0900 Subject: [PATCH] breaking (CDVURLProtocol): delete --- CordovaLib/Classes/Public/CDV.h | 1 - CordovaLib/Classes/Public/CDVURLProtocol.h | 27 ----- CordovaLib/Classes/Public/CDVURLProtocol.m | 113 ------------------ CordovaLib/Cordova/Cordova.h | 1 - .../CordovaLib.xcodeproj/project.pbxproj | 12 -- 5 files changed, 154 deletions(-) delete mode 100644 CordovaLib/Classes/Public/CDVURLProtocol.h delete mode 100644 CordovaLib/Classes/Public/CDVURLProtocol.m diff --git a/CordovaLib/Classes/Public/CDV.h b/CordovaLib/Classes/Public/CDV.h index 96d6efc8fd..3f22df16a1 100644 --- a/CordovaLib/Classes/Public/CDV.h +++ b/CordovaLib/Classes/Public/CDV.h @@ -24,7 +24,6 @@ #import "CDVPluginResult.h" #import "CDVViewController.h" #import "CDVCommandDelegate.h" -#import "CDVURLProtocol.h" #import "CDVInvokedUrlCommand.h" #import "CDVWhitelist.h" #import "CDVScreenOrientationDelegate.h" diff --git a/CordovaLib/Classes/Public/CDVURLProtocol.h b/CordovaLib/Classes/Public/CDVURLProtocol.h deleted file mode 100644 index 0561e04d9a..0000000000 --- a/CordovaLib/Classes/Public/CDVURLProtocol.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -#import -#import "CDVAvailability.h" - -@class CDVViewController; - -@interface CDVURLProtocol : NSURLProtocol {} - -@end diff --git a/CordovaLib/Classes/Public/CDVURLProtocol.m b/CordovaLib/Classes/Public/CDVURLProtocol.m deleted file mode 100644 index 7b2c5ce5b5..0000000000 --- a/CordovaLib/Classes/Public/CDVURLProtocol.m +++ /dev/null @@ -1,113 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -#import -#import -#import -#import -#import "CDVURLProtocol.h" -#import "CDVCommandQueue.h" -#import "CDVViewController.h" - -// Contains a set of NSNumbers of addresses of controllers. It doesn't store -// the actual pointer to avoid retaining. -static NSMutableSet* gRegisteredControllers = nil; - -NSString* const kCDVAssetsLibraryPrefixes = @"assets-library://"; - -@implementation CDVURLProtocol - - -+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest -{ - NSURL* theUrl = [theRequest URL]; - - if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) { - return YES; - } - - return NO; -} - -+ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request -{ - // NSLog(@"%@ received %@", self, NSStringFromSelector(_cmd)); - return request; -} - -- (void)startLoading -{ - // NSLog(@"%@ received %@ - start", self, NSStringFromSelector(_cmd)); - NSURL* url = [[self request] URL]; - - if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) { - ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) { - if (asset) { - // We have the asset! Get the data and send it along. - ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation]; - NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType); - Byte* buffer = (Byte*)malloc((unsigned long)[assetRepresentation size]); - NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:(NSUInteger)[assetRepresentation size] error:nil]; - NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES]; - [self sendResponseWithResponseCode:200 data:data mimeType:MIMEType]; - } else { - // Retrieving the asset failed for some reason. Send an error. - [self sendResponseWithResponseCode:404 data:nil mimeType:nil]; - } - }; - ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) { - // Retrieving the asset failed for some reason. Send an error. - [self sendResponseWithResponseCode:401 data:nil mimeType:nil]; - }; - - ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init]; - [assetsLibrary assetForURL:url resultBlock:resultBlock failureBlock:failureBlock]; - return; - } - - NSString* body = [NSString stringWithFormat:@"Access not allowed to URL: %@", url]; - [self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSASCIIStringEncoding] mimeType:nil]; -} - -- (void)stopLoading -{ - // do any cleanup here -} - -+ (BOOL)requestIsCacheEquivalent:(NSURLRequest*)requestA toRequest:(NSURLRequest*)requestB -{ - return NO; -} - -- (void)sendResponseWithResponseCode:(NSInteger)statusCode data:(NSData*)data mimeType:(NSString*)mimeType -{ - if (mimeType == nil) { - mimeType = @"text/plain"; - } - - NSHTTPURLResponse* response = [[NSHTTPURLResponse alloc] initWithURL:[[self request] URL] statusCode:statusCode HTTPVersion:@"HTTP/1.1" headerFields:@{@"Content-Type" : mimeType}]; - - [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; - if (data != nil) { - [[self client] URLProtocol:self didLoadData:data]; - } - [[self client] URLProtocolDidFinishLoading:self]; -} - -@end diff --git a/CordovaLib/Cordova/Cordova.h b/CordovaLib/Cordova/Cordova.h index 341e0551a2..ecec02b4a5 100644 --- a/CordovaLib/Cordova/Cordova.h +++ b/CordovaLib/Cordova/Cordova.h @@ -38,7 +38,6 @@ FOUNDATION_EXPORT const unsigned char CordovaVersionString[]; #import #import #import -#import #import #import #import diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj index 093643f648..856ed11b45 100644 --- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj +++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj @@ -47,8 +47,6 @@ 7ED95D491AB9029B008C4574 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7ED95D4A1AB9029B008C4574 /* CDVTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D241AB9029B008C4574 /* CDVTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7ED95D4B1AB9029B008C4574 /* CDVTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D251AB9029B008C4574 /* CDVTimer.m */; }; - 7ED95D4C1AB9029B008C4574 /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 7ED95D4D1AB9029B008C4574 /* CDVURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */; }; 7ED95D4E1AB9029B008C4574 /* CDVUserAgentUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7ED95D4F1AB9029B008C4574 /* CDVUserAgentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */; }; 7ED95D501AB9029B008C4574 /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D2A1AB9029B008C4574 /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -69,7 +67,6 @@ 9052DE772150D040008E83D4 /* CDVPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D201AB9029B008C4574 /* CDVPlugin.m */; }; 9052DE782150D040008E83D4 /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D221AB9029B008C4574 /* CDVPluginResult.m */; }; 9052DE792150D040008E83D4 /* CDVTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D251AB9029B008C4574 /* CDVTimer.m */; }; - 9052DE7A2150D040008E83D4 /* CDVURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */; }; 9052DE7B2150D040008E83D4 /* CDVUserAgentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */; }; 9052DE7C2150D040008E83D4 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D2B1AB9029B008C4574 /* CDVViewController.m */; }; 9052DE7D2150D040008E83D4 /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D2E1AB9029B008C4574 /* CDVWhitelist.m */; }; @@ -104,7 +101,6 @@ C0C01EC61E39131A0056E6CB /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D211AB9029B008C4574 /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; C0C01EC71E39131A0056E6CB /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; C0C01EC81E39131A0056E6CB /* CDVTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D241AB9029B008C4574 /* CDVTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C0C01EC91E39131A0056E6CB /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; C0C01ECA1E39131A0056E6CB /* CDVUserAgentUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */; settings = {ATTRIBUTES = (Public, ); }; }; C0C01ECB1E39131A0056E6CB /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D2A1AB9029B008C4574 /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; C0C01ECC1E39131A0056E6CB /* CDVWebViewEngineProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D2C1AB9029B008C4574 /* CDVWebViewEngineProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -154,8 +150,6 @@ 7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVScreenOrientationDelegate.h; sourceTree = ""; }; 7ED95D241AB9029B008C4574 /* CDVTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVTimer.h; sourceTree = ""; }; 7ED95D251AB9029B008C4574 /* CDVTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVTimer.m; sourceTree = ""; }; - 7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVURLProtocol.h; sourceTree = ""; }; - 7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVURLProtocol.m; sourceTree = ""; }; 7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUserAgentUtil.h; sourceTree = ""; }; 7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUserAgentUtil.m; sourceTree = ""; }; 7ED95D2A1AB9029B008C4574 /* CDVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVViewController.h; sourceTree = ""; }; @@ -304,8 +298,6 @@ 7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */, 7ED95D241AB9029B008C4574 /* CDVTimer.h */, 7ED95D251AB9029B008C4574 /* CDVTimer.m */, - 7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */, - 7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */, 7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */, 7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */, 7ED95D2A1AB9029B008C4574 /* CDVViewController.h */, @@ -362,7 +354,6 @@ C0C01EC61E39131A0056E6CB /* CDVPluginResult.h in Headers */, C0C01EC71E39131A0056E6CB /* CDVScreenOrientationDelegate.h in Headers */, C0C01EC81E39131A0056E6CB /* CDVTimer.h in Headers */, - C0C01EC91E39131A0056E6CB /* CDVURLProtocol.h in Headers */, C0C01ECA1E39131A0056E6CB /* CDVUserAgentUtil.h in Headers */, C0C01ECB1E39131A0056E6CB /* CDVViewController.h in Headers */, C0C01ECC1E39131A0056E6CB /* CDVWebViewEngineProtocol.h in Headers */, @@ -400,7 +391,6 @@ 7ED95D491AB9029B008C4574 /* CDVScreenOrientationDelegate.h in Headers */, 4E23F8FC23E16E96006CD852 /* CDVWebViewUIDelegate.h in Headers */, 7ED95D4A1AB9029B008C4574 /* CDVTimer.h in Headers */, - 7ED95D4C1AB9029B008C4574 /* CDVURLProtocol.h in Headers */, 7ED95D4E1AB9029B008C4574 /* CDVUserAgentUtil.h in Headers */, 7ED95D501AB9029B008C4574 /* CDVViewController.h in Headers */, 7ED95D521AB9029B008C4574 /* CDVWebViewEngineProtocol.h in Headers */, @@ -505,7 +495,6 @@ 9052DE772150D040008E83D4 /* CDVPlugin.m in Sources */, 9052DE782150D040008E83D4 /* CDVPluginResult.m in Sources */, 9052DE792150D040008E83D4 /* CDVTimer.m in Sources */, - 9052DE7A2150D040008E83D4 /* CDVURLProtocol.m in Sources */, 9052DE7B2150D040008E83D4 /* CDVUserAgentUtil.m in Sources */, 9052DE7C2150D040008E83D4 /* CDVViewController.m in Sources */, 9052DE7D2150D040008E83D4 /* CDVWhitelist.m in Sources */, @@ -533,7 +522,6 @@ 7ED95D481AB9029B008C4574 /* CDVPluginResult.m in Sources */, 7ED95D4B1AB9029B008C4574 /* CDVTimer.m in Sources */, 4E23F8FE23E16E96006CD852 /* CDVWebViewEngine.m in Sources */, - 7ED95D4D1AB9029B008C4574 /* CDVURLProtocol.m in Sources */, 4E23F8FB23E16E96006CD852 /* CDVWebViewProcessPoolFactory.m in Sources */, 7ED95D4F1AB9029B008C4574 /* CDVUserAgentUtil.m in Sources */, 7ED95D511AB9029B008C4574 /* CDVViewController.m in Sources */,