OLD | NEW |
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/win/windows_version.h" | 7 #include "base/win/windows_version.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/profiles/profiles_state.h" | 10 #include "chrome/browser/profiles/profiles_state.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 void NewAvatarButton::Update() { | 170 void NewAvatarButton::Update() { |
171 const ProfileInfoCache& cache = | 171 const ProfileInfoCache& cache = |
172 g_browser_process->profile_manager()->GetProfileInfoCache(); | 172 g_browser_process->profile_manager()->GetProfileInfoCache(); |
173 | 173 |
174 // If we have a single local profile, then use the generic avatar | 174 // If we have a single local profile, then use the generic avatar |
175 // button instead of the profile name. Never use the generic button if | 175 // button instead of the profile name. Never use the generic button if |
176 // the active profile is Guest. | 176 // the active profile is Guest. |
177 bool use_generic_button = (!browser_->profile()->IsGuestSession() && | 177 bool use_generic_button = (!browser_->profile()->IsGuestSession() && |
178 cache.GetNumberOfProfiles() == 1 && | 178 cache.GetNumberOfProfiles() == 1 && |
179 cache.GetUserNameOfProfileAtIndex(0).empty()); | 179 !cache.ProfileIsAuthenticatedAtIndex(0)); |
180 | 180 |
181 SetText(use_generic_button ? base::string16() : | 181 SetText(use_generic_button ? base::string16() : |
182 profiles::GetAvatarButtonTextForProfile(browser_->profile())); | 182 profiles::GetAvatarButtonTextForProfile(browser_->profile())); |
183 | 183 |
184 // If the button has no text, clear the text shadows to make sure the | 184 // If the button has no text, clear the text shadows to make sure the |
185 // image is centered correctly. | 185 // image is centered correctly. |
186 SetTextShadows( | 186 SetTextShadows( |
187 use_generic_button | 187 use_generic_button |
188 ? gfx::ShadowValues() | 188 ? gfx::ShadowValues() |
189 : gfx::ShadowValues( | 189 : gfx::ShadowValues( |
(...skipping 12 matching lines...) Expand all Loading... |
202 SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia()); | 202 SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia()); |
203 } | 203 } |
204 | 204 |
205 // If we are not using the generic button, then reset the spacing between | 205 // If we are not using the generic button, then reset the spacing between |
206 // the text and the possible authentication error icon. | 206 // the text and the possible authentication error icon. |
207 const int kDefaultImageTextSpacing = 5; | 207 const int kDefaultImageTextSpacing = 5; |
208 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); | 208 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); |
209 | 209 |
210 PreferredSizeChanged(); | 210 PreferredSizeChanged(); |
211 } | 211 } |
OLD | NEW |