OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * |
| 3 * Copyright 2015, Google Inc. |
| 4 * All rights reserved. |
3 * | 5 * |
4 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
6 * met: | 8 * met: |
7 * | 9 * |
8 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 12 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 13 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 14 * in the documentation and/or other materials provided with the |
13 * distribution. | 15 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 16 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 17 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 18 * this software without specific prior written permission. |
17 * | 19 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 * |
29 */ | 32 */ |
30 #ifndef DedicatedWorkerThread_h | |
31 #define DedicatedWorkerThread_h | |
32 | 33 |
33 #include "core/workers/WorkerThread.h" | 34 #import "SelectUserViewController.h" |
34 | 35 |
35 namespace blink { | 36 #import "MakeRPCViewController.h" |
36 | 37 |
37 class InProcessWorkerObjectProxy; | 38 @implementation SelectUserViewController |
38 class WorkerThreadStartupData; | |
39 | 39 |
40 class DedicatedWorkerThread final : public WorkerThread { | 40 - (void)viewDidLoad { |
41 public: | 41 [super viewDidLoad]; |
42 static PassOwnPtr<DedicatedWorkerThread> create(PassRefPtr<WorkerLoaderProxy
>, InProcessWorkerObjectProxy&, double timeOrigin); | |
43 ~DedicatedWorkerThread() override; | |
44 | 42 |
45 WorkerBackingThread& workerBackingThread() override { return *m_workerBackin
gThread; } | 43 self.signOutButton.layer.cornerRadius = 5; |
46 InProcessWorkerObjectProxy& workerObjectProxy() const { return m_workerObjec
tProxy; } | 44 self.signOutButton.hidden = YES; |
47 | 45 |
48 protected: | 46 // As instructed in https://developers.google.com/identity/sign-in/ios/sign-in |
49 WorkerGlobalScope* createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupDat
a>) override; | 47 GIDSignIn *signIn = GIDSignIn.sharedInstance; |
50 void postInitialize() override; | 48 signIn.delegate = self; |
| 49 signIn.uiDelegate = self; |
51 | 50 |
52 private: | 51 // As instructed in https://developers.google.com/identity/sign-in/ios/additio
nal-scopes |
53 DedicatedWorkerThread(PassRefPtr<WorkerLoaderProxy>, InProcessWorkerObjectPr
oxy&, double timeOrigin); | 52 if (![signIn.scopes containsObject:kTestScope]) { |
| 53 signIn.scopes = [signIn.scopes arrayByAddingObject:kTestScope]; |
| 54 } |
54 | 55 |
55 OwnPtr<WorkerBackingThread> m_workerBackingThread; | 56 [signIn signInSilently]; |
56 InProcessWorkerObjectProxy& m_workerObjectProxy; | 57 } |
57 double m_timeOrigin; | |
58 }; | |
59 | 58 |
60 } // namespace blink | 59 - (void)signIn:(GIDSignIn *)signIn |
| 60 didSignInForUser:(GIDGoogleUser *)user |
| 61 withError:(NSError *)error { |
| 62 if (error) { |
| 63 // The user probably cancelled the sign-in flow. |
| 64 return; |
| 65 } |
61 | 66 |
62 #endif // DedicatedWorkerThread_h | 67 self.mainLabel.text = [NSString stringWithFormat:@"User: %@", user.profile.ema
il]; |
| 68 NSString *scopes = [user.accessibleScopes componentsJoinedByString:@", "]; |
| 69 scopes = scopes.length ? scopes : @"(none)"; |
| 70 self.subLabel.text = [NSString stringWithFormat:@"Scopes: %@", scopes]; |
| 71 |
| 72 self.signInButton.hidden = YES; |
| 73 self.signOutButton.hidden = NO; |
| 74 } |
| 75 |
| 76 - (IBAction)didTapSignOut { |
| 77 [GIDSignIn.sharedInstance signOut]; |
| 78 |
| 79 self.mainLabel.text = @"Please sign in."; |
| 80 self.subLabel.text = @""; |
| 81 |
| 82 self.signInButton.hidden = NO; |
| 83 self.signOutButton.hidden = YES; |
| 84 } |
| 85 |
| 86 @end |
OLD | NEW |