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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view.cc

Issue 1004803002: [Win] Cleanup: The BrowserFrameView doesn't need to listen to profile name changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/frame/browser_non_client_frame_view.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/avatar_menu.h" 8 #include "chrome/browser/profiles/avatar_menu.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 views::View* BrowserNonClientFrameView::GetLocationIconView() const { 64 views::View* BrowserNonClientFrameView::GetLocationIconView() const {
65 return nullptr; 65 return nullptr;
66 } 66 }
67 67
68 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, 68 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from,
69 bool is_visible) { 69 bool is_visible) {
70 if (!is_visible) 70 if (!is_visible)
71 return; 71 return;
72 72
73 // The first time UpdateAvatarInfo() is called the window is not visible so 73 // The first time UpdateOldAvatarButton() is called the window is not visible
74 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again 74 // so DrawTaskBarDecoration() has no effect. Therefore we need to call it
75 // once the window is visible. 75 // again once the window is visible.
76 if (!browser_view_->IsRegularOrGuestSession() || 76 if (!browser_view_->IsRegularOrGuestSession() ||
77 !switches::IsNewAvatarMenu()) { 77 !switches::IsNewAvatarMenu()) {
78 UpdateAvatarInfo(); 78 UpdateOldAvatarButton();
79 } 79 }
80 80
81 // Make sure the task bar icon is correctly updated call 81 // Make sure the task bar icon is correctly updated call
82 // |OnProfileAvatarChanged()| in this case, but only for non guest profiles. 82 // |OnProfileAvatarChanged()| in this case, but only for non guest profiles.
83 if (!browser_view_->IsGuestSession() || !switches::IsNewAvatarMenu()) 83 if (!browser_view_->IsGuestSession() || !switches::IsNewAvatarMenu())
84 OnProfileAvatarChanged(base::FilePath()); 84 OnProfileAvatarChanged(base::FilePath());
85 } 85 }
86 86
87 void BrowserNonClientFrameView::ChildPreferredSizeChanged(View* child) { 87 void BrowserNonClientFrameView::ChildPreferredSizeChanged(View* child) {
88 // Only perform a re-layout if the avatar button has changed, since that 88 // Only perform a re-layout if the avatar button has changed, since that
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 int top_area_height = frame_image->height(); 168 int top_area_height = frame_image->height();
169 if (browser_view_->IsTabStripVisible()) { 169 if (browser_view_->IsTabStripVisible()) {
170 top_area_height = std::max(top_area_height, 170 top_area_height = std::max(top_area_height,
171 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); 171 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom());
172 } 172 }
173 return top_area_height; 173 return top_area_height;
174 } 174 }
175 175
176 void BrowserNonClientFrameView::UpdateAvatar() { 176 void BrowserNonClientFrameView::UpdateAvatar() {
177 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) 177 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
178 UpdateNewStyleAvatar(); 178 UpdateNewAvatarButtonImpl();
179 else 179 else
180 UpdateAvatarInfo(); 180 UpdateOldAvatarButton();
181 } 181 }
182 182
183 void BrowserNonClientFrameView::UpdateAvatarInfo() { 183 void BrowserNonClientFrameView::UpdateOldAvatarButton() {
184 if (browser_view_->ShouldShowAvatar()) { 184 if (browser_view_->ShouldShowAvatar()) {
185 if (!avatar_button_) { 185 if (!avatar_button_) {
186 #if defined(ENABLE_SUPERVISED_USERS) 186 #if defined(ENABLE_SUPERVISED_USERS)
187 Profile* profile = browser_view_->browser()->profile(); 187 Profile* profile = browser_view_->browser()->profile();
188 if (profile->IsSupervised() && !supervised_user_avatar_label_) { 188 if (profile->IsSupervised() && !supervised_user_avatar_label_) {
189 supervised_user_avatar_label_ = 189 supervised_user_avatar_label_ =
190 new SupervisedUserAvatarLabel(browser_view_); 190 new SupervisedUserAvatarLabel(browser_view_);
191 supervised_user_avatar_label_->set_id( 191 supervised_user_avatar_label_->set_id(
192 VIEW_ID_SUPERVISED_USER_AVATAR_LABEL); 192 VIEW_ID_SUPERVISED_USER_AVATAR_LABEL);
193 AddChildView(supervised_user_avatar_label_); 193 AddChildView(supervised_user_avatar_label_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return; 230 return;
231 } 231 }
232 232
233 // Disable the menu when we should not show the menu. 233 // Disable the menu when we should not show the menu.
234 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu()) 234 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu())
235 avatar_button_->SetEnabled(false); 235 avatar_button_->SetEnabled(false);
236 if (avatar_button_) 236 if (avatar_button_)
237 avatar_button_->SetAvatarIcon(avatar, is_rectangle); 237 avatar_button_->SetAvatarIcon(avatar, is_rectangle);
238 } 238 }
239 239
240 void BrowserNonClientFrameView::UpdateNewStyleAvatarInfo( 240 void BrowserNonClientFrameView::UpdateNewAvatarButton(
241 views::ButtonListener* listener, 241 views::ButtonListener* listener,
242 const NewAvatarButton::AvatarButtonStyle style) { 242 const NewAvatarButton::AvatarButtonStyle style) {
243 DCHECK(switches::IsNewAvatarMenu()); 243 DCHECK(switches::IsNewAvatarMenu());
244 // This should never be called in incognito mode. 244 // This should never be called in incognito mode.
245 DCHECK(browser_view_->IsRegularOrGuestSession()); 245 DCHECK(browser_view_->IsRegularOrGuestSession());
246 246
247 if (browser_view_->ShouldShowAvatar()) { 247 if (browser_view_->ShouldShowAvatar()) {
248 if (!new_avatar_button_) { 248 if (!new_avatar_button_) {
249 new_avatar_button_ = 249 new_avatar_button_ =
250 new NewAvatarButton(listener, style, browser_view_->browser()); 250 new NewAvatarButton(listener, style, browser_view_->browser());
(...skipping 19 matching lines...) Expand all
270 const base::string16& profile_name) { 270 const base::string16& profile_name) {
271 UpdateTaskbarDecoration(); 271 UpdateTaskbarDecoration();
272 UpdateAvatar(); 272 UpdateAvatar();
273 } 273 }
274 274
275 void BrowserNonClientFrameView::OnProfileAvatarChanged( 275 void BrowserNonClientFrameView::OnProfileAvatarChanged(
276 const base::FilePath& profile_path) { 276 const base::FilePath& profile_path) {
277 UpdateTaskbarDecoration(); 277 UpdateTaskbarDecoration();
278 // Profile avatars are only displayed in the old UI or incognito. 278 // Profile avatars are only displayed in the old UI or incognito.
279 if (browser_view()->IsOffTheRecord() || !switches::IsNewAvatarMenu()) 279 if (browser_view()->IsOffTheRecord() || !switches::IsNewAvatarMenu())
280 UpdateAvatarInfo(); 280 UpdateOldAvatarButton();
281 }
282
283 void BrowserNonClientFrameView::OnProfileNameChanged(
284 const base::FilePath& profile_path,
285 const base::string16& old_profile_name) {
286 UpdateAvatar();
287 } 281 }
288 282
289 void BrowserNonClientFrameView::UpdateTaskbarDecoration() { 283 void BrowserNonClientFrameView::UpdateTaskbarDecoration() {
290 gfx::Image avatar; 284 gfx::Image avatar;
291 gfx::Image taskbar_badge_avatar; 285 gfx::Image taskbar_badge_avatar;
292 bool is_rectangle; 286 bool is_rectangle;
293 // Only need to update the taskbar overlay here. If GetAvatarImages() 287 // Only need to update the taskbar overlay here. If GetAvatarImages()
294 // returns false, don't bother trying to update the taskbar decoration since 288 // returns false, don't bother trying to update the taskbar decoration since
295 // the returned images are not initialized. This can happen if the user 289 // the returned images are not initialized. This can happen if the user
296 // deletes the current profile. 290 // deletes the current profile.
(...skipping 17 matching lines...) Expand all
314 const ProfileInfoCache& cache = 308 const ProfileInfoCache& cache =
315 g_browser_process->profile_manager()->GetProfileInfoCache(); 309 g_browser_process->profile_manager()->GetProfileInfoCache();
316 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; 310 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1;
317 } 311 }
318 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), 312 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(),
319 show_decoration 313 show_decoration
320 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) 314 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar)
321 : nullptr); 315 : nullptr);
322 } 316 }
323 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698