Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audits extension for nullability #218

Merged
merged 1 commit into from
Jun 15, 2015
Merged
Show file tree
Hide file tree
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
20 changes: 12 additions & 8 deletions OnePasswordExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#import <WebKit/WebKit.h>
#endif

NS_ASSUME_NONNULL_BEGIN

// Login Dictionary keys - Used to get or set the properties of a 1Password Login
#define AppExtensionURLStringKey @"url_string"
#define AppExtensionUsernameKey @"username"
Expand Down Expand Up @@ -85,7 +87,7 @@

@param error Reply parameter that is nil if the 1Password Extension has been successfully completed, or it contains error information about the completion failure.
*/
- (void)findLoginForURLString:(NSString *)URLString forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(NSDictionary *loginDictionary, NSError *error))completion;
- (void)findLoginForURLString:(NSString *)URLString forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(NSDictionary * __nullable loginDictionary, NSError *error))completion;

/*!
Create a new login within 1Password and allow the user to generate a new password before saving.
Expand All @@ -108,7 +110,7 @@

@param error Reply parameter that is nil if the 1Password Extension has been successfully completed, or it contains error information about the completion failure.
*/
- (void)storeLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary *)loginDetailsDictionary passwordGenerationOptions:(NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(NSDictionary *loginDictionary, NSError *error))completion;
- (void)storeLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary *)loginDetailsDictionary passwordGenerationOptions:(nullable NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(NSDictionary * __nullable loginDictionary, NSError * __nullable error))completion;

/*!
Change the password for an existing login within 1Password.
Expand All @@ -134,7 +136,7 @@

@param error Reply parameter that is nil if the 1Password Extension has been successfully completed, or it contains error information about the completion failure.
*/
- (void)changePasswordForLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary *)loginDetailsDict passwordGenerationOptions:(NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(NSDictionary *loginDictionary, NSError *error))completion;
- (void)changePasswordForLoginForURLString:(NSString *)URLString loginDetails:(nullable NSDictionary *)loginDetailsDict passwordGenerationOptions:(nullable NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(NSDictionary * __nullable loginDictionary, NSError * __nullable error))completion;

/*!
Called from your web view controller, this method will show all the saved logins for the active page in the provided web
Expand All @@ -154,15 +156,15 @@

@param error Reply parameter that is nil if the 1Password Extension has been successfully completed, or it contains error information about the completion failure.
*/
- (void)fillItemIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(id)sender showOnlyLogins:(BOOL)yesOrNo completion:(void (^)(BOOL success, NSError *error))completion;
- (void)fillItemIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(nullable id)sender showOnlyLogins:(BOOL)yesOrNo completion:(nullable void (^)(BOOL success, NSError * __nullable error))completion;

/*!
Called in the UIActivityViewController completion block to find out whether or not the user selected the 1Password Extension activity.

@param the bundle identidier of the selected activity in the share sheet.
@return YES if the selected activity is the 1Password extension, NO otherwise.
*/
- (BOOL)isOnePasswordExtensionActivityType:(NSString *)activityType;
- (BOOL)isOnePasswordExtensionActivityType:(nullable NSString *)activityType;

/*!
The returned NSExtensionItem can be used to create your own UIActivityViewController. Use `isOnePasswordExtensionActivityType:` and `fillReturnedItems:intoWebView:completion:` in the activity view controller completion block to process the result. The completion block is guaranteed to be called on the main thread.
Expand All @@ -173,7 +175,7 @@

@param error Reply parameter that is nil if the 1Password extension item has been successfully created, or it contains error information about the completion failure.
*/
- (void)createExtensionItemForWebView:(id)webView completion:(void (^)(NSExtensionItem *extensionItem, NSError *error))completion;
- (void)createExtensionItemForWebView:(id)webView completion:(void (^)(NSExtensionItem * __nullable extensionItem, NSError * __nullable error))completion;

/*!
Method used in the UIActivityViewController completion block to fill information into a web view.
Expand All @@ -185,11 +187,13 @@

@param error Reply parameter that is nil if the 1Password Extension has been successfully completed, or it contains error information about the completion failure.
*/
- (void)fillReturnedItems:(NSArray *)returnedItems intoWebView:(id)webView completion:(void (^)(BOOL success, NSError *error))completion;
- (void)fillReturnedItems:(NSArray *)returnedItems intoWebView:(id)webView completion:(nullable void (^)(BOOL success, NSError * __nullable error))completion;

/*!
Deprecated in version 1.3.
@see Use fillItemIntoWebView:forViewController:sender:showOnlyLogins:completion: instead
*/
- (void)fillLoginIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(BOOL success, NSError *error))completion __attribute__((deprecated("Use fillItemIntoWebView:forViewController:sender:showOnlyLogins:completion: instead. Deprecated in version 1.3")));
- (void)fillLoginIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(BOOL success, NSError * __nullable error))completion __attribute__((deprecated("Use fillItemIntoWebView:forViewController:sender:showOnlyLogins:completion: instead. Deprecated in version 1.3")));
@end

