| 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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // The background color of the match count label when results are found. | 57 // The background color of the match count label when results are found. |
| 58 static const SkColor kBackgroundColorMatch = SkColorSetARGB(0, 255, 255, 255); | 58 static const SkColor kBackgroundColorMatch = SkColorSetARGB(0, 255, 255, 255); |
| 59 | 59 |
| 60 // The background color of the match count label when no results are found. | 60 // The background color of the match count label when no results are found. |
| 61 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); | 61 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); |
| 62 | 62 |
| 63 // The default number of average characters that the text box will be. This | 63 // The default number of average characters that the text box will be. This |
| 64 // number brings the width on a "regular fonts" system to about 300px. | 64 // number brings the width on a "regular fonts" system to about 300px. |
| 65 static const int kDefaultCharWidth = 43; | 65 static const int kDefaultCharWidth = 43; |
| 66 | 66 |
| 67 #if defined(OS_CHROMEOS) | |
| 68 // The background color of the find box. | |
| 69 static const SkColor kFindBoxBackgroundColor = SkColorSetARGB(0, 255, 255, 255); | |
| 70 #endif | |
| 71 | |
| 72 //////////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////////// |
| 73 // FindBarView, public: | 68 // FindBarView, public: |
| 74 | 69 |
| 75 FindBarView::FindBarView(FindBarHost* host) | 70 FindBarView::FindBarView(FindBarHost* host) |
| 76 : DropdownBarView(host), | 71 : DropdownBarView(host), |
| 77 find_text_(NULL), | 72 find_text_(NULL), |
| 78 match_count_text_(NULL), | 73 match_count_text_(NULL), |
| 79 focus_forwarder_view_(NULL), | 74 focus_forwarder_view_(NULL), |
| 80 find_previous_button_(NULL), | 75 find_previous_button_(NULL), |
| 81 find_next_button_(NULL), | 76 find_next_button_(NULL), |
| 82 close_button_(NULL), | 77 close_button_(NULL), |
| 83 text_box_background_(NULL), | 78 text_box_background_(NULL), |
| 84 text_box_background_left_(NULL) { | 79 text_box_background_left_(NULL) { |
| 85 set_id(VIEW_ID_FIND_IN_PAGE); | 80 set_id(VIEW_ID_FIND_IN_PAGE); |
| 86 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 87 | 82 |
| 88 find_text_ = new SearchTextfieldView(); | 83 find_text_ = new SearchTextfieldView(); |
| 89 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 84 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
| 90 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 85 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 91 find_text_->set_default_width_in_chars(kDefaultCharWidth); | 86 find_text_->set_default_width_in_chars(kDefaultCharWidth); |
| 92 find_text_->SetController(this); | 87 find_text_->SetController(this); |
| 93 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); | 88 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); |
| 94 | 89 |
| 95 #if defined(OS_CHROMEOS) | |
| 96 // Use a transparent background on ChromeOS as the theme image for the find | |
| 97 // box uses a partially transparent background. | |
| 98 find_text_->SetBackgroundColor(kFindBoxBackgroundColor); | |
| 99 #endif | |
| 100 | |
| 101 AddChildView(find_text_); | 90 AddChildView(find_text_); |
| 102 | 91 |
| 103 match_count_text_ = new views::Label(); | 92 match_count_text_ = new views::Label(); |
| 104 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 93 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 105 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); | 94 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); |
| 106 AddChildView(match_count_text_); | 95 AddChildView(match_count_text_); |
| 107 | 96 |
| 108 // Create a focus forwarder view which sends focus to find_text_. | 97 // Create a focus forwarder view which sends focus to find_text_. |
| 109 focus_forwarder_view_ = new FocusForwarderView(find_text_); | 98 focus_forwarder_view_ = new FocusForwarderView(find_text_); |
| 110 AddChildView(focus_forwarder_view_); | 99 AddChildView(focus_forwarder_view_); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 139 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_D)); | 128 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_D)); |
| 140 find_next_button_->SetTooltipText( | 129 find_next_button_->SetTooltipText( |
| 141 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); | 130 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); |
| 142 find_next_button_->SetAccessibleName( | 131 find_next_button_->SetAccessibleName( |
| 143 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); | 132 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); |
| 144 AddChildView(find_next_button_); | 133 AddChildView(find_next_button_); |
| 145 | 134 |
| 146 close_button_ = new views::ImageButton(this); | 135 close_button_ = new views::ImageButton(this); |
| 147 close_button_->set_tag(CLOSE_TAG); | 136 close_button_->set_tag(CLOSE_TAG); |
| 148 close_button_->set_focusable(true); | 137 close_button_->set_focusable(true); |
| 149 #if defined(OS_CHROMEOS) | |
| 150 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 138 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 151 rb.GetImageSkiaNamed(IDR_TAB_CLOSE)); | 139 rb.GetImageSkiaNamed(IDR_TAB_CLOSE)); |
| 152 close_button_->SetImage(views::CustomButton::BS_HOT, | 140 close_button_->SetImage(views::CustomButton::BS_HOT, |
| 153 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_H)); | 141 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_H)); |
| 154 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 142 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 155 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_P)); | 143 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_P)); |
| 156 #else | |
| 157 close_button_->SetImage(views::CustomButton::BS_NORMAL, | |
| 158 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); | |
| 159 close_button_->SetImage(views::CustomButton::BS_HOT, | |
| 160 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); | |
| 161 close_button_->SetImage(views::CustomButton::BS_PUSHED, | |
| 162 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); | |
| 163 #endif | |
| 164 close_button_->SetTooltipText( | 144 close_button_->SetTooltipText( |
| 165 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); | 145 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); |
| 166 close_button_->SetAccessibleName( | 146 close_button_->SetAccessibleName( |
| 167 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 147 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
| 168 AddChildView(close_button_); | 148 AddChildView(close_button_); |
| 169 | 149 |
| 170 SetBackground(rb.GetImageSkiaNamed(IDR_FIND_DLG_LEFT_BACKGROUND), | 150 SetBackground(rb.GetImageSkiaNamed(IDR_FIND_DLG_LEFT_BACKGROUND), |
| 171 rb.GetImageSkiaNamed(IDR_FIND_DLG_RIGHT_BACKGROUND)); | 151 rb.GetImageSkiaNamed(IDR_FIND_DLG_RIGHT_BACKGROUND)); |
| 172 | 152 |
| 173 SetBorder(IDR_FIND_DIALOG_LEFT, IDR_FIND_DIALOG_MIDDLE, | 153 SetBorder(IDR_FIND_DIALOG_LEFT, IDR_FIND_DIALOG_MIDDLE, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 SelectAll(true); | 487 SelectAll(true); |
| 508 } | 488 } |
| 509 | 489 |
| 510 FindBarHost* FindBarView::find_bar_host() const { | 490 FindBarHost* FindBarView::find_bar_host() const { |
| 511 return static_cast<FindBarHost*>(host()); | 491 return static_cast<FindBarHost*>(host()); |
| 512 } | 492 } |
| 513 | 493 |
| 514 void FindBarView::OnThemeChanged() { | 494 void FindBarView::OnThemeChanged() { |
| 515 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 495 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 516 if (GetThemeProvider()) { | 496 if (GetThemeProvider()) { |
| 517 #if defined(OS_CHROMEOS) | |
| 518 close_button_->SetBackground( | 497 close_button_->SetBackground( |
| 519 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), | 498 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), |
| 520 rb.GetImageSkiaNamed(IDR_TAB_CLOSE), | 499 rb.GetImageSkiaNamed(IDR_TAB_CLOSE), |
| 521 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK)); | 500 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK)); |
| 522 #else | |
| 523 close_button_->SetBackground( | |
| 524 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), | |
| 525 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), | |
| 526 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); | |
| 527 #endif | |
| 528 } | 501 } |
| 529 } | 502 } |
| OLD | NEW |