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

Side by Side Diff: remoting/host/setup/me2me_native_messaging_host.cc

Issue 1076093003: Added method to host daemon to exchange an auth code for just an OAuth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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/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
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") {
Lambros 2015/04/22 18:28:52 Please update me2me_native_messaging_host_unittest
John Williams 2015/04/22 20:11:25 It looks like to do this, I will have to make remo
Lambros 2015/04/22 21:22:59 OK, I thought it would be a simple addition to the
166 ProcessGetCredentialsFromAuthCode(
167 message_dict.Pass(), response.Pass(), false);
164 } else { 168 } else {
165 LOG(ERROR) << "Unsupported request type: " << type; 169 LOG(ERROR) << "Unsupported request type: " << type;
166 OnError(); 170 OnError();
167 } 171 }
168 } 172 }
169 173
170 void Me2MeNativeMessagingHost::OnDisconnect() { 174 void Me2MeNativeMessagingHost::OnDisconnect() {
171 if (!quit_closure_.is_null()) 175 if (!quit_closure_.is_null())
172 base::ResetAndReturn(&quit_closure_).Run(); 176 base::ResetAndReturn(&quit_closure_).Run();
173 } 177 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 scoped_ptr<base::DictionaryValue> response) { 419 scoped_ptr<base::DictionaryValue> response) {
416 DCHECK(thread_checker_.CalledOnValidThread()); 420 DCHECK(thread_checker_.CalledOnValidThread());
417 421
418 response->SetString("clientId", google_apis::GetOAuth2ClientID( 422 response->SetString("clientId", google_apis::GetOAuth2ClientID(
419 google_apis::CLIENT_REMOTING_HOST)); 423 google_apis::CLIENT_REMOTING_HOST));
420 channel_->SendMessage(response.Pass()); 424 channel_->SendMessage(response.Pass());
421 } 425 }
422 426
423 void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode( 427 void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode(
424 scoped_ptr<base::DictionaryValue> message, 428 scoped_ptr<base::DictionaryValue> message,
425 scoped_ptr<base::DictionaryValue> response) { 429 scoped_ptr<base::DictionaryValue> response,
430 bool need_user_email) {
426 DCHECK(thread_checker_.CalledOnValidThread()); 431 DCHECK(thread_checker_.CalledOnValidThread());
427 432
428 std::string auth_code; 433 std::string auth_code;
429 if (!message->GetString("authorizationCode", &auth_code)) { 434 if (!message->GetString("authorizationCode", &auth_code)) {
430 LOG(ERROR) << "'authorizationCode' string not found."; 435 LOG(ERROR) << "'authorizationCode' string not found.";
431 OnError(); 436 OnError();
432 return; 437 return;
433 } 438 }
434 439
435 gaia::OAuthClientInfo oauth_client_info = { 440 gaia::OAuthClientInfo oauth_client_info = {
436 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST), 441 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST),
437 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST), 442 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST),
438 kServiceAccountRedirectUri 443 kServiceAccountRedirectUri
439 }; 444 };
440 445
441 oauth_client_->GetCredentialsFromAuthCode( 446 oauth_client_->GetCredentialsFromAuthCode(
442 oauth_client_info, auth_code, base::Bind( 447 oauth_client_info, auth_code, need_user_email, base::Bind(
443 &Me2MeNativeMessagingHost::SendCredentialsResponse, weak_ptr_, 448 &Me2MeNativeMessagingHost::SendCredentialsResponse, weak_ptr_,
444 base::Passed(&response))); 449 base::Passed(&response)));
445 } 450 }
446 451
447 void Me2MeNativeMessagingHost::SendConfigResponse( 452 void Me2MeNativeMessagingHost::SendConfigResponse(
448 scoped_ptr<base::DictionaryValue> response, 453 scoped_ptr<base::DictionaryValue> response,
449 scoped_ptr<base::DictionaryValue> config) { 454 scoped_ptr<base::DictionaryValue> config) {
450 DCHECK(thread_checker_.CalledOnValidThread()); 455 DCHECK(thread_checker_.CalledOnValidThread());
451 456
452 if (config) { 457 if (config) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 732
728 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( 733 bool Me2MeNativeMessagingHost::DelegateToElevatedHost(
729 scoped_ptr<base::DictionaryValue> message) { 734 scoped_ptr<base::DictionaryValue> message) {
730 NOTREACHED(); 735 NOTREACHED();
731 return false; 736 return false;
732 } 737 }
733 738
734 #endif // !defined(OS_WIN) 739 #endif // !defined(OS_WIN)
735 740
736 } // namespace remoting 741 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698