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/avatar_menu_button.h" | 5 #include "chrome/browser/ui/views/avatar_menu_button.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | |
8 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/command_updater.h" | 8 #include "chrome/browser/command_updater.h" |
10 #include "chrome/browser/managed_mode/managed_mode.h" | 9 #include "chrome/browser/managed_mode/managed_mode.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/avatar_menu_model.h" | 11 #include "chrome/browser/profiles/avatar_menu_model.h" |
13 #include "chrome/browser/profiles/profile_info_util.h" | 12 #include "chrome/browser/profiles/profile_info_util.h" |
14 #include "chrome/browser/profiles/profile_metrics.h" | 13 #include "chrome/browser/profiles/profile_metrics.h" |
15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_commands.h" | |
17 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | 15 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
18 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
19 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
21 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
22 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
23 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
24 | 22 |
25 | 23 |
26 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (incognito_) | 151 if (incognito_) |
154 return; | 152 return; |
155 | 153 |
156 if (ManagedMode::IsInManagedMode()) | 154 if (ManagedMode::IsInManagedMode()) |
157 ManagedMode::LeaveManagedMode(); | 155 ManagedMode::LeaveManagedMode(); |
158 else | 156 else |
159 ShowAvatarBubble(); | 157 ShowAvatarBubble(); |
160 } | 158 } |
161 | 159 |
162 void AvatarMenuButton::ShowAvatarBubble() { | 160 void AvatarMenuButton::ShowAvatarBubble() { |
163 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU)); | |
164 | |
165 gfx::Point origin; | 161 gfx::Point origin; |
166 views::View::ConvertPointToScreen(this, &origin); | 162 views::View::ConvertPointToScreen(this, &origin); |
167 gfx::Rect bounds(origin, size()); | 163 gfx::Rect bounds(origin, size()); |
168 | 164 AvatarMenuBubbleView::ShowBubble(this, views::BubbleBorder::TOP_LEFT, |
169 AvatarMenuBubbleView* bubble = new AvatarMenuBubbleView(this, | 165 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, browser_); |
170 views::BubbleBorder::TOP_LEFT, bounds, browser_); | |
171 views::BubbleDelegateView::CreateBubble(bubble); | |
172 bubble->Show(); | |
173 | 166 |
174 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); | 167 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
175 } | 168 } |
OLD | NEW |