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" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/command_updater.h" | 9 #include "chrome/browser/command_updater.h" |
10 #include "chrome/browser/managed_mode.h" | 10 #include "chrome/browser/managed_mode.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 int dst_height = Round(button_icon_.height() * scale); | 126 int dst_height = Round(button_icon_.height() * scale); |
127 // Round rather than truncating, so that for odd heights we select an extra | 127 // Round rather than truncating, so that for odd heights we select an extra |
128 // pixel below the image center rather than above. This is because the | 128 // pixel below the image center rather than above. This is because the |
129 // incognito image has shadows at the top that make the apparent center below | 129 // incognito image has shadows at the top that make the apparent center below |
130 // the real center. | 130 // the real center. |
131 int dst_y = Round((height() - dst_height) / 2.0); | 131 int dst_y = Round((height() - dst_height) / 2.0); |
132 canvas->DrawImageInt(button_icon_, 0, 0, button_icon_.width(), | 132 canvas->DrawImageInt(button_icon_, 0, 0, button_icon_.width(), |
133 button_icon_.height(), dst_x, dst_y, dst_width, dst_height, false); | 133 button_icon_.height(), dst_x, dst_y, dst_width, dst_height, false); |
134 } | 134 } |
135 | 135 |
136 bool AvatarMenuButton::HitTest(const gfx::Point& point) const { | 136 bool AvatarMenuButton::HitTestRect(const gfx::Rect& rect) const { |
137 if (incognito_) | 137 if (incognito_) |
138 return false; | 138 return false; |
139 return views::MenuButton::HitTest(point); | 139 return views::MenuButton::HitTestRect(rect); |
140 } | 140 } |
141 | 141 |
142 void AvatarMenuButton::SetAvatarIcon(const gfx::Image& icon, | 142 void AvatarMenuButton::SetAvatarIcon(const gfx::Image& icon, |
143 bool is_gaia_picture) { | 143 bool is_gaia_picture) { |
144 icon_.reset(new gfx::Image(icon)); | 144 icon_.reset(new gfx::Image(icon)); |
145 button_icon_ = gfx::ImageSkia(); | 145 button_icon_ = gfx::ImageSkia(); |
146 is_gaia_picture_ = is_gaia_picture; | 146 is_gaia_picture_ = is_gaia_picture; |
147 SchedulePaint(); | 147 SchedulePaint(); |
148 } | 148 } |
149 | 149 |
(...skipping 16 matching lines...) Expand all Loading... |
166 views::View::ConvertPointToScreen(this, &origin); | 166 views::View::ConvertPointToScreen(this, &origin); |
167 gfx::Rect bounds(origin, size()); | 167 gfx::Rect bounds(origin, size()); |
168 | 168 |
169 AvatarMenuBubbleView* bubble = new AvatarMenuBubbleView(this, | 169 AvatarMenuBubbleView* bubble = new AvatarMenuBubbleView(this, |
170 views::BubbleBorder::TOP_LEFT, bounds, browser_); | 170 views::BubbleBorder::TOP_LEFT, bounds, browser_); |
171 views::BubbleDelegateView::CreateBubble(bubble); | 171 views::BubbleDelegateView::CreateBubble(bubble); |
172 bubble->Show(); | 172 bubble->Show(); |
173 | 173 |
174 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); | 174 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
175 } | 175 } |
OLD | NEW |