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

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

Issue 1307093004: Remove references to IsNewAvatarMenu since the flag was removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback Created 5 years, 2 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 views::View* BrowserNonClientFrameView::GetLocationIconView() const { 67 views::View* BrowserNonClientFrameView::GetLocationIconView() const {
68 return nullptr; 68 return nullptr;
69 } 69 }
70 70
71 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, 71 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from,
72 bool is_visible) { 72 bool is_visible) {
73 if (!is_visible) 73 if (!is_visible)
74 return; 74 return;
75 75
76 #if defined(OS_CHROMEOS)
77 // On ChromeOS we always need to give the old avatar button a chance to update
78 // in case we're in a teleported window. On desktop, the old avatar button
79 // only shows up when in incognito mode.
80 UpdateOldAvatarButton();
81 OnProfileAvatarChanged(base::FilePath());
82 #else
76 // The first time UpdateOldAvatarButton() is called the window is not visible 83 // The first time UpdateOldAvatarButton() is called the window is not visible
77 // so DrawTaskBarDecoration() has no effect. Therefore we need to call it 84 // so DrawTaskBarDecoration() has no effect. Therefore we need to call it
78 // again once the window is visible. 85 // again once the window is visible.
79 if (!browser_view_->IsRegularOrGuestSession() || 86 if (!browser_view_->IsRegularOrGuestSession()) {
80 !switches::IsNewAvatarMenu()) {
81 UpdateOldAvatarButton(); 87 UpdateOldAvatarButton();
82 } 88 }
83 89
84 // Make sure the task bar icon is correctly updated call 90 // Call |OnProfileAvatarChanged()| in this case to make sure the task bar icon
Peter Kasting 2015/09/29 20:34:16 Nit: No || on function names
anthonyvd 2015/09/30 18:34:03 Done.
85 // |OnProfileAvatarChanged()| in this case, but only for non guest profiles. 91 // is correctly updated, but only for non guest profiles.
Peter Kasting 2015/09/29 20:34:16 Nit: Is this because guest profiles don't badge th
anthonyvd 2015/09/30 18:34:03 Done.
86 if (!browser_view_->IsGuestSession() || !switches::IsNewAvatarMenu()) 92 if (!browser_view_->IsGuestSession())
87 OnProfileAvatarChanged(base::FilePath()); 93 OnProfileAvatarChanged(base::FilePath());
94 #endif
88 } 95 }
89 96
90 void BrowserNonClientFrameView::ChildPreferredSizeChanged(View* child) { 97 void BrowserNonClientFrameView::ChildPreferredSizeChanged(View* child) {
91 #if defined(FRAME_AVATAR_BUTTON) 98 #if defined(FRAME_AVATAR_BUTTON)
92 // Only perform a re-layout if the avatar button has changed, since that 99 // Only perform a re-layout if the avatar button has changed, since that
93 // can affect the size of the tabs. 100 // can affect the size of the tabs.
94 if (child == new_avatar_button_) { 101 if (child == new_avatar_button_) {
95 InvalidateLayout(); 102 InvalidateLayout();
96 frame_->GetRootView()->Layout(); 103 frame_->GetRootView()->Layout();
97 } 104 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 gfx::ImageSkia* frame_image = GetFrameImage(); 179 gfx::ImageSkia* frame_image = GetFrameImage();
173 int top_area_height = frame_image->height(); 180 int top_area_height = frame_image->height();
174 if (browser_view_->IsTabStripVisible()) { 181 if (browser_view_->IsTabStripVisible()) {
175 top_area_height = std::max(top_area_height, 182 top_area_height = std::max(top_area_height,
176 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); 183 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom());
177 } 184 }
178 return top_area_height; 185 return top_area_height;
179 } 186 }
180 187
181 void BrowserNonClientFrameView::UpdateAvatar() { 188 void BrowserNonClientFrameView::UpdateAvatar() {
182 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) 189 #if !defined(OS_CHROMEOS)
190 if (browser_view()->IsRegularOrGuestSession())
183 UpdateNewAvatarButtonImpl(); 191 UpdateNewAvatarButtonImpl();
184 else 192 else
193 #endif
185 UpdateOldAvatarButton(); 194 UpdateOldAvatarButton();
186 } 195 }
187 196
188 void BrowserNonClientFrameView::UpdateOldAvatarButton() { 197 void BrowserNonClientFrameView::UpdateOldAvatarButton() {
189 if (browser_view_->ShouldShowAvatar()) { 198 if (browser_view_->ShouldShowAvatar()) {
190 if (!avatar_button_) { 199 if (!avatar_button_) {
191 #if defined(ENABLE_SUPERVISED_USERS) 200 #if defined(ENABLE_SUPERVISED_USERS)
192 Profile* profile = browser_view_->browser()->profile(); 201 Profile* profile = browser_view_->browser()->profile();
193 if (profile->IsSupervised() && !supervised_user_avatar_label_) { 202 if (profile->IsSupervised() && !supervised_user_avatar_label_) {
194 supervised_user_avatar_label_ = 203 supervised_user_avatar_label_ =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu()) 248 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu())
240 avatar_button_->SetEnabled(false); 249 avatar_button_->SetEnabled(false);
241 if (avatar_button_) 250 if (avatar_button_)
242 avatar_button_->SetAvatarIcon(avatar, is_rectangle); 251 avatar_button_->SetAvatarIcon(avatar, is_rectangle);
243 } 252 }
244 253
245 #if defined(FRAME_AVATAR_BUTTON) 254 #if defined(FRAME_AVATAR_BUTTON)
246 void BrowserNonClientFrameView::UpdateNewAvatarButton( 255 void BrowserNonClientFrameView::UpdateNewAvatarButton(
247 views::ButtonListener* listener, 256 views::ButtonListener* listener,
248 const NewAvatarButton::AvatarButtonStyle style) { 257 const NewAvatarButton::AvatarButtonStyle style) {
249 DCHECK(switches::IsNewAvatarMenu());
250 // This should never be called in incognito mode. 258 // This should never be called in incognito mode.
251 DCHECK(browser_view_->IsRegularOrGuestSession()); 259 DCHECK(browser_view_->IsRegularOrGuestSession());
252 260
253 if (browser_view_->ShouldShowAvatar()) { 261 if (browser_view_->ShouldShowAvatar()) {
254 if (!new_avatar_button_) { 262 if (!new_avatar_button_) {
255 new_avatar_button_ = 263 new_avatar_button_ =
256 new NewAvatarButton(listener, style, browser_view_->browser()); 264 new NewAvatarButton(listener, style, browser_view_->browser());
257 new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON); 265 new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON);
258 AddChildView(new_avatar_button_); 266 AddChildView(new_avatar_button_);
259 frame_->GetRootView()->Layout(); 267 frame_->GetRootView()->Layout();
(...skipping 15 matching lines...) Expand all
275 void BrowserNonClientFrameView::OnProfileWasRemoved( 283 void BrowserNonClientFrameView::OnProfileWasRemoved(
276 const base::FilePath& profile_path, 284 const base::FilePath& profile_path,
277 const base::string16& profile_name) { 285 const base::string16& profile_name) {
278 UpdateTaskbarDecoration(); 286 UpdateTaskbarDecoration();
279 UpdateAvatar(); 287 UpdateAvatar();
280 } 288 }
281 289
282 void BrowserNonClientFrameView::OnProfileAvatarChanged( 290 void BrowserNonClientFrameView::OnProfileAvatarChanged(
283 const base::FilePath& profile_path) { 291 const base::FilePath& profile_path) {
284 UpdateTaskbarDecoration(); 292 UpdateTaskbarDecoration();
285 // Profile avatars are only displayed in the old UI or incognito. 293 // Profile avatars are only displayed in incognito or on ChromeOS teleported
286 if ((!browser_view()->IsGuestSession() && browser_view()->IsOffTheRecord()) || 294 // windows.
287 !switches::IsNewAvatarMenu()) { 295 #if !defined(OS_CHROMEOS)
296 if (!browser_view()->IsGuestSession() && browser_view()->IsOffTheRecord())
297 #endif
288 UpdateOldAvatarButton(); 298 UpdateOldAvatarButton();
289 }
290 } 299 }
291 300
292 void BrowserNonClientFrameView::UpdateTaskbarDecoration() { 301 void BrowserNonClientFrameView::UpdateTaskbarDecoration() {
293 gfx::Image avatar; 302 gfx::Image avatar;
294 gfx::Image taskbar_badge_avatar; 303 gfx::Image taskbar_badge_avatar;
295 bool is_rectangle; 304 bool is_rectangle;
296 // Only need to update the taskbar overlay here. If GetAvatarImages() 305 // Only need to update the taskbar overlay here. If GetAvatarImages()
297 // returns false, don't bother trying to update the taskbar decoration since 306 // returns false, don't bother trying to update the taskbar decoration since
298 // the returned images are not initialized. This can happen if the user 307 // the returned images are not initialized. This can happen if the user
299 // deletes the current profile. 308 // deletes the current profile.
(...skipping 17 matching lines...) Expand all
317 const ProfileInfoCache& cache = 326 const ProfileInfoCache& cache =
318 g_browser_process->profile_manager()->GetProfileInfoCache(); 327 g_browser_process->profile_manager()->GetProfileInfoCache();
319 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; 328 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1;
320 } 329 }
321 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), 330 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(),
322 show_decoration 331 show_decoration
323 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) 332 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar)
324 : nullptr); 333 : nullptr);
325 } 334 }
326 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698