Commit 8023bc89 authored by rogerta@chromium.org's avatar rogerta@chromium.org

Make sure auth error reporting handles guest mode correctly.

BUG=376648

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273070 0039d316-1c4b-4281-b951-d872f2087c98
parent 1b6a1c23
...@@ -122,4 +122,10 @@ void UpdateGaiaProfilePhotoIfNeeded(Profile* profile) { ...@@ -122,4 +122,10 @@ void UpdateGaiaProfilePhotoIfNeeded(Profile* profile) {
GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update();
} }
SigninErrorController* GetSigninErrorController(Profile* profile) {
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
return token_service ? token_service->signin_error_controller() : NULL;
}
} // namespace profiles } // namespace profiles
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
class Browser; class Browser;
class PrefRegistrySimple; class PrefRegistrySimple;
class Profile; class Profile;
class SigninErrorController;
namespace base { class FilePath; } namespace base { class FilePath; }
namespace profiles { namespace profiles {
...@@ -52,6 +53,11 @@ bool IsRegularOrGuestSession(Browser* browser); ...@@ -52,6 +53,11 @@ bool IsRegularOrGuestSession(Browser* browser);
// version of the Gaia profile picture. // version of the Gaia profile picture.
void UpdateGaiaProfilePhotoIfNeeded(Profile* profile); void UpdateGaiaProfilePhotoIfNeeded(Profile* profile);
// Returns the sign-in error controller for the given profile. Some profiles,
// like guest profiles, may not have a controller so this function may return
// NULL.
SigninErrorController* GetSigninErrorController(Profile* profile);
} // namespace profiles } // namespace profiles
#endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_ #endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
...@@ -104,12 +104,14 @@ NewAvatarButton::NewAvatarButton( ...@@ -104,12 +104,14 @@ NewAvatarButton::NewAvatarButton(
g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
// Subscribe to authentication error changes so that the avatar button // Subscribe to authentication error changes so that the avatar button
// can update itself. // can update itself. Note that guest mode profiles won't have a token
// service.
SigninErrorController* error = SigninErrorController* error =
ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile())-> profiles::GetSigninErrorController(browser_->profile());
signin_error_controller(); if (error) {
error->AddObserver(this); error->AddObserver(this);
OnErrorChanged(); OnErrorChanged();
}
SchedulePaint(); SchedulePaint();
} }
...@@ -118,9 +120,9 @@ NewAvatarButton::~NewAvatarButton() { ...@@ -118,9 +120,9 @@ NewAvatarButton::~NewAvatarButton() {
g_browser_process->profile_manager()-> g_browser_process->profile_manager()->
GetProfileInfoCache().RemoveObserver(this); GetProfileInfoCache().RemoveObserver(this);
SigninErrorController* error = SigninErrorController* error =
ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile())-> profiles::GetSigninErrorController(browser_->profile());
signin_error_controller(); if (error)
error->RemoveObserver(this); error->RemoveObserver(this);
} }
void NewAvatarButton::OnPaintText(gfx::Canvas* canvas, PaintButtonMode mode) { void NewAvatarButton::OnPaintText(gfx::Canvas* canvas, PaintButtonMode mode) {
...@@ -159,10 +161,9 @@ void NewAvatarButton::OnErrorChanged() { ...@@ -159,10 +161,9 @@ void NewAvatarButton::OnErrorChanged() {
gfx::ImageSkia icon; gfx::ImageSkia icon;
// If there is an error, show an warning icon. // If there is an error, show an warning icon.
SigninErrorController* error = const SigninErrorController* error =
ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile())-> profiles::GetSigninErrorController(browser_->profile());
signin_error_controller(); if (error && error->HasError()) {
if (error->HasError()) {
ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia(); icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia();
} }
......
...@@ -101,16 +101,14 @@ gfx::ImageSkia CreateSquarePlaceholderImage(int size) { ...@@ -101,16 +101,14 @@ gfx::ImageSkia CreateSquarePlaceholderImage(int size) {
} }
bool HasAuthError(Profile* profile) { bool HasAuthError(Profile* profile) {
SigninErrorController* error = const SigninErrorController* error =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> profiles::GetSigninErrorController(profile);
signin_error_controller();
return error && error->HasError(); return error && error->HasError();
} }
std::string GetAuthErrorAccountId(Profile* profile) { std::string GetAuthErrorAccountId(Profile* profile) {
SigninErrorController* error = const SigninErrorController* error =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> profiles::GetSigninErrorController(profile);
signin_error_controller();
if (!error) if (!error)
return std::string(); return std::string();
...@@ -118,9 +116,8 @@ std::string GetAuthErrorAccountId(Profile* profile) { ...@@ -118,9 +116,8 @@ std::string GetAuthErrorAccountId(Profile* profile) {
} }
std::string GetAuthErrorUsername(Profile* profile) { std::string GetAuthErrorUsername(Profile* profile) {
SigninErrorController* error = const SigninErrorController* error =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> profiles::GetSigninErrorController(profile);
signin_error_controller();
if (!error) if (!error)
return std::string(); return std::string();
......
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