| 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" | 8 #include "chrome/browser/ui/layout_constants.h" |
| 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 11 #include "ui/accessibility/ax_node_data.h" | 11 #include "ui/accessibility/ax_node_data.h" |
| 12 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
| 13 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
| 14 #include "ui/gfx/paint_vector_icon.h" | 14 #include "ui/gfx/paint_vector_icon.h" |
| 15 #include "ui/native_theme/native_theme.h" | 15 #include "ui/native_theme/native_theme.h" |
| 16 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 16 #include "ui/views/animation/ink_drop_highlight.h" | 17 #include "ui/views/animation/ink_drop_highlight.h" |
| 17 #include "ui/views/animation/ink_drop_impl.h" | 18 #include "ui/views/animation/ink_drop_impl.h" |
| 18 #include "ui/views/bubble/bubble_dialog_delegate.h" | 19 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 19 | 20 |
| 20 void BubbleIconView::Init() { | 21 void BubbleIconView::Init() { |
| 21 AddChildView(image_); | 22 AddChildView(image_); |
| 22 image_->set_can_process_events_within_subtree(false); | 23 image_->set_can_process_events_within_subtree(false); |
| 23 image_->EnableCanvasFlippingForRTLUI(true); | 24 image_->EnableCanvasFlippingForRTLUI(true); |
| 24 SetInkDropMode(InkDropMode::ON); | 25 SetInkDropMode(InkDropMode::ON); |
| 25 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 26 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 image_->layer()->SetFillsBoundsOpaquely(false); | 146 image_->layer()->SetFillsBoundsOpaquely(false); |
| 146 views::InkDropHostView::AddInkDropLayer(ink_drop_layer); | 147 views::InkDropHostView::AddInkDropLayer(ink_drop_layer); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 150 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 150 views::InkDropHostView::RemoveInkDropLayer(ink_drop_layer); | 151 views::InkDropHostView::RemoveInkDropLayer(ink_drop_layer); |
| 151 image_->DestroyLayer(); | 152 image_->DestroyLayer(); |
| 152 } | 153 } |
| 153 | 154 |
| 154 std::unique_ptr<views::InkDrop> BubbleIconView::CreateInkDrop() { | 155 std::unique_ptr<views::InkDrop> BubbleIconView::CreateInkDrop() { |
| 155 std::unique_ptr<views::InkDropImpl> ink_drop = CreateDefaultInkDropImpl(); | 156 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 157 CreateDefaultFloodFillInkDropImpl(); |
| 156 ink_drop->SetShowHighlightOnFocus(true); | 158 ink_drop->SetShowHighlightOnFocus(true); |
| 157 return std::move(ink_drop); | 159 return std::move(ink_drop); |
| 158 } | 160 } |
| 159 | 161 |
| 160 SkColor BubbleIconView::GetInkDropBaseColor() const { | 162 SkColor BubbleIconView::GetInkDropBaseColor() const { |
| 161 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor( | 163 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor( |
| 162 ui::NativeTheme::kColorId_TextfieldDefaultColor)); | 164 ui::NativeTheme::kColorId_TextfieldDefaultColor)); |
| 163 } | 165 } |
| 164 | 166 |
| 167 std::unique_ptr<views::InkDropRipple> BubbleIconView::CreateInkDropRipple() |
| 168 const { |
| 169 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 170 gfx::Size(kDefaultInkDropSize, kDefaultInkDropSize), |
| 171 GetLocalBounds().CenterPoint(), GetInkDropBaseColor(), |
| 172 ink_drop_visible_opacity()); |
| 173 } |
| 174 |
| 165 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { | 175 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { |
| 166 if (event->type() == ui::ET_GESTURE_TAP) { | 176 if (event->type() == ui::ET_GESTURE_TAP) { |
| 167 AnimateInkDrop(views::InkDropState::ACTIVATED, event); | 177 AnimateInkDrop(views::InkDropState::ACTIVATED, event); |
| 168 ExecuteCommand(EXECUTE_SOURCE_GESTURE); | 178 ExecuteCommand(EXECUTE_SOURCE_GESTURE); |
| 169 event->SetHandled(); | 179 event->SetHandled(); |
| 170 } | 180 } |
| 171 } | 181 } |
| 172 | 182 |
| 173 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { | 183 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { |
| 174 widget->RemoveObserver(this); | 184 widget->RemoveObserver(this); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 203 image_->SetImage(gfx::CreateVectorIcon( | 213 image_->SetImage(gfx::CreateVectorIcon( |
| 204 GetVectorIcon(), LocationBarView::kIconWidth, icon_color)); | 214 GetVectorIcon(), LocationBarView::kIconWidth, icon_color)); |
| 205 } | 215 } |
| 206 | 216 |
| 207 void BubbleIconView::SetActiveInternal(bool active) { | 217 void BubbleIconView::SetActiveInternal(bool active) { |
| 208 if (active_ == active) | 218 if (active_ == active) |
| 209 return; | 219 return; |
| 210 active_ = active; | 220 active_ = active; |
| 211 UpdateIcon(); | 221 UpdateIcon(); |
| 212 } | 222 } |
| OLD | NEW |