| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/avatar_menu_button.h" | 5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 int dst_height = Round(button_icon_.height() * scale); | 69 int dst_height = Round(button_icon_.height() * scale); |
| 70 // Round rather than truncating, so that for odd heights we select an extra | 70 // Round rather than truncating, so that for odd heights we select an extra |
| 71 // pixel below the image center rather than above. This is because the | 71 // pixel below the image center rather than above. This is because the |
| 72 // incognito image has shadows at the top that make the apparent center below | 72 // incognito image has shadows at the top that make the apparent center below |
| 73 // the real center. | 73 // the real center. |
| 74 int dst_y = Round((height() - dst_height) / 2.0); | 74 int dst_y = Round((height() - dst_height) / 2.0); |
| 75 canvas->DrawImageInt(button_icon_, 0, 0, button_icon_.width(), | 75 canvas->DrawImageInt(button_icon_, 0, 0, button_icon_.width(), |
| 76 button_icon_.height(), dst_x, dst_y, dst_width, dst_height, false); | 76 button_icon_.height(), dst_x, dst_y, dst_width, dst_height, false); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool AvatarMenuButton::HitTestRect(const gfx::Rect& rect) const { | 79 bool AvatarMenuButton::HitTestRect(const gfx::RectF& rect) const { |
| 80 if (disabled_) | 80 if (disabled_) |
| 81 return false; | 81 return false; |
| 82 return views::MenuButton::HitTestRect(rect); | 82 return views::MenuButton::HitTestRect(rect); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void AvatarMenuButton::SetAvatarIcon(const gfx::Image& icon, | 85 void AvatarMenuButton::SetAvatarIcon(const gfx::Image& icon, |
| 86 bool is_rectangle) { | 86 bool is_rectangle) { |
| 87 icon_.reset(new gfx::Image(icon)); | 87 icon_.reset(new gfx::Image(icon)); |
| 88 button_icon_ = gfx::ImageSkia(); | 88 button_icon_ = gfx::ImageSkia(); |
| 89 is_rectangle_ = is_rectangle; | 89 is_rectangle_ = is_rectangle; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 111 this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, | 111 this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, |
| 112 browser_); | 112 browser_); |
| 113 } else { | 113 } else { |
| 114 AvatarMenuBubbleView::ShowBubble( | 114 AvatarMenuBubbleView::ShowBubble( |
| 115 this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, | 115 this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, |
| 116 browser_); | 116 browser_); |
| 117 } | 117 } |
| 118 | 118 |
| 119 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); | 119 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
| 120 } | 120 } |
| OLD | NEW |