Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_CLIENT_IOS_FACADE_REMOTING_SERVICE_H_ | 5 #ifndef REMOTING_CLIENT_IOS_FACADE_REMOTING_SERVICE_H_ |
| 6 #define REMOTING_CLIENT_IOS_FACADE_REMOTING_SERVICE_H_ | 6 #define REMOTING_CLIENT_IOS_FACADE_REMOTING_SERVICE_H_ |
| 7 | 7 |
| 8 #import "remoting/client/chromoting_client_runtime.h" | 8 #import "remoting/client/chromoting_client_runtime.h" |
| 9 #import "remoting/client/ios/domain/host_info.h" | |
| 10 #import "remoting/client/ios/domain/user_info.h" | |
| 11 | 9 |
| 12 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 13 #include "remoting/base/oauth_token_getter.h" | 11 #include "remoting/base/oauth_token_getter.h" |
| 14 | 12 |
| 15 // |RemotingAuthenticationDelegate|s are interested in authentication related | 13 @class HostInfo; |
| 16 // notifications. | 14 @class UserInfo; |
| 17 @protocol RemotingAuthenticationDelegate<NSObject> | 15 @class RemotingAuthentication; |
| 18 | 16 |
| 19 // Notifies the delegate that the authentication status of the current user has | 17 // Eventing related keys: |
| 20 // changed to a new state. | |
| 21 - (void)nowAuthenticated:(BOOL)authenticated; | |
| 22 | 18 |
| 23 @end | 19 // Hosts did update event. |
| 24 | 20 extern NSString* const kHostsDidUpdate; |
| 25 // |RemotingHostListDelegate|s are interested in notifications related to host | 21 // User did update event name. |
| 26 // list. | 22 extern NSString* const kUserDidUpdate; |
| 27 @protocol RemotingHostListDelegate<NSObject> | 23 // Map key for UserInfo object. |
| 28 | 24 extern NSString* const kUserInfo; |
| 29 - (void)hostListUpdated; | |
| 30 | |
| 31 @end | |
| 32 | 25 |
| 33 // |RemotingService| is the centralized place to ask for information about | 26 // |RemotingService| is the centralized place to ask for information about |
| 34 // authentication or query the remote services. It also helps deal with the | 27 // authentication or query the remote services. It also helps deal with the |
| 35 // runtime and threading used in the application. |RemotingService| is a | 28 // runtime and threading used in the application. |RemotingService| is a |
| 36 // singleton and should only be accessed via the |SharedInstance| method. | 29 // singleton and should only be accessed via the |SharedInstance| method. |
| 37 @interface RemotingService : NSObject | 30 @interface RemotingService : NSObject |
| 38 | 31 |
| 39 // Access to the singleton shared instance from this method. | 32 // Access to the singleton shared instance from this method. |
| 40 + (RemotingService*)SharedInstance; | 33 + (RemotingService*)SharedInstance; |
| 41 | 34 |
| 42 // Access to the current |ChromotingClientRuntime| from this method. | 35 // Logout of the current account and clear data. |
|
Yuwei
2017/05/04 05:10:14
It's kind of confusing that this class provides me
nicholss
2017/05/08 17:08:10
I like the fact that authentication object is expo
| |
| 43 - (remoting::ChromotingClientRuntime*)runtime; | 36 - (void)logout; |
| 44 | 37 |
| 45 // Register to be a |RemotingAuthenticationDelegate|. | 38 // Start a request to fetch the host list. This will produce an notification on |
| 46 - (void)setAuthenticationDelegate:(id<RemotingAuthenticationDelegate>)delegate; | 39 // |kHostsDidUpdate| when a new host is ready. |
| 40 - (void)requestHostListFetch; | |
| 47 | 41 |
| 48 // A cached answer if there is a currently authenticated user. | 42 @property(nonatomic, readonly) RemotingAuthentication* authentication; |
| 49 - (BOOL)isAuthenticated; | |
| 50 | 43 |
| 51 // Provide an |authorizationCode| to authenticate a user as the first time user | 44 // Returns the currently logged in user or nil. |
| 52 // of the application or OAuth Flow. | 45 @property(nonatomic, readonly) UserInfo* user; |
|
Yuwei
2017/05/04 05:10:14
I'm not sure how useful this can be given that it'
nicholss
2017/05/08 17:08:10
I was not 100% sure how the api would end up but I
| |
| 53 - (void)authenticateWithAuthorizationCode:(NSString*)authorizationCode; | |
| 54 | 46 |
| 55 // Provide the |refreshToken| and |email| to authenticate a user as a returning | 47 // Returns the current host list. |
| 56 // user of the application. | 48 @property(nonatomic, readonly) NSArray<HostInfo*>* hosts; |
| 57 - (void)authenticateWithRefreshToken:(NSString*)refreshToken | |
| 58 email:(NSString*)email; | |
| 59 | 49 |
| 60 // Returns the currently logged in user info from cache, or nil if no | 50 // The Chromoting Client Runtime, this holds the threads and other shared |
| 61 // currently authenticated user. | 51 // resources used by the Chromoting clients |
| 62 - (UserInfo*)getUser; | 52 @property(nonatomic, readonly) remoting::ChromotingClientRuntime* runtime; |
| 63 | |
| 64 // Register to be a |RemotingHostListDelegate|. Side effect of setting this | |
| 65 // delegate is the application will attempt to fetch a fresh host list. | |
| 66 - (void)setHostListDelegate:(id<RemotingHostListDelegate>)delegate; | |
| 67 | |
| 68 // Returns the currently cached host list or nil if none exist. | |
| 69 - (NSArray<HostInfo*>*)getHosts; | |
| 70 | |
| 71 // Fetches an OAuth Access Token and passes it back to the callback. | |
| 72 - (void)callbackWithAccessToken: | |
| 73 (const remoting::OAuthTokenGetter::TokenCallback&)onAccessToken; | |
| 74 | 53 |
| 75 @end | 54 @end |
| 76 | 55 |
| 77 #endif // REMOTING_CLIENT_IOS_FACADE_REMOTING_SERVICE_H_ | 56 #endif // REMOTING_CLIENT_IOS_FACADE_REMOTING_SERVICE_H_ |
| OLD | NEW |