| 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/find_bar_view.h" | 5 #include "chrome/browser/ui/views/find_bar_view.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 | 8 | 
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" | 
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" | 
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" | 
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" | 
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" | 
| 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 
| 15 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 15 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 
| 16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | 16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | 
| 17 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 17 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 
| 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 
| 19 #include "chrome/browser/ui/view_ids.h" | 19 #include "chrome/browser/ui/view_ids.h" | 
|  | 20 #include "chrome/browser/ui/views/bar_control_button.h" | 
| 20 #include "chrome/browser/ui/views/find_bar_host.h" | 21 #include "chrome/browser/ui/views/find_bar_host.h" | 
| 21 #include "chrome/browser/ui/views/frame/browser_view.h" | 22 #include "chrome/browser/ui/views/frame/browser_view.h" | 
| 22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" | 
| 23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" | 
| 24 #include "third_party/skia/include/core/SkPaint.h" | 25 #include "third_party/skia/include/core/SkPaint.h" | 
| 25 #include "ui/base/ime/input_method.h" | 26 #include "ui/base/ime/input_method.h" | 
| 26 #include "ui/base/ime/text_input_flags.h" | 27 #include "ui/base/ime/text_input_flags.h" | 
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" | 
| 28 #include "ui/base/resource/material_design/material_design_controller.h" | 29 #include "ui/base/resource/material_design/material_design_controller.h" | 
| 29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" | 
| 30 #include "ui/base/theme_provider.h" | 31 #include "ui/base/theme_provider.h" | 
| 31 #include "ui/events/event.h" | 32 #include "ui/events/event.h" | 
| 32 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" | 
| 33 #include "ui/gfx/color_palette.h" | 34 #include "ui/gfx/color_palette.h" | 
| 34 #include "ui/gfx/paint_vector_icon.h" | 35 #include "ui/gfx/paint_vector_icon.h" | 
| 35 #include "ui/gfx/vector_icons_public.h" | 36 #include "ui/gfx/vector_icons_public.h" | 
| 36 #include "ui/native_theme/common_theme.h" | 37 #include "ui/native_theme/common_theme.h" | 
| 37 #include "ui/native_theme/native_theme.h" | 38 #include "ui/native_theme/native_theme.h" | 
| 38 #include "ui/resources/grit/ui_resources.h" | 39 #include "ui/resources/grit/ui_resources.h" | 
| 39 #include "ui/views/animation/ink_drop_animation_controller.h" |  | 
| 40 #include "ui/views/animation/ink_drop_animation_controller_factory.h" |  | 
| 41 #include "ui/views/animation/ink_drop_host.h" |  | 
| 42 #include "ui/views/background.h" | 40 #include "ui/views/background.h" | 
| 43 #include "ui/views/border.h" | 41 #include "ui/views/border.h" | 
| 44 #include "ui/views/bubble/bubble_border.h" | 42 #include "ui/views/bubble/bubble_border.h" | 
| 45 #include "ui/views/controls/button/image_button.h" | 43 #include "ui/views/controls/button/image_button.h" | 
| 46 #include "ui/views/controls/label.h" | 44 #include "ui/views/controls/label.h" | 
| 47 #include "ui/views/controls/separator.h" | 45 #include "ui/views/controls/separator.h" | 
| 48 #include "ui/views/layout/box_layout.h" | 46 #include "ui/views/layout/box_layout.h" | 
| 49 #include "ui/views/painter.h" | 47 #include "ui/views/painter.h" | 
| 50 #include "ui/views/view_targeter.h" | 48 #include "ui/views/view_targeter.h" | 
| 51 #include "ui/views/widget/widget.h" | 49 #include "ui/views/widget/widget.h" | 
| 52 | 50 | 
| 53 namespace { | 51 namespace { | 
| 54 | 52 | 
| 55 // The margins around the UI controls, derived from assets and design specs. | 53 // The margins around the UI controls, derived from assets and design specs. | 
| 56 const int kMarginLeftOfCloseButton = 3; | 54 const int kMarginLeftOfCloseButton = 3; | 
| 57 const int kMarginRightOfCloseButton = 7; | 55 const int kMarginRightOfCloseButton = 7; | 
| 58 const int kMarginLeftOfMatchCountLabel = 3; | 56 const int kMarginLeftOfMatchCountLabel = 3; | 
| 59 const int kMarginRightOfMatchCountLabel = 1; | 57 const int kMarginRightOfMatchCountLabel = 1; | 
| 60 const int kMarginLeftOfFindTextfield = 12; | 58 const int kMarginLeftOfFindTextfield = 12; | 
| 61 const int kMarginVerticalFindTextfield = 6; | 59 const int kMarginVerticalFindTextfield = 6; | 
| 62 | 60 | 
| 63 // Constants for the MD layout, all in dp. | 61 // Constants for the MD layout, all in dp. | 
| 64 // The horizontal and vertical insets for the bar. | 62 // The horizontal and vertical insets for the bar. | 
| 65 const int kInteriorPadding = 8; | 63 const int kInteriorPadding = 8; | 
| 66 // Default spacing between child views. | 64 // Default spacing between child views. | 
| 67 const int kInterChildSpacing = 4; | 65 const int kInterChildSpacing = 4; | 
| 68 // Additional spacing around the separator. | 66 // Additional spacing around the separator. | 
| 69 const int kSeparatorLeftSpacing = 12 - kInterChildSpacing; | 67 const int kSeparatorLeftSpacing = 12 - kInterChildSpacing; | 
| 70 const int kSeparatorRightSpacing = 8 - kInterChildSpacing; | 68 const int kSeparatorRightSpacing = 8 - kInterChildSpacing; | 
| 71 // Extra space around the buttons to increase their event target size. |  | 
| 72 const int kButtonExtraTouchSize = 4; |  | 
| 73 | 69 | 
| 74 // The margins around the match count label (We add extra space so that the | 70 // The margins around the match count label (We add extra space so that the | 
| 75 // background highlight extends beyond just the text). | 71 // background highlight extends beyond just the text). | 
| 76 const int kMatchCountExtraWidth = 9; | 72 const int kMatchCountExtraWidth = 9; | 
| 77 | 73 | 
| 78 // Minimum width for the match count label. | 74 // Minimum width for the match count label. | 
| 79 const int kMatchCountMinWidth = 30; | 75 const int kMatchCountMinWidth = 30; | 
| 80 | 76 | 
| 81 // The text color for the match count label. | 77 // The text color for the match count label. | 
| 82 const SkColor kTextColorMatchCount = SkColorSetRGB(178, 178, 178); | 78 const SkColor kTextColorMatchCount = SkColorSetRGB(178, 178, 178); | 
| 83 | 79 | 
| 84 // The text color for the match count label when no matches are found. | 80 // The text color for the match count label when no matches are found. | 
| 85 const SkColor kTextColorNoMatch = SK_ColorBLACK; | 81 const SkColor kTextColorNoMatch = SK_ColorBLACK; | 
| 86 | 82 | 
| 87 // The background color of the match count label when results are found. | 83 // The background color of the match count label when results are found. | 
| 88 const SkColor kBackgroundColorMatch = SkColorSetARGB(0, 255, 255, 255); | 84 const SkColor kBackgroundColorMatch = SkColorSetARGB(0, 255, 255, 255); | 
| 89 | 85 | 
| 90 // The background color of the match count label when no results are found. | 86 // The background color of the match count label when no results are found. | 
| 91 const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); | 87 const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); | 
| 92 | 88 | 
| 93 // The color of the match count label for Material Design. |  | 
| 94 const SkColor kMatchTextColorMD = SkColorSetRGB(0x96, 0x96, 0x96); |  | 
| 95 |  | 
| 96 // Color of the vertical separator between match count and buttons. (MD only.) |  | 
| 97 const SkColor kSeparatorColor = SkColorSetARGB(0x26, 0, 0, 0); |  | 
| 98 |  | 
| 99 // The default number of average characters that the text box will be. This | 89 // The default number of average characters that the text box will be. This | 
| 100 // number brings the width on a "regular fonts" system to about 300px. | 90 // number brings the width on a "regular fonts" system to about 300px. | 
| 101 const int kDefaultCharWidth = 43; | 91 const int kDefaultCharWidth = 43; | 
| 102 | 92 | 
| 103 class FindBarButton : public views::ImageButton, public views::InkDropHost { |  | 
| 104  public: |  | 
| 105   explicit FindBarButton(views::ButtonListener* listener); |  | 
| 106   ~FindBarButton() override; |  | 
| 107 |  | 
| 108  private: |  | 
| 109   void Layout() override; |  | 
| 110   void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |  | 
| 111   void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; |  | 
| 112   bool OnMousePressed(const ui::MouseEvent& event) override; |  | 
| 113   void OnGestureEvent(ui::GestureEvent* event) override; |  | 
| 114   void OnMouseReleased(const ui::MouseEvent& event) override; |  | 
| 115   void NotifyClick(const ui::Event& event) override; |  | 
| 116 |  | 
| 117   // Animation controller for the ink drop ripple effect. |  | 
| 118   scoped_ptr<views::InkDropAnimationController> ink_drop_animation_controller_; |  | 
| 119 |  | 
| 120   DISALLOW_COPY_AND_ASSIGN(FindBarButton); |  | 
| 121 }; |  | 
| 122 |  | 
| 123 // The match count label is like a normal label, but can process events (which | 93 // The match count label is like a normal label, but can process events (which | 
| 124 // makes it easier to forward events to the text input --- see | 94 // makes it easier to forward events to the text input --- see | 
| 125 // FindBarView::TargetForRect). | 95 // FindBarView::TargetForRect). | 
| 126 class MatchCountLabel : public views::Label { | 96 class MatchCountLabel : public views::Label { | 
| 127  public: | 97  public: | 
| 128   MatchCountLabel() {} | 98   MatchCountLabel() {} | 
| 129   ~MatchCountLabel() override {} | 99   ~MatchCountLabel() override {} | 
| 130 | 100 | 
| 131   // views::Label overrides: | 101   // views::Label overrides: | 
| 132   bool CanProcessEventsWithinSubtree() const override { return true; } | 102   bool CanProcessEventsWithinSubtree() const override { return true; } | 
| 133 | 103 | 
| 134  private: | 104  private: | 
| 135   DISALLOW_COPY_AND_ASSIGN(MatchCountLabel); | 105   DISALLOW_COPY_AND_ASSIGN(MatchCountLabel); | 
| 136 }; | 106 }; | 
| 137 | 107 | 
| 138 }  // namespace | 108 }  // namespace | 
| 139 | 109 | 
| 140 //////////////////////////////////////////////////////////////////////////////// | 110 //////////////////////////////////////////////////////////////////////////////// | 
| 141 // FindBarButton, public: |  | 
| 142 |  | 
| 143 FindBarButton::FindBarButton(views::ButtonListener* listener) |  | 
| 144     : views::ImageButton(listener), |  | 
| 145       ink_drop_animation_controller_( |  | 
| 146           views::InkDropAnimationControllerFactory:: |  | 
| 147               CreateInkDropAnimationController(this)) { |  | 
| 148   const int kInkDropLargeSize = 32; |  | 
| 149   const int kInkDropLargeCornerRadius = 4; |  | 
| 150   const int kInkDropSmallSize = 24; |  | 
| 151   const int kInkDropSmallCornerRadius = 2; |  | 
| 152 |  | 
| 153   ink_drop_animation_controller_->SetInkDropSize( |  | 
| 154       gfx::Size(kInkDropLargeSize, kInkDropLargeSize), |  | 
| 155       kInkDropLargeCornerRadius, |  | 
| 156       gfx::Size(kInkDropSmallSize, kInkDropSmallSize), |  | 
| 157       kInkDropSmallCornerRadius); |  | 
| 158 } |  | 
| 159 |  | 
| 160 FindBarButton::~FindBarButton() {} |  | 
| 161 |  | 
| 162 //////////////////////////////////////////////////////////////////////////////// |  | 
| 163 // FindBarButton, private: |  | 
| 164 |  | 
| 165 void FindBarButton::Layout() { |  | 
| 166   ImageButton::Layout(); |  | 
| 167 |  | 
| 168   ink_drop_animation_controller_->SetInkDropCenter( |  | 
| 169       GetLocalBounds().CenterPoint()); |  | 
| 170 } |  | 
| 171 |  | 
| 172 void FindBarButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |  | 
| 173   SetPaintToLayer(true); |  | 
| 174   SetFillsBoundsOpaquely(false); |  | 
| 175   layer()->Add(ink_drop_layer); |  | 
| 176   layer()->StackAtBottom(ink_drop_layer); |  | 
| 177 } |  | 
| 178 |  | 
| 179 void FindBarButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |  | 
| 180   layer()->Remove(ink_drop_layer); |  | 
| 181   SetFillsBoundsOpaquely(true); |  | 
| 182   SetPaintToLayer(false); |  | 
| 183 } |  | 
| 184 |  | 
| 185 bool FindBarButton::OnMousePressed(const ui::MouseEvent& event) { |  | 
| 186   if (IsTriggerableEvent(event)) { |  | 
| 187     ink_drop_animation_controller_->AnimateToState( |  | 
| 188         views::InkDropState::ACTION_PENDING); |  | 
| 189   } |  | 
| 190 |  | 
| 191   return ImageButton::OnMousePressed(event); |  | 
| 192 } |  | 
| 193 |  | 
| 194 void FindBarButton::OnGestureEvent(ui::GestureEvent* event) { |  | 
| 195   views::InkDropState ink_drop_state = views::InkDropState::HIDDEN; |  | 
| 196   switch (event->type()) { |  | 
| 197     case ui::ET_GESTURE_TAP_DOWN: |  | 
| 198       ink_drop_state = views::InkDropState::ACTION_PENDING; |  | 
| 199       // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so |  | 
| 200       // that subsequent events for the gesture are sent to |this|. |  | 
| 201       event->SetHandled(); |  | 
| 202       break; |  | 
| 203     case ui::ET_GESTURE_LONG_PRESS: |  | 
| 204       ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; |  | 
| 205       break; |  | 
| 206     case ui::ET_GESTURE_TAP: |  | 
| 207       ink_drop_state = views::InkDropState::QUICK_ACTION; |  | 
| 208       break; |  | 
| 209     case ui::ET_GESTURE_LONG_TAP: |  | 
| 210       ink_drop_state = views::InkDropState::SLOW_ACTION; |  | 
| 211       break; |  | 
| 212     case ui::ET_GESTURE_END: |  | 
| 213     case ui::ET_GESTURE_TAP_CANCEL: |  | 
| 214       ink_drop_state = views::InkDropState::HIDDEN; |  | 
| 215       break; |  | 
| 216     default: |  | 
| 217       return; |  | 
| 218   } |  | 
| 219   ink_drop_animation_controller_->AnimateToState(ink_drop_state); |  | 
| 220 |  | 
| 221   ImageButton::OnGestureEvent(event); |  | 
| 222 } |  | 
| 223 |  | 
| 224 void FindBarButton::OnMouseReleased(const ui::MouseEvent& event) { |  | 
| 225   if (!HitTestPoint(event.location())) |  | 
| 226     ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); |  | 
| 227 |  | 
| 228   ImageButton::OnMouseReleased(event); |  | 
| 229 } |  | 
| 230 |  | 
| 231 void FindBarButton::NotifyClick(const ui::Event& event) { |  | 
| 232   ink_drop_animation_controller_->AnimateToState( |  | 
| 233       views::InkDropState::QUICK_ACTION); |  | 
| 234 |  | 
| 235   ImageButton::NotifyClick(event); |  | 
| 236 } |  | 
| 237 |  | 
| 238 //////////////////////////////////////////////////////////////////////////////// |  | 
| 239 // FindBarView, public: | 111 // FindBarView, public: | 
| 240 | 112 | 
| 241 FindBarView::FindBarView(FindBarHost* host) | 113 FindBarView::FindBarView(FindBarHost* host) | 
| 242     : DropdownBarView(host), | 114     : DropdownBarView(host), | 
| 243       find_text_(NULL), | 115       find_text_(nullptr), | 
| 244       match_count_text_(NULL), | 116       match_count_text_(nullptr), | 
| 245       focus_forwarder_view_(NULL), | 117       focus_forwarder_view_(nullptr), | 
| 246       find_previous_button_(NULL), | 118       separator_(nullptr), | 
| 247       find_next_button_(NULL), | 119       find_previous_button_(nullptr), | 
| 248       close_button_(NULL) { | 120       find_next_button_(nullptr), | 
|  | 121       close_button_(nullptr) { | 
| 249   find_text_ = new views::Textfield; | 122   find_text_ = new views::Textfield; | 
| 250   find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 123   find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 
| 251   find_text_->set_default_width_in_chars(kDefaultCharWidth); | 124   find_text_->set_default_width_in_chars(kDefaultCharWidth); | 
| 252   find_text_->set_controller(this); | 125   find_text_->set_controller(this); | 
| 253   find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); | 126   find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); | 
| 254   find_text_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF); | 127   find_text_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF); | 
| 255   AddChildView(find_text_); | 128   AddChildView(find_text_); | 
| 256 | 129 | 
| 257   find_previous_button_ = new FindBarButton(this); | 130   if (ui::MaterialDesignController::IsModeMaterial()) { | 
|  | 131     BarControlButton* find_previous = new BarControlButton(this); | 
|  | 132     find_previous->SetIcon( | 
|  | 133         gfx::VectorIconId::FIND_PREV, | 
|  | 134         base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); | 
|  | 135     BarControlButton* find_next = new BarControlButton(this); | 
|  | 136     find_next->SetIcon( | 
|  | 137         gfx::VectorIconId::FIND_NEXT, | 
|  | 138         base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); | 
|  | 139     BarControlButton* close = new BarControlButton(this); | 
|  | 140     close->SetIcon( | 
|  | 141         gfx::VectorIconId::BAR_CLOSE, | 
|  | 142         base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); | 
|  | 143 | 
|  | 144     find_previous_button_ = find_previous; | 
|  | 145     find_next_button_ = find_next; | 
|  | 146     close_button_ = close; | 
|  | 147   } else { | 
|  | 148     find_previous_button_ = new views::ImageButton(this); | 
|  | 149     find_next_button_ = new views::ImageButton(this); | 
|  | 150     close_button_ = new views::ImageButton(this); | 
|  | 151   } | 
|  | 152 | 
| 258   find_previous_button_->set_tag(FIND_PREVIOUS_TAG); | 153   find_previous_button_->set_tag(FIND_PREVIOUS_TAG); | 
| 259   find_previous_button_->SetFocusable(true); | 154   find_previous_button_->SetFocusable(true); | 
| 260   find_previous_button_->set_request_focus_on_press(false); | 155   find_previous_button_->set_request_focus_on_press(false); | 
| 261   find_previous_button_->SetTooltipText( | 156   find_previous_button_->SetTooltipText( | 
| 262       l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); | 157       l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); | 
| 263   find_previous_button_->SetAccessibleName( | 158   find_previous_button_->SetAccessibleName( | 
| 264       l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); | 159       l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); | 
| 265   AddChildView(find_previous_button_); | 160   AddChildView(find_previous_button_); | 
| 266 | 161 | 
| 267   find_next_button_ = new FindBarButton(this); |  | 
| 268   find_next_button_->set_tag(FIND_NEXT_TAG); | 162   find_next_button_->set_tag(FIND_NEXT_TAG); | 
| 269   find_next_button_->SetFocusable(true); | 163   find_next_button_->SetFocusable(true); | 
| 270   find_next_button_->set_request_focus_on_press(false); | 164   find_next_button_->set_request_focus_on_press(false); | 
| 271   find_next_button_->SetTooltipText( | 165   find_next_button_->SetTooltipText( | 
| 272       l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); | 166       l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); | 
| 273   find_next_button_->SetAccessibleName( | 167   find_next_button_->SetAccessibleName( | 
| 274       l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); | 168       l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); | 
| 275   AddChildView(find_next_button_); | 169   AddChildView(find_next_button_); | 
| 276 | 170 | 
| 277   close_button_ = new FindBarButton(this); |  | 
| 278   close_button_->set_tag(CLOSE_TAG); | 171   close_button_->set_tag(CLOSE_TAG); | 
| 279   close_button_->SetFocusable(true); | 172   close_button_->SetFocusable(true); | 
| 280   close_button_->set_request_focus_on_press(false); | 173   close_button_->set_request_focus_on_press(false); | 
| 281   close_button_->SetTooltipText( | 174   close_button_->SetTooltipText( | 
| 282       l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); | 175       l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); | 
| 283   close_button_->SetAccessibleName( | 176   close_button_->SetAccessibleName( | 
| 284       l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 177       l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 
| 285   close_button_->SetAnimationDuration(0); | 178   close_button_->SetAnimationDuration(0); | 
| 286   AddChildView(close_button_); | 179   AddChildView(close_button_); | 
| 287 | 180 | 
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 648   // The background color is not used since there's no arrow. | 541   // The background color is not used since there's no arrow. | 
| 649   SetBorder(make_scoped_ptr(new views::BubbleBorder( | 542   SetBorder(make_scoped_ptr(new views::BubbleBorder( | 
| 650       views::BubbleBorder::NONE, views::BubbleBorder::SMALL_SHADOW, | 543       views::BubbleBorder::NONE, views::BubbleBorder::SMALL_SHADOW, | 
| 651       SK_ColorGREEN))); | 544       SK_ColorGREEN))); | 
| 652 | 545 | 
| 653   match_count_text_ = new MatchCountLabel(); | 546   match_count_text_ = new MatchCountLabel(); | 
| 654   match_count_text_->SetEventTargeter( | 547   match_count_text_->SetEventTargeter( | 
| 655       make_scoped_ptr(new views::ViewTargeter(this))); | 548       make_scoped_ptr(new views::ViewTargeter(this))); | 
| 656   AddChildViewAt(match_count_text_, 1); | 549   AddChildViewAt(match_count_text_, 1); | 
| 657 | 550 | 
| 658   views::Separator* separator = | 551   separator_ = new views::Separator(views::Separator::VERTICAL); | 
| 659       new views::Separator(views::Separator::VERTICAL); | 552   separator_->SetBorder(views::Border::CreateEmptyBorder( | 
| 660   separator->SetColor(kSeparatorColor); |  | 
| 661   separator->SetBorder(views::Border::CreateEmptyBorder( |  | 
| 662       0, kSeparatorLeftSpacing, 0, kSeparatorRightSpacing)); | 553       0, kSeparatorLeftSpacing, 0, kSeparatorRightSpacing)); | 
| 663   AddChildViewAt(separator, 2); | 554   AddChildViewAt(separator_, 2); | 
| 664 | 555 | 
| 665   find_text_->SetBorder(views::Border::NullBorder()); | 556   find_text_->SetBorder(views::Border::NullBorder()); | 
| 666 | 557 | 
| 667   struct { |  | 
| 668     views::ImageButton* button; |  | 
| 669     gfx::VectorIconId id; |  | 
| 670   } button_images[] = { |  | 
| 671       {find_previous_button_, gfx::VectorIconId::FIND_PREV}, |  | 
| 672       {find_next_button_, gfx::VectorIconId::FIND_NEXT}, |  | 
| 673       {close_button_, gfx::VectorIconId::BAR_CLOSE}, |  | 
| 674   }; |  | 
| 675 |  | 
| 676   for (size_t i = 0; i < arraysize(button_images); ++i) { |  | 
| 677     views::ImageButton* button = button_images[i].button; |  | 
| 678     button->SetBorder(views::Border::CreateEmptyBorder( |  | 
| 679         kButtonExtraTouchSize, kButtonExtraTouchSize, kButtonExtraTouchSize, |  | 
| 680         kButtonExtraTouchSize)); |  | 
| 681     button->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |  | 
| 682                               views::ImageButton::ALIGN_MIDDLE); |  | 
| 683 |  | 
| 684     gfx::ImageSkia image = |  | 
| 685         gfx::CreateVectorIcon(button_images[i].id, 16, gfx::kChromeIconGrey); |  | 
| 686     button->SetImage(views::CustomButton::STATE_NORMAL, &image); |  | 
| 687     image = gfx::CreateVectorIcon(button_images[i].id, 16, |  | 
| 688                                   SkColorSetA(gfx::kChromeIconGrey, 0xff / 2)); |  | 
| 689     button->SetImage(views::CustomButton::STATE_DISABLED, &image); |  | 
| 690   } |  | 
| 691 |  | 
| 692   views::BoxLayout* manager = | 558   views::BoxLayout* manager = | 
| 693       new views::BoxLayout(views::BoxLayout::kHorizontal, kInteriorPadding, | 559       new views::BoxLayout(views::BoxLayout::kHorizontal, kInteriorPadding, | 
| 694                            kInteriorPadding, kInterChildSpacing); | 560                            kInteriorPadding, kInterChildSpacing); | 
| 695   SetLayoutManager(manager); | 561   SetLayoutManager(manager); | 
| 696   manager->SetFlexForView(find_text_, 1); | 562   manager->SetFlexForView(find_text_, 1); | 
| 697 } | 563 } | 
| 698 | 564 | 
| 699 void FindBarView::Find(const base::string16& search_text) { | 565 void FindBarView::Find(const base::string16& search_text) { | 
| 700   FindBarController* controller = find_bar_host()->GetFindBarController(); | 566   FindBarController* controller = find_bar_host()->GetFindBarController(); | 
| 701   DCHECK(controller); | 567   DCHECK(controller); | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 774         GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 640         GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 
| 775         rb.GetImageSkiaNamed(IDR_CLOSE_1), | 641         rb.GetImageSkiaNamed(IDR_CLOSE_1), | 
| 776         rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 642         rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 
| 777   } | 643   } | 
| 778 } | 644 } | 
| 779 | 645 | 
| 780 void FindBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 646 void FindBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 
| 781   if (!ui::MaterialDesignController::IsModeMaterial()) | 647   if (!ui::MaterialDesignController::IsModeMaterial()) | 
| 782     return; | 648     return; | 
| 783 | 649 | 
| 784   SkColor color = | 650   SkColor bg_color = theme->GetSystemColor( | 
| 785       theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 651       ui::NativeTheme::kColorId_TextfieldDefaultBackground); | 
| 786   set_background(views::Background::CreateSolidBackground(color)); | 652   set_background(views::Background::CreateSolidBackground(bg_color)); | 
| 787   match_count_text_->SetBackgroundColor(color); | 653   match_count_text_->SetBackgroundColor(bg_color); | 
| 788   match_count_text_->SetEnabledColor(kMatchTextColorMD); | 654 | 
|  | 655   SkColor text_color = | 
|  | 656       theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); | 
|  | 657   match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); | 
|  | 658   separator_->SetColor(SkColorSetA(text_color, 0x26)); | 
| 789 } | 659 } | 
|  | 660 | 
|  | 661 SkColor FindBarView::GetTextColorForIcon() { | 
|  | 662   return GetNativeTheme()->GetSystemColor( | 
|  | 663       ui::NativeTheme::kColorId_TextfieldDefaultColor); | 
|  | 664 } | 
| OLD | NEW | 
|---|