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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 | 174 |
175 // static | 175 // static |
176 bool OAuth2MintTokenFetcher::ParseMintTokenResponse( | 176 bool OAuth2MintTokenFetcher::ParseMintTokenResponse( |
177 const URLFetcher* source, | 177 const URLFetcher* source, |
178 std::string* access_token) { | 178 std::string* access_token) { |
179 CHECK(source); | 179 CHECK(source); |
180 CHECK(access_token); | 180 CHECK(access_token); |
181 std::string data; | 181 std::string data; |
182 source->GetResponseAsString(&data); | 182 source->GetResponseAsString(&data); |
183 base::JSONReader reader; | 183 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); |
184 scoped_ptr<base::Value> value(reader.Read(data, false)); | |
185 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) | 184 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) |
186 return false; | 185 return false; |
187 | 186 |
188 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); | 187 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
189 return dict->GetString(kAccessTokenKey, access_token); | 188 return dict->GetString(kAccessTokenKey, access_token); |
190 } | 189 } |
OLD | NEW |