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

Side by Side Diff: remoting/test/host_info.cc

Issue 1237093004: Support for connecting to localhost on the chromoting test driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up ConnectionSetupInfo, comments, and merge changes. Created 5 years, 5 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 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/host_info.h" 8 #include "remoting/test/host_info.h"
6 9
7 #include "base/logging.h" 10 #include "base/logging.h"
8 11
12 namespace {
13 const char kChromotingAuthenticationMethods[] =
14 "spake2_pair,spake2_plain,spake2_hmac,third_party";
15 }
16
9 namespace remoting { 17 namespace remoting {
10 namespace test { 18 namespace test {
11 19
12 HostInfo::HostInfo() { 20 HostInfo::HostInfo() {
13 } 21 }
14 22
15 HostInfo::~HostInfo() { 23 HostInfo::~HostInfo() {
16 } 24 }
17 25
18 bool HostInfo::ParseHostInfo(const base::DictionaryValue& host_info) { 26 bool HostInfo::ParseHostInfo(const base::DictionaryValue& host_info) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 status == kHostStatusOnline) { 71 status == kHostStatusOnline) {
64 LOG(ERROR) << host_name << " is online but is missing a jabberId"; 72 LOG(ERROR) << host_name << " is online but is missing a jabberId";
65 return false; 73 return false;
66 } 74 }
67 75
68 host_info.GetString("hostOfflineReason", &offline_reason); 76 host_info.GetString("hostOfflineReason", &offline_reason);
69 77
70 return true; 78 return true;
71 } 79 }
72 80
81 bool HostInfo::IsReadyForConnection() const {
82 return !host_jid.empty() && status == kHostStatusOnline;
83 }
84
85 ConnectionSetupInfo HostInfo::GenerateConnectionSetupInfo(
86 const std::string& access_token,
87 const std::string& user_name,
88 const std::string& pin) const {
89 ConnectionSetupInfo connection_setup_info;
90 connection_setup_info.access_token = access_token;
91 connection_setup_info.host_id = host_id;
92 connection_setup_info.host_jid = host_jid;
93 connection_setup_info.host_name = host_name;
94 connection_setup_info.pin = pin;
95 connection_setup_info.public_key = public_key;
96 connection_setup_info.user_name = user_name;
97
98 // Parse |kChromotingAuthenticationMethods| for authentication methods.
99 std::vector<std::string> parts;
100 base::SplitString(kChromotingAuthenticationMethods, ',', &parts);
101 std::vector<protocol::AuthenticationMethod> auth_methods;
102 for (std::string part : parts) {
joedow 2015/07/16 23:26:34 I don't think you need to do any string parsing he
tonychun 2015/07/17 16:25:49 Done.
103 protocol::AuthenticationMethod auth_method =
104 protocol::AuthenticationMethod::FromString(part);
105 if (auth_method.is_valid()) {
106 connection_setup_info.auth_methods.push_back(auth_method);
107 }
108 }
109
110 return connection_setup_info;
111 }
112
73 } // namespace test 113 } // namespace test
74 } // namespace remoting 114 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698