Chromium Code Reviews| Index: remoting/client/jni/chromoting_jni_instance.cc |
| diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc |
| index efe2ea5a5887c41813c19af1698129b2cff7543b..9e847665a1583fe9296be4e364eb2874d23b2092 100644 |
| --- a/remoting/client/jni/chromoting_jni_instance.cc |
| +++ b/remoting/client/jni/chromoting_jni_instance.cc |
| @@ -48,7 +48,8 @@ ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, |
| : jni_runtime_(jni_runtime), |
| host_id_(host_id), |
| create_pairing_(false), |
| - stats_logging_enabled_(false) { |
| + stats_logging_enabled_(false), |
| + weak_factory_(this) { |
| DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); |
| // Intialize XMPP config. |
| @@ -110,10 +111,41 @@ void ChromotingJniInstance::FetchThirdPartyToken( |
| const GURL& token_url, |
| const std::string& client_id, |
| const std::string& scope, |
| - base::WeakPtr<TokenFetcherProxy> jni_token_fetcher) { |
| - // TODO(kelvinp) Calls into the jni_runtime_ to obtain a token from the |
| - // android app (Android Third Party Auth - Part II). |
| -} |
| + 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.
|
| + DCHECK(!token_fetcher_proxy_.get()); |
| + |
| + __android_log_print(ANDROID_LOG_INFO, |
| + "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
|
| + "Fetching Third Party Token from user."); |
| + |
| + token_fetcher_proxy_ = token_fetcher_proxy; |
| + jni_runtime_->ui_task_runner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&ChromotingJniRuntime::FetchThirdPartyToken, |
| + base::Unretained(jni_runtime_), |
| + token_url, |
| + client_id, |
| + scope)); |
| +}; |
|
Sergey Ulanov
2014/06/07 01:32:45
don't need semicolon
kelvinp
2014/06/09 18:42:32
Done.
|
| + |
| +void ChromotingJniInstance::HandleOnThirdPartyTokenFetched( |
| + const std::string& token, |
| + const std::string& shared_secret) { |
| + DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); |
| + |
| + __android_log_print( |
| + ANDROID_LOG_INFO, "ThirdPartyAuth", "Third Party Token Fetched."); |
| + |
| + if (token_fetcher_proxy_.get()) { |
| + token_fetcher_proxy_->OnTokenFetched(token, shared_secret); |
| + token_fetcher_proxy_.reset(); |
| + } else { |
| + __android_log_print( |
| + ANDROID_LOG_WARN, |
| + "ThirdPartyAuth", |
| + "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.
|
| + } |
| +}; |
|
Sergey Ulanov
2014/06/07 01:32:45
don't need semicolon
kelvinp
2014/06/09 18:42:32
Done.
|
| void ChromotingJniInstance::ProvideSecret(const std::string& pin, |
| bool create_pairing, |
| @@ -286,8 +318,11 @@ protocol::CursorShapeStub* ChromotingJniInstance::GetCursorShapeStub() { |
| 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
|
| ChromotingJniInstance::GetTokenFetcher(const std::string& host_public_key) { |
| - // Return null to indicate that third-party authentication is unsupported. |
| - return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(); |
| + return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>( |
| + new TokenFetcherProxy( |
| + base::Bind(&ChromotingJniInstance::FetchThirdPartyToken, |
| + weak_factory_.GetWeakPtr()), |
| + host_public_key)); |
| } |
| void ChromotingJniInstance::InjectClipboardEvent( |