Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions OnePasswordExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
NSInteger const AppExtensionErrorCodeCollectFieldsScriptFailed = 4;
NSInteger const AppExtensionErrorCodeFillFieldsScriptFailed = 5;
NSInteger const AppExtensionErrorCodeUnexpectedData = 6;
NSInteger const AppExtensionErrorCodeFailedToObtainURLStringFromWebView = 7;


@implementation OnePasswordExtension
Expand Down Expand Up @@ -352,6 +353,12 @@ + (NSError *)failedToLoadItemProviderDataErrorWithUnderlyingError:(NSError *)und
return [[NSError alloc] initWithDomain:AppExtensionErrorDomain code:AppExtensionErrorCodeFailedToLoadItemProviderData userInfo:userInfo];
}

+ (NSError *)failedToObtainURLStringFromWebViewError {
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") };
return [NSError errorWithDomain:AppExtensionErrorDomain code:AppExtensionErrorCodeFailedToObtainURLStringFromWebView userInfo:userInfo];
}


#pragma mark - App Extension ItemProvider Callback

#ifdef __IPHONE_8_0
Expand Down Expand Up @@ -433,6 +440,12 @@ - (void)fillLoginIntoUIWebView:(UIWebView *)webView webViewController:(UIViewCon
}

- (void)findLoginIn1PasswordWithURLString:URLString collectedPageDetails:(NSString *)collectedPageDetails forWebViewController:(UIViewController *)forViewController sender:(id)sender withWebView:(id)webView completion:(void (^)(BOOL success, NSError *error))completion {
if ([URLString length] == 0) {
NSError *URLStringError = [OnePasswordExtension failedToObtainURLStringFromWebViewError];
NSLog(@"Failed to findLoginIn1PasswordWithURLString: %@", URLStringError);
completion(NO, URLStringError);
}

NSDictionary *item = @{ AppExtensionVersionNumberKey : VERSION_NUMBER, AppExtensionURLStringKey : URLString, AppExtensionWebViewPageDetails : collectedPageDetails };

__weak __typeof__ (self) miniMe = self;
Expand Down