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

Side by Side Diff: remoting/client/jni/chromoting_jni_instance.cc

Issue 319273003: Third Party Authentication for Android Part II - Java Native Interface plumbing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Feedbacks Created 6 years, 6 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 #include "remoting/client/jni/chromoting_jni_instance.h" 5 #include "remoting/client/jni/chromoting_jni_instance.h"
6 6
7 #include <android/log.h> 7 #include <android/log.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 30 matching lines...) Expand all
41 const char* username, 41 const char* username,
42 const char* auth_token, 42 const char* auth_token,
43 const char* host_jid, 43 const char* host_jid,
44 const char* host_id, 44 const char* host_id,
45 const char* host_pubkey, 45 const char* host_pubkey,
46 const char* pairing_id, 46 const char* pairing_id,
47 const char* pairing_secret) 47 const char* pairing_secret)
48 : jni_runtime_(jni_runtime), 48 : jni_runtime_(jni_runtime),
49 host_id_(host_id), 49 host_id_(host_id),
50 create_pairing_(false), 50 create_pairing_(false),
51 stats_logging_enabled_(false) { 51 stats_logging_enabled_(false),
52 weak_factory_(this) {
52 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); 53 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
53 54
54 // Intialize XMPP config. 55 // Intialize XMPP config.
55 xmpp_config_.host = kXmppServer; 56 xmpp_config_.host = kXmppServer;
56 xmpp_config_.port = kXmppPort; 57 xmpp_config_.port = kXmppPort;
57 xmpp_config_.use_tls = kXmppUseTls; 58 xmpp_config_.use_tls = kXmppUseTls;
58 xmpp_config_.username = username; 59 xmpp_config_.username = username;
59 xmpp_config_.auth_token = auth_token; 60 xmpp_config_.auth_token = auth_token;
60 xmpp_config_.auth_service = "oauth2"; 61 xmpp_config_.auth_service = "oauth2";
61 62
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 jni_runtime_->network_task_runner()->PostTask( 104 jni_runtime_->network_task_runner()->PostTask(
104 FROM_HERE, 105 FROM_HERE,
105 base::Bind(&ChromotingJniInstance::DisconnectFromHostOnNetworkThread, 106 base::Bind(&ChromotingJniInstance::DisconnectFromHostOnNetworkThread,
106 this)); 107 this));
107 } 108 }
108 109
109 void ChromotingJniInstance::FetchThirdPartyToken( 110 void ChromotingJniInstance::FetchThirdPartyToken(
110 const GURL& token_url, 111 const GURL& token_url,
111 const std::string& client_id, 112 const std::string& client_id,
112 const std::string& scope, 113 const std::string& scope,
113 base::WeakPtr<TokenFetcherProxy> jni_token_fetcher) { 114 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) {
114 // TODO(kelvinp) Calls into the jni_runtime_ to obtain a token from the 115 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread());
115 // android app (Android Third Party Auth - Part II). 116 DCHECK(!token_fetcher_proxy_.get());
117
118 __android_log_print(ANDROID_LOG_INFO,
119 "ThirdPartyAuth",
120 "Fetching Third Party Token from user.");
121
122 token_fetcher_proxy_ = token_fetcher_proxy;
123 jni_runtime_->ui_task_runner()->PostTask(
124 FROM_HERE,
125 base::Bind(&ChromotingJniRuntime::FetchThirdPartyToken,
126 base::Unretained(jni_runtime_),
127 token_url,
128 client_id,
129 scope));
130 }
131
132 void ChromotingJniInstance::HandleOnThirdPartyTokenFetched(
133 const std::string& token,
134 const std::string& shared_secret) {
135 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread());
136
137 __android_log_print(
138 ANDROID_LOG_INFO, "ThirdPartyAuth", "Third Party Token Fetched.");
139
140 if (token_fetcher_proxy_.get()) {
141 token_fetcher_proxy_->OnTokenFetched(token, shared_secret);
142 token_fetcher_proxy_.reset();
143 } else {
144 __android_log_print(
145 ANDROID_LOG_WARN,
146 "ThirdPartyAuth",
147 "Ignored OnThirdPartyTokenFetched() without a pending fetch.");
148 }
116 } 149 }
117 150
118 void ChromotingJniInstance::ProvideSecret(const std::string& pin, 151 void ChromotingJniInstance::ProvideSecret(const std::string& pin,
119 bool create_pairing, 152 bool create_pairing,
120 const std::string& device_name) { 153 const std::string& device_name) {
121 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); 154 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
122 DCHECK(!pin_callback_.is_null()); 155 DCHECK(!pin_callback_.is_null());
123 156
124 create_pairing_ = create_pairing; 157 create_pairing_ = create_pairing;
125 158
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 protocol::ClipboardStub* ChromotingJniInstance::GetClipboardStub() { 312 protocol::ClipboardStub* ChromotingJniInstance::GetClipboardStub() {
280 return this; 313 return this;
281 } 314 }
282 315
283 protocol::CursorShapeStub* ChromotingJniInstance::GetCursorShapeStub() { 316 protocol::CursorShapeStub* ChromotingJniInstance::GetCursorShapeStub() {
284 return this; 317 return this;
285 } 318 }
286 319
287 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> 320 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
288 ChromotingJniInstance::GetTokenFetcher(const std::string& host_public_key) { 321 ChromotingJniInstance::GetTokenFetcher(const std::string& host_public_key) {
289 // Return null to indicate that third-party authentication is unsupported. 322 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(
290 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(); 323 new TokenFetcherProxy(
324 base::Bind(&ChromotingJniInstance::FetchThirdPartyToken,
325 weak_factory_.GetWeakPtr()),
326 host_public_key));
291 } 327 }
292 328
293 void ChromotingJniInstance::InjectClipboardEvent( 329 void ChromotingJniInstance::InjectClipboardEvent(
294 const protocol::ClipboardEvent& event) { 330 const protocol::ClipboardEvent& event) {
295 NOTIMPLEMENTED(); 331 NOTIMPLEMENTED();
296 } 332 }
297 333
298 void ChromotingJniInstance::SetCursorShape( 334 void ChromotingJniInstance::SetCursorShape(
299 const protocol::CursorShapeInfo& shape) { 335 const protocol::CursorShapeInfo& shape) {
300 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { 336 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 stats->round_trip_ms()->Average()); 479 stats->round_trip_ms()->Average());
444 480
445 log_to_server_->LogStatistics(stats); 481 log_to_server_->LogStatistics(stats);
446 482
447 jni_runtime_->network_task_runner()->PostDelayedTask( 483 jni_runtime_->network_task_runner()->PostDelayedTask(
448 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), 484 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this),
449 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 485 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
450 } 486 }
451 487
452 } // namespace remoting 488 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_instance.h ('k') | remoting/client/jni/chromoting_jni_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698