forked from google/GoogleSignIn-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGIDSignInInternalOptions.m
More file actions
126 lines (116 loc) · 6.08 KB
/
GIDSignInInternalOptions.m
File metadata and controls
126 lines (116 loc) · 6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright 2021 Google LLC
//
// Licensed 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 "GoogleSignIn/Sources/GIDSignInInternalOptions.h"
#if __has_include(<UIKit/UIKit.h>)
#import <UIKit/UIKit.h>
#elif __has_include(<AppKit/AppKit.h>)
#import <AppKit/AppKit.h>
#endif
#import "GoogleSignIn/Sources/GIDScopes.h"
NS_ASSUME_NONNULL_BEGIN
@implementation GIDSignInInternalOptions
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
presentingViewController:(nullable UIViewController *)presentingViewController
loginHint:(nullable NSString *)loginHint
addScopesFlow:(BOOL)addScopesFlow
scopes:(nullable NSArray *)scopes
completion:(nullable GIDSignInCompletion)completion {
#elif TARGET_OS_OSX
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
presentingWindow:(nullable NSWindow *)presentingWindow
loginHint:(nullable NSString *)loginHint
addScopesFlow:(BOOL)addScopesFlow
scopes:(nullable NSArray *)scopes
completion:(nullable GIDSignInCompletion)completion {
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
if (options) {
options->_interactive = YES;
options->_continuation = NO;
options->_addScopesFlow = addScopesFlow;
options->_configuration = configuration;
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
options->_presentingViewController = presentingViewController;
#elif TARGET_OS_OSX
options->_presentingWindow = presentingWindow;
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
options->_loginHint = loginHint;
options->_completion = completion;
options->_scopes = [GIDScopes scopesWithBasicProfile:scopes];
}
return options;
}
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
presentingViewController:(nullable UIViewController *)presentingViewController
loginHint:(nullable NSString *)loginHint
addScopesFlow:(BOOL)addScopesFlow
completion:(nullable GIDSignInCompletion)completion {
#elif TARGET_OS_OSX
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
presentingWindow:(nullable NSWindow *)presentingWindow
loginHint:(nullable NSString *)loginHint
addScopesFlow:(BOOL)addScopesFlow
completion:(nullable GIDSignInCompletion)completion {
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:configuration
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
presentingViewController:presentingViewController
#elif TARGET_OS_OSX
presentingWindow:presentingWindow
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
loginHint:loginHint
addScopesFlow:addScopesFlow
scopes:@[]
completion:completion];
return options;
}
+ (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion {
GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:nil
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
presentingViewController:nil
#elif TARGET_OS_OSX
presentingWindow:nil
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
loginHint:nil
addScopesFlow:NO
completion:completion];
if (options) {
options->_interactive = NO;
}
return options;
}
- (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams
forContinuation:(BOOL)continuation {
GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
if (options) {
options->_interactive = _interactive;
options->_continuation = continuation;
options->_addScopesFlow = _addScopesFlow;
options->_configuration = _configuration;
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
options->_presentingViewController = _presentingViewController;
#elif TARGET_OS_OSX
options->_presentingWindow = _presentingWindow;
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
options->_loginHint = _loginHint;
options->_completion = _completion;
options->_scopes = _scopes;
options->_extraParams = [extraParams copy];
}
return options;
}
@end
NS_ASSUME_NONNULL_END