| 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 480 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() {} | 501 FindBarView::SearchTextfieldView::SearchTextfieldView() |
| 502 : select_all_on_focus_(true) {} |
| 502 | 503 |
| 503 FindBarView::SearchTextfieldView::~SearchTextfieldView() {} | 504 FindBarView::SearchTextfieldView::~SearchTextfieldView() {} |
| 504 | 505 |
| 505 void FindBarView::SearchTextfieldView::RequestFocus() { | 506 bool FindBarView::SearchTextfieldView::OnMousePressed( |
| 506 if (HasFocus()) | 507 const ui::MouseEvent& event) { |
| 507 return; | 508 // Avoid temporarily selecting all the text on focus from a mouse press; this |
| 508 views::View::RequestFocus(); | 509 // prevents flickering before setting a cursor or dragging to select text. |
| 509 SelectAll(true); | 510 select_all_on_focus_ = false; |
| 511 return views::Textfield::OnMousePressed(event); |
| 512 } |
| 513 |
| 514 void FindBarView::SearchTextfieldView::OnMouseReleased( |
| 515 const ui::MouseEvent& event) { |
| 516 views::Textfield::OnMouseReleased(event); |
| 517 select_all_on_focus_ = true; |
| 518 } |
| 519 |
| 520 void FindBarView::SearchTextfieldView::OnFocus() { |
| 521 views::Textfield::OnFocus(); |
| 522 if (select_all_on_focus_) |
| 523 SelectAll(true); |
| 510 } | 524 } |
| 511 | 525 |
| 512 FindBarHost* FindBarView::find_bar_host() const { | 526 FindBarHost* FindBarView::find_bar_host() const { |
| 513 return static_cast<FindBarHost*>(host()); | 527 return static_cast<FindBarHost*>(host()); |
| 514 } | 528 } |
| 515 | 529 |
| 516 void FindBarView::OnThemeChanged() { | 530 void FindBarView::OnThemeChanged() { |
| 517 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 531 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 518 if (GetThemeProvider()) { | 532 if (GetThemeProvider()) { |
| 519 close_button_->SetBackground( | 533 close_button_->SetBackground( |
| 520 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 534 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), |
| 521 rb.GetImageSkiaNamed(IDR_CLOSE_1), | 535 rb.GetImageSkiaNamed(IDR_CLOSE_1), |
| 522 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 536 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); |
| 523 } | 537 } |
| 524 } | 538 } |
| OLD | NEW |