Commit 0096addf authored by anthonyvd's avatar anthonyvd Committed by Commit bot

Show SigninErrorController username and status in AboutSigninInternals

BUG=405038
TEST=
1. Sign in to Chrome and make sure there are no Auth Errors
2. Navigate to chrome://signin-internals
3. In the Basic Information section, observe that there is no ErrorController Username or ErrorController Status section
4. Trigger an Auth Error (for example by revoking Chrome's access token at accounts.google.com)
5. In chrome://signin-internals, observe that the Basic Information section was updated with the ErrorController Username and ErrorController Status fields.

Review URL: https://codereview.chromium.org/1025323004

Cr-Commit-Position: refs/heads/master@{#322426}
parent cdeb2805
......@@ -9,6 +9,7 @@
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
......@@ -27,6 +28,7 @@ AboutSigninInternalsFactory::AboutSigninInternalsFactory()
DependsOn(AccountTrackerServiceFactory::GetInstance());
DependsOn(ChromeSigninClientFactory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
DependsOn(SigninErrorControllerFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance());
}
......@@ -82,7 +84,8 @@ KeyedService* AboutSigninInternalsFactory::BuildServiceInstanceFor(
AboutSigninInternals* service = new AboutSigninInternals(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile));
SigninManagerFactory::GetForProfile(profile),
SigninErrorControllerFactory::GetForProfile(profile));
service->Initialize(ChromeSigninClientFactory::GetForProfile(profile));
return service;
}
......@@ -134,11 +134,13 @@ void ClearPref(PrefService* prefs, TimedSigninStatusField field) {
AboutSigninInternals::AboutSigninInternals(
ProfileOAuth2TokenService* token_service,
AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager)
SigninManagerBase* signin_manager,
SigninErrorController* signin_error_controller)
: token_service_(token_service),
account_tracker_(account_tracker),
signin_manager_(signin_manager),
client_(NULL) {}
client_(NULL),
signin_error_controller_(signin_error_controller) {}
AboutSigninInternals::~AboutSigninInternals() {}
......@@ -206,6 +208,7 @@ void AboutSigninInternals::Initialize(SigninClient* client) {
RefreshSigninPrefs();
signin_error_controller_->AddObserver(this);
signin_manager_->AddSigninDiagnosticsObserver(this);
token_service_->AddDiagnosticsObserver(this);
cookie_changed_subscription_ = client_->AddCookieChangedCallback(
......@@ -216,6 +219,7 @@ void AboutSigninInternals::Initialize(SigninClient* client) {
}
void AboutSigninInternals::Shutdown() {
signin_error_controller_->RemoveObserver(this);
signin_manager_->RemoveSigninDiagnosticsObserver(this);
token_service_->RemoveDiagnosticsObserver(this);
cookie_changed_subscription_.reset();
......@@ -240,7 +244,9 @@ void AboutSigninInternals::NotifyObservers() {
"422460 AboutSigninInternals::NotifyObservers 0.5"));
scoped_ptr<base::DictionaryValue> signin_status_value =
signin_status_.ToValue(account_tracker_, signin_manager_,
signin_status_.ToValue(account_tracker_,
signin_manager_,
signin_error_controller_,
product_version);
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
......@@ -255,7 +261,9 @@ void AboutSigninInternals::NotifyObservers() {
}
scoped_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() {
return signin_status_.ToValue(account_tracker_, signin_manager_,
return signin_status_.ToValue(account_tracker_,
signin_manager_,
signin_error_controller_,
client_->GetProductVersion()).Pass();
}
......@@ -328,6 +336,10 @@ void AboutSigninInternals::OnCookieChanged(const net::CanonicalCookie& cookie,
}
}
void AboutSigninInternals::OnErrorChanged() {
NotifyObservers();
}
void AboutSigninInternals::GetCookieAccountsAsync() {
// Don't bother calling /ListAccounts if no one will observe the response.
if (!gaia_fetcher_ && signin_observers_.might_have_observers()) {
......@@ -479,6 +491,7 @@ AboutSigninInternals::TokenInfo* AboutSigninInternals::SigninStatus::FindToken(
scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue(
AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager,
SigninErrorController* signin_error_controller,
const std::string& product_version) {
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
// fixed.
......@@ -524,6 +537,14 @@ scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue(
SigninStatusFieldToLabel(
static_cast<UntimedSigninStatusField>(USERNAME)),
signin_manager->GetAuthenticatedUsername());
if (signin_error_controller->HasError()) {
AddSectionEntry(basic_info, "Auth Error",
signin_error_controller->auth_error().ToString());
AddSectionEntry(basic_info, "Auth Error Username",
signin_error_controller->error_username());
} else {
AddSectionEntry(basic_info, "Auth Error", "None");
}
}
#if !defined(OS_CHROMEOS)
......
......@@ -14,6 +14,7 @@
#include "base/values.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/signin/core/browser/signin_client.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_internals_util.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
......@@ -35,7 +36,8 @@ class AboutSigninInternals
public signin_internals_util::SigninDiagnosticsObserver,
public OAuth2TokenService::DiagnosticsObserver,
public GaiaAuthConsumer,
SigninManagerBase::Observer {
SigninManagerBase::Observer,
SigninErrorController::Observer {
public:
class Observer {
public:
......@@ -49,7 +51,8 @@ class AboutSigninInternals
AboutSigninInternals(ProfileOAuth2TokenService* token_service,
AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager);
SigninManagerBase* signin_manager,
SigninErrorController* signin_error_controller);
~AboutSigninInternals() override;
// Each instance of SigninInternalsUI adds itself as an observer to be
......@@ -147,6 +150,7 @@ class AboutSigninInternals
scoped_ptr<base::DictionaryValue> ToValue(
AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager,
SigninErrorController* signin_error_controller,
const std::string& product_version);
};
......@@ -191,6 +195,9 @@ class AboutSigninInternals
// then we call ListAccounts and update the UI element.
void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed);
// SigninErrorController::Observer implementation
void OnErrorChanged() override;
// Weak pointer to the token service.
ProfileOAuth2TokenService* token_service_;
......@@ -203,6 +210,9 @@ class AboutSigninInternals
// Weak pointer to the client.
SigninClient* client_;
// Weak pointer to the SigninErrorController
SigninErrorController* signin_error_controller_;
// Fetcher for information about accounts in the cookie jar from GAIA.
scoped_ptr<GaiaAuthFetcher> gaia_fetcher_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment