| 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 "ui/accessibility/ax_view_state.h" | 8 #include "ui/accessibility/ax_view_state.h" |
| 9 #include "ui/base/material_design/material_design_controller.h" | 9 #include "ui/base/material_design/material_design_controller.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 command_id_(command_id), | 22 command_id_(command_id), |
| 23 active_(false), | 23 active_(false), |
| 24 suppress_mouse_released_action_(false), | 24 suppress_mouse_released_action_(false), |
| 25 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)) { | 25 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)) { |
| 26 AddChildView(image_); | 26 AddChildView(image_); |
| 27 image_->set_interactive(false); | 27 image_->set_interactive(false); |
| 28 image_->EnableCanvasFlippingForRTLUI(true); | 28 image_->EnableCanvasFlippingForRTLUI(true); |
| 29 image_->SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 29 image_->SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 30 } | 30 } |
| 31 | 31 |
| 32 BubbleIconView::~BubbleIconView() { | 32 BubbleIconView::~BubbleIconView() {} |
| 33 } | |
| 34 | 33 |
| 35 bool BubbleIconView::IsBubbleShowing() const { | 34 bool BubbleIconView::IsBubbleShowing() const { |
| 36 // If the bubble is being destroyed, it's considered showing though it may be | 35 // If the bubble is being destroyed, it's considered showing though it may be |
| 37 // already invisible currently. | 36 // already invisible currently. |
| 38 return GetBubble() != nullptr; | 37 return GetBubble() != nullptr; |
| 39 } | 38 } |
| 40 | 39 |
| 41 void BubbleIconView::SetImage(const gfx::ImageSkia* image_skia) { | 40 void BubbleIconView::SetImage(const gfx::ImageSkia* image_skia) { |
| 42 image_->SetImage(image_skia); | 41 image_->SetImage(image_skia); |
| 43 } | 42 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // for buttons. | 78 // for buttons. |
| 80 return true; | 79 return true; |
| 81 } | 80 } |
| 82 | 81 |
| 83 void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) { | 82 void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) { |
| 84 // If this is the second click on this view then the bubble was showing on the | 83 // If this is the second click on this view then the bubble was showing on the |
| 85 // mouse pressed event and is hidden now. Prevent the bubble from reshowing by | 84 // mouse pressed event and is hidden now. Prevent the bubble from reshowing by |
| 86 // doing nothing here. | 85 // doing nothing here. |
| 87 if (suppress_mouse_released_action_) { | 86 if (suppress_mouse_released_action_) { |
| 88 suppress_mouse_released_action_ = false; | 87 suppress_mouse_released_action_ = false; |
| 88 OnPressed(false); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 if (!event.IsLeftMouseButton()) | 91 if (!event.IsLeftMouseButton()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 const bool activated = HitTestPoint(event.location()); | 94 const bool activated = HitTestPoint(event.location()); |
| 95 ink_drop_delegate_->OnAction( | 95 ink_drop_delegate_->OnAction(activated ? views::InkDropState::ACTIVATED |
| 96 activated ? views::InkDropState::ACTIVATED : views::InkDropState::HIDDEN); | 96 : views::InkDropState::HIDDEN); |
| 97 if (activated) | 97 if (activated) |
| 98 ExecuteCommand(EXECUTE_SOURCE_MOUSE); | 98 ExecuteCommand(EXECUTE_SOURCE_MOUSE); |
| 99 OnPressed(activated); |
| 99 } | 100 } |
| 100 | 101 |
| 101 bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { | 102 bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { |
| 102 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE) | 103 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE) |
| 103 return false; | 104 return false; |
| 104 | 105 |
| 105 ink_drop_delegate_->OnAction(views::InkDropState::ACTIVATED); | 106 ink_drop_delegate_->OnAction(views::InkDropState::ACTIVATED); |
| 106 // As with CustomButton, return activates on key down and space activates on | 107 // As with CustomButton, return activates on key down and space activates on |
| 107 // key up. | 108 // key up. |
| 108 if (event.key_code() == ui::VKEY_RETURN) | 109 if (event.key_code() == ui::VKEY_RETURN) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 image_->SetImage( | 205 image_->SetImage( |
| 205 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color)); | 206 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color)); |
| 206 } | 207 } |
| 207 | 208 |
| 208 void BubbleIconView::SetActiveInternal(bool active) { | 209 void BubbleIconView::SetActiveInternal(bool active) { |
| 209 if (active_ == active) | 210 if (active_ == active) |
| 210 return; | 211 return; |
| 211 active_ = active; | 212 active_ = active; |
| 212 UpdateIcon(); | 213 UpdateIcon(); |
| 213 } | 214 } |
| OLD | NEW |