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

Unified Diff: google_apis/gaia/fake_gaia.cc

Issue 382673002: Fixes for re-enabling more MSVC level 4 warnings: misc edition #2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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 | « extensions/common/id_util.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/fake_gaia.cc
diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc
index 4cfe6040e53e0ab68bc4dac93116348e3fa8caf1..cdc1237a319a9e6d126ed78f5ddb36b628208d34 100644
--- a/google_apis/gaia/fake_gaia.cc
+++ b/google_apis/gaia/fake_gaia.cc
@@ -413,14 +413,10 @@ void FakeGaia::HandleSSO(const HttpRequest& request,
void FakeGaia::HandleAuthToken(const HttpRequest& request,
BasicHttpResponse* http_response) {
- std::string grant_type;
- std::string refresh_token;
- std::string client_id;
std::string scope;
- std::string auth_code;
- const AccessTokenInfo* token_info = NULL;
GetQueryParameter(request.content, "scope", &scope);
+ std::string grant_type;
if (!GetQueryParameter(request.content, "grant_type", &grant_type)) {
http_response->set_code(net::HTTP_BAD_REQUEST);
LOG(ERROR) << "No 'grant_type' param in /o/oauth2/token";
@@ -428,6 +424,7 @@ void FakeGaia::HandleAuthToken(const HttpRequest& request,
}
if (grant_type == "authorization_code") {
+ std::string auth_code;
if (!GetQueryParameter(request.content, "code", &auth_code) ||
auth_code != merge_session_params_.auth_code) {
http_response->set_code(net::HTTP_BAD_REQUEST);
@@ -448,26 +445,29 @@ void FakeGaia::HandleAuthToken(const HttpRequest& request,
merge_session_params_.access_token);
response_dict.SetInteger("expires_in", 3600);
FormatJSONResponse(response_dict, http_response);
- } else if (GetQueryParameter(request.content,
- "refresh_token",
- &refresh_token) &&
- GetQueryParameter(request.content,
- "client_id",
- &client_id) &&
- (token_info = FindAccessTokenInfo(refresh_token,
- client_id,
- scope))) {
- base::DictionaryValue response_dict;
- response_dict.SetString("access_token", token_info->token);
- response_dict.SetInteger("expires_in", 3600);
- FormatJSONResponse(response_dict, http_response);
- } else {
- LOG(ERROR) << "Bad request for /o/oauth2/token - "
- << "refresh_token = " << refresh_token
- << ", scope = " << scope
- << ", client_id = " << client_id;
- http_response->set_code(net::HTTP_BAD_REQUEST);
+ return;
}
+
+ std::string refresh_token;
+ std::string client_id;
+ if (GetQueryParameter(request.content, "refresh_token", &refresh_token) &&
+ GetQueryParameter(request.content, "client_id", &client_id)) {
+ const AccessTokenInfo* token_info =
+ FindAccessTokenInfo(refresh_token, client_id, scope);
+ if (token_info) {
+ base::DictionaryValue response_dict;
+ response_dict.SetString("access_token", token_info->token);
+ response_dict.SetInteger("expires_in", 3600);
+ FormatJSONResponse(response_dict, http_response);
+ return;
+ }
+ }
+
+ LOG(ERROR) << "Bad request for /o/oauth2/token - "
+ << "refresh_token = " << refresh_token
+ << ", scope = " << scope
+ << ", client_id = " << client_id;
+ http_response->set_code(net::HTTP_BAD_REQUEST);
}
void FakeGaia::HandleTokenInfo(const HttpRequest& request,
@@ -507,20 +507,22 @@ void FakeGaia::HandleIssueToken(const HttpRequest& request,
std::string access_token;
std::string scope;
std::string client_id;
- const AccessTokenInfo* token_info = NULL;
if (GetAccessToken(request, kAuthHeaderBearer, &access_token) &&
GetQueryParameter(request.content, "scope", &scope) &&
- GetQueryParameter(request.content, "client_id", &client_id) &&
- (token_info = FindAccessTokenInfo(access_token, client_id, scope))) {
- base::DictionaryValue response_dict;
- response_dict.SetString("issueAdvice", "auto");
- response_dict.SetString("expiresIn",
- base::IntToString(token_info->expires_in));
- response_dict.SetString("token", token_info->token);
- FormatJSONResponse(response_dict, http_response);
- } else {
- http_response->set_code(net::HTTP_BAD_REQUEST);
+ GetQueryParameter(request.content, "client_id", &client_id)) {
+ const AccessTokenInfo* token_info =
+ FindAccessTokenInfo(access_token, client_id, scope);
+ if (token_info) {
+ base::DictionaryValue response_dict;
+ response_dict.SetString("issueAdvice", "auto");
+ response_dict.SetString("expiresIn",
+ base::IntToString(token_info->expires_in));
+ response_dict.SetString("token", token_info->token);
+ FormatJSONResponse(response_dict, http_response);
+ return;
+ }
}
+ http_response->set_code(net::HTTP_BAD_REQUEST);
}
void FakeGaia::HandleListAccounts(const HttpRequest& request,
« no previous file with comments | « extensions/common/id_util.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698