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

Unified Diff: remoting/client/ios/session/remoting_client.mm

Issue 2871993003: Moving the iOS directory to be remoting top level. (Closed)
Patch Set: //remoting/ios was the old landing target for the internal iOS application. Fix. 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/ios/session/remoting_client.mm
diff --git a/remoting/client/ios/session/remoting_client.mm b/remoting/client/ios/session/remoting_client.mm
deleted file mode 100644
index 3338641dd05570114f7838f6be232c2789727f7d..0000000000000000000000000000000000000000
--- a/remoting/client/ios/session/remoting_client.mm
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
-#import "remoting/client/ios/session/remoting_client.h"
-
-#include <memory>
-
-#import "base/mac/bind_objc_block.h"
-#import "ios/third_party/material_components_ios/src/components/Dialogs/src/MaterialDialogs.h"
-#import "remoting/client/ios/display/gl_display_handler.h"
-#import "remoting/client/ios/domain/client_session_details.h"
-#import "remoting/client/ios/domain/host_info.h"
-
-#include "base/strings/sys_string_conversions.h"
-#include "remoting/client/chromoting_client_runtime.h"
-#include "remoting/client/chromoting_session.h"
-#include "remoting/client/connect_to_host_info.h"
-#include "remoting/client/gesture_interpreter.h"
-#include "remoting/client/ios/session/remoting_client_session_delegate.h"
-#include "remoting/protocol/session.h"
-#include "remoting/protocol/video_renderer.h"
-
-NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged";
-NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided";
-
-NSString* const kSessionDetails = @"kSessionDetails";
-NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode";
-NSString* const kHostSessionPin = @"kHostSessionPin";
-
-@interface RemotingClient () {
- remoting::ChromotingClientRuntime* _runtime;
- std::unique_ptr<remoting::ChromotingSession> _session;
- remoting::RemotingClientSessonDelegate* _sessonDelegate;
- ClientSessionDetails* _sessionDetails;
- // Call _secretFetchedCallback on the network thread.
- remoting::protocol::SecretFetchedCallback _secretFetchedCallback;
- std::unique_ptr<remoting::GestureInterpreter> _gestureInterpreter;
-}
-@end
-
-@implementation RemotingClient
-
-@synthesize displayHandler = _displayHandler;
-
-- (instancetype)init {
- self = [super init];
- if (self) {
- _runtime = remoting::ChromotingClientRuntime::GetInstance();
- _sessonDelegate = new remoting::RemotingClientSessonDelegate(self);
- _sessionDetails = [[ClientSessionDetails alloc] init];
-
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(hostSessionPinProvided:)
- name:kHostSessionPinProvided
- object:nil];
- }
- return self;
-}
-
-- (void)connectToHost:(HostInfo*)hostInfo
- username:(NSString*)username
- accessToken:(NSString*)accessToken {
- DCHECK(_runtime->ui_task_runner()->BelongsToCurrentThread());
- DCHECK(hostInfo);
- DCHECK(hostInfo.jabberId);
- DCHECK(hostInfo.hostId);
- DCHECK(hostInfo.publicKey);
-
- _sessionDetails.hostInfo = hostInfo;
-
- remoting::ConnectToHostInfo info;
- info.username = base::SysNSStringToUTF8(username);
- info.auth_token = base::SysNSStringToUTF8(accessToken);
- info.host_jid = base::SysNSStringToUTF8(hostInfo.jabberId);
- info.host_id = base::SysNSStringToUTF8(hostInfo.hostId);
- info.host_pubkey = base::SysNSStringToUTF8(hostInfo.publicKey);
- // TODO(nicholss): If iOS supports pairing, pull the stored data and
- // insert it here.
- info.pairing_id = "";
- info.pairing_secret = "";
-
- // TODO(nicholss): I am not sure about the following fields yet.
- // info.capabilities =
- // info.flags =
- // info.host_version =
- // info.host_os =
- // info.host_os_version =
-
- remoting::protocol::ClientAuthenticationConfig client_auth_config;
- client_auth_config.host_id = info.host_id;
- client_auth_config.pairing_client_id = info.pairing_id;
- client_auth_config.pairing_secret = info.pairing_secret;
- client_auth_config.fetch_secret_callback = base::BindBlockArc(
- ^(bool pairing_supported, const remoting::protocol::SecretFetchedCallback&
- secret_fetched_callback) {
- _secretFetchedCallback = secret_fetched_callback;
- _sessionDetails.state = SessionPinPrompt;
- [[NSNotificationCenter defaultCenter]
- postNotificationName:kHostSessionStatusChanged
- object:self
- userInfo:[NSDictionary
- dictionaryWithObject:_sessionDetails
- forKey:kSessionDetails]];
- });
-
- // TODO(nicholss): Add audio support to iOS.
- base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr;
-
- _displayHandler = [[GlDisplayHandler alloc] init];
- _displayHandler.delegate = self;
-
- _session.reset(new remoting::ChromotingSession(
- _sessonDelegate->GetWeakPtr(), [_displayHandler CreateCursorShapeStub],
- [_displayHandler CreateVideoRenderer], audioPlayer, info,
- client_auth_config));
- _session->Connect();
-
- __weak GlDisplayHandler* weakDisplayHandler = _displayHandler;
- _gestureInterpreter.reset(new remoting::GestureInterpreter(
- base::BindBlockArc(^(const remoting::ViewMatrix& matrix) {
- [weakDisplayHandler onPixelTransformationChanged:matrix];
- }),
- _session.get()));
-}
-
-- (void)disconnectFromHost {
- if (_session) {
- _session->Disconnect();
- }
- // TODO(nicholss): Do we need to cleanup more?
-}
-
-#pragma mark - Eventing
-
-- (void)hostSessionPinProvided:(NSNotification*)notification {
- NSString* pin = [[notification userInfo] objectForKey:kHostSessionPin];
- if (_secretFetchedCallback) {
- _runtime->network_task_runner()->PostTask(
- FROM_HERE, base::BindBlockArc(^{
- _secretFetchedCallback.Run(base::SysNSStringToUTF8(pin));
- }));
- }
-}
-
-#pragma mark - Properties
-
-- (HostInfo*)hostInfo {
- return _sessionDetails.hostInfo;
-}
-
-- (remoting::GestureInterpreter*)gestureInterpreter {
- return _gestureInterpreter.get();
-}
-
-#pragma mark - ChromotingSession::Delegate
-
-- (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state
- error:(remoting::protocol::ErrorCode)error {
- switch (state) {
- case remoting::protocol::ConnectionToHost::INITIALIZING:
- NSLog(@"State --> INITIALIZING");
- _sessionDetails.state = SessionInitializing;
- break;
- case remoting::protocol::ConnectionToHost::CONNECTING:
- NSLog(@"State --> CONNECTING");
- _sessionDetails.state = SessionConnecting;
- break;
- case remoting::protocol::ConnectionToHost::AUTHENTICATED:
- NSLog(@"State --> AUTHENTICATED");
- _sessionDetails.state = SessionAuthenticated;
- break;
- case remoting::protocol::ConnectionToHost::CONNECTED:
- NSLog(@"State --> CONNECTED");
- _sessionDetails.state = SessionConnected;
- break;
- case remoting::protocol::ConnectionToHost::FAILED:
- NSLog(@"State --> FAILED");
- _sessionDetails.state = SessionFailed;
- break;
- case remoting::protocol::ConnectionToHost::CLOSED:
- NSLog(@"State --> CLOSED");
- _sessionDetails.state = SessionClosed;
- break;
- default:
- LOG(ERROR) << "onConnectionState, unknown state: " << state;
- }
-
- // TODO(nicholss): Send along the error code when we know what to do about it.
- [[NSNotificationCenter defaultCenter]
- postNotificationName:kHostSessionStatusChanged
- object:self
- userInfo:[NSDictionary dictionaryWithObject:_sessionDetails
- forKey:kSessionDetails]];
-}
-
-- (void)commitPairingCredentialsForHost:(NSString*)host
- id:(NSString*)id
- secret:(NSString*)secret {
- NSLog(@"TODO(nicholss): implement this, commitPairingCredentialsForHost.");
-}
-
-- (void)fetchThirdPartyTokenForUrl:(NSString*)tokenUrl
- clientId:(NSString*)clientId
- scope:(NSString*)scope {
- NSLog(@"TODO(nicholss): implement this, fetchThirdPartyTokenForUrl.");
-}
-
-- (void)setCapabilities:(NSString*)capabilities {
- NSLog(@"TODO(nicholss): implement this, setCapabilities.");
-}
-
-- (void)handleExtensionMessageOfType:(NSString*)type
- message:(NSString*)message {
- NSLog(@"TODO(nicholss): implement this, handleExtensionMessageOfType %@:%@.",
- type, message);
-}
-
-- (void)surfaceChanged:(const CGRect&)frame {
- [_displayHandler onSurfaceChanged:frame];
- _gestureInterpreter->OnSurfaceSizeChanged(frame.size.width,
- frame.size.height);
-}
-
-#pragma mark - GlDisplayHandlerDelegate
-
-- (void)canvasSizeChanged:(CGSize)size {
- if (_gestureInterpreter) {
- _gestureInterpreter->OnDesktopSizeChanged(size.width, size.height);
- }
-}
-
-@end
« no previous file with comments | « remoting/client/ios/session/remoting_client.h ('k') | remoting/client/ios/session/remoting_client_session_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698