| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 147 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 148 layer()->Remove(ink_drop_layer); | 148 layer()->Remove(ink_drop_layer); |
| 149 SetFillsBoundsOpaquely(true); | 149 SetFillsBoundsOpaquely(true); |
| 150 SetPaintToLayer(false); | 150 SetPaintToLayer(false); |
| 151 image_->SetFillsBoundsOpaquely(true); | 151 image_->SetFillsBoundsOpaquely(true); |
| 152 image_->SetPaintToLayer(false); | 152 image_->SetPaintToLayer(false); |
| 153 } | 153 } |
| 154 | 154 |
| 155 gfx::Point BubbleIconView::CalculateInkDropCenter() const { |
| 156 return GetLocalBounds().CenterPoint(); |
| 157 } |
| 158 |
| 159 bool BubbleIconView::ShouldShowInkDropHover() const { |
| 160 // BubbleIconView views don't show hover effect. |
| 161 return false; |
| 162 } |
| 163 |
| 164 SkColor BubbleIconView::GetInkDropBaseColor() const { |
| 165 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor( |
| 166 ui::NativeTheme::kColorId_TextfieldDefaultColor)); |
| 167 } |
| 168 |
| 155 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { | 169 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { |
| 156 widget->RemoveObserver(this); | 170 widget->RemoveObserver(this); |
| 157 } | 171 } |
| 158 | 172 |
| 159 void BubbleIconView::OnWidgetVisibilityChanged(views::Widget* widget, | 173 void BubbleIconView::OnWidgetVisibilityChanged(views::Widget* widget, |
| 160 bool visible) { | 174 bool visible) { |
| 161 // |widget| is a bubble that has just got shown / hidden. | 175 // |widget| is a bubble that has just got shown / hidden. |
| 162 if (!visible) | 176 if (!visible) |
| 163 ink_drop_delegate_->OnAction(views::InkDropState::DEACTIVATED); | 177 ink_drop_delegate_->OnAction(views::InkDropState::DEACTIVATED); |
| 164 } | 178 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 177 return false; | 191 return false; |
| 178 } | 192 } |
| 179 | 193 |
| 180 void BubbleIconView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 194 void BubbleIconView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 181 views::BubbleDelegateView* bubble = GetBubble(); | 195 views::BubbleDelegateView* bubble = GetBubble(); |
| 182 if (bubble) | 196 if (bubble) |
| 183 bubble->OnAnchorBoundsChanged(); | 197 bubble->OnAnchorBoundsChanged(); |
| 184 ink_drop_delegate_->OnLayout(); | 198 ink_drop_delegate_->OnLayout(); |
| 185 } | 199 } |
| 186 | 200 |
| 187 gfx::Point BubbleIconView::CalculateInkDropCenter() const { | |
| 188 return GetLocalBounds().CenterPoint(); | |
| 189 } | |
| 190 | |
| 191 bool BubbleIconView::ShouldShowInkDropHover() const { | |
| 192 // BubbleIconView views don't show hover effect. | |
| 193 return false; | |
| 194 } | |
| 195 | |
| 196 void BubbleIconView::UpdateIcon() { | 201 void BubbleIconView::UpdateIcon() { |
| 197 if (SetRasterIcon()) | 202 if (SetRasterIcon()) |
| 198 return; | 203 return; |
| 199 | 204 |
| 200 const int icon_size = | 205 const int icon_size = |
| 201 ui::MaterialDesignController::IsModeMaterial() ? 16 : 18; | 206 ui::MaterialDesignController::IsModeMaterial() ? 16 : 18; |
| 202 const ui::NativeTheme* theme = GetNativeTheme(); | 207 SkColor icon_color = active_ |
| 203 SkColor icon_color = | 208 ? GetNativeTheme()->GetSystemColor( |
| 204 active_ | 209 ui::NativeTheme::kColorId_CallToActionColor) |
| 205 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor) | 210 : GetInkDropBaseColor(); |
| 206 : color_utils::DeriveDefaultIconColor(theme->GetSystemColor( | |
| 207 ui::NativeTheme::kColorId_TextfieldDefaultColor)); | |
| 208 image_->SetImage( | 211 image_->SetImage( |
| 209 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color)); | 212 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color)); |
| 210 } | 213 } |
| 211 | 214 |
| 212 void BubbleIconView::SetActiveInternal(bool active) { | 215 void BubbleIconView::SetActiveInternal(bool active) { |
| 213 if (active_ == active) | 216 if (active_ == active) |
| 214 return; | 217 return; |
| 215 active_ = active; | 218 active_ = active; |
| 216 UpdateIcon(); | 219 UpdateIcon(); |
| 217 } | 220 } |
| OLD | NEW |