| 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/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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "components/signin/core/browser/account_tracker_service.h" |
| 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 17 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 17 #include "components/signin/core/browser/signin_client.h" | 18 #include "components/signin/core/browser/signin_client.h" |
| 18 #include "components/signin/core/browser/signin_internals_util.h" | 19 #include "components/signin/core/browser/signin_internals_util.h" |
| 19 #include "components/signin/core/browser/signin_manager.h" | 20 #include "components/signin/core/browser/signin_manager.h" |
| 20 #include "components/signin/core/common/profile_management_switches.h" | 21 #include "components/signin/core/common/profile_management_switches.h" |
| 21 #include "components/signin/core/common/signin_switches.h" | 22 #include "components/signin/core/common/signin_switches.h" |
| 22 #include "google_apis/gaia/gaia_auth_fetcher.h" | 23 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 23 #include "google_apis/gaia/gaia_auth_util.h" | 24 #include "google_apis/gaia/gaia_auth_util.h" |
| 24 #include "google_apis/gaia/gaia_constants.h" | 25 #include "google_apis/gaia/gaia_constants.h" |
| 25 #include "google_apis/gaia/gaia_urls.h" | 26 #include "google_apis/gaia/gaia_urls.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const std::string& field_email, | 61 const std::string& field_email, |
| 61 const std::string& field_valid) { | 62 const std::string& field_valid) { |
| 62 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 63 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 63 entry->SetString("email", field_email); | 64 entry->SetString("email", field_email); |
| 64 entry->SetString("valid", field_valid); | 65 entry->SetString("valid", field_valid); |
| 65 accounts_list->Append(entry.release()); | 66 accounts_list->Append(entry.release()); |
| 66 } | 67 } |
| 67 | 68 |
| 68 std::string SigninStatusFieldToLabel(UntimedSigninStatusField field) { | 69 std::string SigninStatusFieldToLabel(UntimedSigninStatusField field) { |
| 69 switch (field) { | 70 switch (field) { |
| 71 case ACCOUNT_ID: |
| 72 return "Account Id"; |
| 73 case GAIA_ID: |
| 74 return "Gaia Id"; |
| 70 case USERNAME: | 75 case USERNAME: |
| 71 return "User Id"; | 76 return "Username"; |
| 72 case UNTIMED_FIELDS_END: | 77 case UNTIMED_FIELDS_END: |
| 73 NOTREACHED(); | 78 NOTREACHED(); |
| 74 return std::string(); | 79 return std::string(); |
| 75 } | 80 } |
| 76 NOTREACHED(); | 81 NOTREACHED(); |
| 77 return std::string(); | 82 return std::string(); |
| 78 } | 83 } |
| 79 | 84 |
| 80 #if !defined (OS_CHROMEOS) | 85 #if !defined (OS_CHROMEOS) |
| 81 std::string SigninStatusFieldToLabel(TimedSigninStatusField field) { | 86 std::string SigninStatusFieldToLabel(TimedSigninStatusField field) { |
| 82 switch (field) { | 87 switch (field) { |
| 83 case SIGNIN_TYPE: | |
| 84 return "Type"; | |
| 85 case AUTHENTICATION_RESULT_RECEIVED: | 88 case AUTHENTICATION_RESULT_RECEIVED: |
| 86 return "Last Authentication Result Received"; | 89 return "Gaia Authentication Result"; |
| 87 case REFRESH_TOKEN_RECEIVED: | 90 case REFRESH_TOKEN_RECEIVED: |
| 88 return "Last RefreshToken Received"; | 91 return "RefreshToken Received"; |
| 89 case GET_USER_INFO_STATUS: | 92 case SIGNIN_STARTED: |
| 90 return "Last OnGetUserInfo Received"; | 93 return "SigninManager Started"; |
| 91 case UBER_TOKEN_STATUS: | 94 case SIGNIN_COMPLETED: |
| 92 return "Last OnUberToken Received"; | 95 return "SigninManager Completed"; |
| 93 case MERGE_SESSION_STATUS: | |
| 94 return "Last OnMergeSession Received"; | |
| 95 case TIMED_FIELDS_END: | 96 case TIMED_FIELDS_END: |
| 96 NOTREACHED(); | 97 NOTREACHED(); |
| 97 return "Error"; | 98 return "Error"; |
| 98 } | 99 } |
| 99 NOTREACHED(); | 100 NOTREACHED(); |
| 100 return "Error"; | 101 return "Error"; |
| 101 } | 102 } |
| 102 #endif // !defined (OS_CHROMEOS) | 103 #endif // !defined (OS_CHROMEOS) |
| 103 | 104 |
| 105 void SetPref(PrefService* prefs, |
| 106 TimedSigninStatusField field, |
| 107 const std::string& time, |
| 108 const std::string& value) { |
| 109 std::string value_pref = SigninStatusFieldToString(field) + ".value"; |
| 110 std::string time_pref = SigninStatusFieldToString(field) + ".time"; |
| 111 prefs->SetString(value_pref, value); |
| 112 prefs->SetString(time_pref, time); |
| 113 } |
| 114 |
| 115 void GetPref(PrefService* prefs, |
| 116 TimedSigninStatusField field, |
| 117 std::string* time, |
| 118 std::string* value) { |
| 119 std::string value_pref = SigninStatusFieldToString(field) + ".value"; |
| 120 std::string time_pref = SigninStatusFieldToString(field) + ".time"; |
| 121 *value = prefs->GetString(value_pref); |
| 122 *time = prefs->GetString(time_pref); |
| 123 } |
| 124 |
| 125 void ClearPref(PrefService* prefs, TimedSigninStatusField field) { |
| 126 std::string value_pref = SigninStatusFieldToString(field) + ".value"; |
| 127 std::string time_pref = SigninStatusFieldToString(field) + ".time"; |
| 128 prefs->ClearPref(value_pref); |
| 129 prefs->ClearPref(time_pref); |
| 130 } |
| 131 |
| 104 } // anonymous namespace | 132 } // anonymous namespace |
| 105 | 133 |
| 106 AboutSigninInternals::AboutSigninInternals( | 134 AboutSigninInternals::AboutSigninInternals( |
| 107 ProfileOAuth2TokenService* token_service, | 135 ProfileOAuth2TokenService* token_service, |
| 136 AccountTrackerService* account_tracker, |
| 108 SigninManagerBase* signin_manager) | 137 SigninManagerBase* signin_manager) |
| 109 : token_service_(token_service), | 138 : token_service_(token_service), |
| 139 account_tracker_(account_tracker), |
| 110 signin_manager_(signin_manager), | 140 signin_manager_(signin_manager), |
| 111 client_(NULL) {} | 141 client_(NULL) {} |
| 112 | 142 |
| 113 AboutSigninInternals::~AboutSigninInternals() {} | 143 AboutSigninInternals::~AboutSigninInternals() {} |
| 114 | 144 |
| 115 void AboutSigninInternals::AddSigninObserver( | 145 void AboutSigninInternals::AddSigninObserver( |
| 116 AboutSigninInternals::Observer* observer) { | 146 AboutSigninInternals::Observer* observer) { |
| 117 signin_observers_.AddObserver(observer); | 147 signin_observers_.AddObserver(observer); |
| 118 } | 148 } |
| 119 | 149 |
| 120 void AboutSigninInternals::RemoveSigninObserver( | 150 void AboutSigninInternals::RemoveSigninObserver( |
| 121 AboutSigninInternals::Observer* observer) { | 151 AboutSigninInternals::Observer* observer) { |
| 122 signin_observers_.RemoveObserver(observer); | 152 signin_observers_.RemoveObserver(observer); |
| 123 } | 153 } |
| 124 | 154 |
| 125 void AboutSigninInternals::NotifySigninValueChanged( | 155 void AboutSigninInternals::NotifySigninValueChanged( |
| 126 const UntimedSigninStatusField& field, | |
| 127 const std::string& value) { | |
| 128 unsigned int field_index = field - UNTIMED_FIELDS_BEGIN; | |
| 129 DCHECK(field_index >= 0 && | |
| 130 field_index < signin_status_.untimed_signin_fields.size()); | |
| 131 | |
| 132 signin_status_.untimed_signin_fields[field_index] = value; | |
| 133 | |
| 134 // Also persist these values in the prefs. | |
| 135 const std::string pref_path = SigninStatusFieldToString(field); | |
| 136 client_->GetPrefs()->SetString(pref_path.c_str(), value); | |
| 137 | |
| 138 NotifyObservers(); | |
| 139 } | |
| 140 | |
| 141 void AboutSigninInternals::NotifySigninValueChanged( | |
| 142 const TimedSigninStatusField& field, | 156 const TimedSigninStatusField& field, |
| 143 const std::string& value) { | 157 const std::string& value) { |
| 144 unsigned int field_index = field - TIMED_FIELDS_BEGIN; | 158 unsigned int field_index = field - TIMED_FIELDS_BEGIN; |
| 145 DCHECK(field_index >= 0 && | 159 DCHECK(field_index >= 0 && |
| 146 field_index < signin_status_.timed_signin_fields.size()); | 160 field_index < signin_status_.timed_signin_fields.size()); |
| 147 | 161 |
| 148 Time now = Time::NowFromSystemTime(); | 162 Time now = Time::NowFromSystemTime(); |
| 149 std::string time_as_str = | 163 std::string time_as_str = |
| 150 base::UTF16ToUTF8(base::TimeFormatShortDateAndTime(now)); | 164 base::UTF16ToUTF8(base::TimeFormatShortDateAndTime(now)); |
| 151 TimedSigninStatusValue timed_value(value, time_as_str); | 165 TimedSigninStatusValue timed_value(value, time_as_str); |
| 152 | 166 |
| 153 signin_status_.timed_signin_fields[field_index] = timed_value; | 167 signin_status_.timed_signin_fields[field_index] = timed_value; |
| 154 | 168 |
| 155 // Also persist these values in the prefs. | 169 // Also persist these values in the prefs. |
| 156 const std::string value_pref = SigninStatusFieldToString(field) + ".value"; | 170 SetPref(client_->GetPrefs(), field, value, time_as_str); |
| 157 const std::string time_pref = SigninStatusFieldToString(field) + ".time"; | 171 |
| 158 client_->GetPrefs()->SetString(value_pref.c_str(), value); | 172 // If the user is restarting a sign in process, clear the fields that are |
| 159 client_->GetPrefs()->SetString(time_pref.c_str(), time_as_str); | 173 // to come. |
| 174 if (field == AUTHENTICATION_RESULT_RECEIVED) { |
| 175 ClearPref(client_->GetPrefs(), REFRESH_TOKEN_RECEIVED); |
| 176 ClearPref(client_->GetPrefs(), SIGNIN_STARTED); |
| 177 ClearPref(client_->GetPrefs(), SIGNIN_COMPLETED); |
| 178 } |
| 160 | 179 |
| 161 NotifyObservers(); | 180 NotifyObservers(); |
| 162 } | 181 } |
| 163 | 182 |
| 164 void AboutSigninInternals::RefreshSigninPrefs() { | 183 void AboutSigninInternals::RefreshSigninPrefs() { |
| 165 // Since the AboutSigninInternals has a dependency on the SigninManager | |
| 166 // (as seen in the AboutSigninInternalsFactory) the SigninManager can have | |
| 167 // the AuthenticatedUsername set before AboutSigninInternals can observe it. | |
| 168 // For that scenario, read the AuthenticatedUsername if it exists. | |
| 169 if (signin_manager_->IsAuthenticated()) { | |
| 170 signin_status_.untimed_signin_fields[USERNAME] = | |
| 171 signin_manager_->GetAuthenticatedUsername(); | |
| 172 } | |
| 173 | |
| 174 // Return if no client exists. Can occur in unit tests. | 184 // Return if no client exists. Can occur in unit tests. |
| 175 if (!client_) | 185 if (!client_) |
| 176 return; | 186 return; |
| 177 | 187 |
| 178 PrefService* pref_service = client_->GetPrefs(); | 188 PrefService* pref_service = client_->GetPrefs(); |
| 179 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) { | |
| 180 const std::string pref_path = | |
| 181 SigninStatusFieldToString(static_cast<UntimedSigninStatusField>(i)); | |
| 182 | |
| 183 signin_status_.untimed_signin_fields[i - UNTIMED_FIELDS_BEGIN] = | |
| 184 pref_service->GetString(pref_path.c_str()); | |
| 185 } | |
| 186 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) { | 189 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) { |
| 187 const std::string value_pref = | 190 std::string time_str; |
| 188 SigninStatusFieldToString(static_cast<TimedSigninStatusField>(i)) + | 191 std::string value_str; |
| 189 ".value"; | 192 GetPref(pref_service, static_cast<TimedSigninStatusField>(i), |
| 190 const std::string time_pref = | 193 &time_str, &value_str); |
| 191 SigninStatusFieldToString(static_cast<TimedSigninStatusField>(i)) + | 194 TimedSigninStatusValue value(value_str, time_str); |
| 192 ".time"; | |
| 193 | |
| 194 TimedSigninStatusValue value(pref_service->GetString(value_pref.c_str()), | |
| 195 pref_service->GetString(time_pref.c_str())); | |
| 196 signin_status_.timed_signin_fields[i - TIMED_FIELDS_BEGIN] = value; | 195 signin_status_.timed_signin_fields[i - TIMED_FIELDS_BEGIN] = value; |
| 197 } | 196 } |
| 198 | 197 |
| 199 // TODO(rogerta): Get status and timestamps for oauth2 tokens. | 198 // TODO(rogerta): Get status and timestamps for oauth2 tokens. |
| 200 | 199 |
| 201 NotifyObservers(); | 200 NotifyObservers(); |
| 202 } | 201 } |
| 203 | 202 |
| 204 void AboutSigninInternals::Initialize(SigninClient* client) { | 203 void AboutSigninInternals::Initialize(SigninClient* client) { |
| 205 DCHECK(!client_); | 204 DCHECK(!client_); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 234 | 233 |
| 235 const std::string product_version = client_->GetProductVersion(); | 234 const std::string product_version = client_->GetProductVersion(); |
| 236 | 235 |
| 237 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 236 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 238 // fixed. | 237 // fixed. |
| 239 tracked_objects::ScopedTracker tracking_profile05( | 238 tracked_objects::ScopedTracker tracking_profile05( |
| 240 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 239 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 241 "422460 AboutSigninInternals::NotifyObservers 0.5")); | 240 "422460 AboutSigninInternals::NotifyObservers 0.5")); |
| 242 | 241 |
| 243 scoped_ptr<base::DictionaryValue> signin_status_value = | 242 scoped_ptr<base::DictionaryValue> signin_status_value = |
| 244 signin_status_.ToValue(product_version); | 243 signin_status_.ToValue(account_tracker_, signin_manager_, |
| 244 product_version); |
| 245 | 245 |
| 246 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 246 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 247 // fixed. | 247 // fixed. |
| 248 tracked_objects::ScopedTracker tracking_profile1( | 248 tracked_objects::ScopedTracker tracking_profile1( |
| 249 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 249 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 250 "422460 AboutSigninInternals::NotifyObservers1")); | 250 "422460 AboutSigninInternals::NotifyObservers1")); |
| 251 | 251 |
| 252 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, | 252 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, |
| 253 signin_observers_, | 253 signin_observers_, |
| 254 OnSigninStateChanged(signin_status_value.get())); | 254 OnSigninStateChanged(signin_status_value.get())); |
| 255 } | 255 } |
| 256 | 256 |
| 257 scoped_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() { | 257 scoped_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() { |
| 258 return signin_status_.ToValue(client_->GetProductVersion()).Pass(); | 258 return signin_status_.ToValue(account_tracker_, signin_manager_, |
| 259 client_->GetProductVersion()).Pass(); |
| 259 } | 260 } |
| 260 | 261 |
| 261 void AboutSigninInternals::OnAccessTokenRequested( | 262 void AboutSigninInternals::OnAccessTokenRequested( |
| 262 const std::string& account_id, | 263 const std::string& account_id, |
| 263 const std::string& consumer_id, | 264 const std::string& consumer_id, |
| 264 const OAuth2TokenService::ScopeSet& scopes) { | 265 const OAuth2TokenService::ScopeSet& scopes) { |
| 265 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 266 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 266 // fixed. | 267 // fixed. |
| 267 tracked_objects::ScopedTracker tracking_profile( | 268 tracked_objects::ScopedTracker tracking_profile( |
| 268 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 269 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 OnListAccountsComplete(gaia_accounts); | 350 OnListAccountsComplete(gaia_accounts); |
| 350 } | 351 } |
| 351 } | 352 } |
| 352 | 353 |
| 353 void AboutSigninInternals::OnListAccountsFailure( | 354 void AboutSigninInternals::OnListAccountsFailure( |
| 354 const GoogleServiceAuthError& error) { | 355 const GoogleServiceAuthError& error) { |
| 355 gaia_fetcher_.reset(); | 356 gaia_fetcher_.reset(); |
| 356 VLOG(1) << "AboutSigninInternals::OnListAccountsFailure:" << error.ToString(); | 357 VLOG(1) << "AboutSigninInternals::OnListAccountsFailure:" << error.ToString(); |
| 357 } | 358 } |
| 358 | 359 |
| 360 void AboutSigninInternals::GoogleSigninFailed( |
| 361 const GoogleServiceAuthError& error) { |
| 362 NotifyObservers(); |
| 363 } |
| 364 |
| 365 void AboutSigninInternals::GoogleSigninSucceeded(const std::string& account_id, |
| 366 const std::string& username, |
| 367 const std::string& password) { |
| 368 NotifyObservers(); |
| 369 } |
| 370 |
| 371 void AboutSigninInternals::GoogleSignedOut(const std::string& account_id, |
| 372 const std::string& username) { |
| 373 NotifyObservers(); |
| 374 } |
| 375 |
| 359 void AboutSigninInternals::OnListAccountsComplete( | 376 void AboutSigninInternals::OnListAccountsComplete( |
| 360 std::vector<std::pair<std::string, bool> >& gaia_accounts) { | 377 std::vector<std::pair<std::string, bool> >& gaia_accounts) { |
| 361 base::DictionaryValue signin_status; | 378 base::DictionaryValue cookie_status; |
| 362 base::ListValue* cookie_info = new base::ListValue(); | 379 base::ListValue* cookie_info = new base::ListValue(); |
| 363 signin_status.Set("cookie_info", cookie_info); | 380 cookie_status.Set("cookie_info", cookie_info); |
| 364 | 381 |
| 365 for (size_t i = 0; i < gaia_accounts.size(); ++i) { | 382 for (size_t i = 0; i < gaia_accounts.size(); ++i) { |
| 366 AddCookieEntry(cookie_info, | 383 AddCookieEntry(cookie_info, |
| 367 gaia_accounts[i].first, | 384 gaia_accounts[i].first, |
| 368 gaia_accounts[i].second ? "Valid" : "Invalid"); | 385 gaia_accounts[i].second ? "Valid" : "Invalid"); |
| 369 } | 386 } |
| 370 | 387 |
| 371 if (gaia_accounts.size() == 0) | 388 if (gaia_accounts.size() == 0) |
| 372 AddCookieEntry(cookie_info, "No Accounts Present.", ""); | 389 AddCookieEntry(cookie_info, "No Accounts Present.", ""); |
| 373 | 390 |
| 374 // Update the observers that the cookie's accounts are updated. | 391 // Update the observers that the cookie's accounts are updated. |
| 375 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, | 392 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, |
| 376 signin_observers_, | 393 signin_observers_, |
| 377 OnCookieAccountsFetched(&signin_status)); | 394 OnCookieAccountsFetched(&cookie_status)); |
| 378 } | 395 } |
| 379 | 396 |
| 380 AboutSigninInternals::TokenInfo::TokenInfo( | 397 AboutSigninInternals::TokenInfo::TokenInfo( |
| 381 const std::string& consumer_id, | 398 const std::string& consumer_id, |
| 382 const OAuth2TokenService::ScopeSet& scopes) | 399 const OAuth2TokenService::ScopeSet& scopes) |
| 383 : consumer_id(consumer_id), | 400 : consumer_id(consumer_id), |
| 384 scopes(scopes), | 401 scopes(scopes), |
| 385 request_time(base::Time::Now()), | 402 request_time(base::Time::Now()), |
| 386 error(GoogleServiceAuthError::AuthErrorNone()), | 403 error(GoogleServiceAuthError::AuthErrorNone()), |
| 387 removed_(false) {} | 404 removed_(false) {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 base::StringPrintf("Failure: %s", error.ToString().c_str())); | 447 base::StringPrintf("Failure: %s", error.ToString().c_str())); |
| 431 } | 448 } |
| 432 } else { | 449 } else { |
| 433 token_info->SetString("status", "Waiting for response"); | 450 token_info->SetString("status", "Waiting for response"); |
| 434 } | 451 } |
| 435 | 452 |
| 436 return token_info.release(); | 453 return token_info.release(); |
| 437 } | 454 } |
| 438 | 455 |
| 439 AboutSigninInternals::SigninStatus::SigninStatus() | 456 AboutSigninInternals::SigninStatus::SigninStatus() |
| 440 : untimed_signin_fields(UNTIMED_FIELDS_COUNT), | 457 : timed_signin_fields(TIMED_FIELDS_COUNT) {} |
| 441 timed_signin_fields(TIMED_FIELDS_COUNT) {} | |
| 442 | 458 |
| 443 AboutSigninInternals::SigninStatus::~SigninStatus() { | 459 AboutSigninInternals::SigninStatus::~SigninStatus() { |
| 444 for (TokenInfoMap::iterator it = token_info_map.begin(); | 460 for (TokenInfoMap::iterator it = token_info_map.begin(); |
| 445 it != token_info_map.end(); | 461 it != token_info_map.end(); |
| 446 ++it) { | 462 ++it) { |
| 447 STLDeleteElements(&it->second); | 463 STLDeleteElements(&it->second); |
| 448 } | 464 } |
| 449 } | 465 } |
| 450 | 466 |
| 451 AboutSigninInternals::TokenInfo* AboutSigninInternals::SigninStatus::FindToken( | 467 AboutSigninInternals::TokenInfo* AboutSigninInternals::SigninStatus::FindToken( |
| 452 const std::string& account_id, | 468 const std::string& account_id, |
| 453 const std::string& consumer_id, | 469 const std::string& consumer_id, |
| 454 const OAuth2TokenService::ScopeSet& scopes) { | 470 const OAuth2TokenService::ScopeSet& scopes) { |
| 455 for (size_t i = 0; i < token_info_map[account_id].size(); ++i) { | 471 for (size_t i = 0; i < token_info_map[account_id].size(); ++i) { |
| 456 TokenInfo* tmp = token_info_map[account_id][i]; | 472 TokenInfo* tmp = token_info_map[account_id][i]; |
| 457 if (tmp->consumer_id == consumer_id && tmp->scopes == scopes) | 473 if (tmp->consumer_id == consumer_id && tmp->scopes == scopes) |
| 458 return tmp; | 474 return tmp; |
| 459 } | 475 } |
| 460 return NULL; | 476 return NULL; |
| 461 } | 477 } |
| 462 | 478 |
| 463 scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue( | 479 scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue( |
| 464 std::string product_version) { | 480 AccountTrackerService* account_tracker, |
| 481 SigninManagerBase* signin_manager, |
| 482 const std::string& product_version) { |
| 465 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 483 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 466 // fixed. | 484 // fixed. |
| 467 tracked_objects::ScopedTracker tracking_profile1( | 485 tracked_objects::ScopedTracker tracking_profile1( |
| 468 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 486 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 469 "422460 AboutSigninInternals::SigninStatus::ToValue1")); | 487 "422460 AboutSigninInternals::SigninStatus::ToValue1")); |
| 470 | 488 |
| 471 scoped_ptr<base::DictionaryValue> signin_status(new base::DictionaryValue()); | 489 scoped_ptr<base::DictionaryValue> signin_status(new base::DictionaryValue()); |
| 472 base::ListValue* signin_info = new base::ListValue(); | 490 base::ListValue* signin_info = new base::ListValue(); |
| 473 signin_status->Set("signin_info", signin_info); | 491 signin_status->Set("signin_info", signin_info); |
| 474 | 492 |
| 475 // A summary of signin related info first. | 493 // A summary of signin related info first. |
| 476 base::ListValue* basic_info = AddSection(signin_info, "Basic Information"); | 494 base::ListValue* basic_info = AddSection(signin_info, "Basic Information"); |
| 477 const std::string signin_status_string = | |
| 478 untimed_signin_fields[USERNAME - UNTIMED_FIELDS_BEGIN].empty() | |
| 479 ? "Not Signed In" | |
| 480 : "Signed In"; | |
| 481 AddSectionEntry(basic_info, "Chrome Version", product_version); | 495 AddSectionEntry(basic_info, "Chrome Version", product_version); |
| 482 AddSectionEntry(basic_info, "Signin Status", signin_status_string); | 496 AddSectionEntry(basic_info, "Webview Based Signin?", |
| 483 AddSectionEntry(basic_info, "Webview Based Signin Enabled?", | 497 switches::IsEnableWebviewBasedSignin() == true ? "On" : "Off"); |
| 484 switches::IsEnableWebviewBasedSignin() == true ? "True" : "False"); | 498 AddSectionEntry(basic_info, "New Avatar Menu?", |
| 485 AddSectionEntry(basic_info, "New Avatar Menu Enabled?", | 499 switches::IsNewAvatarMenu() == true ? "On" : "Off"); |
| 486 switches::IsNewAvatarMenu() == true ? "True" : "False"); | 500 AddSectionEntry(basic_info, "New Profile Management?", |
| 487 AddSectionEntry(basic_info, "New Profile Management Enabled?", | 501 switches::IsNewProfileManagement() == true ? "On" : "Off"); |
| 488 switches::IsNewProfileManagement() == true ? "True" : "False"); | 502 AddSectionEntry(basic_info, "Account Consistency?", |
| 489 AddSectionEntry(basic_info, "Account Consistency Enabled?", | 503 switches::IsEnableAccountConsistency() == true ? "On" : "Off"); |
| 490 switches::IsEnableAccountConsistency() == true ? "True" : "False"); | 504 AddSectionEntry(basic_info, "Signin Status", |
| 505 signin_manager->IsAuthenticated() ? "Signed In" : "Not Signed In"); |
| 491 | 506 |
| 492 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 507 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 493 // fixed. | 508 // fixed. |
| 494 tracked_objects::ScopedTracker tracking_profile2( | 509 tracked_objects::ScopedTracker tracking_profile2( |
| 495 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 510 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 496 "422460 AboutSigninInternals::SigninStatus::ToValue2")); | 511 "422460 AboutSigninInternals::SigninStatus::ToValue2")); |
| 497 | 512 |
| 498 // Only add username. SID and LSID have moved to tokens section. | 513 if (signin_manager->IsAuthenticated()) { |
| 499 const std::string field = | 514 std::string account_id = signin_manager->GetAuthenticatedAccountId(); |
| 500 SigninStatusFieldToLabel(static_cast<UntimedSigninStatusField>(USERNAME)); | 515 AddSectionEntry(basic_info, |
| 501 AddSectionEntry(basic_info, | 516 SigninStatusFieldToLabel( |
| 502 field, | 517 static_cast<UntimedSigninStatusField>(ACCOUNT_ID)), |
| 503 untimed_signin_fields[USERNAME - UNTIMED_FIELDS_BEGIN]); | 518 account_id); |
| 519 AddSectionEntry(basic_info, |
| 520 SigninStatusFieldToLabel( |
| 521 static_cast<UntimedSigninStatusField>(GAIA_ID)), |
| 522 account_tracker->GetAccountInfo(account_id).gaia); |
| 523 AddSectionEntry(basic_info, |
| 524 SigninStatusFieldToLabel( |
| 525 static_cast<UntimedSigninStatusField>(USERNAME)), |
| 526 signin_manager->GetAuthenticatedUsername()); |
| 527 } |
| 504 | 528 |
| 505 #if !defined(OS_CHROMEOS) | 529 #if !defined(OS_CHROMEOS) |
| 506 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 530 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 507 // fixed. | 531 // fixed. |
| 508 tracked_objects::ScopedTracker tracking_profile3( | 532 tracked_objects::ScopedTracker tracking_profile3( |
| 509 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 533 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 510 "422460 AboutSigninInternals::SigninStatus::ToValue3")); | 534 "422460 AboutSigninInternals::SigninStatus::ToValue3")); |
| 511 | 535 |
| 512 // Time and status information of the possible sign in types. | 536 // Time and status information of the possible sign in types. |
| 513 base::ListValue* detailed_info = | 537 base::ListValue* detailed_info = |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 "422460 AboutSigninInternals::SigninStatus::ToValue43")); | 583 "422460 AboutSigninInternals::SigninStatus::ToValue43")); |
| 560 | 584 |
| 561 for (size_t i = 0; i < tokens.size(); ++i) { | 585 for (size_t i = 0; i < tokens.size(); ++i) { |
| 562 base::DictionaryValue* token_info = tokens[i]->ToValue(); | 586 base::DictionaryValue* token_info = tokens[i]->ToValue(); |
| 563 token_details->Append(token_info); | 587 token_details->Append(token_info); |
| 564 } | 588 } |
| 565 } | 589 } |
| 566 | 590 |
| 567 return signin_status.Pass(); | 591 return signin_status.Pass(); |
| 568 } | 592 } |
| OLD | NEW |