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

Unified Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

Issue 297853006: Make sure auth error reporting handles guest mode correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/profiles/new_avatar_button.cc
diff --git a/chrome/browser/ui/views/profiles/new_avatar_button.cc b/chrome/browser/ui/views/profiles/new_avatar_button.cc
index ec28c46d12f6bfd6ecc1366fa9ca58afb44a29c7..81f1b6e2367d1051a484c4c0e099212e3cb94686 100644
--- a/chrome/browser/ui/views/profiles/new_avatar_button.cc
+++ b/chrome/browser/ui/views/profiles/new_avatar_button.cc
@@ -56,6 +56,12 @@ base::string16 GetElidedText(const base::string16& original_text) {
gfx::ELIDE_AT_END);
}
+SigninErrorController* GetSigninErrorController(Browser* browser) {
noms (inactive) 2014/05/23 16:59:57 Maybe this should go in profiles_state.h, given th
Roger Tawa OOO till Jul 10th 2014/05/23 20:54:37 Done.
+ ProfileOAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(browser->profile());
+ return token_service ? token_service->signin_error_controller() : NULL;
+}
+
} // namespace
NewAvatarButton::NewAvatarButton(
@@ -104,12 +110,13 @@ NewAvatarButton::NewAvatarButton(
g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
// Subscribe to authentication error changes so that the avatar button
- // can update itself.
- SigninErrorController* error =
- ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile())->
- signin_error_controller();
- error->AddObserver(this);
- OnErrorChanged();
+ // can update itself. Note that guest mode profiles won't have a token
+ // service.
+ SigninErrorController* error = GetSigninErrorController(browser_);
+ if (error) {
+ error->AddObserver(this);
+ OnErrorChanged();
+ }
SchedulePaint();
}
@@ -117,10 +124,9 @@ NewAvatarButton::NewAvatarButton(
NewAvatarButton::~NewAvatarButton() {
g_browser_process->profile_manager()->
GetProfileInfoCache().RemoveObserver(this);
- SigninErrorController* error =
- ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile())->
- signin_error_controller();
- error->RemoveObserver(this);
+ SigninErrorController* error = GetSigninErrorController(browser_);
+ if (error)
+ error->RemoveObserver(this);
}
void NewAvatarButton::OnPaintText(gfx::Canvas* canvas, PaintButtonMode mode) {
@@ -159,10 +165,8 @@ void NewAvatarButton::OnErrorChanged() {
gfx::ImageSkia icon;
// If there is an error, show an warning icon.
- SigninErrorController* error =
- ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile())->
- signin_error_controller();
- if (error->HasError()) {
+ const SigninErrorController* error = GetSigninErrorController(browser_);
+ if (error && error->HasError()) {
ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia();
}
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698