| 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/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/theme_properties.h" | 15 #include "chrome/browser/themes/theme_properties.h" |
| 16 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 16 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 17 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 17 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 18 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | 18 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" |
| 19 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 19 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 20 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 20 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 21 #include "chrome/browser/ui/view_ids.h" | 21 #include "chrome/browser/ui/view_ids.h" |
| 22 #include "chrome/browser/ui/views/bar_control_button.h" | |
| 23 #include "chrome/browser/ui/views/find_bar_host.h" | 22 #include "chrome/browser/ui/views/find_bar_host.h" |
| 24 #include "chrome/browser/ui/views/frame/browser_view.h" | 23 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 25 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
| 26 #include "chrome/grit/theme_resources.h" | 25 #include "chrome/grit/theme_resources.h" |
| 27 #include "components/strings/grit/components_strings.h" | 26 #include "components/strings/grit/components_strings.h" |
| 28 #include "third_party/skia/include/core/SkPaint.h" | 27 #include "third_party/skia/include/core/SkPaint.h" |
| 29 #include "ui/base/ime/input_method.h" | 28 #include "ui/base/ime/input_method.h" |
| 30 #include "ui/base/ime/text_input_flags.h" | 29 #include "ui/base/ime/text_input_flags.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/material_design/material_design_controller.h" | 31 #include "ui/base/material_design/material_design_controller.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/base/theme_provider.h" | 33 #include "ui/base/theme_provider.h" |
| 35 #include "ui/events/event.h" | 34 #include "ui/events/event.h" |
| 36 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 37 #include "ui/gfx/color_palette.h" | 36 #include "ui/gfx/color_palette.h" |
| 38 #include "ui/gfx/paint_vector_icon.h" | 37 #include "ui/gfx/paint_vector_icon.h" |
| 39 #include "ui/gfx/vector_icons_public.h" | 38 #include "ui/gfx/vector_icons_public.h" |
| 40 #include "ui/native_theme/common_theme.h" | 39 #include "ui/native_theme/common_theme.h" |
| 41 #include "ui/native_theme/native_theme.h" | 40 #include "ui/native_theme/native_theme.h" |
| 42 #include "ui/resources/grit/ui_resources.h" | 41 #include "ui/resources/grit/ui_resources.h" |
| 43 #include "ui/views/background.h" | 42 #include "ui/views/background.h" |
| 44 #include "ui/views/border.h" | 43 #include "ui/views/border.h" |
| 45 #include "ui/views/bubble/bubble_border.h" | 44 #include "ui/views/bubble/bubble_border.h" |
| 46 #include "ui/views/controls/button/image_button.h" | 45 #include "ui/views/controls/button/image_button.h" |
| 46 #include "ui/views/controls/button/vector_icon_button.h" |
| 47 #include "ui/views/controls/label.h" | 47 #include "ui/views/controls/label.h" |
| 48 #include "ui/views/controls/separator.h" | 48 #include "ui/views/controls/separator.h" |
| 49 #include "ui/views/layout/box_layout.h" | 49 #include "ui/views/layout/box_layout.h" |
| 50 #include "ui/views/painter.h" | 50 #include "ui/views/painter.h" |
| 51 #include "ui/views/view_targeter.h" | 51 #include "ui/views/view_targeter.h" |
| 52 #include "ui/views/widget/widget.h" | 52 #include "ui/views/widget/widget.h" |
| 53 | 53 |
| 54 namespace { | 54 namespace { |
| 55 | 55 |
| 56 // The margins around the UI controls, derived from assets and design specs. | 56 // The margins around the UI controls, derived from assets and design specs. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 135 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
| 136 find_text_->set_default_width_in_chars( | 136 find_text_->set_default_width_in_chars( |
| 137 ui::MaterialDesignController::IsModeMaterial() ? kDefaultCharWidthMd | 137 ui::MaterialDesignController::IsModeMaterial() ? kDefaultCharWidthMd |
| 138 : kDefaultCharWidth); | 138 : kDefaultCharWidth); |
| 139 find_text_->set_controller(this); | 139 find_text_->set_controller(this); |
| 140 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); | 140 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); |
| 141 find_text_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF); | 141 find_text_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF); |
| 142 AddChildView(find_text_); | 142 AddChildView(find_text_); |
| 143 | 143 |
| 144 if (ui::MaterialDesignController::IsModeMaterial()) { | 144 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 145 BarControlButton* find_previous = new BarControlButton(this); | 145 views::VectorIconButton* find_previous = new views::VectorIconButton(this); |
| 146 find_previous->SetIcon( | 146 find_previous->SetIcon( |
| 147 gfx::VectorIconId::FIND_PREV, | 147 gfx::VectorIconId::FIND_PREV, |
| 148 base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); | 148 base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); |
| 149 BarControlButton* find_next = new BarControlButton(this); | 149 views::VectorIconButton* find_next = new views::VectorIconButton(this); |
| 150 find_next->SetIcon( | 150 find_next->SetIcon( |
| 151 gfx::VectorIconId::FIND_NEXT, | 151 gfx::VectorIconId::FIND_NEXT, |
| 152 base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); | 152 base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); |
| 153 BarControlButton* close = new BarControlButton(this); | 153 views::VectorIconButton* close = new views::VectorIconButton(this); |
| 154 close->SetIcon( | 154 close->SetIcon( |
| 155 gfx::VectorIconId::BAR_CLOSE, | 155 gfx::VectorIconId::BAR_CLOSE, |
| 156 base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); | 156 base::Bind(&FindBarView::GetTextColorForIcon, base::Unretained(this))); |
| 157 | 157 |
| 158 find_previous_button_ = find_previous; | 158 find_previous_button_ = find_previous; |
| 159 find_next_button_ = find_next; | 159 find_next_button_ = find_next; |
| 160 close_button_ = close; | 160 close_button_ = close; |
| 161 } else { | 161 } else { |
| 162 find_previous_button_ = new views::ImageButton(this); | 162 find_previous_button_ = new views::ImageButton(this); |
| 163 find_next_button_ = new views::ImageButton(this); | 163 find_next_button_ = new views::ImageButton(this); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 SkColor text_color = | 663 SkColor text_color = |
| 664 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); | 664 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 665 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); | 665 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); |
| 666 separator_->SetColor(SkColorSetA(text_color, 0x26)); | 666 separator_->SetColor(SkColorSetA(text_color, 0x26)); |
| 667 } | 667 } |
| 668 | 668 |
| 669 SkColor FindBarView::GetTextColorForIcon() { | 669 SkColor FindBarView::GetTextColorForIcon() { |
| 670 return GetNativeTheme()->GetSystemColor( | 670 return GetNativeTheme()->GetSystemColor( |
| 671 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 671 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 672 } | 672 } |
| OLD | NEW |