OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | |
6 #include "base/strings/string_split.h" | |
7 #include "remoting/protocol/authentication_method.h" | |
5 #include "remoting/test/remote_host_info.h" | 8 #include "remoting/test/remote_host_info.h" |
6 | 9 |
7 #include "base/logging.h" | 10 #include "base/logging.h" |
8 | 11 |
12 namespace { | |
13 const char kAppRemotingCapabilities[] = | |
14 "rateLimitResizeRequests desktopShape sendInitialResolution googleDrive"; | |
15 const char kAppRemotingAuthenticationMethods[] = "third_party"; | |
16 const char kFakeHostPublicKey[] = "FAKE_HOST_PUBLIC_KEY"; | |
17 } | |
18 | |
9 namespace remoting { | 19 namespace remoting { |
10 namespace test { | 20 namespace test { |
11 | 21 |
12 RemoteHostInfo::RemoteHostInfo() | 22 RemoteHostInfo::RemoteHostInfo() |
13 : remote_host_status(kRemoteHostStatusUnknown) { | 23 : remote_host_status(kRemoteHostStatusUnknown) { |
14 } | 24 } |
15 | 25 |
16 RemoteHostInfo::~RemoteHostInfo() { | 26 RemoteHostInfo::~RemoteHostInfo() { |
17 } | 27 } |
18 | 28 |
19 bool RemoteHostInfo::IsReadyForConnection() const { | 29 bool RemoteHostInfo::IsReadyForConnection() const { |
20 return (remote_host_status == kRemoteHostStatusReady); | 30 return remote_host_status == kRemoteHostStatusReady; |
21 } | 31 } |
22 | 32 |
23 void RemoteHostInfo::SetRemoteHostStatusFromString( | 33 void RemoteHostInfo::SetRemoteHostStatusFromString( |
24 const std::string& status_string) { | 34 const std::string& status_string) { |
25 if (status_string == "done") { | 35 if (status_string == "done") { |
26 remote_host_status = kRemoteHostStatusReady; | 36 remote_host_status = kRemoteHostStatusReady; |
27 } else if (status_string == "pending") { | 37 } else if (status_string == "pending") { |
28 remote_host_status = kRemoteHostStatusPending; | 38 remote_host_status = kRemoteHostStatusPending; |
29 } else { | 39 } else { |
30 LOG(WARNING) << "Unknown status passed in: " << status_string; | 40 LOG(WARNING) << "Unknown status passed in: " << status_string; |
31 remote_host_status = kRemoteHostStatusUnknown; | 41 remote_host_status = kRemoteHostStatusUnknown; |
32 } | 42 } |
33 } | 43 } |
34 | 44 |
45 ConnectionSetupInfo RemoteHostInfo::GenerateConnectionSetupInfo( | |
46 const std::string& access_token, | |
47 const std::string& user_name) const { | |
48 ConnectionSetupInfo connection_setup_info; | |
49 connection_setup_info.access_token = access_token; | |
50 connection_setup_info.authorization_code = authorization_code; | |
51 connection_setup_info.capabilities = kAppRemotingCapabilities; | |
52 connection_setup_info.host_id = host_id; | |
53 connection_setup_info.host_jid = host_jid; | |
54 connection_setup_info.public_key = kFakeHostPublicKey; | |
55 connection_setup_info.shared_secret = shared_secret; | |
56 connection_setup_info.user_name = user_name; | |
57 | |
58 // Parse |kAppRemotingAuthenticationMethods| for authentication methods. | |
59 std::vector<std::string> parts; | |
60 base::SplitString(kAppRemotingAuthenticationMethods, ',', &parts); | |
61 std::vector<protocol::AuthenticationMethod> auth_methods; | |
62 for (std::string part : parts) { | |
63 protocol::AuthenticationMethod auth_method = | |
64 protocol::AuthenticationMethod::FromString(part); | |
65 if (auth_method.is_valid()) { | |
66 connection_setup_info.auth_methods.push_back(auth_method); | |
joedow
2015/07/16 23:26:34
same as the chromoting version, please remove the
tonychun
2015/07/17 16:25:49
Done.
| |
67 } | |
68 } | |
69 | |
70 return connection_setup_info; | |
71 } | |
72 | |
35 } // namespace test | 73 } // namespace test |
36 } // namespace remoting | 74 } // namespace remoting |
OLD | NEW |