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

Unified 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: for review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.h ('k') | remoting/host/setup/oauth_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/setup/me2me_native_messaging_host.cc
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc
index 12e688b13856cb29876693648cf88aa6965aa5c4..d2957fdf8c5a0c276be641e503aec965714f72f1 100644
--- a/remoting/host/setup/me2me_native_messaging_host.cc
+++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -49,7 +49,8 @@ const char* kServiceAccountRedirectUri = "oob";
// Features supported in addition to the base protocol.
const char* kSupportedFeatures[] = {
"pairingRegistry",
- "oauthClient"
+ "oauthClient",
+ "getRefreshTokenFromAuthCode",
};
// Helper to extract the "config" part of a message as a DictionaryValue.
@@ -160,7 +161,11 @@ void Me2MeNativeMessagingHost::OnMessage(scoped_ptr<base::Value> message) {
} else if (type == "getHostClientId") {
ProcessGetHostClientId(message_dict.Pass(), response.Pass());
} else if (type == "getCredentialsFromAuthCode") {
- ProcessGetCredentialsFromAuthCode(message_dict.Pass(), response.Pass());
+ ProcessGetCredentialsFromAuthCode(
+ message_dict.Pass(), response.Pass(), true);
+ } else if (type == "getRefreshTokenFromAuthCode") {
+ ProcessGetCredentialsFromAuthCode(
+ message_dict.Pass(), response.Pass(), false);
} else {
LOG(ERROR) << "Unsupported request type: " << type;
OnError();
@@ -422,7 +427,8 @@ void Me2MeNativeMessagingHost::ProcessGetHostClientId(
void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode(
scoped_ptr<base::DictionaryValue> message,
- scoped_ptr<base::DictionaryValue> response) {
+ scoped_ptr<base::DictionaryValue> response,
+ bool need_user_email) {
DCHECK(thread_checker_.CalledOnValidThread());
std::string auth_code;
@@ -439,7 +445,7 @@ void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode(
};
oauth_client_->GetCredentialsFromAuthCode(
- oauth_client_info, auth_code, base::Bind(
+ oauth_client_info, auth_code, need_user_email, base::Bind(
&Me2MeNativeMessagingHost::SendCredentialsResponse, weak_ptr_,
base::Passed(&response)));
}
@@ -513,7 +519,9 @@ void Me2MeNativeMessagingHost::SendCredentialsResponse(
const std::string& refresh_token) {
DCHECK(thread_checker_.CalledOnValidThread());
- response->SetString("userEmail", user_email);
+ if (!user_email.empty()) {
+ response->SetString("userEmail", user_email);
+ }
response->SetString("refreshToken", refresh_token);
channel_->SendMessage(response.Pass());
}
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.h ('k') | remoting/host/setup/oauth_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698