| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/content_setting_image_view.h" | 5 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
| 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 11 #include "chrome/browser/ui/layout_constants.h" | |
| 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 11 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
| 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 14 #include "chrome/grit/theme_resources.h" | 13 #include "chrome/grit/theme_resources.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/material_design/material_design_controller.h" | 15 #include "ui/base/material_design/material_design_controller.h" |
| 17 #include "ui/base/theme_provider.h" | 16 #include "ui/base/theme_provider.h" |
| 18 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
| 19 #include "ui/gfx/color_palette.h" | 18 #include "ui/gfx/color_palette.h" |
| 20 #include "ui/gfx/color_utils.h" | 19 #include "ui/gfx/color_utils.h" |
| 21 #include "ui/views/animation/ink_drop_impl.h" | 20 #include "ui/views/animation/ink_drop_impl.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return std::move(ink_drop); | 155 return std::move(ink_drop); |
| 157 } | 156 } |
| 158 | 157 |
| 159 SkColor ContentSettingImageView::GetTextColor() const { | 158 SkColor ContentSettingImageView::GetTextColor() const { |
| 160 return GetNativeTheme()->GetSystemColor( | 159 return GetNativeTheme()->GetSystemColor( |
| 161 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 160 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 162 } | 161 } |
| 163 | 162 |
| 164 bool ContentSettingImageView::ShouldShowLabel() const { | 163 bool ContentSettingImageView::ShouldShowLabel() const { |
| 165 return (!IsShrinking() || | 164 return (!IsShrinking() || |
| 166 (width() > | 165 (width() > (image()->GetPreferredSize().width() + |
| 167 (image()->GetPreferredSize().width() + | 166 2 * LocationBarView::kHorizontalPadding))) && |
| 168 2 * GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING)))) && | |
| 169 (slide_animator_.is_animating() || pause_animation_); | 167 (slide_animator_.is_animating() || pause_animation_); |
| 170 } | 168 } |
| 171 | 169 |
| 172 double ContentSettingImageView::WidthMultiplier() const { | 170 double ContentSettingImageView::WidthMultiplier() const { |
| 173 double state = pause_animation_ ? pause_animation_state_ | 171 double state = pause_animation_ ? pause_animation_state_ |
| 174 : slide_animator_.GetCurrentValue(); | 172 : slide_animator_.GetCurrentValue(); |
| 175 // The fraction of the animation we'll spend animating the string into view, | 173 // The fraction of the animation we'll spend animating the string into view, |
| 176 // which is also the fraction we'll spend animating it closed; total | 174 // which is also the fraction we'll spend animating it closed; total |
| 177 // animation (slide out, show, then slide in) is 1.0. | 175 // animation (slide out, show, then slide in) is 1.0. |
| 178 const double kOpenFraction = | 176 const double kOpenFraction = |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void ContentSettingImageView::OnWidgetVisibilityChanged(views::Widget* widget, | 275 void ContentSettingImageView::OnWidgetVisibilityChanged(views::Widget* widget, |
| 278 bool visible) { | 276 bool visible) { |
| 279 // |widget| is a bubble that has just got shown / hidden. | 277 // |widget| is a bubble that has just got shown / hidden. |
| 280 if (!visible && !label()->visible()) | 278 if (!visible && !label()->visible()) |
| 281 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */); | 279 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */); |
| 282 } | 280 } |
| 283 | 281 |
| 284 void ContentSettingImageView::UpdateImage() { | 282 void ContentSettingImageView::UpdateImage() { |
| 285 SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia()); | 283 SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia()); |
| 286 } | 284 } |
| OLD | NEW |