Factor out configuration of the file upload image picker
authorconrad_shultz@apple.com <conrad_shultz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 18:26:46 +0000 (18:26 +0000)
committerconrad_shultz@apple.com <conrad_shultz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 18:26:46 +0000 (18:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192138
<rdar://problem/46334871>

Reviewed by Tim Horton.

By factoring configuration of the picker into its own method, it makes it easier
to apply custom configuration in subclasses in the future.

* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
(-[WKFileUploadPanel _configureImagePicker:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238674 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm

index 8b6cc70..7668712 100644 (file)
@@ -1,3 +1,18 @@
+2018-11-29  Conrad Shultz  <conrad_shultz@apple.com>
+
+        Factor out configuration of the file upload image picker
+        https://bugs.webkit.org/show_bug.cgi?id=192138
+        <rdar://problem/46334871>
+
+        Reviewed by Tim Horton.
+
+        By factoring configuration of the picker into its own method, it makes it easier
+        to apply custom configuration in subclasses in the future.
+
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
+        (-[WKFileUploadPanel _configureImagePicker:]):
+
 2018-11-29  Tomas Popela  <tpopela@redhat.com>
 
         [GTK][WPE] Fix BubblewrapLauncher clang warnings
index 862b122..6801646 100644 (file)
@@ -413,17 +413,11 @@ static NSArray *UTIsForMIMETypes(NSArray *mimeTypes)
 - (void)_showPhotoPickerWithSourceType:(UIImagePickerControllerSourceType)sourceType
 {
     ASSERT([UIImagePickerController isSourceTypeAvailable:sourceType]);
-    
+
     _imagePicker = adoptNS([[UIImagePickerController alloc] init]);
-    [_imagePicker setDelegate:self];
+    [self _configureImagePicker:_imagePicker.get()];
     [_imagePicker setSourceType:sourceType];
-    [_imagePicker setAllowsEditing:NO];
-    [_imagePicker setModalPresentationStyle:UIModalPresentationFullScreen];
-    [_imagePicker _setAllowsMultipleSelection:_allowMultipleFiles];
     [_imagePicker setMediaTypes:[self _mediaTypesForPickerSourceType:sourceType]];
-
-    if (_mediaCaptureType != WebCore::MediaCaptureTypeNone)
-        [_imagePicker setCameraDevice:cameraDeviceForMediaCaptureType(_mediaCaptureType)];
     
     // Use a popover on the iPad if the source type is not the camera.
     // The camera will use a fullscreen, modal view controller.
@@ -434,6 +428,17 @@ static NSArray *UTIsForMIMETypes(NSArray *mimeTypes)
         [self _presentFullscreenViewController:_imagePicker.get() animated:YES];
 }
 
+- (void)_configureImagePicker:(UIImagePickerController *)imagePicker
+{
+    [imagePicker setDelegate:self];
+    [imagePicker setAllowsEditing:NO];
+    [imagePicker setModalPresentationStyle:UIModalPresentationFullScreen];
+    [imagePicker _setAllowsMultipleSelection:_allowMultipleFiles];
+
+    if (_mediaCaptureType != WebCore::MediaCaptureTypeNone)
+        [imagePicker setCameraDevice:cameraDeviceForMediaCaptureType(_mediaCaptureType)];
+}
+
 #pragma mark - Presenting View Controllers
 
 - (void)_presentMenuOptionForCurrentInterfaceIdiom:(UIViewController *)viewController