Commit 5ca50e0b authored by msw@chromium.org's avatar msw@chromium.org

Revert FindBarView::SearchTextfieldView deletion.

My http://crrev.com/192493 caused a regression:
FindBarView doesn't select-all on tab-switch focus restoration.

Restore the FindBarView::SearchTextfieldView class with RestoreFocus override.
( this restores the previous select-all behavior to fix the regression )

BUG=232290
TEST=Switching back to a tab that had the find bar focused (from a tab that didn't have the find bar focused) restores find bar focus and selects the entire text content.
R=finnur@chromium.org
TBR=ben@chromium.org

Review URL: https://codereview.chromium.org/13976011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194630 0039d316-1c4b-4281-b951-d872f2087c98
parent 42a3748c
......@@ -81,7 +81,7 @@ FindBarView::FindBarView(FindBarHost* host)
set_id(VIEW_ID_FIND_IN_PAGE);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
find_text_ = new views::Textfield();
find_text_ = new SearchTextfieldView;
find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont));
find_text_->set_default_width_in_chars(kDefaultCharWidth);
......@@ -498,6 +498,17 @@ bool FindBarView::FocusForwarderView::OnMousePressed(
return true;
}
FindBarView::SearchTextfieldView::SearchTextfieldView() {}
FindBarView::SearchTextfieldView::~SearchTextfieldView() {}
void FindBarView::SearchTextfieldView::RequestFocus() {
if (HasFocus())
return;
views::View::RequestFocus();
SelectAll(true);
}
FindBarHost* FindBarView::find_bar_host() const {
return static_cast<FindBarHost*>(host());
}
......
......@@ -110,12 +110,25 @@ class FindBarView : public DropdownBarView,
DISALLOW_COPY_AND_ASSIGN(FocusForwarderView);
};
// A wrapper of views::TextField that allows us to select all text when we
// get focus. Represents the text field where the user enters a search term.
class SearchTextfieldView : public views::Textfield {
public:
SearchTextfieldView();
virtual ~SearchTextfieldView();
virtual void RequestFocus() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(SearchTextfieldView);
};
// Returns the OS-specific view for the find bar that acts as an intermediary
// between us and the WebContentsView.
FindBarHost* find_bar_host() const;
// The controls in the window.
views::Textfield* find_text_;
SearchTextfieldView* find_text_;
views::Label* match_count_text_;
FocusForwarderView* focus_forwarder_view_;
views::ImageButton* find_previous_button_;
......
......@@ -726,7 +726,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
virtual const FocusManager* GetFocusManager() const;
// Request keyboard focus. The receiving view will become the focused view.
void RequestFocus();
virtual void RequestFocus();
// Invoked when a view is about to be requested for focus due to the focus
// traversal. Reverse is this request was generated going backward
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment