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_flow.h" | 5 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 CHECK(access_token); | 220 CHECK(access_token); |
221 return dict->GetString(kAccessTokenKey, access_token); | 221 return dict->GetString(kAccessTokenKey, access_token); |
222 } | 222 } |
223 | 223 |
224 // static | 224 // static |
225 bool OAuth2MintTokenFlow::ParseIssueAdviceResponse( | 225 bool OAuth2MintTokenFlow::ParseIssueAdviceResponse( |
226 const base::DictionaryValue* dict, IssueAdviceInfo* issue_advice) { | 226 const base::DictionaryValue* dict, IssueAdviceInfo* issue_advice) { |
227 CHECK(dict); | 227 CHECK(dict); |
228 CHECK(issue_advice); | 228 CHECK(issue_advice); |
229 | 229 |
230 base::DictionaryValue* consent_dict = NULL; | 230 const base::DictionaryValue* consent_dict = NULL; |
231 if (!dict->GetDictionary(kConsentKey, &consent_dict)) | 231 if (!dict->GetDictionary(kConsentKey, &consent_dict)) |
232 return false; | 232 return false; |
233 | 233 |
234 base::ListValue* scopes_list = NULL; | 234 const base::ListValue* scopes_list = NULL; |
235 if (!consent_dict->GetList(kScopesKey, &scopes_list)) | 235 if (!consent_dict->GetList(kScopesKey, &scopes_list)) |
236 return false; | 236 return false; |
237 | 237 |
238 bool success = true; | 238 bool success = true; |
239 for (size_t index = 0; index < scopes_list->GetSize(); ++index) { | 239 for (size_t index = 0; index < scopes_list->GetSize(); ++index) { |
240 base::DictionaryValue* scopes_entry = NULL; | 240 base::DictionaryValue* scopes_entry = NULL; |
241 IssueAdviceInfoEntry entry; | 241 IssueAdviceInfoEntry entry; |
242 string16 detail; | 242 string16 detail; |
243 if (!scopes_list->GetDictionary(index, &scopes_entry) || | 243 if (!scopes_list->GetDictionary(index, &scopes_entry) || |
244 !scopes_entry->GetString(kDescriptionKey, &entry.description) || | 244 !scopes_entry->GetString(kDescriptionKey, &entry.description) || |
245 !scopes_entry->GetString(kDetailKey, &detail)) { | 245 !scopes_entry->GetString(kDetailKey, &detail)) { |
246 success = false; | 246 success = false; |
247 break; | 247 break; |
248 } | 248 } |
249 | 249 |
250 TrimWhitespace(entry.description, TRIM_ALL, &entry.description); | 250 TrimWhitespace(entry.description, TRIM_ALL, &entry.description); |
251 static const string16 detail_separators = ASCIIToUTF16(kDetailSeparators); | 251 static const string16 detail_separators = ASCIIToUTF16(kDetailSeparators); |
252 Tokenize(detail, detail_separators, &entry.details); | 252 Tokenize(detail, detail_separators, &entry.details); |
253 for (size_t i = 0; i < entry.details.size(); i++) | 253 for (size_t i = 0; i < entry.details.size(); i++) |
254 TrimWhitespace(entry.details[i], TRIM_ALL, &entry.details[i]); | 254 TrimWhitespace(entry.details[i], TRIM_ALL, &entry.details[i]); |
255 issue_advice->push_back(entry); | 255 issue_advice->push_back(entry); |
256 } | 256 } |
257 | 257 |
258 if (!success) | 258 if (!success) |
259 issue_advice->clear(); | 259 issue_advice->clear(); |
260 | 260 |
261 return success; | 261 return success; |
262 } | 262 } |
OLD | NEW |