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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/HostListLoader.java

Issue 633703004: Android Chromoting: Don't include API key with Directory request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.HandlerThread; 8 import android.os.HandlerThread;
9 import android.os.Looper; 9 import android.os.Looper;
10 import android.util.Log; 10 import android.util.Log;
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 /** Callback for receiving the host list, or getting notified of an error. * / 37 /** Callback for receiving the host list, or getting notified of an error. * /
38 public interface Callback { 38 public interface Callback {
39 void onHostListReceived(HostInfo[] hosts); 39 void onHostListReceived(HostInfo[] hosts);
40 void onError(Error error); 40 void onError(Error error);
41 } 41 }
42 42
43 /** Path from which to download a user's host list JSON object. */ 43 /** Path from which to download a user's host list JSON object. */
44 private static final String HOST_LIST_PATH = 44 private static final String HOST_LIST_PATH =
45 "https://www.googleapis.com/chromoting/v1/@me/hosts?key="; 45 "https://www.googleapis.com/chromoting/v1/@me/hosts";
46 46
47 /** Callback handler to be used for network operations. */ 47 /** Callback handler to be used for network operations. */
48 private Handler mNetworkThread; 48 private Handler mNetworkThread;
49 49
50 /** Handler for main thread. */ 50 /** Handler for main thread. */
51 private Handler mMainThread; 51 private Handler mMainThread;
52 52
53 public HostListLoader() { 53 public HostListLoader() {
54 // Thread responsible for downloading the host list. 54 // Thread responsible for downloading the host list.
55 55
(...skipping 23 matching lines...) Expand all
79 public void run() { 79 public void run() {
80 doRetrieveHostList(authTokenFinal, callbackFinal); 80 doRetrieveHostList(authTokenFinal, callbackFinal);
81 } 81 }
82 }); 82 });
83 } 83 }
84 84
85 private void doRetrieveHostList(String authToken, Callback callback) { 85 private void doRetrieveHostList(String authToken, Callback callback) {
86 HttpURLConnection link = null; 86 HttpURLConnection link = null;
87 String response = null; 87 String response = null;
88 try { 88 try {
89 link = (HttpURLConnection) 89 link = (HttpURLConnection) new URL(HOST_LIST_PATH).openConnection();
90 new URL(HOST_LIST_PATH + JniInterface.nativeGetApiKey()).ope nConnection();
91 link.addRequestProperty("client_id", JniInterface.nativeGetClientId( )); 90 link.addRequestProperty("client_id", JniInterface.nativeGetClientId( ));
Lambros 2014/10/06 23:03:21 Maybe we should remove these lines as well (client
rmsousa 2014/10/06 23:13:25 Yes, we should, I don't think they're currently do
Lambros 2014/10/07 00:11:01 Done.
92 link.addRequestProperty("client_secret", JniInterface.nativeGetClien tSecret()); 91 link.addRequestProperty("client_secret", JniInterface.nativeGetClien tSecret());
93 link.setRequestProperty("Authorization", "OAuth " + authToken); 92 link.setRequestProperty("Authorization", "OAuth " + authToken);
94 93
95 // Listen for the server to respond. 94 // Listen for the server to respond.
96 int status = link.getResponseCode(); 95 int status = link.getResponseCode();
97 switch (status) { 96 switch (status) {
98 case HttpURLConnection.HTTP_OK: // 200 97 case HttpURLConnection.HTTP_OK: // 200
99 break; 98 break;
100 case HttpURLConnection.HTTP_UNAUTHORIZED: // 401 99 case HttpURLConnection.HTTP_UNAUTHORIZED: // 401
101 postError(callback, Error.AUTH_FAILED); 100 postError(callback, Error.AUTH_FAILED);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return a.isOnline ? -1 : 1; 187 return a.isOnline ? -1 : 1;
189 } 188 }
190 String aName = a.name.toUpperCase(Locale.getDefault()); 189 String aName = a.name.toUpperCase(Locale.getDefault());
191 String bName = b.name.toUpperCase(Locale.getDefault()); 190 String bName = b.name.toUpperCase(Locale.getDefault());
192 return aName.compareTo(bName); 191 return aName.compareTo(bName);
193 } 192 }
194 }; 193 };
195 Collections.sort(hosts, hostComparator); 194 Collections.sort(hosts, hostComparator);
196 } 195 }
197 } 196 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698