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_util.h" | 9 #include "base/string_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 match_count_text_(NULL), | 74 match_count_text_(NULL), |
75 focus_forwarder_view_(NULL), | 75 focus_forwarder_view_(NULL), |
76 find_previous_button_(NULL), | 76 find_previous_button_(NULL), |
77 find_next_button_(NULL), | 77 find_next_button_(NULL), |
78 close_button_(NULL), | 78 close_button_(NULL), |
79 text_box_background_(NULL), | 79 text_box_background_(NULL), |
80 text_box_background_left_(NULL) { | 80 text_box_background_left_(NULL) { |
81 set_id(VIEW_ID_FIND_IN_PAGE); | 81 set_id(VIEW_ID_FIND_IN_PAGE); |
82 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 82 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
83 | 83 |
84 find_text_ = new views::Textfield(); | 84 find_text_ = new SearchTextfieldView; |
85 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 85 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
86 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 86 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
87 find_text_->set_default_width_in_chars(kDefaultCharWidth); | 87 find_text_->set_default_width_in_chars(kDefaultCharWidth); |
88 find_text_->SetController(this); | 88 find_text_->SetController(this); |
89 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); | 89 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); |
90 | 90 |
91 AddChildView(find_text_); | 91 AddChildView(find_text_); |
92 | 92 |
93 match_count_text_ = new views::Label(); | 93 match_count_text_ = new views::Label(); |
94 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 94 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 } | 491 } |
492 } | 492 } |
493 | 493 |
494 bool FindBarView::FocusForwarderView::OnMousePressed( | 494 bool FindBarView::FocusForwarderView::OnMousePressed( |
495 const ui::MouseEvent& event) { | 495 const ui::MouseEvent& event) { |
496 if (view_to_focus_on_mousedown_) | 496 if (view_to_focus_on_mousedown_) |
497 view_to_focus_on_mousedown_->RequestFocus(); | 497 view_to_focus_on_mousedown_->RequestFocus(); |
498 return true; | 498 return true; |
499 } | 499 } |
500 | 500 |
501 FindBarView::SearchTextfieldView::SearchTextfieldView() {} | |
502 | |
503 FindBarView::SearchTextfieldView::~SearchTextfieldView() {} | |
504 | |
505 void FindBarView::SearchTextfieldView::RequestFocus() { | |
Ben Goodger (Google)
2013/04/18 17:51:13
Can you do this in an OnFocus() handler? It'd be n
msw
2013/04/18 19:10:24
Done in https://codereview.chromium.org/13852009/
| |
506 if (HasFocus()) | |
507 return; | |
508 views::View::RequestFocus(); | |
509 SelectAll(true); | |
510 } | |
511 | |
501 FindBarHost* FindBarView::find_bar_host() const { | 512 FindBarHost* FindBarView::find_bar_host() const { |
502 return static_cast<FindBarHost*>(host()); | 513 return static_cast<FindBarHost*>(host()); |
503 } | 514 } |
504 | 515 |
505 void FindBarView::OnThemeChanged() { | 516 void FindBarView::OnThemeChanged() { |
506 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 517 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
507 if (GetThemeProvider()) { | 518 if (GetThemeProvider()) { |
508 close_button_->SetBackground( | 519 close_button_->SetBackground( |
509 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 520 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), |
510 rb.GetImageSkiaNamed(IDR_CLOSE_1), | 521 rb.GetImageSkiaNamed(IDR_CLOSE_1), |
511 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 522 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); |
512 } | 523 } |
513 } | 524 } |
OLD | NEW |