Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 base::ListValue* section_contents = new base::ListValue(); | 35 base::ListValue* section_contents = new base::ListValue(); |
| 36 | 36 |
| 37 section->SetString("title", title); | 37 section->SetString("title", title); |
| 38 section->Set("data", section_contents); | 38 section->Set("data", section_contents); |
| 39 parent_list->Append(section.release()); | 39 parent_list->Append(section.release()); |
| 40 return section_contents; | 40 return section_contents; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void AddSectionEntry(base::ListValue* section_list, | 43 void AddSectionEntry(base::ListValue* section_list, |
| 44 const std::string& field_name, | 44 const std::string& field_name, |
| 45 const std::string& field_val) { | 45 const std::string& field_val, |
| 46 const std::string& field_val2 = "") { | |
| 46 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 47 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 47 entry->SetString("label", field_name); | 48 entry->SetString("label", field_name); |
| 48 entry->SetString("value", field_val); | 49 entry->SetString("value", field_val); |
| 50 entry->SetString("value2", field_val2); | |
|
Evan Stade
2014/04/24 00:36:47
"value"/"value2" is perhaps the least descriptive
Mike Lerman
2014/04/24 15:53:58
You're right, with the change I'm making I can now
| |
| 49 section_list->Append(entry.release()); | 51 section_list->Append(entry.release()); |
| 50 } | 52 } |
| 51 | 53 |
| 52 std::string SigninStatusFieldToLabel(UntimedSigninStatusField field) { | 54 std::string SigninStatusFieldToLabel(UntimedSigninStatusField field) { |
| 53 switch (field) { | 55 switch (field) { |
| 54 case USERNAME: | 56 case USERNAME: |
| 55 return "User Id"; | 57 return "User Id"; |
| 56 case UNTIMED_FIELDS_END: | 58 case UNTIMED_FIELDS_END: |
| 57 NOTREACHED(); | 59 NOTREACHED(); |
| 58 return std::string(); | 60 return std::string(); |
| 59 } | 61 } |
| 60 NOTREACHED(); | 62 NOTREACHED(); |
| 61 return std::string(); | 63 return std::string(); |
| 62 } | 64 } |
| 63 | 65 |
| 64 TimedSigninStatusValue SigninStatusFieldToLabel(TimedSigninStatusField field) { | 66 std::string SigninStatusFieldToLabel(TimedSigninStatusField field) { |
| 65 switch (field) { | 67 switch (field) { |
| 66 case SIGNIN_TYPE: | 68 case SIGNIN_TYPE: |
| 67 return TimedSigninStatusValue("Type", "Time"); | 69 return "Type"; |
| 68 case CLIENT_LOGIN_STATUS: | 70 case CLIENT_LOGIN_STATUS: |
| 69 return TimedSigninStatusValue("Last OnClientLogin Status", | 71 return "Last OnClientLogin Status"; |
| 70 "Last OnClientLogin Time"); | |
| 71 case OAUTH_LOGIN_STATUS: | 72 case OAUTH_LOGIN_STATUS: |
| 72 return TimedSigninStatusValue("Last OnOAuthLogin Status", | 73 return "Last OnOAuthLogin Status"; |
| 73 "Last OnOAuthLogin Time"); | |
| 74 | |
| 75 case GET_USER_INFO_STATUS: | 74 case GET_USER_INFO_STATUS: |
| 76 return TimedSigninStatusValue("Last OnGetUserInfo Status", | 75 return "Last OnGetUserInfo Status"; |
| 77 "Last OnGetUserInfo Time"); | |
| 78 case UBER_TOKEN_STATUS: | 76 case UBER_TOKEN_STATUS: |
| 79 return TimedSigninStatusValue("Last OnUberToken Status", | 77 return "Last OnUberToken Status"; |
| 80 "Last OnUberToken Time"); | |
| 81 case MERGE_SESSION_STATUS: | 78 case MERGE_SESSION_STATUS: |
| 82 return TimedSigninStatusValue("Last OnMergeSession Status", | 79 return "Last OnMergeSession Status"; |
| 83 "Last OnMergeSession Time"); | |
| 84 case TIMED_FIELDS_END: | 80 case TIMED_FIELDS_END: |
| 85 NOTREACHED(); | 81 NOTREACHED(); |
| 86 return TimedSigninStatusValue("Error", std::string()); | 82 return "Error"; |
| 87 } | 83 } |
| 88 NOTREACHED(); | 84 NOTREACHED(); |
| 89 return TimedSigninStatusValue("Error", std::string()); | 85 return "Error"; |
| 90 } | 86 } |
| 91 | 87 |
| 92 } // anonymous namespace | 88 } // anonymous namespace |
| 93 | 89 |
| 94 AboutSigninInternals::AboutSigninInternals( | 90 AboutSigninInternals::AboutSigninInternals( |
| 95 ProfileOAuth2TokenService* token_service, | 91 ProfileOAuth2TokenService* token_service, |
| 96 SigninManagerBase* signin_manager) | 92 SigninManagerBase* signin_manager) |
| 97 : token_service_(token_service), | 93 : token_service_(token_service), |
| 98 signin_manager_(signin_manager), | 94 signin_manager_(signin_manager), |
| 99 client_(NULL) {} | 95 client_(NULL) {} |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 const std::string field = | 359 const std::string field = |
| 364 SigninStatusFieldToLabel(static_cast<UntimedSigninStatusField>(USERNAME)); | 360 SigninStatusFieldToLabel(static_cast<UntimedSigninStatusField>(USERNAME)); |
| 365 AddSectionEntry(basic_info, | 361 AddSectionEntry(basic_info, |
| 366 field, | 362 field, |
| 367 untimed_signin_fields[USERNAME - UNTIMED_FIELDS_BEGIN]); | 363 untimed_signin_fields[USERNAME - UNTIMED_FIELDS_BEGIN]); |
| 368 | 364 |
| 369 // Time and status information of the possible sign in types. | 365 // Time and status information of the possible sign in types. |
| 370 base::ListValue* detailed_info = | 366 base::ListValue* detailed_info = |
| 371 AddSection(signin_info, "Last Signin Details"); | 367 AddSection(signin_info, "Last Signin Details"); |
| 372 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) { | 368 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) { |
| 373 const std::string value_field = | 369 const std::string status_field_label = |
| 374 SigninStatusFieldToLabel(static_cast<TimedSigninStatusField>(i)).first; | 370 SigninStatusFieldToLabel(static_cast<TimedSigninStatusField>(i)); |
| 375 const std::string time_field = | |
| 376 SigninStatusFieldToLabel(static_cast<TimedSigninStatusField>(i)).second; | |
| 377 | 371 |
| 378 AddSectionEntry(detailed_info, | 372 AddSectionEntry(detailed_info, |
| 379 value_field, | 373 status_field_label, |
| 380 timed_signin_fields[i - TIMED_FIELDS_BEGIN].first); | 374 timed_signin_fields[i - TIMED_FIELDS_BEGIN].first, |
| 381 AddSectionEntry(detailed_info, | |
| 382 time_field, | |
| 383 timed_signin_fields[i - TIMED_FIELDS_BEGIN].second); | 375 timed_signin_fields[i - TIMED_FIELDS_BEGIN].second); |
| 384 } | 376 } |
| 385 | 377 |
| 386 // Token information for all services. | 378 // Token information for all services. |
| 387 base::ListValue* token_info = new base::ListValue(); | 379 base::ListValue* token_info = new base::ListValue(); |
| 388 signin_status->Set("token_info", token_info); | 380 signin_status->Set("token_info", token_info); |
| 389 for (TokenInfoMap::iterator it = token_info_map.begin(); | 381 for (TokenInfoMap::iterator it = token_info_map.begin(); |
| 390 it != token_info_map.end(); | 382 it != token_info_map.end(); |
| 391 ++it) { | 383 ++it) { |
| 392 base::ListValue* token_details = AddSection(token_info, it->first); | 384 base::ListValue* token_details = AddSection(token_info, it->first); |
| 393 | 385 |
| 394 std::sort(it->second.begin(), it->second.end(), TokenInfo::LessThan); | 386 std::sort(it->second.begin(), it->second.end(), TokenInfo::LessThan); |
| 395 const std::vector<TokenInfo*>& tokens = it->second; | 387 const std::vector<TokenInfo*>& tokens = it->second; |
| 396 for (size_t i = 0; i < tokens.size(); ++i) { | 388 for (size_t i = 0; i < tokens.size(); ++i) { |
| 397 base::DictionaryValue* token_info = tokens[i]->ToValue(); | 389 base::DictionaryValue* token_info = tokens[i]->ToValue(); |
| 398 token_details->Append(token_info); | 390 token_details->Append(token_info); |
| 399 } | 391 } |
| 400 } | 392 } |
| 401 | 393 |
| 402 return signin_status.Pass(); | 394 return signin_status.Pass(); |
| 403 } | 395 } |
| OLD | NEW |