OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/find_bar_view.h" | 5 #include "chrome/browser/views/find_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #endif | 90 #endif |
91 find_text_(NULL), | 91 find_text_(NULL), |
92 match_count_text_(NULL), | 92 match_count_text_(NULL), |
93 focus_forwarder_view_(NULL), | 93 focus_forwarder_view_(NULL), |
94 find_previous_button_(NULL), | 94 find_previous_button_(NULL), |
95 find_next_button_(NULL), | 95 find_next_button_(NULL), |
96 close_button_(NULL) { | 96 close_button_(NULL) { |
97 SetID(VIEW_ID_FIND_IN_PAGE); | 97 SetID(VIEW_ID_FIND_IN_PAGE); |
98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
99 | 99 |
100 find_text_ = new views::Textfield(); | 100 find_text_ = new SearchTextfieldView(); |
101 find_text_->SetID(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 101 find_text_->SetID(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
102 find_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); | 102 find_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); |
103 find_text_->set_default_width_in_chars(kDefaultCharWidth); | 103 find_text_->set_default_width_in_chars(kDefaultCharWidth); |
104 find_text_->SetController(this); | 104 find_text_->SetController(this); |
105 find_text_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_FIND)); | 105 find_text_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_FIND)); |
106 AddChildView(find_text_); | 106 AddChildView(find_text_); |
107 | 107 |
108 match_count_text_ = new views::Label(); | 108 match_count_text_ = new views::Label(); |
109 match_count_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); | 109 match_count_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); |
110 match_count_text_->SetColor(kTextColorMatchCount); | 110 match_count_text_->SetColor(kTextColorMatchCount); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 find_text_->SetText(find_text); | 180 find_text_->SetText(find_text); |
181 #if defined(OS_LINUX) | 181 #if defined(OS_LINUX) |
182 ignore_contents_changed_ = false; | 182 ignore_contents_changed_ = false; |
183 #endif | 183 #endif |
184 } | 184 } |
185 | 185 |
186 string16 FindBarView::GetFindText() const { | 186 string16 FindBarView::GetFindText() const { |
187 return find_text_->text(); | 187 return find_text_->text(); |
188 } | 188 } |
189 | 189 |
| 190 string16 FindBarView::GetFindSelectedText() const { |
| 191 return find_text_->GetSelectedText(); |
| 192 } |
| 193 |
190 string16 FindBarView::GetMatchCountText() const { | 194 string16 FindBarView::GetMatchCountText() const { |
191 return WideToUTF16Hack(match_count_text_->GetText()); | 195 return WideToUTF16Hack(match_count_text_->GetText()); |
192 } | 196 } |
193 | 197 |
194 void FindBarView::UpdateForResult(const FindNotificationDetails& result, | 198 void FindBarView::UpdateForResult(const FindNotificationDetails& result, |
195 const string16& find_text) { | 199 const string16& find_text) { |
196 bool have_valid_range = | 200 bool have_valid_range = |
197 result.number_of_matches() != -1 && result.active_match_ordinal() != -1; | 201 result.number_of_matches() != -1 && result.active_match_ordinal() != -1; |
198 | 202 |
199 // http://crbug.com/34970: some IMEs get confused if we change the text | 203 // http://crbug.com/34970: some IMEs get confused if we change the text |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 538 |
535 bool FindBarView::FocusForwarderView::OnMousePressed( | 539 bool FindBarView::FocusForwarderView::OnMousePressed( |
536 const views::MouseEvent& event) { | 540 const views::MouseEvent& event) { |
537 if (view_to_focus_on_mousedown_) { | 541 if (view_to_focus_on_mousedown_) { |
538 view_to_focus_on_mousedown_->ClearSelection(); | 542 view_to_focus_on_mousedown_->ClearSelection(); |
539 view_to_focus_on_mousedown_->RequestFocus(); | 543 view_to_focus_on_mousedown_->RequestFocus(); |
540 } | 544 } |
541 return true; | 545 return true; |
542 } | 546 } |
543 | 547 |
| 548 FindBarView::SearchTextfieldView::SearchTextfieldView() { |
| 549 } |
| 550 |
| 551 FindBarView::SearchTextfieldView::~SearchTextfieldView() { |
| 552 } |
| 553 |
| 554 void FindBarView::SearchTextfieldView::RequestFocus() { |
| 555 views::View::RequestFocus(); |
| 556 SelectAll(); |
| 557 } |
| 558 |
544 FindBarHost* FindBarView::find_bar_host() const { | 559 FindBarHost* FindBarView::find_bar_host() const { |
545 return static_cast<FindBarHost*>(host()); | 560 return static_cast<FindBarHost*>(host()); |
546 } | 561 } |
547 | 562 |
548 void FindBarView::OnThemeChanged() { | 563 void FindBarView::OnThemeChanged() { |
549 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 564 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
550 if (GetThemeProvider()) { | 565 if (GetThemeProvider()) { |
551 close_button_->SetBackground( | 566 close_button_->SetBackground( |
552 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), | 567 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), |
553 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 568 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
554 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 569 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
555 } | 570 } |
556 } | 571 } |
OLD | NEW |