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/host/setup/me2me_native_messaging_host.h" | 5 #include "remoting/host/setup/me2me_native_messaging_host.h" |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 ProcessGetUsageStatsConsent(message_dict.Pass(), response.Pass()); | 153 ProcessGetUsageStatsConsent(message_dict.Pass(), response.Pass()); |
| 154 } else if (type == "startDaemon") { | 154 } else if (type == "startDaemon") { |
| 155 ProcessStartDaemon(message_dict.Pass(), response.Pass()); | 155 ProcessStartDaemon(message_dict.Pass(), response.Pass()); |
| 156 } else if (type == "stopDaemon") { | 156 } else if (type == "stopDaemon") { |
| 157 ProcessStopDaemon(message_dict.Pass(), response.Pass()); | 157 ProcessStopDaemon(message_dict.Pass(), response.Pass()); |
| 158 } else if (type == "getDaemonState") { | 158 } else if (type == "getDaemonState") { |
| 159 ProcessGetDaemonState(message_dict.Pass(), response.Pass()); | 159 ProcessGetDaemonState(message_dict.Pass(), response.Pass()); |
| 160 } else if (type == "getHostClientId") { | 160 } else if (type == "getHostClientId") { |
| 161 ProcessGetHostClientId(message_dict.Pass(), response.Pass()); | 161 ProcessGetHostClientId(message_dict.Pass(), response.Pass()); |
| 162 } else if (type == "getCredentialsFromAuthCode") { | 162 } else if (type == "getCredentialsFromAuthCode") { |
| 163 ProcessGetCredentialsFromAuthCode(message_dict.Pass(), response.Pass()); | 163 ProcessGetCredentialsFromAuthCode( |
| 164 message_dict.Pass(), response.Pass(), true); | |
| 165 } else if (type == "getTokenFromAuthCode") { | |
| 166 // TODO(jrw): Add a capability for this method so the webapp can | |
| 167 // check that it's supported before registering a host with GCD. | |
| 168 ProcessGetCredentialsFromAuthCode( | |
| 169 message_dict.Pass(), response.Pass(), false); | |
| 164 } else { | 170 } else { |
| 165 LOG(ERROR) << "Unsupported request type: " << type; | 171 LOG(ERROR) << "Unsupported request type: " << type; |
| 166 OnError(); | 172 OnError(); |
| 167 } | 173 } |
| 168 } | 174 } |
| 169 | 175 |
| 170 void Me2MeNativeMessagingHost::OnDisconnect() { | 176 void Me2MeNativeMessagingHost::OnDisconnect() { |
| 171 if (!quit_closure_.is_null()) | 177 if (!quit_closure_.is_null()) |
| 172 base::ResetAndReturn(&quit_closure_).Run(); | 178 base::ResetAndReturn(&quit_closure_).Run(); |
| 173 } | 179 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 scoped_ptr<base::DictionaryValue> response) { | 421 scoped_ptr<base::DictionaryValue> response) { |
| 416 DCHECK(thread_checker_.CalledOnValidThread()); | 422 DCHECK(thread_checker_.CalledOnValidThread()); |
| 417 | 423 |
| 418 response->SetString("clientId", google_apis::GetOAuth2ClientID( | 424 response->SetString("clientId", google_apis::GetOAuth2ClientID( |
| 419 google_apis::CLIENT_REMOTING_HOST)); | 425 google_apis::CLIENT_REMOTING_HOST)); |
| 420 channel_->SendMessage(response.Pass()); | 426 channel_->SendMessage(response.Pass()); |
| 421 } | 427 } |
| 422 | 428 |
| 423 void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode( | 429 void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode( |
| 424 scoped_ptr<base::DictionaryValue> message, | 430 scoped_ptr<base::DictionaryValue> message, |
| 425 scoped_ptr<base::DictionaryValue> response) { | 431 scoped_ptr<base::DictionaryValue> response, |
| 432 bool need_user_email) { | |
| 426 DCHECK(thread_checker_.CalledOnValidThread()); | 433 DCHECK(thread_checker_.CalledOnValidThread()); |
| 427 | 434 |
| 428 std::string auth_code; | 435 std::string auth_code; |
| 429 if (!message->GetString("authorizationCode", &auth_code)) { | 436 if (!message->GetString("authorizationCode", &auth_code)) { |
| 430 LOG(ERROR) << "'authorizationCode' string not found."; | 437 LOG(ERROR) << "'authorizationCode' string not found."; |
| 431 OnError(); | 438 OnError(); |
| 432 return; | 439 return; |
| 433 } | 440 } |
| 434 | 441 |
| 435 gaia::OAuthClientInfo oauth_client_info = { | 442 gaia::OAuthClientInfo oauth_client_info = { |
| 436 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST), | 443 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST), |
| 437 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST), | 444 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST), |
| 438 kServiceAccountRedirectUri | 445 kServiceAccountRedirectUri |
| 439 }; | 446 }; |
| 440 | 447 |
| 441 oauth_client_->GetCredentialsFromAuthCode( | 448 oauth_client_->GetCredentialsFromAuthCode( |
| 442 oauth_client_info, auth_code, base::Bind( | 449 oauth_client_info, auth_code, need_user_email, base::Bind( |
| 443 &Me2MeNativeMessagingHost::SendCredentialsResponse, weak_ptr_, | 450 &Me2MeNativeMessagingHost::SendCredentialsResponse, weak_ptr_, |
| 444 base::Passed(&response))); | 451 base::Passed(&response))); |
| 445 } | 452 } |
| 446 | 453 |
| 447 void Me2MeNativeMessagingHost::SendConfigResponse( | 454 void Me2MeNativeMessagingHost::SendConfigResponse( |
| 448 scoped_ptr<base::DictionaryValue> response, | 455 scoped_ptr<base::DictionaryValue> response, |
| 449 scoped_ptr<base::DictionaryValue> config) { | 456 scoped_ptr<base::DictionaryValue> config) { |
| 450 DCHECK(thread_checker_.CalledOnValidThread()); | 457 DCHECK(thread_checker_.CalledOnValidThread()); |
| 451 | 458 |
| 452 if (config) { | 459 if (config) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 response->SetBoolean("result", result); | 513 response->SetBoolean("result", result); |
| 507 channel_->SendMessage(response.Pass()); | 514 channel_->SendMessage(response.Pass()); |
| 508 } | 515 } |
| 509 | 516 |
| 510 void Me2MeNativeMessagingHost::SendCredentialsResponse( | 517 void Me2MeNativeMessagingHost::SendCredentialsResponse( |
| 511 scoped_ptr<base::DictionaryValue> response, | 518 scoped_ptr<base::DictionaryValue> response, |
| 512 const std::string& user_email, | 519 const std::string& user_email, |
| 513 const std::string& refresh_token) { | 520 const std::string& refresh_token) { |
| 514 DCHECK(thread_checker_.CalledOnValidThread()); | 521 DCHECK(thread_checker_.CalledOnValidThread()); |
| 515 | 522 |
| 516 response->SetString("userEmail", user_email); | 523 response->SetString("userEmail", user_email); |
|
Sergey Ulanov
2015/04/22 21:55:40
This will set an empty email when processing getTo
John Williams
2015/04/24 00:00:47
Fixed.
| |
| 517 response->SetString("refreshToken", refresh_token); | 524 response->SetString("refreshToken", refresh_token); |
| 518 channel_->SendMessage(response.Pass()); | 525 channel_->SendMessage(response.Pass()); |
| 519 } | 526 } |
| 520 | 527 |
| 521 void Me2MeNativeMessagingHost::OnError() { | 528 void Me2MeNativeMessagingHost::OnError() { |
| 522 // Trigger a host shutdown by sending a nullptr message. | 529 // Trigger a host shutdown by sending a nullptr message. |
| 523 channel_->SendMessage(nullptr); | 530 channel_->SendMessage(nullptr); |
| 524 } | 531 } |
| 525 | 532 |
| 526 void Me2MeNativeMessagingHost::Stop() { | 533 void Me2MeNativeMessagingHost::Stop() { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 | 734 |
| 728 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( | 735 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( |
| 729 scoped_ptr<base::DictionaryValue> message) { | 736 scoped_ptr<base::DictionaryValue> message) { |
| 730 NOTREACHED(); | 737 NOTREACHED(); |
| 731 return false; | 738 return false; |
| 732 } | 739 } |
| 733 | 740 |
| 734 #endif // !defined(OS_WIN) | 741 #endif // !defined(OS_WIN) |
| 735 | 742 |
| 736 } // namespace remoting | 743 } // namespace remoting |
| OLD | NEW |