| 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" | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 36     LocationBarView* parent, | 36     LocationBarView* parent, | 
| 37     const gfx::FontList& font_list) | 37     const gfx::FontList& font_list) | 
| 38     : IconLabelBubbleView(font_list, false), | 38     : IconLabelBubbleView(font_list, false), | 
| 39       parent_(parent), | 39       parent_(parent), | 
| 40       content_setting_image_model_(std::move(image_model)), | 40       content_setting_image_model_(std::move(image_model)), | 
| 41       slide_animator_(this), | 41       slide_animator_(this), | 
| 42       pause_animation_(false), | 42       pause_animation_(false), | 
| 43       pause_animation_state_(0.0), | 43       pause_animation_state_(0.0), | 
| 44       bubble_view_(nullptr), | 44       bubble_view_(nullptr), | 
| 45       suppress_mouse_released_action_(false) { | 45       suppress_mouse_released_action_(false) { | 
|  | 46   set_next_element_interior_padding(LocationBarView::kIconInteriorPadding); | 
| 46   SetInkDropMode(InkDropMode::ON); | 47   SetInkDropMode(InkDropMode::ON); | 
| 47   SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 48   SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 
| 48   image()->SetHorizontalAlignment(base::i18n::IsRTL() |  | 
| 49                                       ? views::ImageView::TRAILING |  | 
| 50                                       : views::ImageView::LEADING); |  | 
| 51   image()->EnableCanvasFlippingForRTLUI(true); | 49   image()->EnableCanvasFlippingForRTLUI(true); | 
| 52   label()->SetElideBehavior(gfx::NO_ELIDE); | 50   label()->SetElideBehavior(gfx::NO_ELIDE); | 
| 53   label()->SetVisible(false); | 51   label()->SetVisible(false); | 
| 54 | 52 | 
| 55   slide_animator_.SetSlideDuration(kAnimationDurationMS); | 53   slide_animator_.SetSlideDuration(kAnimationDurationMS); | 
| 56   slide_animator_.SetTweenType(gfx::Tween::LINEAR); | 54   slide_animator_.SetTweenType(gfx::Tween::LINEAR); | 
| 57 } | 55 } | 
| 58 | 56 | 
| 59 ContentSettingImageView::~ContentSettingImageView() { | 57 ContentSettingImageView::~ContentSettingImageView() { | 
| 60   if (bubble_view_ && bubble_view_->GetWidget()) | 58   if (bubble_view_ && bubble_view_->GetWidget()) | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 154   ink_drop->SetShowHighlightOnFocus(true); | 152   ink_drop->SetShowHighlightOnFocus(true); | 
| 155   return std::move(ink_drop); | 153   return std::move(ink_drop); | 
| 156 } | 154 } | 
| 157 | 155 | 
| 158 SkColor ContentSettingImageView::GetTextColor() const { | 156 SkColor ContentSettingImageView::GetTextColor() const { | 
| 159   return GetNativeTheme()->GetSystemColor( | 157   return GetNativeTheme()->GetSystemColor( | 
| 160       ui::NativeTheme::kColorId_TextfieldDefaultColor); | 158       ui::NativeTheme::kColorId_TextfieldDefaultColor); | 
| 161 } | 159 } | 
| 162 | 160 | 
| 163 bool ContentSettingImageView::ShouldShowLabel() const { | 161 bool ContentSettingImageView::ShouldShowLabel() const { | 
| 164   return (!IsShrinking() || | 162   return (!IsShrinking() || (width() > image()->GetPreferredSize().width())) && | 
| 165           (width() > (image()->GetPreferredSize().width() + |  | 
| 166                       2 * LocationBarView::kHorizontalPadding))) && |  | 
| 167          (slide_animator_.is_animating() || pause_animation_); | 163          (slide_animator_.is_animating() || pause_animation_); | 
| 168 } | 164 } | 
| 169 | 165 | 
| 170 double ContentSettingImageView::WidthMultiplier() const { | 166 double ContentSettingImageView::WidthMultiplier() const { | 
| 171   double state = pause_animation_ ? pause_animation_state_ | 167   double state = pause_animation_ ? pause_animation_state_ | 
| 172                                   : slide_animator_.GetCurrentValue(); | 168                                   : slide_animator_.GetCurrentValue(); | 
| 173   // The fraction of the animation we'll spend animating the string into view, | 169   // The fraction of the animation we'll spend animating the string into view, | 
| 174   // which is also the fraction we'll spend animating it closed; total | 170   // which is also the fraction we'll spend animating it closed; total | 
| 175   // animation (slide out, show, then slide in) is 1.0. | 171   // animation (slide out, show, then slide in) is 1.0. | 
| 176   const double kOpenFraction = | 172   const double kOpenFraction = | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 275 void ContentSettingImageView::OnWidgetVisibilityChanged(views::Widget* widget, | 271 void ContentSettingImageView::OnWidgetVisibilityChanged(views::Widget* widget, | 
| 276                                                         bool visible) { | 272                                                         bool visible) { | 
| 277   // |widget| is a bubble that has just got shown / hidden. | 273   // |widget| is a bubble that has just got shown / hidden. | 
| 278   if (!visible && !label()->visible()) | 274   if (!visible && !label()->visible()) | 
| 279     AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */); | 275     AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */); | 
| 280 } | 276 } | 
| 281 | 277 | 
| 282 void ContentSettingImageView::UpdateImage() { | 278 void ContentSettingImageView::UpdateImage() { | 
| 283   SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia()); | 279   SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia()); | 
| 284 } | 280 } | 
| OLD | NEW | 
|---|