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 29 matching lines...) Expand all Loading... |
40 : IconLabelBubbleView(0, font_list, parent_background_color, false), | 40 : IconLabelBubbleView(0, font_list, parent_background_color, false), |
41 parent_(parent), | 41 parent_(parent), |
42 content_setting_image_model_(image_model), | 42 content_setting_image_model_(image_model), |
43 slide_animator_(this), | 43 slide_animator_(this), |
44 pause_animation_(false), | 44 pause_animation_(false), |
45 pause_animation_state_(0.0), | 45 pause_animation_state_(0.0), |
46 bubble_view_(nullptr), | 46 bubble_view_(nullptr), |
47 suppress_mouse_released_action_(false) { | 47 suppress_mouse_released_action_(false) { |
48 if (ui::MaterialDesignController::IsModeMaterial()) { | 48 if (ui::MaterialDesignController::IsModeMaterial()) { |
49 SetHasInkDrop(true); | 49 SetHasInkDrop(true); |
| 50 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
50 } else { | 51 } else { |
51 static const int kBackgroundImages[] = | 52 static const int kBackgroundImages[] = |
52 IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE); | 53 IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE); |
53 SetBackgroundImageGrid(kBackgroundImages); | 54 SetBackgroundImageGrid(kBackgroundImages); |
| 55 image()->set_interactive(true); |
| 56 image()->SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
54 } | 57 } |
55 | 58 |
56 image()->SetHorizontalAlignment(base::i18n::IsRTL() | 59 image()->SetHorizontalAlignment(base::i18n::IsRTL() |
57 ? views::ImageView::TRAILING | 60 ? views::ImageView::TRAILING |
58 : views::ImageView::LEADING); | 61 : views::ImageView::LEADING); |
59 image()->set_interactive(true); | |
60 image()->EnableCanvasFlippingForRTLUI(true); | 62 image()->EnableCanvasFlippingForRTLUI(true); |
61 image()->SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | |
62 label()->SetElideBehavior(gfx::NO_ELIDE); | 63 label()->SetElideBehavior(gfx::NO_ELIDE); |
63 label()->SetVisible(false); | 64 label()->SetVisible(false); |
64 | 65 |
65 slide_animator_.SetSlideDuration(kAnimationDurationMS); | 66 slide_animator_.SetSlideDuration(kAnimationDurationMS); |
66 slide_animator_.SetTweenType(gfx::Tween::LINEAR); | 67 slide_animator_.SetTweenType(gfx::Tween::LINEAR); |
67 } | 68 } |
68 | 69 |
69 ContentSettingImageView::~ContentSettingImageView() { | 70 ContentSettingImageView::~ContentSettingImageView() { |
70 if (bubble_view_ && bubble_view_->GetWidget()) | 71 if (bubble_view_ && bubble_view_->GetWidget()) |
71 bubble_view_->GetWidget()->RemoveObserver(this); | 72 bubble_view_->GetWidget()->RemoveObserver(this); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 149 } |
149 | 150 |
150 void ContentSettingImageView::OnNativeThemeChanged( | 151 void ContentSettingImageView::OnNativeThemeChanged( |
151 const ui::NativeTheme* native_theme) { | 152 const ui::NativeTheme* native_theme) { |
152 if (ui::MaterialDesignController::IsModeMaterial()) | 153 if (ui::MaterialDesignController::IsModeMaterial()) |
153 UpdateImage(); | 154 UpdateImage(); |
154 | 155 |
155 IconLabelBubbleView::OnNativeThemeChanged(native_theme); | 156 IconLabelBubbleView::OnNativeThemeChanged(native_theme); |
156 } | 157 } |
157 | 158 |
| 159 bool ContentSettingImageView::ShouldShowInkDropForFocus() const { |
| 160 return true; |
| 161 } |
| 162 |
158 SkColor ContentSettingImageView::GetTextColor() const { | 163 SkColor ContentSettingImageView::GetTextColor() const { |
159 return GetNativeTheme()->GetSystemColor( | 164 return GetNativeTheme()->GetSystemColor( |
160 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 165 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
161 } | 166 } |
162 | 167 |
163 SkColor ContentSettingImageView::GetBorderColor() const { | 168 SkColor ContentSettingImageView::GetBorderColor() const { |
164 return gfx::kGoogleYellow700; | 169 return gfx::kGoogleYellow700; |
165 } | 170 } |
166 | 171 |
167 bool ContentSettingImageView::ShouldShowBackground() const { | 172 bool ContentSettingImageView::ShouldShowBackground() const { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 bool visible) { | 282 bool visible) { |
278 // |widget| is a bubble that has just got shown / hidden. | 283 // |widget| is a bubble that has just got shown / hidden. |
279 if (!visible && !label()->visible()) | 284 if (!visible && !label()->visible()) |
280 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */); | 285 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */); |
281 } | 286 } |
282 | 287 |
283 void ContentSettingImageView::UpdateImage() { | 288 void ContentSettingImageView::UpdateImage() { |
284 SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia()); | 289 SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia()); |
285 image()->SetTooltipText(content_setting_image_model_->get_tooltip()); | 290 image()->SetTooltipText(content_setting_image_model_->get_tooltip()); |
286 } | 291 } |
OLD | NEW |