OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
6 #error "This file requires ARC support." | |
7 #endif | |
8 | |
9 #include "remoting/client/ios/session/remoting_client_session_delegate.h" | |
10 | |
11 #import "remoting/client/ios/session/remoting_client.h" | |
12 | |
13 #include "base/strings/sys_string_conversions.h" | |
14 #include "remoting/client/chromoting_client_runtime.h" | |
15 | |
16 using base::SysUTF8ToNSString; | |
17 | |
18 namespace remoting { | |
19 | |
20 RemotingClientSessonDelegate::RemotingClientSessonDelegate( | |
21 RemotingClient* client) | |
22 : client_(client), weak_factory_(this) { | |
23 runtime_ = ChromotingClientRuntime::GetInstance(); | |
24 } | |
25 | |
26 RemotingClientSessonDelegate::~RemotingClientSessonDelegate() { | |
27 client_ = nil; | |
28 } | |
29 | |
30 void RemotingClientSessonDelegate::OnConnectionState( | |
31 protocol::ConnectionToHost::State state, | |
32 protocol::ErrorCode error) { | |
33 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | |
34 | |
35 [client_ onConnectionState:state error:error]; | |
36 } | |
37 | |
38 void RemotingClientSessonDelegate::CommitPairingCredentials( | |
39 const std::string& host, | |
40 const std::string& id, | |
41 const std::string& secret) { | |
42 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | |
43 | |
44 [client_ commitPairingCredentialsForHost:SysUTF8ToNSString(host) | |
45 id:SysUTF8ToNSString(id) | |
46 secret:SysUTF8ToNSString(secret)]; | |
47 } | |
48 | |
49 void RemotingClientSessonDelegate::FetchThirdPartyToken( | |
50 const std::string& token_url, | |
51 const std::string& client_id, | |
52 const std::string& scope) { | |
53 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | |
54 | |
55 [client_ fetchThirdPartyTokenForUrl:SysUTF8ToNSString(token_url) | |
56 clientId:SysUTF8ToNSString(client_id) | |
57 scope:SysUTF8ToNSString(scope)]; | |
58 } | |
59 | |
60 void RemotingClientSessonDelegate::SetCapabilities( | |
61 const std::string& capabilities) { | |
62 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | |
63 | |
64 [client_ setCapabilities:SysUTF8ToNSString(capabilities)]; | |
65 } | |
66 | |
67 void RemotingClientSessonDelegate::HandleExtensionMessage( | |
68 const std::string& type, | |
69 const std::string& message) { | |
70 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | |
71 | |
72 [client_ handleExtensionMessageOfType:SysUTF8ToNSString(type) | |
73 message:SysUTF8ToNSString(message)]; | |
74 } | |
75 | |
76 base::WeakPtr<RemotingClientSessonDelegate> | |
77 RemotingClientSessonDelegate::GetWeakPtr() { | |
78 return weak_factory_.GetWeakPtr(); | |
79 } | |
80 | |
81 } // namespace remoting | |
OLD | NEW |