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

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

Issue 1614523002: Remove old-avatar supervised user labels on non-Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/avatar_menu.h" 9 #include "chrome/browser/profiles/avatar_menu.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 12 matching lines...) Expand all
23 #include "components/signin/core/common/profile_management_switches.h" 23 #include "components/signin/core/common/profile_management_switches.h"
24 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
25 #include "third_party/skia/include/core/SkColor.h" 25 #include "third_party/skia/include/core/SkColor.h"
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/base/theme_provider.h" 27 #include "ui/base/theme_provider.h"
28 #include "ui/gfx/image/image.h" 28 #include "ui/gfx/image/image.h"
29 #include "ui/resources/grit/ui_resources.h" 29 #include "ui/resources/grit/ui_resources.h"
30 #include "ui/views/background.h" 30 #include "ui/views/background.h"
31 #include "ui/views/resources/grit/views_resources.h" 31 #include "ui/views/resources/grit/views_resources.h"
32 32
33 #if defined(ENABLE_SUPERVISED_USERS)
34 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
35 #endif
36
37 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, 33 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame,
38 BrowserView* browser_view) 34 BrowserView* browser_view)
39 : frame_(frame), 35 : frame_(frame),
40 browser_view_(browser_view), 36 browser_view_(browser_view),
41 #if defined(ENABLE_SUPERVISED_USERS)
42 supervised_user_avatar_label_(nullptr),
43 #endif
44 #if defined(FRAME_AVATAR_BUTTON) 37 #if defined(FRAME_AVATAR_BUTTON)
45 new_avatar_button_(nullptr), 38 new_avatar_button_(nullptr),
46 #endif 39 #endif
47 avatar_button_(nullptr) { 40 avatar_button_(nullptr) {
48 // The profile manager may by null in tests. 41 // The profile manager may by null in tests.
49 if (g_browser_process->profile_manager()) { 42 if (g_browser_process->profile_manager()) {
50 ProfileInfoCache& cache = 43 ProfileInfoCache& cache =
51 g_browser_process->profile_manager()->GetProfileInfoCache(); 44 g_browser_process->profile_manager()->GetProfileInfoCache();
52 cache.AddObserver(this); 45 cache.AddObserver(this);
53 } 46 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #if defined(FRAME_AVATAR_BUTTON) 95 #if defined(FRAME_AVATAR_BUTTON)
103 // Only perform a re-layout if the avatar button has changed, since that 96 // Only perform a re-layout if the avatar button has changed, since that
104 // can affect the size of the tabs. 97 // can affect the size of the tabs.
105 if (child == new_avatar_button_) { 98 if (child == new_avatar_button_) {
106 InvalidateLayout(); 99 InvalidateLayout();
107 frame_->GetRootView()->Layout(); 100 frame_->GetRootView()->Layout();
108 } 101 }
109 #endif 102 #endif
110 } 103 }
111 104
112 #if defined(ENABLE_SUPERVISED_USERS)
113 void BrowserNonClientFrameView::OnThemeChanged() {
114 if (supervised_user_avatar_label_)
115 supervised_user_avatar_label_->UpdateLabelStyle();
116 }
117 #endif
118
119 bool BrowserNonClientFrameView::ShouldPaintAsThemed() const { 105 bool BrowserNonClientFrameView::ShouldPaintAsThemed() const {
120 return browser_view_->IsBrowserTypeNormal(); 106 return browser_view_->IsBrowserTypeNormal();
121 } 107 }
122 108
123 SkColor BrowserNonClientFrameView::GetFrameColor() const { 109 SkColor BrowserNonClientFrameView::GetFrameColor() const {
124 ThemeProperties::OverwritableByUserThemeProperty color_id = 110 ThemeProperties::OverwritableByUserThemeProperty color_id =
125 ShouldPaintAsActive() ? ThemeProperties::COLOR_FRAME 111 ShouldPaintAsActive() ? ThemeProperties::COLOR_FRAME
126 : ThemeProperties::COLOR_FRAME_INACTIVE; 112 : ThemeProperties::COLOR_FRAME_INACTIVE;
127 return ShouldPaintAsThemed() ? GetThemeProvider()->GetColor(color_id) 113 return ShouldPaintAsThemed() ? GetThemeProvider()->GetColor(color_id)
128 : ThemeProperties::GetDefaultColor( 114 : ThemeProperties::GetDefaultColor(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (browser_view()->IsRegularOrGuestSession()) 175 if (browser_view()->IsRegularOrGuestSession())
190 UpdateNewAvatarButtonImpl(); 176 UpdateNewAvatarButtonImpl();
191 else 177 else
192 #endif 178 #endif
193 UpdateOldAvatarButton(); 179 UpdateOldAvatarButton();
194 } 180 }
195 181
196 void BrowserNonClientFrameView::UpdateOldAvatarButton() { 182 void BrowserNonClientFrameView::UpdateOldAvatarButton() {
197 if (browser_view_->ShouldShowAvatar()) { 183 if (browser_view_->ShouldShowAvatar()) {
198 if (!avatar_button_) { 184 if (!avatar_button_) {
199 #if defined(ENABLE_SUPERVISED_USERS)
200 Profile* profile = browser_view_->browser()->profile();
201 if (profile->IsSupervised() && !supervised_user_avatar_label_) {
202 supervised_user_avatar_label_ =
203 new SupervisedUserAvatarLabel(browser_view_);
204 supervised_user_avatar_label_->set_id(
205 VIEW_ID_SUPERVISED_USER_AVATAR_LABEL);
206 AddChildView(supervised_user_avatar_label_);
207 }
208 #endif
209 avatar_button_ = new AvatarMenuButton(browser_view_); 185 avatar_button_ = new AvatarMenuButton(browser_view_);
210 avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON); 186 avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON);
211 AddChildView(avatar_button_); 187 AddChildView(avatar_button_);
212 // Invalidate here because adding a child does not invalidate the layout. 188 // Invalidate here because adding a child does not invalidate the layout.
213 InvalidateLayout(); 189 InvalidateLayout();
214 frame_->GetRootView()->Layout(); 190 frame_->GetRootView()->Layout();
215 } 191 }
216 } else if (avatar_button_) { 192 } else if (avatar_button_) {
217 #if defined(ENABLE_SUPERVISED_USERS)
218 // The avatar label can just be there if there is also an avatar button.
219 if (supervised_user_avatar_label_) {
220 RemoveChildView(supervised_user_avatar_label_);
221 delete supervised_user_avatar_label_;
222 supervised_user_avatar_label_ = nullptr;
223 }
224 #endif
225 RemoveChildView(avatar_button_); 193 RemoveChildView(avatar_button_);
226 delete avatar_button_; 194 delete avatar_button_;
227 avatar_button_ = nullptr; 195 avatar_button_ = nullptr;
228 frame_->GetRootView()->Layout(); 196 frame_->GetRootView()->Layout();
229 } 197 }
230 198
231 gfx::Image avatar; 199 gfx::Image avatar;
232 gfx::Image taskbar_badge_avatar; 200 gfx::Image taskbar_badge_avatar;
233 bool is_rectangle = false; 201 bool is_rectangle = false;
234 202
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const ProfileInfoCache& cache = 291 const ProfileInfoCache& cache =
324 g_browser_process->profile_manager()->GetProfileInfoCache(); 292 g_browser_process->profile_manager()->GetProfileInfoCache();
325 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; 293 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1;
326 } 294 }
327 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), 295 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(),
328 show_decoration 296 show_decoration
329 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) 297 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar)
330 : nullptr); 298 : nullptr);
331 } 299 }
332 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698