| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/location_bar/bubble_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/bubble_icon_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/command_updater.h" | 7 #include "chrome/browser/command_updater.h" |
| 8 #include "chrome/browser/ui/layout_constants.h" |
| 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 9 #include "ui/accessibility/ax_node_data.h" | 11 #include "ui/accessibility/ax_node_data.h" |
| 10 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
| 11 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
| 12 #include "ui/gfx/paint_vector_icon.h" | 14 #include "ui/gfx/paint_vector_icon.h" |
| 13 #include "ui/native_theme/native_theme.h" | 15 #include "ui/native_theme/native_theme.h" |
| 14 #include "ui/views/animation/ink_drop_highlight.h" | 16 #include "ui/views/animation/ink_drop_highlight.h" |
| 15 #include "ui/views/animation/ink_drop_impl.h" | 17 #include "ui/views/animation/ink_drop_impl.h" |
| 16 #include "ui/views/bubble/bubble_dialog_delegate.h" | 18 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 17 | 19 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 image_->GetAccessibleNodeData(node_data); | 54 image_->GetAccessibleNodeData(node_data); |
| 53 node_data->role = ui::AX_ROLE_BUTTON; | 55 node_data->role = ui::AX_ROLE_BUTTON; |
| 54 } | 56 } |
| 55 | 57 |
| 56 bool BubbleIconView::GetTooltipText(const gfx::Point& p, | 58 bool BubbleIconView::GetTooltipText(const gfx::Point& p, |
| 57 base::string16* tooltip) const { | 59 base::string16* tooltip) const { |
| 58 return !IsBubbleShowing() && image_->GetTooltipText(p, tooltip); | 60 return !IsBubbleShowing() && image_->GetTooltipText(p, tooltip); |
| 59 } | 61 } |
| 60 | 62 |
| 61 gfx::Size BubbleIconView::GetPreferredSize() const { | 63 gfx::Size BubbleIconView::GetPreferredSize() const { |
| 62 return image_->GetPreferredSize(); | 64 gfx::Rect image_rect(image_->GetPreferredSize()); |
| 65 image_rect.Inset(-gfx::Insets(LocationBarView::kIconInteriorPadding)); |
| 66 DCHECK_EQ(image_rect.height(), |
| 67 GetLayoutConstant(LOCATION_BAR_HEIGHT) - |
| 68 2 * (GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) + |
| 69 BackgroundWith1PxBorder::kLocationBarBorderThicknessDip)); |
| 70 return image_rect.size(); |
| 63 } | 71 } |
| 64 | 72 |
| 65 void BubbleIconView::Layout() { | 73 void BubbleIconView::Layout() { |
| 66 View::Layout(); | 74 View::Layout(); |
| 67 image_->SetBoundsRect(GetLocalBounds()); | 75 image_->SetBoundsRect(GetLocalBounds()); |
| 68 } | 76 } |
| 69 | 77 |
| 70 bool BubbleIconView::OnMousePressed(const ui::MouseEvent& event) { | 78 bool BubbleIconView::OnMousePressed(const ui::MouseEvent& event) { |
| 71 // If the bubble is showing then don't reshow it when the mouse is released. | 79 // If the bubble is showing then don't reshow it when the mouse is released. |
| 72 suppress_mouse_released_action_ = IsBubbleShowing(); | 80 suppress_mouse_released_action_ = IsBubbleShowing(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 image_->SetImage(gfx::CreateVectorIcon( | 205 image_->SetImage(gfx::CreateVectorIcon( |
| 198 GetVectorIcon(), LocationBarView::kIconWidth, icon_color)); | 206 GetVectorIcon(), LocationBarView::kIconWidth, icon_color)); |
| 199 } | 207 } |
| 200 | 208 |
| 201 void BubbleIconView::SetActiveInternal(bool active) { | 209 void BubbleIconView::SetActiveInternal(bool active) { |
| 202 if (active_ == active) | 210 if (active_ == active) |
| 203 return; | 211 return; |
| 204 active_ = active; | 212 active_ = active; |
| 205 UpdateIcon(); | 213 UpdateIcon(); |
| 206 } | 214 } |
| OLD | NEW |