| 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/client/ios/facade/remoting_service.h" | 9 #import "remoting/client/ios/facade/remoting_service.h" |
| 10 | 10 |
| 11 #import <Foundation/Foundation.h> | 11 #import <Foundation/Foundation.h> |
| 12 | 12 |
| 13 #import "base/mac/bind_objc_block.h" | 13 #import "base/mac/bind_objc_block.h" |
| 14 | 14 |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 #include "remoting/base/oauth_token_getter.h" | 18 #include "remoting/base/oauth_token_getter.h" |
| 19 #include "remoting/base/oauth_token_getter_impl.h" | 19 #include "remoting/base/oauth_token_getter_impl.h" |
| 20 #include "remoting/client/ios/facade/host_info.h" | 20 #include "remoting/client/ios/facade/host_info.h" |
| 21 #include "remoting/client/ios/facade/host_list_fetcher.h" | 21 #include "remoting/client/ios/facade/host_list_fetcher.h" |
| 22 #include "remoting/client/ios/facade/ios_client_runtime_delegate.h" |
| 22 | 23 |
| 23 const char kOauthRedirectUrl[] = | 24 const char kOauthRedirectUrl[] = |
| 24 "https://chromoting-oauth.talkgadget." | 25 "https://chromoting-oauth.talkgadget." |
| 25 "google.com/talkgadget/oauth/chrome-remote-desktop/dev"; | 26 "google.com/talkgadget/oauth/chrome-remote-desktop/dev"; |
| 26 | 27 |
| 27 std::unique_ptr<remoting::OAuthTokenGetter> | 28 std::unique_ptr<remoting::OAuthTokenGetter> |
| 28 CreateOAuthTokenGetterWithAuthorizationCode( | 29 CreateOAuthTokenGetterWithAuthorizationCode( |
| 29 const std::string& auth_code, | 30 const std::string& auth_code, |
| 30 const remoting::OAuthTokenGetter::CredentialsUpdatedCallback& | 31 const remoting::OAuthTokenGetter::CredentialsUpdatedCallback& |
| 31 on_credentials_update) { | 32 on_credentials_update) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 59 return oauth_tokenGetter; | 60 return oauth_tokenGetter; |
| 60 } | 61 } |
| 61 | 62 |
| 62 @interface RemotingService () { | 63 @interface RemotingService () { |
| 63 std::unique_ptr<remoting::OAuthTokenGetter> _tokenGetter; | 64 std::unique_ptr<remoting::OAuthTokenGetter> _tokenGetter; |
| 64 UserInfo* _user; | 65 UserInfo* _user; |
| 65 NSArray<HostInfo*>* _hosts; | 66 NSArray<HostInfo*>* _hosts; |
| 66 id<RemotingAuthenticationDelegate> _authDelegate; | 67 id<RemotingAuthenticationDelegate> _authDelegate; |
| 67 id<RemotingHostListDelegate> _hostListDelegate; | 68 id<RemotingHostListDelegate> _hostListDelegate; |
| 68 remoting::HostListFetcher* _hostListFetcher; | 69 remoting::HostListFetcher* _hostListFetcher; |
| 70 remoting::IosClientRuntimeDelegate* _clientRuntimeDelegate; |
| 69 } | 71 } |
| 70 | 72 |
| 71 @end | 73 @end |
| 72 | 74 |
| 73 // | 75 // |
| 74 // RemodingService will act as the facade to the C++ layer that has not been | 76 // RemodingService will act as the facade to the C++ layer that has not been |
| 75 // implemented/integrated yet. | 77 // implemented/integrated yet. |
| 76 // TODO(nicholss): Implement/Integrate this class. At the moment it is being | 78 // TODO(nicholss): Implement/Integrate this class. At the moment it is being |
| 77 // used to generate fake data to implement the UI of the app. | 79 // used to generate fake data to implement the UI of the app. |
| 78 // Update: Half implemented now. User is still fake, but now real hosts lists. | 80 // Update: Half implemented now. User is still fake, but now real hosts lists. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 89 return sharedInstance; | 91 return sharedInstance; |
| 90 } | 92 } |
| 91 | 93 |
| 92 - (instancetype)init { | 94 - (instancetype)init { |
| 93 self = [super init]; | 95 self = [super init]; |
| 94 if (self) { | 96 if (self) { |
| 95 _user = nil; | 97 _user = nil; |
| 96 _hosts = nil; | 98 _hosts = nil; |
| 97 _hostListFetcher = new remoting::HostListFetcher( | 99 _hostListFetcher = new remoting::HostListFetcher( |
| 98 remoting::ChromotingClientRuntime::GetInstance()->url_requester()); | 100 remoting::ChromotingClientRuntime::GetInstance()->url_requester()); |
| 101 // TODO(nicholss): This might need a pointer back to the service. |
| 102 _clientRuntimeDelegate = |
| 103 new remoting::IosClientRuntimeDelegate(); |
| 104 [self runtime]->SetDelegate(_clientRuntimeDelegate); |
| 99 } | 105 } |
| 100 return self; | 106 return self; |
| 101 } | 107 } |
| 102 | 108 |
| 103 #pragma mark - RemotingService Implementation | 109 #pragma mark - RemotingService Implementation |
| 104 | 110 |
| 105 // TODO(nicholss): isAuthenticated needs to just kick off a request to | 111 // TODO(nicholss): isAuthenticated needs to just kick off a request to |
| 106 // authenticate a user. and more than one controller might want to be a delegate | 112 // authenticate a user. and more than one controller might want to be a delegate |
| 107 // for this info so need to change this to be more of the registration types. | 113 // for this info so need to change this to be more of the registration types. |
| 108 // The remoting_service might also want to be registered for authentication | 114 // The remoting_service might also want to be registered for authentication |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (![self isAuthenticated]) { | 251 if (![self isAuthenticated]) { |
| 246 return nil; | 252 return nil; |
| 247 } | 253 } |
| 248 return _hosts; | 254 return _hosts; |
| 249 } | 255 } |
| 250 | 256 |
| 251 - (remoting::ChromotingClientRuntime*)runtime { | 257 - (remoting::ChromotingClientRuntime*)runtime { |
| 252 return remoting::ChromotingClientRuntime::GetInstance(); | 258 return remoting::ChromotingClientRuntime::GetInstance(); |
| 253 } | 259 } |
| 254 | 260 |
| 261 - (void)callbackWithAccessToken: |
| 262 (const remoting::OAuthTokenGetter::TokenCallback&)onAccessToken { |
| 263 if (_tokenGetter) { |
| 264 _tokenGetter->CallWithToken(onAccessToken); |
| 265 } |
| 266 } |
| 267 |
| 255 @end | 268 @end |
| OLD | NEW |