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

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

Issue 334283002: New avatar button: Update when the supervised user ID changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/profiles/new_avatar_button.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/profiles/new_avatar_button.h" 5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 const base::string16& profile_name) { 144 const base::string16& profile_name) {
145 UpdateAvatarButtonAndRelayoutParent(); 145 UpdateAvatarButtonAndRelayoutParent();
146 } 146 }
147 147
148 void NewAvatarButton::OnProfileNameChanged( 148 void NewAvatarButton::OnProfileNameChanged(
149 const base::FilePath& profile_path, 149 const base::FilePath& profile_path,
150 const base::string16& old_profile_name) { 150 const base::string16& old_profile_name) {
151 UpdateAvatarButtonAndRelayoutParent(); 151 UpdateAvatarButtonAndRelayoutParent();
152 } 152 }
153 153
154 void NewAvatarButton::OnProfileSupervisedUserIdChanged(
155 const base::FilePath& profile_path) {
156 UpdateAvatarButtonAndRelayoutParent();
157 }
158
154 void NewAvatarButton::OnErrorChanged() { 159 void NewAvatarButton::OnErrorChanged() {
155 gfx::ImageSkia icon; 160 gfx::ImageSkia icon;
156 161
157 // If there is an error, show an warning icon. 162 // If there is an error, show an warning icon.
158 const SigninErrorController* error = 163 const SigninErrorController* error =
159 profiles::GetSigninErrorController(browser_->profile()); 164 profiles::GetSigninErrorController(browser_->profile());
160 if (error && error->HasError()) { 165 if (error && error->HasError()) {
161 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 166 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
162 icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia(); 167 icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia();
163 } 168 }
164 169
165 SetImage(views::Button::STATE_NORMAL, icon); 170 SetImage(views::Button::STATE_NORMAL, icon);
166 UpdateAvatarButtonAndRelayoutParent(); 171 UpdateAvatarButtonAndRelayoutParent();
167 } 172 }
168 173
169 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() { 174 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
170 // We want the button to resize if the new text is shorter. 175 // We want the button to resize if the new text is shorter.
171 SetText(GetButtonText(browser_->profile())); 176 SetText(GetButtonText(browser_->profile()));
172 set_min_size(gfx::Size()); 177 set_min_size(gfx::Size());
173 InvalidateLayout(); 178 InvalidateLayout();
174 179
175 // Because the width of the button might have changed, the parent browser 180 // Because the width of the button might have changed, the parent browser
176 // frame needs to recalculate the button bounds and redraw it. 181 // frame needs to recalculate the button bounds and redraw it.
177 if (parent()) 182 if (parent())
178 parent()->Layout(); 183 parent()->Layout();
179 } 184 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/new_avatar_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698