OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/net/gaia/oauth2_mint_token_fetcher.h" | 5 #include "chrome/common/net/gaia/oauth2_mint_token_fetcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 std::string access_token; | 130 std::string access_token; |
131 ParseMintTokenResponse(source, &access_token); | 131 ParseMintTokenResponse(source, &access_token); |
132 OnMintTokenSuccess(access_token); | 132 OnMintTokenSuccess(access_token); |
133 } | 133 } |
134 | 134 |
135 void OAuth2MintTokenFetcher::OnMintTokenSuccess( | 135 void OAuth2MintTokenFetcher::OnMintTokenSuccess( |
136 const std::string& access_token) { | 136 const std::string& access_token) { |
137 consumer_->OnMintTokenSuccess(access_token); | 137 consumer_->OnMintTokenSuccess(access_token); |
138 } | 138 } |
139 | 139 |
140 void OAuth2MintTokenFetcher::OnMintTokenFailure(GoogleServiceAuthError error) { | 140 void OAuth2MintTokenFetcher::OnMintTokenFailure( |
| 141 const GoogleServiceAuthError& error) { |
141 state_ = ERROR_STATE; | 142 state_ = ERROR_STATE; |
142 consumer_->OnMintTokenFailure(error); | 143 consumer_->OnMintTokenFailure(error); |
143 } | 144 } |
144 | 145 |
145 void OAuth2MintTokenFetcher::OnURLFetchComplete(const URLFetcher* source) { | 146 void OAuth2MintTokenFetcher::OnURLFetchComplete(const URLFetcher* source) { |
146 CHECK(source); | 147 CHECK(source); |
147 CHECK_EQ(MINT_TOKEN_STARTED, state_); | 148 CHECK_EQ(MINT_TOKEN_STARTED, state_); |
148 EndMintToken(source); | 149 EndMintToken(source); |
149 } | 150 } |
150 | 151 |
(...skipping 29 matching lines...) Expand all Loading... |
180 std::string data; | 181 std::string data; |
181 source->GetResponseAsString(&data); | 182 source->GetResponseAsString(&data); |
182 base::JSONReader reader; | 183 base::JSONReader reader; |
183 scoped_ptr<base::Value> value(reader.Read(data, false)); | 184 scoped_ptr<base::Value> value(reader.Read(data, false)); |
184 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) | 185 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) |
185 return false; | 186 return false; |
186 | 187 |
187 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); | 188 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
188 return dict->GetString(kAccessTokenKey, access_token); | 189 return dict->GetString(kAccessTokenKey, access_token); |
189 } | 190 } |
OLD | NEW |