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 "components/signin/core/browser/about_signin_internals.h" | 5 #include "components/signin/core/browser/about_signin_internals.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (a->consumer_id == b->consumer_id) { | 422 if (a->consumer_id == b->consumer_id) { |
423 return a->scopes < b->scopes; | 423 return a->scopes < b->scopes; |
424 } | 424 } |
425 return a->consumer_id < b->consumer_id; | 425 return a->consumer_id < b->consumer_id; |
426 } | 426 } |
427 return a->request_time < b->request_time; | 427 return a->request_time < b->request_time; |
428 } | 428 } |
429 | 429 |
430 void AboutSigninInternals::TokenInfo::Invalidate() { removed_ = true; } | 430 void AboutSigninInternals::TokenInfo::Invalidate() { removed_ = true; } |
431 | 431 |
432 base::DictionaryValue* AboutSigninInternals::TokenInfo::ToValue() const { | 432 std::unique_ptr<base::DictionaryValue> |
| 433 AboutSigninInternals::TokenInfo::ToValue() const { |
433 std::unique_ptr<base::DictionaryValue> token_info( | 434 std::unique_ptr<base::DictionaryValue> token_info( |
434 new base::DictionaryValue()); | 435 new base::DictionaryValue()); |
435 token_info->SetString("service", consumer_id); | 436 token_info->SetString("service", consumer_id); |
436 | 437 |
437 std::string scopes_str; | 438 std::string scopes_str; |
438 for (OAuth2TokenService::ScopeSet::const_iterator it = scopes.begin(); | 439 for (OAuth2TokenService::ScopeSet::const_iterator it = scopes.begin(); |
439 it != scopes.end(); | 440 it != scopes.end(); |
440 ++it) { | 441 ++it) { |
441 scopes_str += *it + "<br/>"; | 442 scopes_str += *it + "<br/>"; |
442 } | 443 } |
(...skipping 21 matching lines...) Expand all Loading... |
464 token_info->SetString("status", status_str); | 465 token_info->SetString("status", status_str); |
465 } else { | 466 } else { |
466 token_info->SetString( | 467 token_info->SetString( |
467 "status", | 468 "status", |
468 base::StringPrintf("Failure: %s", error.ToString().c_str())); | 469 base::StringPrintf("Failure: %s", error.ToString().c_str())); |
469 } | 470 } |
470 } else { | 471 } else { |
471 token_info->SetString("status", "Waiting for response"); | 472 token_info->SetString("status", "Waiting for response"); |
472 } | 473 } |
473 | 474 |
474 return token_info.release(); | 475 return token_info; |
475 } | 476 } |
476 | 477 |
477 AboutSigninInternals::SigninStatus::SigninStatus() | 478 AboutSigninInternals::SigninStatus::SigninStatus() |
478 : timed_signin_fields(TIMED_FIELDS_COUNT) {} | 479 : timed_signin_fields(TIMED_FIELDS_COUNT) {} |
479 | 480 |
480 AboutSigninInternals::SigninStatus::~SigninStatus() { | 481 AboutSigninInternals::SigninStatus::~SigninStatus() { |
481 for (TokenInfoMap::iterator it = token_info_map.begin(); | 482 for (TokenInfoMap::iterator it = token_info_map.begin(); |
482 it != token_info_map.end(); | 483 it != token_info_map.end(); |
483 ++it) { | 484 ++it) { |
484 base::STLDeleteElements(&it->second); | 485 base::STLDeleteElements(&it->second); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 std::sort(it->second.begin(), it->second.end(), TokenInfo::LessThan); | 647 std::sort(it->second.begin(), it->second.end(), TokenInfo::LessThan); |
647 const std::vector<TokenInfo*>& tokens = it->second; | 648 const std::vector<TokenInfo*>& tokens = it->second; |
648 | 649 |
649 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 | 650 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 |
650 // is fixed. | 651 // is fixed. |
651 tracked_objects::ScopedTracker tracking_profile43( | 652 tracked_objects::ScopedTracker tracking_profile43( |
652 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 653 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
653 "422460 AboutSigninInternals::SigninStatus::ToValue43")); | 654 "422460 AboutSigninInternals::SigninStatus::ToValue43")); |
654 | 655 |
655 for (size_t i = 0; i < tokens.size(); ++i) { | 656 for (size_t i = 0; i < tokens.size(); ++i) { |
656 base::DictionaryValue* token_info = tokens[i]->ToValue(); | 657 token_details->Append(tokens[i]->ToValue()); |
657 token_details->Append(token_info); | |
658 } | 658 } |
659 } | 659 } |
660 | 660 |
661 base::ListValue* account_info = new base::ListValue(); | 661 base::ListValue* account_info = new base::ListValue(); |
662 signin_status->Set("accountInfo", account_info); | 662 signin_status->Set("accountInfo", account_info); |
663 const std::vector<std::string>& accounts_in_token_service = | 663 const std::vector<std::string>& accounts_in_token_service = |
664 token_service->GetAccounts(); | 664 token_service->GetAccounts(); |
665 | 665 |
666 if(accounts_in_token_service.size() == 0) { | 666 if(accounts_in_token_service.size() == 0) { |
667 std::unique_ptr<base::DictionaryValue> no_token_entry( | 667 std::unique_ptr<base::DictionaryValue> no_token_entry( |
668 new base::DictionaryValue()); | 668 new base::DictionaryValue()); |
669 no_token_entry->SetString("accountId", "No token in Token Service."); | 669 no_token_entry->SetString("accountId", "No token in Token Service."); |
670 account_info->Append(std::move(no_token_entry)); | 670 account_info->Append(std::move(no_token_entry)); |
671 } | 671 } |
672 | 672 |
673 for(const std::string& account_id : accounts_in_token_service) { | 673 for(const std::string& account_id : accounts_in_token_service) { |
674 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 674 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
675 entry->SetString("accountId", account_id); | 675 entry->SetString("accountId", account_id); |
676 account_info->Append(std::move(entry)); | 676 account_info->Append(std::move(entry)); |
677 } | 677 } |
678 | 678 |
679 return signin_status; | 679 return signin_status; |
680 } | 680 } |
OLD | NEW |