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

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

Issue 355233002: Fix build when ENABLE_MANAGED_USERS is not defined (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More bauerb comments Created 6 years, 5 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"
11 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/profiles/profiles_state.h" 13 #include "chrome/browser/profiles/profiles_state.h"
14 #include "chrome/browser/ui/view_ids.h" 14 #include "chrome/browser/ui/view_ids.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 15 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" 16 #include "chrome/browser/ui/views/frame/taskbar_decorator.h"
17 #include "chrome/browser/ui/views/profiles/avatar_label.h"
18 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 17 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
19 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 18 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
20 #include "components/signin/core/common/profile_management_switches.h" 19 #include "components/signin/core/common/profile_management_switches.h"
21 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
23 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
24 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/base/theme_provider.h" 25 #include "ui/base/theme_provider.h"
27 #include "ui/gfx/image/image.h" 26 #include "ui/gfx/image/image.h"
28 #include "ui/views/background.h" 27 #include "ui/views/background.h"
29 28
29 #if defined(ENABLE_MANAGED_USERS)
30 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
31 #endif
32
30 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, 33 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame,
31 BrowserView* browser_view) 34 BrowserView* browser_view)
32 : frame_(frame), 35 : frame_(frame),
33 browser_view_(browser_view), 36 browser_view_(browser_view),
34 avatar_button_(NULL), 37 avatar_button_(NULL),
35 avatar_label_(NULL), 38 #if defined(ENABLE_MANAGED_USERS)
39 supervised_user_avatar_label_(NULL),
40 #endif
36 new_avatar_button_(NULL) { 41 new_avatar_button_(NULL) {
37 } 42 }
38 43
39 BrowserNonClientFrameView::~BrowserNonClientFrameView() { 44 BrowserNonClientFrameView::~BrowserNonClientFrameView() {
40 } 45 }
41 46
42 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, 47 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from,
43 bool is_visible) { 48 bool is_visible) {
44 if (!is_visible) 49 if (!is_visible)
45 return; 50 return;
46 // The first time UpdateAvatarInfo() is called the window is not visible so 51 // The first time UpdateAvatarInfo() is called the window is not visible so
47 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again 52 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again
48 // once the window is visible. 53 // once the window is visible.
49 if (!browser_view_->IsRegularOrGuestSession() || 54 if (!browser_view_->IsRegularOrGuestSession() ||
50 !switches::IsNewProfileManagement()) 55 !switches::IsNewProfileManagement())
51 UpdateAvatarInfo(); 56 UpdateAvatarInfo();
52 } 57 }
53 58
59 #if defined(ENABLE_MANAGED_USERS)
54 void BrowserNonClientFrameView::OnThemeChanged() { 60 void BrowserNonClientFrameView::OnThemeChanged() {
55 if (avatar_label_) 61 if (supervised_user_avatar_label_)
56 avatar_label_->UpdateLabelStyle(); 62 supervised_user_avatar_label_->UpdateLabelStyle();
57 } 63 }
64 #endif
58 65
59 void BrowserNonClientFrameView::UpdateAvatarInfo() { 66 void BrowserNonClientFrameView::UpdateAvatarInfo() {
60 if (browser_view_->ShouldShowAvatar()) { 67 if (browser_view_->ShouldShowAvatar()) {
61 if (!avatar_button_) { 68 if (!avatar_button_) {
69 #if defined(ENABLE_MANAGED_USERS)
62 Profile* profile = browser_view_->browser()->profile(); 70 Profile* profile = browser_view_->browser()->profile();
63 if (profile->IsSupervised() && !avatar_label_) { 71 if (profile->IsSupervised() && !supervised_user_avatar_label_) {
64 avatar_label_ = new AvatarLabel(browser_view_); 72 supervised_user_avatar_label_ =
65 avatar_label_->set_id(VIEW_ID_AVATAR_LABEL); 73 new SupervisedUserAvatarLabel(browser_view_);
66 AddChildView(avatar_label_); 74 supervised_user_avatar_label_->set_id(
75 VIEW_ID_SUPERVISED_USER_AVATAR_LABEL);
76 AddChildView(supervised_user_avatar_label_);
67 } 77 }
78 #endif
68 avatar_button_ = new AvatarMenuButton( 79 avatar_button_ = new AvatarMenuButton(
69 browser_view_->browser(), !browser_view_->IsRegularOrGuestSession()); 80 browser_view_->browser(), !browser_view_->IsRegularOrGuestSession());
70 avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON); 81 avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON);
71 AddChildView(avatar_button_); 82 AddChildView(avatar_button_);
72 // Invalidate here because adding a child does not invalidate the layout. 83 // Invalidate here because adding a child does not invalidate the layout.
73 InvalidateLayout(); 84 InvalidateLayout();
74 frame_->GetRootView()->Layout(); 85 frame_->GetRootView()->Layout();
75 } 86 }
76 } else if (avatar_button_) { 87 } else if (avatar_button_) {
88 #if defined(ENABLE_MANAGED_USERS)
77 // The avatar label can just be there if there is also an avatar button. 89 // The avatar label can just be there if there is also an avatar button.
78 if (avatar_label_) { 90 if (supervised_user_avatar_label_) {
79 RemoveChildView(avatar_label_); 91 RemoveChildView(supervised_user_avatar_label_);
80 delete avatar_label_; 92 delete supervised_user_avatar_label_;
81 avatar_label_ = NULL; 93 supervised_user_avatar_label_ = NULL;
82 } 94 }
95 #endif
83 RemoveChildView(avatar_button_); 96 RemoveChildView(avatar_button_);
84 delete avatar_button_; 97 delete avatar_button_;
85 avatar_button_ = NULL; 98 avatar_button_ = NULL;
86 frame_->GetRootView()->Layout(); 99 frame_->GetRootView()->Layout();
87 } 100 }
88 101
89 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 102 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
90 gfx::Image avatar; 103 gfx::Image avatar;
91 gfx::Image taskbar_badge_avatar; 104 gfx::Image taskbar_badge_avatar;
92 base::string16 text; 105 base::string16 text;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON); 168 new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON);
156 AddChildView(new_avatar_button_); 169 AddChildView(new_avatar_button_);
157 frame_->GetRootView()->Layout(); 170 frame_->GetRootView()->Layout();
158 } 171 }
159 } else if (new_avatar_button_) { 172 } else if (new_avatar_button_) {
160 delete new_avatar_button_; 173 delete new_avatar_button_;
161 new_avatar_button_ = NULL; 174 new_avatar_button_ = NULL;
162 frame_->GetRootView()->Layout(); 175 frame_->GetRootView()->Layout();
163 } 176 }
164 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698