| 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/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 9 #include "ui/accessibility/ax_node_data.h" | 9 #include "ui/accessibility/ax_node_data.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| 11 #include "ui/gfx/color_utils.h" | 11 #include "ui/gfx/color_utils.h" |
| 12 #include "ui/gfx/paint_vector_icon.h" | 12 #include "ui/gfx/paint_vector_icon.h" |
| 13 #include "ui/native_theme/native_theme.h" | 13 #include "ui/native_theme/native_theme.h" |
| 14 #include "ui/views/animation/ink_drop_highlight.h" | 14 #include "ui/views/animation/ink_drop_highlight.h" |
| 15 #include "ui/views/animation/ink_drop_impl.h" |
| 15 #include "ui/views/bubble/bubble_dialog_delegate.h" | 16 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 16 | 17 |
| 17 BubbleIconView::BubbleIconView(CommandUpdater* command_updater, int command_id) | 18 BubbleIconView::BubbleIconView(CommandUpdater* command_updater, int command_id) |
| 18 : image_(new views::ImageView()), | 19 : image_(new views::ImageView()), |
| 19 command_updater_(command_updater), | 20 command_updater_(command_updater), |
| 20 command_id_(command_id), | 21 command_id_(command_id), |
| 21 active_(false), | 22 active_(false), |
| 22 suppress_mouse_released_action_(false) { | 23 suppress_mouse_released_action_(false) { |
| 23 AddChildView(image_); | 24 AddChildView(image_); |
| 24 image_->set_interactive(false); | 25 image_->set_interactive(false); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 image_->SetPaintToLayer(true); | 134 image_->SetPaintToLayer(true); |
| 134 image_->layer()->SetFillsBoundsOpaquely(false); | 135 image_->layer()->SetFillsBoundsOpaquely(false); |
| 135 views::InkDropHostView::AddInkDropLayer(ink_drop_layer); | 136 views::InkDropHostView::AddInkDropLayer(ink_drop_layer); |
| 136 } | 137 } |
| 137 | 138 |
| 138 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 139 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 139 views::InkDropHostView::RemoveInkDropLayer(ink_drop_layer); | 140 views::InkDropHostView::RemoveInkDropLayer(ink_drop_layer); |
| 140 image_->SetPaintToLayer(false); | 141 image_->SetPaintToLayer(false); |
| 141 } | 142 } |
| 142 | 143 |
| 144 std::unique_ptr<views::InkDrop> BubbleIconView::CreateInkDrop() { |
| 145 std::unique_ptr<views::InkDropImpl> ink_drop = CreateDefaultInkDropImpl(); |
| 146 ink_drop->SetShowHighlightOnFocus(true); |
| 147 return std::move(ink_drop); |
| 148 } |
| 149 |
| 143 SkColor BubbleIconView::GetInkDropBaseColor() const { | 150 SkColor BubbleIconView::GetInkDropBaseColor() const { |
| 144 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor( | 151 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor( |
| 145 ui::NativeTheme::kColorId_TextfieldDefaultColor)); | 152 ui::NativeTheme::kColorId_TextfieldDefaultColor)); |
| 146 } | 153 } |
| 147 | 154 |
| 148 bool BubbleIconView::ShouldShowInkDropForFocus() const { | |
| 149 return true; | |
| 150 } | |
| 151 | |
| 152 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { | 155 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { |
| 153 if (event->type() == ui::ET_GESTURE_TAP) { | 156 if (event->type() == ui::ET_GESTURE_TAP) { |
| 154 AnimateInkDrop(views::InkDropState::ACTIVATED, event); | 157 AnimateInkDrop(views::InkDropState::ACTIVATED, event); |
| 155 ExecuteCommand(EXECUTE_SOURCE_GESTURE); | 158 ExecuteCommand(EXECUTE_SOURCE_GESTURE); |
| 156 event->SetHandled(); | 159 event->SetHandled(); |
| 157 } | 160 } |
| 158 } | 161 } |
| 159 | 162 |
| 160 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { | 163 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { |
| 161 widget->RemoveObserver(this); | 164 widget->RemoveObserver(this); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 image_->SetImage(gfx::CreateVectorIcon( | 197 image_->SetImage(gfx::CreateVectorIcon( |
| 195 GetVectorIcon(), LocationBarView::kIconWidth, icon_color)); | 198 GetVectorIcon(), LocationBarView::kIconWidth, icon_color)); |
| 196 } | 199 } |
| 197 | 200 |
| 198 void BubbleIconView::SetActiveInternal(bool active) { | 201 void BubbleIconView::SetActiveInternal(bool active) { |
| 199 if (active_ == active) | 202 if (active_ == active) |
| 200 return; | 203 return; |
| 201 active_ = active; | 204 active_ = active; |
| 202 UpdateIcon(); | 205 UpdateIcon(); |
| 203 } | 206 } |
| OLD | NEW |