OLD | NEW |
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 */ | 148 */ |
149 @Override | 149 @Override |
150 public void onCreate(Bundle savedInstanceState) { | 150 public void onCreate(Bundle savedInstanceState) { |
151 super.onCreate(savedInstanceState); | 151 super.onCreate(savedInstanceState); |
152 setContentView(R.layout.main); | 152 setContentView(R.layout.main); |
153 | 153 |
154 mTriedNewAuthToken = false; | 154 mTriedNewAuthToken = false; |
155 mHostListLoader = new HostListLoader(); | 155 mHostListLoader = new HostListLoader(); |
156 | 156 |
157 // Get ahold of our view widgets. | 157 // Get ahold of our view widgets. |
158 mHostListView = (ListView)findViewById(R.id.hostList_chooser); | 158 mHostListView = (ListView) findViewById(R.id.hostList_chooser); |
159 mHostListView.setEmptyView(findViewById(R.id.hostList_empty)); | 159 mHostListView.setEmptyView(findViewById(R.id.hostList_empty)); |
160 mProgressView = findViewById(R.id.hostList_progress); | 160 mProgressView = findViewById(R.id.hostList_progress); |
161 | 161 |
162 findViewById(R.id.host_setup_link_android).setOnClickListener(this); | 162 findViewById(R.id.host_setup_link_android).setOnClickListener(this); |
163 | 163 |
164 // Bring native components online. | 164 // Bring native components online. |
165 JniInterface.loadLibrary(this); | 165 JniInterface.loadLibrary(this); |
166 } | 166 } |
167 | 167 |
168 @Override | 168 @Override |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 450 } |
451 | 451 |
452 if (dismissProgress && mProgressIndicator != null) { | 452 if (dismissProgress && mProgressIndicator != null) { |
453 mProgressIndicator.dismiss(); | 453 mProgressIndicator.dismiss(); |
454 mProgressIndicator = null; | 454 mProgressIndicator = null; |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 private ThirdPartyTokenFetcher createTokenFetcher(HostInfo host) { | 458 private ThirdPartyTokenFetcher createTokenFetcher(HostInfo host) { |
459 ThirdPartyTokenFetcher.Callback callback = new ThirdPartyTokenFetcher.Ca
llback() { | 459 ThirdPartyTokenFetcher.Callback callback = new ThirdPartyTokenFetcher.Ca
llback() { |
| 460 @Override |
460 public void onTokenFetched(String code, String accessToken) { | 461 public void onTokenFetched(String code, String accessToken) { |
461 // The native client sends the OAuth authorization code to the h
ost as the token so | 462 // The native client sends the OAuth authorization code to the h
ost as the token so |
462 // that the host can obtain the shared secret from the third par
ty authorization | 463 // that the host can obtain the shared secret from the third par
ty authorization |
463 // server. | 464 // server. |
464 String token = code; | 465 String token = code; |
465 | 466 |
466 // The native client uses the OAuth access token as the shared s
ecret to | 467 // The native client uses the OAuth access token as the shared s
ecret to |
467 // authenticate itself with the host using spake. | 468 // authenticate itself with the host using spake. |
468 String sharedSecret = accessToken; | 469 String sharedSecret = accessToken; |
469 | 470 |
470 JniInterface.onThirdPartyTokenFetched(token, sharedSecret); | 471 JniInterface.onThirdPartyTokenFetched(token, sharedSecret); |
471 } | 472 } |
472 }; | 473 }; |
473 return new ThirdPartyTokenFetcher(this, host.getTokenUrlPatterns(), call
back); | 474 return new ThirdPartyTokenFetcher(this, host.getTokenUrlPatterns(), call
back); |
474 } | 475 } |
475 | 476 |
476 public void fetchThirdPartyToken(String tokenUrl, String clientId, String sc
ope) { | 477 public void fetchThirdPartyToken(String tokenUrl, String clientId, String sc
ope) { |
477 assert mTokenFetcher != null; | 478 assert mTokenFetcher != null; |
478 mTokenFetcher.fetchToken(tokenUrl, clientId, scope); | 479 mTokenFetcher.fetchToken(tokenUrl, clientId, scope); |
479 } | 480 } |
480 } | 481 } |
OLD | NEW |