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
3 // found in the LICENSE file.
5 #include "remoting/test/host_info.h"
7 #include "base/logging.h"
12 HostInfo::HostInfo() {
15 HostInfo::~HostInfo() {
18 bool HostInfo::ParseHostInfo(const base::DictionaryValue
& host_info
) {
19 const base::ListValue
* list_value
= nullptr;
21 // Add TokenUrlPatterns to HostInfo.
22 if (host_info
.GetList("tokenUrlPatterns", &list_value
)) {
23 if (!list_value
->empty()) {
24 for (base::Value
* item
: *list_value
) {
25 std::string token_url_pattern
;
26 if (!item
->GetAsString(&token_url_pattern
)) {
29 token_url_patterns
.push_back(token_url_pattern
);
34 std::string response_status
;
35 host_info
.GetString("status", &response_status
);
36 if (response_status
== "ONLINE") {
37 status
= kHostStatusOnline
;
38 } else if (response_status
== "OFFLINE") {
39 status
= kHostStatusOffline
;
41 LOG(ERROR
) << "Response Status is " << response_status
;
45 if (!host_info
.GetString("hostId", &host_id
)) {
46 LOG(ERROR
) << "hostId was not found in host_info";
50 if (!host_info
.GetString("hostName", &host_name
)) {
51 LOG(ERROR
) << "hostName was not found in host_info";
55 if (!host_info
.GetString("publicKey", &public_key
)) {
56 LOG(ERROR
) << "publicKey was not found for " << host_name
;
60 // If the host entry was created but the host was never online, then the jid
62 if (!host_info
.GetString("jabberId", &host_jid
) &&
63 status
== kHostStatusOnline
) {
64 LOG(ERROR
) << host_name
<< " is online but is missing a jabberId";
68 host_info
.GetString("hostOfflineReason", &offline_reason
);
74 } // namespace remoting