Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: remoting/client/ios/app/remoting_view_controller.mm

Issue 2828113002: Provide HostView with data required for creating a new and session, and render for CRD iOS. (Closed)
Patch Set: fixing issue based on feedback. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/app/remoting_view_controller.h" 9 #import "remoting/client/ios/app/remoting_view_controller.h"
10 10
11 #import "base/mac/bind_objc_block.h"
11 #import "ios/third_party/material_components_ios/src/components/AnimationTiming/ src/MaterialAnimationTiming.h" 12 #import "ios/third_party/material_components_ios/src/components/AnimationTiming/ src/MaterialAnimationTiming.h"
12 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h" 13 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h"
13 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate rialDialogs.h" 14 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate rialDialogs.h"
14 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 15 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
15 #import "remoting/client/ios/app/host_collection_view_controller.h" 16 #import "remoting/client/ios/app/host_collection_view_controller.h"
16 #import "remoting/client/ios/app/host_view_controller.h" 17 #import "remoting/client/ios/app/host_view_controller.h"
17 #import "remoting/client/ios/app/pin_entry_view_controller.h" 18 #import "remoting/client/ios/app/pin_entry_view_controller.h"
18 #import "remoting/client/ios/app/remoting_settings_view_controller.h" 19 #import "remoting/client/ios/app/remoting_settings_view_controller.h"
19 #import "remoting/client/ios/facade/remoting_service.h" 20 #import "remoting/client/ios/facade/remoting_service.h"
21 #import "remoting/client/ios/session/remoting_client.h"
22
23 #include "base/strings/sys_string_conversions.h"
24 #include "remoting/base/oauth_token_getter.h"
25 #include "remoting/client/connect_to_host_info.h"
20 26
21 static CGFloat kHostInset = 5.f; 27 static CGFloat kHostInset = 5.f;
22 28
23 @interface RemotingViewController ()<HostCollectionViewControllerDelegate, 29 @interface RemotingViewController ()<HostCollectionViewControllerDelegate,
24 UIViewControllerAnimatedTransitioning, 30 UIViewControllerAnimatedTransitioning,
25 UIViewControllerTransitioningDelegate> { 31 UIViewControllerTransitioningDelegate> {
26 bool _isAuthenticated; 32 bool _isAuthenticated;
27 MDCDialogTransitionController* _dialogTransitionController; 33 MDCDialogTransitionController* _dialogTransitionController;
28 MDCAppBar* _appBar; 34 MDCAppBar* _appBar;
29 HostCollectionViewController* _collectionViewController; 35 HostCollectionViewController* _collectionViewController;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 - (void)viewDidLoad { 91 - (void)viewDidLoad {
86 [super viewDidLoad]; 92 [super viewDidLoad];
87 [_appBar addSubviewsToParent]; 93 [_appBar addSubviewsToParent];
88 [self presentStatus]; 94 [self presentStatus];
89 } 95 }
90 96
91 - (void)viewDidAppear:(BOOL)animated { 97 - (void)viewDidAppear:(BOOL)animated {
92 if (!_isAuthenticated) { 98 if (!_isAuthenticated) {
93 // TODO(nicholss): This is used as a demo of the app functionality for the 99 // TODO(nicholss): This is used as a demo of the app functionality for the
94 // moment but the real app will force the login flow if unauthenticated. 100 // moment but the real app will force the login flow if unauthenticated.
95 //[self didSelectSettings]; 101 [self didSelectSettings];
96 [self didSelectRefresh]; 102 // [self didSelectRefresh];
97 MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; 103 MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init];
98 message.text = @"Please login."; 104 message.text = @"Please login.";
99 [MDCSnackbarManager showMessage:message]; 105 [MDCSnackbarManager showMessage:message];
100 } 106 }
101 } 107 }
102 108
103 #pragma mark - RemotingAuthenticationDelegate 109 #pragma mark - RemotingAuthenticationDelegate
104 110
105 - (void)nowAuthenticated:(BOOL)authenticated { 111 - (void)nowAuthenticated:(BOOL)authenticated {
106 if (authenticated) { 112 if (authenticated) {
(...skipping 16 matching lines...) Expand all
123 // TODO(nicholss): these need to be a stats change like "none, loading, 129 // TODO(nicholss): these need to be a stats change like "none, loading,
124 // updated"... 130 // updated"...
125 - (void)hostListUpdated { 131 - (void)hostListUpdated {
126 [_collectionViewController.collectionView reloadData]; 132 [_collectionViewController.collectionView reloadData];
127 } 133 }
128 134
129 #pragma mark - HostCollectionViewControllerDelegate 135 #pragma mark - HostCollectionViewControllerDelegate
130 136
131 - (void)didSelectCell:(HostCollectionViewCell*)cell 137 - (void)didSelectCell:(HostCollectionViewCell*)cell
132 completion:(void (^)())completionBlock { 138 completion:(void (^)())completionBlock {
133 HostViewController* hostVC = [HostViewController new]; 139 RemotingClient* client = [[RemotingClient alloc] init];
134 [self presentViewController:hostVC animated:YES completion:nil]; 140
141 [_remotingService
142 callbackWithAccessToken:base::BindBlockArc(^(
Jamie 2017/04/24 21:54:11 Can you pull this block out into a variable? It's
nicholss 2017/04/24 22:03:07 The blind blocks are suppose to be used inline lik
Jamie 2017/04/24 22:07:42 One advantage is that the name of the variable mak
143 remoting::OAuthTokenGetter::Status status,
144 const std::string& user_email,
145 const std::string& access_token) {
146 // TODO(nicholss): Check status.
147 HostInfo* hostInfo = cell.hostInfo;
148 DCHECK(hostInfo);
149 DCHECK(hostInfo.jabberId);
150 DCHECK(hostInfo.hostId);
151 DCHECK(hostInfo.publicKey);
152
153 remoting::ConnectToHostInfo info;
154 info.username = user_email;
155 info.auth_token = access_token;
156 info.host_jid = base::SysNSStringToUTF8(hostInfo.jabberId);
157 info.host_id = base::SysNSStringToUTF8(hostInfo.hostId);
158 info.host_pubkey = base::SysNSStringToUTF8(hostInfo.publicKey);
159 // TODO(nicholss): If iOS supports pairing, pull the stored data and
160 // insert it here.
161 info.pairing_id = "";
162 info.pairing_secret = "";
163
164 // TODO(nicholss): I am not sure about the following fields yet.
165 // info.capabilities =
166 // info.flags =
167 // info.host_version =
168 // info.host_os =
169 // info.host_os_version =
170 [client connectToHost:info];
171 })];
172
173 HostViewController* hostViewController =
174 [[HostViewController alloc] initWithClient:client];
175
176 // TODO(nicholss): Add feedback on status of request.
177 [self presentViewController:hostViewController animated:YES completion:nil];
178
179 completionBlock();
135 } 180 }
136 181
137 - (NSInteger)getHostCount { 182 - (NSInteger)getHostCount {
138 NSArray<HostInfo*>* hosts = [_remotingService getHosts]; 183 NSArray<HostInfo*>* hosts = [_remotingService getHosts];
139 return [hosts count]; 184 return [hosts count];
140 } 185 }
141 186
142 - (HostInfo*)getHostAtIndexPath:(NSIndexPath*)path { 187 - (HostInfo*)getHostAtIndexPath:(NSIndexPath*)path {
143 NSArray<HostInfo*>* hosts = [_remotingService getHosts]; 188 NSArray<HostInfo*>* hosts = [_remotingService getHosts];
144 return hosts[path.row]; 189 return hosts[path.row];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; 242 MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init];
198 if (_isAuthenticated) { 243 if (_isAuthenticated) {
199 UserInfo* user = [_remotingService getUser]; 244 UserInfo* user = [_remotingService getUser];
200 message.text = [NSString 245 message.text = [NSString
201 stringWithFormat:@"Currently signed in as %@.", [user userEmail]]; 246 stringWithFormat:@"Currently signed in as %@.", [user userEmail]];
202 [MDCSnackbarManager showMessage:message]; 247 [MDCSnackbarManager showMessage:message];
203 } 248 }
204 } 249 }
205 250
206 @end 251 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698