|
46 | 46 | NSInteger const AppExtensionErrorCodeCollectFieldsScriptFailed = 4; |
47 | 47 | NSInteger const AppExtensionErrorCodeFillFieldsScriptFailed = 5; |
48 | 48 | NSInteger const AppExtensionErrorCodeUnexpectedData = 6; |
| 49 | +NSInteger const AppExtensionErrorCodeFailedToObtainURLStringFromWebView = 7; |
49 | 50 |
|
50 | 51 |
|
51 | 52 | @implementation OnePasswordExtension |
@@ -352,6 +353,12 @@ + (NSError *)failedToLoadItemProviderDataErrorWithUnderlyingError:(NSError *)und |
352 | 353 | return [[NSError alloc] initWithDomain:AppExtensionErrorDomain code:AppExtensionErrorCodeFailedToLoadItemProviderData userInfo:userInfo]; |
353 | 354 | } |
354 | 355 |
|
| 356 | ++ (NSError *)failedToObtainURLStringFromWebViewError { |
| 357 | + NSDictionary *userInfo = @{ NSLocalizedDescriptionKey : NSLocalizedString(@"Failed to obtain URL String from web view. The web view must be loaded completely when calling the 1Password Extension", @"1Password Extension Error Message") }; |
| 358 | + return [NSError errorWithDomain:AppExtensionErrorDomain code:AppExtensionErrorCodeFailedToObtainURLStringFromWebView userInfo:userInfo]; |
| 359 | +} |
| 360 | + |
| 361 | + |
355 | 362 | #pragma mark - App Extension ItemProvider Callback |
356 | 363 |
|
357 | 364 | #ifdef __IPHONE_8_0 |
@@ -433,6 +440,12 @@ - (void)fillLoginIntoUIWebView:(UIWebView *)webView webViewController:(UIViewCon |
433 | 440 | } |
434 | 441 |
|
435 | 442 | - (void)findLoginIn1PasswordWithURLString:URLString collectedPageDetails:(NSString *)collectedPageDetails forWebViewController:(UIViewController *)forViewController sender:(id)sender withWebView:(id)webView completion:(void (^)(BOOL success, NSError *error))completion { |
| 443 | + if ([URLString length] == 0) { |
| 444 | + NSError *URLStringError = [OnePasswordExtension failedToObtainURLStringFromWebViewError]; |
| 445 | + NSLog(@"Failed to findLoginIn1PasswordWithURLString: %@", URLStringError); |
| 446 | + completion(NO, URLStringError); |
| 447 | + } |
| 448 | + |
436 | 449 | NSDictionary *item = @{ AppExtensionVersionNumberKey : VERSION_NUMBER, AppExtensionURLStringKey : URLString, AppExtensionWebViewPageDetails : collectedPageDetails }; |
437 | 450 |
|
438 | 451 | __weak __typeof__ (self) miniMe = self; |
|
0 commit comments