Chromium Code Reviews| 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 #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 Loading... | |
| 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 Loading... | |
| 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) { |
|
Lambros
2014/06/07 01:38:12
Add
DCHECK(jni_runtime_->network_task_runner()->Be
kelvinp
2014/06/09 18:42:32
Done.
| |
| 114 // TODO(kelvinp) Calls into the jni_runtime_ to obtain a token from the | 115 DCHECK(!token_fetcher_proxy_.get()); |
| 115 // android app (Android Third Party Auth - Part II). | 116 |
| 116 } | 117 __android_log_print(ANDROID_LOG_INFO, |
| 118 "ThirdPartyAuth", | |
|
Sergey Ulanov
2014/06/07 01:32:45
maybe add a tag to be used for all log messages in
kelvinp
2014/06/09 18:42:32
The convention in the current file is to log messa
| |
| 119 "Fetching Third Party Token from user."); | |
| 120 | |
| 121 token_fetcher_proxy_ = token_fetcher_proxy; | |
| 122 jni_runtime_->ui_task_runner()->PostTask( | |
| 123 FROM_HERE, | |
| 124 base::Bind(&ChromotingJniRuntime::FetchThirdPartyToken, | |
| 125 base::Unretained(jni_runtime_), | |
| 126 token_url, | |
| 127 client_id, | |
| 128 scope)); | |
| 129 }; | |
|
Sergey Ulanov
2014/06/07 01:32:45
don't need semicolon
kelvinp
2014/06/09 18:42:32
Done.
| |
| 130 | |
| 131 void ChromotingJniInstance::HandleOnThirdPartyTokenFetched( | |
| 132 const std::string& token, | |
| 133 const std::string& shared_secret) { | |
| 134 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); | |
| 135 | |
| 136 __android_log_print( | |
| 137 ANDROID_LOG_INFO, "ThirdPartyAuth", "Third Party Token Fetched."); | |
| 138 | |
| 139 if (token_fetcher_proxy_.get()) { | |
| 140 token_fetcher_proxy_->OnTokenFetched(token, shared_secret); | |
| 141 token_fetcher_proxy_.reset(); | |
| 142 } else { | |
| 143 __android_log_print( | |
| 144 ANDROID_LOG_WARN, | |
| 145 "ThirdPartyAuth", | |
| 146 "Ignored OnThirdPartyTokenFetched without a pending fetch."); | |
|
Sergey Ulanov
2014/06/07 01:32:45
nit: add () after function name
kelvinp
2014/06/09 18:42:32
Done.
| |
| 147 } | |
| 148 }; | |
|
Sergey Ulanov
2014/06/07 01:32:45
don't need semicolon
kelvinp
2014/06/09 18:42:32
Done.
| |
| 117 | 149 |
| 118 void ChromotingJniInstance::ProvideSecret(const std::string& pin, | 150 void ChromotingJniInstance::ProvideSecret(const std::string& pin, |
| 119 bool create_pairing, | 151 bool create_pairing, |
| 120 const std::string& device_name) { | 152 const std::string& device_name) { |
| 121 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); | 153 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); |
| 122 DCHECK(!pin_callback_.is_null()); | 154 DCHECK(!pin_callback_.is_null()); |
| 123 | 155 |
| 124 create_pairing_ = create_pairing; | 156 create_pairing_ = create_pairing; |
| 125 | 157 |
| 126 if (create_pairing) | 158 if (create_pairing) |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 } | 309 } |
| 278 | 310 |
| 279 protocol::ClipboardStub* ChromotingJniInstance::GetClipboardStub() { | 311 protocol::ClipboardStub* ChromotingJniInstance::GetClipboardStub() { |
| 280 return this; | 312 return this; |
| 281 } | 313 } |
| 282 | 314 |
| 283 protocol::CursorShapeStub* ChromotingJniInstance::GetCursorShapeStub() { | 315 protocol::CursorShapeStub* ChromotingJniInstance::GetCursorShapeStub() { |
| 284 return this; | 316 return this; |
| 285 } | 317 } |
| 286 | 318 |
| 287 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> | 319 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> |
|
Lambros
2014/06/07 01:38:12
Maybe add 'using' declaration for
remoting::protoc
kelvinp
2014/06/09 18:42:32
The using directive doesn't work with template arg
| |
| 288 ChromotingJniInstance::GetTokenFetcher(const std::string& host_public_key) { | 320 ChromotingJniInstance::GetTokenFetcher(const std::string& host_public_key) { |
| 289 // Return null to indicate that third-party authentication is unsupported. | 321 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>( |
| 290 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(); | 322 new TokenFetcherProxy( |
| 323 base::Bind(&ChromotingJniInstance::FetchThirdPartyToken, | |
| 324 weak_factory_.GetWeakPtr()), | |
| 325 host_public_key)); | |
| 291 } | 326 } |
| 292 | 327 |
| 293 void ChromotingJniInstance::InjectClipboardEvent( | 328 void ChromotingJniInstance::InjectClipboardEvent( |
| 294 const protocol::ClipboardEvent& event) { | 329 const protocol::ClipboardEvent& event) { |
| 295 NOTIMPLEMENTED(); | 330 NOTIMPLEMENTED(); |
| 296 } | 331 } |
| 297 | 332 |
| 298 void ChromotingJniInstance::SetCursorShape( | 333 void ChromotingJniInstance::SetCursorShape( |
| 299 const protocol::CursorShapeInfo& shape) { | 334 const protocol::CursorShapeInfo& shape) { |
| 300 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { | 335 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 stats->round_trip_ms()->Average()); | 478 stats->round_trip_ms()->Average()); |
| 444 | 479 |
| 445 log_to_server_->LogStatistics(stats); | 480 log_to_server_->LogStatistics(stats); |
| 446 | 481 |
| 447 jni_runtime_->network_task_runner()->PostDelayedTask( | 482 jni_runtime_->network_task_runner()->PostDelayedTask( |
| 448 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), | 483 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), |
| 449 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); | 484 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
| 450 } | 485 } |
| 451 | 486 |
| 452 } // namespace remoting | 487 } // namespace remoting |
| OLD | NEW |