OLD | NEW |
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_model.h" | 8 #include "chrome/browser/profiles/avatar_menu_model.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 void BrowserNonClientFrameView::OnThemeChanged() { | 51 void BrowserNonClientFrameView::OnThemeChanged() { |
52 if (avatar_label_) | 52 if (avatar_label_) |
53 avatar_label_->UpdateLabelStyle(); | 53 avatar_label_->UpdateLabelStyle(); |
54 } | 54 } |
55 | 55 |
56 void BrowserNonClientFrameView::UpdateAvatarInfo() { | 56 void BrowserNonClientFrameView::UpdateAvatarInfo() { |
57 if (browser_view_->ShouldShowAvatar()) { | 57 if (browser_view_->ShouldShowAvatar()) { |
58 if (!avatar_button_) { | 58 if (!avatar_button_) { |
59 avatar_button_ = new AvatarMenuButton(browser_view_->browser(), | |
60 browser_view_->IsOffTheRecord()); | |
61 AddChildView(avatar_button_); | |
62 #if defined(ENABLE_MANAGED_USERS) | 59 #if defined(ENABLE_MANAGED_USERS) |
63 Profile* profile = browser_view_->browser()->profile(); | 60 Profile* profile = browser_view_->browser()->profile(); |
64 ManagedUserService* service = | 61 ManagedUserService* service = |
65 ManagedUserServiceFactory::GetForProfile(profile); | 62 ManagedUserServiceFactory::GetForProfile(profile); |
66 if (service->ProfileIsManaged() && !avatar_label_) { | 63 if (service->ProfileIsManaged() && !avatar_label_) { |
67 avatar_label_ = | 64 avatar_label_ = |
68 new AvatarLabel(browser_view_, frame_->GetThemeProvider()); | 65 new AvatarLabel(browser_view_, frame_->GetThemeProvider()); |
69 AddChildView(avatar_label_); | 66 AddChildView(avatar_label_); |
70 } | 67 } |
71 #endif | 68 #endif |
| 69 avatar_button_ = new AvatarMenuButton(browser_view_->browser(), |
| 70 browser_view_->IsOffTheRecord()); |
| 71 AddChildView(avatar_button_); |
72 frame_->GetRootView()->Layout(); | 72 frame_->GetRootView()->Layout(); |
73 } | 73 } |
74 } else if (avatar_button_) { | 74 } else if (avatar_button_) { |
75 // The avatar label can just be there if there is also an avatar button. | 75 // The avatar label can just be there if there is also an avatar button. |
76 if (avatar_label_) { | 76 if (avatar_label_) { |
77 RemoveChildView(avatar_label_); | 77 RemoveChildView(avatar_label_); |
78 delete avatar_label_; | 78 delete avatar_label_; |
79 avatar_label_ = NULL; | 79 avatar_label_ = NULL; |
80 } | 80 } |
81 RemoveChildView(avatar_button_); | 81 RemoveChildView(avatar_button_); |
(...skipping 26 matching lines...) Expand all Loading... |
108 if (!text.empty()) | 108 if (!text.empty()) |
109 avatar_button_->SetText(text); | 109 avatar_button_->SetText(text); |
110 } | 110 } |
111 | 111 |
112 // For popups and panels which don't have the avatar button, we still | 112 // For popups and panels which don't have the avatar button, we still |
113 // need to draw the taskbar decoration. | 113 // need to draw the taskbar decoration. |
114 chrome::DrawTaskbarDecoration( | 114 chrome::DrawTaskbarDecoration( |
115 frame_->GetNativeWindow(), | 115 frame_->GetNativeWindow(), |
116 AvatarMenuModel::ShouldShowAvatarMenu() ? &avatar : NULL); | 116 AvatarMenuModel::ShouldShowAvatarMenu() ? &avatar : NULL); |
117 } | 117 } |
OLD | NEW |