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" |
11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/view_ids.h" |
12 #include "chrome/browser/ui/views/avatar_label.h" | 13 #include "chrome/browser/ui/views/avatar_label.h" |
13 #include "chrome/browser/ui/views/avatar_menu_button.h" | 14 #include "chrome/browser/ui/views/avatar_menu_button.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" | 16 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/base/theme_provider.h" | 22 #include "ui/base/theme_provider.h" |
(...skipping 25 matching lines...) Expand all Loading... |
47 if (avatar_label_) | 48 if (avatar_label_) |
48 avatar_label_->UpdateLabelStyle(); | 49 avatar_label_->UpdateLabelStyle(); |
49 } | 50 } |
50 | 51 |
51 void BrowserNonClientFrameView::UpdateAvatarInfo() { | 52 void BrowserNonClientFrameView::UpdateAvatarInfo() { |
52 if (browser_view_->ShouldShowAvatar()) { | 53 if (browser_view_->ShouldShowAvatar()) { |
53 if (!avatar_button_) { | 54 if (!avatar_button_) { |
54 Profile* profile = browser_view_->browser()->profile(); | 55 Profile* profile = browser_view_->browser()->profile(); |
55 if (profile->IsManaged() && !avatar_label_) { | 56 if (profile->IsManaged() && !avatar_label_) { |
56 avatar_label_ = new AvatarLabel(browser_view_); | 57 avatar_label_ = new AvatarLabel(browser_view_); |
| 58 avatar_label_->set_id(VIEW_ID_AVATAR_LABEL); |
57 AddChildView(avatar_label_); | 59 AddChildView(avatar_label_); |
58 } | 60 } |
59 avatar_button_ = new AvatarMenuButton( | 61 avatar_button_ = new AvatarMenuButton( |
60 browser_view_->browser(), | 62 browser_view_->browser(), |
61 browser_view_->IsOffTheRecord() && !browser_view_->IsGuestSession()); | 63 browser_view_->IsOffTheRecord() && !browser_view_->IsGuestSession()); |
| 64 avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON); |
62 AddChildView(avatar_button_); | 65 AddChildView(avatar_button_); |
63 frame_->GetRootView()->Layout(); | 66 frame_->GetRootView()->Layout(); |
64 } | 67 } |
65 } else if (avatar_button_) { | 68 } else if (avatar_button_) { |
66 // The avatar label can just be there if there is also an avatar button. | 69 // The avatar label can just be there if there is also an avatar button. |
67 if (avatar_label_) { | 70 if (avatar_label_) { |
68 RemoveChildView(avatar_label_); | 71 RemoveChildView(avatar_label_); |
69 delete avatar_label_; | 72 delete avatar_label_; |
70 avatar_label_ = NULL; | 73 avatar_label_ = NULL; |
71 } | 74 } |
(...skipping 29 matching lines...) Expand all Loading... |
101 if (!text.empty()) | 104 if (!text.empty()) |
102 avatar_button_->SetText(text); | 105 avatar_button_->SetText(text); |
103 } | 106 } |
104 | 107 |
105 // For popups and panels which don't have the avatar button, we still | 108 // For popups and panels which don't have the avatar button, we still |
106 // need to draw the taskbar decoration. | 109 // need to draw the taskbar decoration. |
107 chrome::DrawTaskbarDecoration( | 110 chrome::DrawTaskbarDecoration( |
108 frame_->GetNativeWindow(), | 111 frame_->GetNativeWindow(), |
109 AvatarMenuModel::ShouldShowAvatarMenu() ? &avatar : NULL); | 112 AvatarMenuModel::ShouldShowAvatarMenu() ? &avatar : NULL); |
110 } | 113 } |
OLD | NEW |