Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / android / java / src / org / chromium / chromoting / HostInfo.java
blobe45ff74575662347a0422c1a020ff2c1e0a25fe2
1 // Copyright 2014 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 package org.chromium.chromoting;
7 import org.json.JSONArray;
8 import org.json.JSONException;
9 import org.json.JSONObject;
11 import java.util.ArrayList;
13 /** Class to represent a Host returned by {@link HostListLoader}. */
14 public class HostInfo {
15 public final String name;
16 public final String id;
17 public final String jabberId;
18 public final String publicKey;
19 public final boolean isOnline;
20 public final String hostOfflineReason;
21 private final ArrayList<String> mTokenUrlPatterns;
23 public HostInfo(String name,
24 String id,
25 String jabberId,
26 String publicKey,
27 ArrayList<String> tokenUrlPatterns,
28 boolean isOnline,
29 String hostOfflineReason) {
30 this.name = name;
31 this.id = id;
32 this.jabberId = jabberId;
33 this.publicKey = publicKey;
34 this.mTokenUrlPatterns = tokenUrlPatterns;
35 this.isOnline = isOnline;
36 this.hostOfflineReason = hostOfflineReason;
39 public ArrayList<String> getTokenUrlPatterns() {
40 return new ArrayList<String>(mTokenUrlPatterns);
43 public static HostInfo create(JSONObject json) throws JSONException {
44 assert json != null;
46 ArrayList<String> tokenUrlPatterns = new ArrayList<String>();
47 JSONArray jsonPatterns = json.optJSONArray("tokenUrlPatterns");
49 if (jsonPatterns != null) {
50 for (int i = 0; i < jsonPatterns.length(); i++) {
51 String pattern = jsonPatterns.getString(i);
52 if (pattern != null && !pattern.isEmpty()) {
53 tokenUrlPatterns.add(pattern);
57 return new HostInfo(
58 json.getString("hostName"),
59 json.getString("hostId"),
60 json.optString("jabberId"),
61 json.optString("publicKey"),
62 tokenUrlPatterns,
63 json.optString("status").equals("ONLINE"),
64 json.optString("hostOfflineReason"));