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

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

Issue 105943010: Android Chromoting - Close the Desktop view on disconnection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.accounts.Account; 7 import android.accounts.Account;
8 import android.accounts.AccountManager; 8 import android.accounts.AccountManager;
9 import android.accounts.AccountManagerCallback; 9 import android.accounts.AccountManagerCallback;
10 import android.accounts.AccountManagerFuture; 10 import android.accounts.AccountManagerFuture;
(...skipping 20 matching lines...) Expand all
31 31
32 import java.io.IOException; 32 import java.io.IOException;
33 import java.net.URL; 33 import java.net.URL;
34 import java.net.URLConnection; 34 import java.net.URLConnection;
35 import java.util.Scanner; 35 import java.util.Scanner;
36 36
37 /** 37 /**
38 * The user interface for querying and displaying a user's host list from the di rectory server. It 38 * The user interface for querying and displaying a user's host list from the di rectory server. It
39 * also requests and renews authentication tokens using the system account manag er. 39 * also requests and renews authentication tokens using the system account manag er.
40 */ 40 */
41 public class Chromoting extends Activity { 41 public class Chromoting extends Activity implements JniInterface.ConnectionListe ner {
42 /** Only accounts of this type will be selectable for authentication. */ 42 /** Only accounts of this type will be selectable for authentication. */
43 private static final String ACCOUNT_TYPE = "com.google"; 43 private static final String ACCOUNT_TYPE = "com.google";
44 44
45 /** Scopes at which the authentication token we request will be valid. */ 45 /** Scopes at which the authentication token we request will be valid. */
46 private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com /auth/chromoting " + 46 private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com /auth/chromoting " +
47 "https://www.googleapis.com/auth/googletalk"; 47 "https://www.googleapis.com/auth/googletalk";
48 48
49 /** Path from which to download a user's host list JSON object. */ 49 /** Path from which to download a user's host list JSON object. */
50 private static final String HOST_LIST_PATH = 50 private static final String HOST_LIST_PATH =
51 "https://www.googleapis.com/chromoting/v1/@me/hosts?key="; 51 "https://www.googleapis.com/chromoting/v1/@me/hosts?key=";
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 return true; 182 return true;
183 } 183 }
184 184
185 /** Called when the user taps on a host entry. */ 185 /** Called when the user taps on a host entry. */
186 public void connectToHost(JSONObject host) { 186 public void connectToHost(JSONObject host) {
187 try { 187 try {
188 synchronized (mLock) { 188 synchronized (mLock) {
189 JniInterface.connectToHost(mAccount.name, mToken, host.getString ("jabberId"), 189 JniInterface.connectToHost(mAccount.name, mToken, host.getString ("jabberId"),
190 host.getString("hostId"), host.getString("publicKey"), 190 host.getString("hostId"), host.getString("publicKey"), t his);
191 new Runnable() {
192 @Override
193 public void run() {
194 startActivity(new Intent(Chromoting.this, De sktop.class));
195 }
196 });
197 } 191 }
198 } catch (JSONException ex) { 192 } catch (JSONException ex) {
199 Log.w("host", ex); 193 Log.w("host", ex);
200 Toast.makeText(this, getString(R.string.error_reading_host), 194 Toast.makeText(this, getString(R.string.error_reading_host),
201 Toast.LENGTH_LONG).show(); 195 Toast.LENGTH_LONG).show();
202 // Close the application. 196 // Close the application.
203 finish(); 197 finish();
204 } 198 }
205 } 199 }
206 200
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 mList.setAdapter(displayer); 347 mList.setAdapter(displayer);
354 } catch (JSONException ex) { 348 } catch (JSONException ex) {
355 Log.w("hostlist", ex); 349 Log.w("hostlist", ex);
356 Toast.makeText(this, getString(R.string.error_cataloging_hosts), 350 Toast.makeText(this, getString(R.string.error_cataloging_hosts),
357 Toast.LENGTH_LONG).show(); 351 Toast.LENGTH_LONG).show();
358 352
359 // Close the application. 353 // Close the application.
360 finish(); 354 finish();
361 } 355 }
362 } 356 }
357
358 @Override
359 public void onConnected() {
360 startActivityForResult(new Intent(Chromoting.this, Desktop.class), 0);
361 }
362
363 @Override
364 public void onDisconnected() {
365 finishActivity(0);
366 }
363 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698