| 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 <tuple> | 9 #include <tuple> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
| 23 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
| 24 #include "components/signin/core/browser/account_tracker_service.h" | 24 #include "components/signin/core/browser/account_tracker_service.h" |
| 25 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 25 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 26 #include "components/signin/core/browser/signin_client.h" | 26 #include "components/signin/core/browser/signin_client.h" |
| 27 #include "components/signin/core/browser/signin_internals_util.h" | 27 #include "components/signin/core/browser/signin_internals_util.h" |
| 28 #include "components/signin/core/browser/signin_manager.h" | 28 #include "components/signin/core/browser/signin_manager.h" |
| 29 #include "components/signin/core/common/profile_management_switches.h" | 29 #include "components/signin/core/common/profile_management_switches.h" |
| 30 #include "components/signin/core/common/signin_switches.h" | 30 #include "components/signin/core/common/signin_switches.h" |
| 31 #include "google_apis/gaia/oauth2_token_service_delegate.h" |
| 31 #include "net/base/backoff_entry.h" | 32 #include "net/base/backoff_entry.h" |
| 32 | 33 |
| 33 using base::Time; | 34 using base::Time; |
| 34 using namespace signin_internals_util; | 35 using namespace signin_internals_util; |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 std::string GetTimeStr(base::Time time) { | 39 std::string GetTimeStr(base::Time time) { |
| 39 return base::UTF16ToUTF8(base::TimeFormatShortDateAndTime(time)); | 40 return base::UTF16ToUTF8(base::TimeFormatShortDateAndTime(time)); |
| 40 } | 41 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 case USERNAME: | 82 case USERNAME: |
| 82 return "Username"; | 83 return "Username"; |
| 83 case UNTIMED_FIELDS_END: | 84 case UNTIMED_FIELDS_END: |
| 84 NOTREACHED(); | 85 NOTREACHED(); |
| 85 return std::string(); | 86 return std::string(); |
| 86 } | 87 } |
| 87 NOTREACHED(); | 88 NOTREACHED(); |
| 88 return std::string(); | 89 return std::string(); |
| 89 } | 90 } |
| 90 | 91 |
| 92 std::string TokenServiceLoadCredentialsStateToLabel( |
| 93 OAuth2TokenServiceDelegate::LoadCredentialsState state) { |
| 94 switch (state) { |
| 95 case OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_UNKNOWN: |
| 96 return "Unknown"; |
| 97 case OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_NOT_STARTED: |
| 98 return "Load credentials not started"; |
| 99 case OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_IN_PROGRESS: |
| 100 return "Load credentials in progress"; |
| 101 case OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_FINISHED_WITH_SUCCESS: |
| 102 return "Load credentials finished with success"; |
| 103 case OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_FINISHED_WITH_DB_ERRORS: |
| 104 return "Load credentials failed with database errors"; |
| 105 case OAuth2TokenServiceDelegate:: |
| 106 LOAD_CREDENTIALS_FINISHED_WITH_DECRYPT_ERRORS: |
| 107 return "Load credentials failed with decrypt errors"; |
| 108 case OAuth2TokenServiceDelegate:: |
| 109 LOAD_CREDENTIALS_FINISHED_WITH_UNKNOWN_ERRORS: |
| 110 return "Load credentials failed with unknown errors"; |
| 111 } |
| 112 NOTREACHED(); |
| 113 return std::string(); |
| 114 } |
| 115 |
| 91 #if !defined (OS_CHROMEOS) | 116 #if !defined (OS_CHROMEOS) |
| 92 std::string SigninStatusFieldToLabel(TimedSigninStatusField field) { | 117 std::string SigninStatusFieldToLabel(TimedSigninStatusField field) { |
| 93 switch (field) { | 118 switch (field) { |
| 94 case AUTHENTICATION_RESULT_RECEIVED: | 119 case AUTHENTICATION_RESULT_RECEIVED: |
| 95 return "Gaia Authentication Result"; | 120 return "Gaia Authentication Result"; |
| 96 case REFRESH_TOKEN_RECEIVED: | 121 case REFRESH_TOKEN_RECEIVED: |
| 97 return "RefreshToken Received"; | 122 return "RefreshToken Received"; |
| 98 case SIGNIN_STARTED: | 123 case SIGNIN_STARTED: |
| 99 return "SigninManager Started"; | 124 return "SigninManager Started"; |
| 100 case SIGNIN_COMPLETED: | 125 case SIGNIN_COMPLETED: |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return; | 352 return; |
| 328 } | 353 } |
| 329 | 354 |
| 330 token->receive_time = base::Time::Now(); | 355 token->receive_time = base::Time::Now(); |
| 331 token->error = error; | 356 token->error = error; |
| 332 token->expiration_time = expiration_time; | 357 token->expiration_time = expiration_time; |
| 333 | 358 |
| 334 NotifyObservers(); | 359 NotifyObservers(); |
| 335 } | 360 } |
| 336 | 361 |
| 362 void AboutSigninInternals::OnRefreshTokensLoaded() { |
| 363 NotifyObservers(); |
| 364 } |
| 365 |
| 337 void AboutSigninInternals::OnTokenRemoved( | 366 void AboutSigninInternals::OnTokenRemoved( |
| 338 const std::string& account_id, | 367 const std::string& account_id, |
| 339 const OAuth2TokenService::ScopeSet& scopes) { | 368 const OAuth2TokenService::ScopeSet& scopes) { |
| 340 for (const std::unique_ptr<TokenInfo>& token : | 369 for (const std::unique_ptr<TokenInfo>& token : |
| 341 signin_status_.token_info_map[account_id]) { | 370 signin_status_.token_info_map[account_id]) { |
| 342 if (token->scopes == scopes) | 371 if (token->scopes == scopes) |
| 343 token->Invalidate(); | 372 token->Invalidate(); |
| 344 } | 373 } |
| 345 NotifyObservers(); | 374 NotifyObservers(); |
| 346 } | 375 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 536 |
| 508 // A summary of signin related info first. | 537 // A summary of signin related info first. |
| 509 base::ListValue* basic_info = AddSection(signin_info, "Basic Information"); | 538 base::ListValue* basic_info = AddSection(signin_info, "Basic Information"); |
| 510 AddSectionEntry(basic_info, "Chrome Version", product_version); | 539 AddSectionEntry(basic_info, "Chrome Version", product_version); |
| 511 AddSectionEntry(basic_info, "New Profile Management?", | 540 AddSectionEntry(basic_info, "New Profile Management?", |
| 512 switches::IsNewProfileManagement() == true ? "On" : "Off"); | 541 switches::IsNewProfileManagement() == true ? "On" : "Off"); |
| 513 AddSectionEntry(basic_info, "Account Consistency?", | 542 AddSectionEntry(basic_info, "Account Consistency?", |
| 514 switches::IsEnableAccountConsistency() == true ? "On" : "Off"); | 543 switches::IsEnableAccountConsistency() == true ? "On" : "Off"); |
| 515 AddSectionEntry(basic_info, "Signin Status", | 544 AddSectionEntry(basic_info, "Signin Status", |
| 516 signin_manager->IsAuthenticated() ? "Signed In" : "Not Signed In"); | 545 signin_manager->IsAuthenticated() ? "Signed In" : "Not Signed In"); |
| 546 OAuth2TokenServiceDelegate::LoadCredentialsState load_tokens_state = |
| 547 token_service->GetDelegate()->GetLoadCredentialsState(); |
| 548 AddSectionEntry(basic_info, "TokenService Status", |
| 549 TokenServiceLoadCredentialsStateToLabel(load_tokens_state)); |
| 517 | 550 |
| 518 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 551 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 519 // fixed. | 552 // fixed. |
| 520 tracked_objects::ScopedTracker tracking_profile2( | 553 tracked_objects::ScopedTracker tracking_profile2( |
| 521 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 554 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 522 "422460 AboutSigninInternals::SigninStatus::ToValue2")); | 555 "422460 AboutSigninInternals::SigninStatus::ToValue2")); |
| 523 | 556 |
| 524 if (signin_manager->IsAuthenticated()) { | 557 if (signin_manager->IsAuthenticated()) { |
| 525 std::string account_id = signin_manager->GetAuthenticatedAccountId(); | 558 std::string account_id = signin_manager->GetAuthenticatedAccountId(); |
| 526 AddSectionEntry(basic_info, | 559 AddSectionEntry(basic_info, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 690 } |
| 658 | 691 |
| 659 for(const std::string& account_id : accounts_in_token_service) { | 692 for(const std::string& account_id : accounts_in_token_service) { |
| 660 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 693 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 661 entry->SetString("accountId", account_id); | 694 entry->SetString("accountId", account_id); |
| 662 account_info->Append(std::move(entry)); | 695 account_info->Append(std::move(entry)); |
| 663 } | 696 } |
| 664 | 697 |
| 665 return signin_status; | 698 return signin_status; |
| 666 } | 699 } |
| OLD | NEW |