Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: components/signin/core/browser/about_signin_internals.cc

Issue 1058513002: Add an Accounts in Token Service section to about:signin-internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const std::string product_version = client_->GetProductVersion(); 234 const std::string product_version = client_->GetProductVersion();
235 235
236 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is 236 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
237 // fixed. 237 // fixed.
238 tracked_objects::ScopedTracker tracking_profile05( 238 tracked_objects::ScopedTracker tracking_profile05(
239 FROM_HERE_WITH_EXPLICIT_FUNCTION( 239 FROM_HERE_WITH_EXPLICIT_FUNCTION(
240 "422460 AboutSigninInternals::NotifyObservers 0.5")); 240 "422460 AboutSigninInternals::NotifyObservers 0.5"));
241 241
242 scoped_ptr<base::DictionaryValue> signin_status_value = 242 scoped_ptr<base::DictionaryValue> signin_status_value =
243 signin_status_.ToValue(account_tracker_, signin_manager_, 243 signin_status_.ToValue(account_tracker_, signin_manager_,
244 token_service_,
244 product_version); 245 product_version);
245 246
246 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is 247 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
247 // fixed. 248 // fixed.
248 tracked_objects::ScopedTracker tracking_profile1( 249 tracked_objects::ScopedTracker tracking_profile1(
249 FROM_HERE_WITH_EXPLICIT_FUNCTION( 250 FROM_HERE_WITH_EXPLICIT_FUNCTION(
250 "422460 AboutSigninInternals::NotifyObservers1")); 251 "422460 AboutSigninInternals::NotifyObservers1"));
251 252
252 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, 253 FOR_EACH_OBSERVER(AboutSigninInternals::Observer,
253 signin_observers_, 254 signin_observers_,
254 OnSigninStateChanged(signin_status_value.get())); 255 OnSigninStateChanged(signin_status_value.get()));
255 } 256 }
256 257
257 scoped_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() { 258 scoped_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() {
258 return signin_status_.ToValue(account_tracker_, signin_manager_, 259 return signin_status_.ToValue(account_tracker_, signin_manager_,
260 token_service_,
259 client_->GetProductVersion()).Pass(); 261 client_->GetProductVersion()).Pass();
260 } 262 }
261 263
262 void AboutSigninInternals::OnAccessTokenRequested( 264 void AboutSigninInternals::OnAccessTokenRequested(
263 const std::string& account_id, 265 const std::string& account_id,
264 const std::string& consumer_id, 266 const std::string& consumer_id,
265 const OAuth2TokenService::ScopeSet& scopes) { 267 const OAuth2TokenService::ScopeSet& scopes) {
266 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is 268 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
267 // fixed. 269 // fixed.
268 tracked_objects::ScopedTracker tracking_profile( 270 tracked_objects::ScopedTracker tracking_profile(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 : consumer_id(consumer_id), 402 : consumer_id(consumer_id),
401 scopes(scopes), 403 scopes(scopes),
402 request_time(base::Time::Now()), 404 request_time(base::Time::Now()),
403 error(GoogleServiceAuthError::AuthErrorNone()), 405 error(GoogleServiceAuthError::AuthErrorNone()),
404 removed_(false) {} 406 removed_(false) {}
405 407
406 AboutSigninInternals::TokenInfo::~TokenInfo() {} 408 AboutSigninInternals::TokenInfo::~TokenInfo() {}
407 409
408 bool AboutSigninInternals::TokenInfo::LessThan(const TokenInfo* a, 410 bool AboutSigninInternals::TokenInfo::LessThan(const TokenInfo* a,
409 const TokenInfo* b) { 411 const TokenInfo* b) {
410 return a->consumer_id < b->consumer_id || 412 if (a->request_time == b->request_time) {
411 (a->consumer_id == b->consumer_id && a->scopes < b->scopes); 413 if (a->consumer_id == b->consumer_id) {
414 return a->scopes < b->scopes;
415 }
416 return a->consumer_id < b->consumer_id;
417 }
418 return a->request_time < b->request_time;
412 } 419 }
413 420
414 void AboutSigninInternals::TokenInfo::Invalidate() { removed_ = true; } 421 void AboutSigninInternals::TokenInfo::Invalidate() { removed_ = true; }
415 422
416 base::DictionaryValue* AboutSigninInternals::TokenInfo::ToValue() const { 423 base::DictionaryValue* AboutSigninInternals::TokenInfo::ToValue() const {
417 scoped_ptr<base::DictionaryValue> token_info(new base::DictionaryValue()); 424 scoped_ptr<base::DictionaryValue> token_info(new base::DictionaryValue());
418 token_info->SetString("service", consumer_id); 425 token_info->SetString("service", consumer_id);
419 426
420 std::string scopes_str; 427 std::string scopes_str;
421 for (OAuth2TokenService::ScopeSet::const_iterator it = scopes.begin(); 428 for (OAuth2TokenService::ScopeSet::const_iterator it = scopes.begin();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 TokenInfo* tmp = token_info_map[account_id][i]; 479 TokenInfo* tmp = token_info_map[account_id][i];
473 if (tmp->consumer_id == consumer_id && tmp->scopes == scopes) 480 if (tmp->consumer_id == consumer_id && tmp->scopes == scopes)
474 return tmp; 481 return tmp;
475 } 482 }
476 return NULL; 483 return NULL;
477 } 484 }
478 485
479 scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue( 486 scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue(
480 AccountTrackerService* account_tracker, 487 AccountTrackerService* account_tracker,
481 SigninManagerBase* signin_manager, 488 SigninManagerBase* signin_manager,
489 ProfileOAuth2TokenService* token_service,
482 const std::string& product_version) { 490 const std::string& product_version) {
483 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is 491 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
484 // fixed. 492 // fixed.
485 tracked_objects::ScopedTracker tracking_profile1( 493 tracked_objects::ScopedTracker tracking_profile1(
486 FROM_HERE_WITH_EXPLICIT_FUNCTION( 494 FROM_HERE_WITH_EXPLICIT_FUNCTION(
487 "422460 AboutSigninInternals::SigninStatus::ToValue1")); 495 "422460 AboutSigninInternals::SigninStatus::ToValue1"));
488 496
489 scoped_ptr<base::DictionaryValue> signin_status(new base::DictionaryValue()); 497 scoped_ptr<base::DictionaryValue> signin_status(new base::DictionaryValue());
490 base::ListValue* signin_info = new base::ListValue(); 498 base::ListValue* signin_info = new base::ListValue();
491 signin_status->Set("signin_info", signin_info); 499 signin_status->Set("signin_info", signin_info);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 tracked_objects::ScopedTracker tracking_profile43( 589 tracked_objects::ScopedTracker tracking_profile43(
582 FROM_HERE_WITH_EXPLICIT_FUNCTION( 590 FROM_HERE_WITH_EXPLICIT_FUNCTION(
583 "422460 AboutSigninInternals::SigninStatus::ToValue43")); 591 "422460 AboutSigninInternals::SigninStatus::ToValue43"));
584 592
585 for (size_t i = 0; i < tokens.size(); ++i) { 593 for (size_t i = 0; i < tokens.size(); ++i) {
586 base::DictionaryValue* token_info = tokens[i]->ToValue(); 594 base::DictionaryValue* token_info = tokens[i]->ToValue();
587 token_details->Append(token_info); 595 token_details->Append(token_info);
588 } 596 }
589 } 597 }
590 598
599 base::ListValue* account_info = new base::ListValue();
600 signin_status->Set("account_info", account_info);
James Hawkins 2015/04/01 16:19:44 nit: accountInfo, since this is ultimately a JS va
anthonyvd 2015/04/07 15:16:06 Done.
601 const std::vector<std::string>& accounts_in_token_service =
602 token_service->GetAccounts();
603
604 if(accounts_in_token_service.size() == 0) {
605 base::DictionaryValue* no_token_entry = new base::DictionaryValue();
606 no_token_entry->SetString("account_id", "No token in Token Service.");
James Hawkins 2015/04/01 16:19:44 nit: accountId, since this is ultimately a JS vari
anthonyvd 2015/04/07 15:16:06 Done.
607 account_info->Append(no_token_entry);
608 }
609
610 for(const std::string& account_id : accounts_in_token_service) {
611 base::DictionaryValue* entry = new base::DictionaryValue();
612 entry->SetString("account_id", account_id);
James Hawkins 2015/04/01 16:19:44 nit: accountId, since this is ultimately a JS vari
anthonyvd 2015/04/07 15:16:06 Done.
613 account_info->Append(entry);
614 }
615
591 return signin_status.Pass(); 616 return signin_status.Pass();
592 } 617 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698