NS_ASSUME_NONNULL_END
18 changes: 10 additions & 8 deletions OnePasswordExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ - (BOOL)isAppExtensionAvailable {

#pragma mark - Native app Login

- (void)findLoginForURLString:(NSString *)URLString forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(NSDictionary *loginDictionary, NSError *error))completion {
- (void)findLoginForURLString:(NSString *)URLString forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(NSDictionary * __nullable loginDictionary, NSError * __nullable error))completion {
NSAssert(URLString != nil, @"URLString must not be nil");
NSAssert(viewController != nil, @"viewController must not be nil");

Expand Down Expand Up @@ -103,7 +103,7 @@ - (void)findLoginForURLString:(NSString *)URLString forViewController:(UIViewCon

#pragma mark - New User Registration

- (void)storeLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary *)loginDetailsDictionary passwordGenerationOptions:(NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(NSDictionary *loginDictionary, NSError *error))completion {
- (void)storeLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary *)loginDetailsDictionary passwordGenerationOptions:(nullable NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(NSDictionary * __nullable loginDictionary, NSError * __nullable error))completion {
NSAssert(URLString != nil, @"URLString must not be nil");
NSAssert(loginDetailsDictionary != nil, @"loginDetailsDict must not be nil");
NSAssert(viewController != nil, @"viewController must not be nil");
Expand Down Expand Up @@ -159,7 +159,7 @@ - (void)storeLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary

#pragma mark - Change Password

- (void)changePasswordForLoginForURLString:(NSString *)URLString loginDetails:(NSDictionary *)loginDetailsDict passwordGenerationOptions:(NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(NSDictionary *loginDictionary, NSError *error))completion {
- (void)changePasswordForLoginForURLString:(NSString *)URLString loginDetails:(nullable NSDictionary *)loginDetailsDict passwordGenerationOptions:(nullable NSDictionary *)passwordGenerationOptions forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(NSDictionary * __nullable loginDictionary, NSError * __nullable error))completion {
NSAssert(URLString != nil, @"URLString must not be nil");
NSAssert(viewController != nil, @"viewController must not be nil");

Expand Down Expand Up @@ -214,7 +214,7 @@ - (void)changePasswordForLoginForURLString:(NSString *)URLString loginDetails:(N

#pragma mark - Web View filling Support

- (void)fillItemIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(id)sender showOnlyLogins:(BOOL)yesOrNo completion:(void (^)(BOOL success, NSError *error))completion {
- (void)fillItemIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(nullable id)sender showOnlyLogins:(BOOL)yesOrNo completion:(nullable void (^)(BOOL success, NSError * __nullable error))completion {
NSAssert(webView != nil, @"webView must not be nil");
NSAssert(viewController != nil, @"viewController must not be nil");

Expand Down Expand Up @@ -243,11 +243,11 @@ - (void)fillItemIntoWebView:(id)webView forViewController:(UIViewController *)vi

#pragma mark - Support for custom UIActivityViewControllers

- (BOOL)isOnePasswordExtensionActivityType:(NSString *)activityType {
- (BOOL)isOnePasswordExtensionActivityType:(nullable NSString *)activityType {
return [@"com.agilebits.onepassword-ios.extension" isEqualToString:activityType] || [@"com.agilebits.beta.onepassword-ios.extension" isEqualToString:activityType];
}

- (void)createExtensionItemForWebView:(id)webView completion:(void (^)(NSExtensionItem *extensionItem, NSError *error))completion {
- (void)createExtensionItemForWebView:(id)webView completion:(void (^)(NSExtensionItem * __nullable extensionItem, NSError * __nullable error))completion {
NSAssert(webView != nil, @"webView must not be nil");

#ifdef __IPHONE_8_0
Expand Down Expand Up @@ -288,7 +288,9 @@ - (void)createExtensionItemForWebView:(id)webView completion:(void (^)(NSExtensi
#endif
}

- (void)fillReturnedItems:(NSArray *)returnedItems intoWebView:(id)webView completion:(void (^)(BOOL success, NSError *error))completion {
- (void)fillReturnedItems:(NSArray *)returnedItems intoWebView:(id)webView completion:(nullable void (^)(BOOL success, NSError * __nullable error))completion {
NSAssert(webView != nil, @"webView must not be nil");

if (returnedItems.count == 0) {
NSError *error = [OnePasswordExtension extensionCancelledByUserError];
if (completion) {
Expand Down Expand Up @@ -667,7 +669,7 @@ + (NSError *)failedToObtainURLStringFromWebViewError {
Deprecated in version 1.3.
Use fillItemIntoWebView:forViewController:sender:showOnlyLogins:completion: instead
*/
- (void)fillLoginIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(BOOL success, NSError *error))completion {
- (void)fillLoginIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(nullable id)sender completion:(nullable void (^)(BOOL success, NSError * __nullable error))completion {
[self fillItemIntoWebView:webView forViewController:viewController sender:sender showOnlyLogins:YES completion:completion];
}

Expand Down