Chromium Code Reviews| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 find_previous_button_ = find_previous; | 146 find_previous_button_ = find_previous; |
| 147 find_next_button_ = find_next; | 147 find_next_button_ = find_next; |
| 148 close_button_ = close; | 148 close_button_ = close; |
| 149 } else { | 149 } else { |
| 150 find_previous_button_ = new views::ImageButton(this); | 150 find_previous_button_ = new views::ImageButton(this); |
| 151 find_next_button_ = new views::ImageButton(this); | 151 find_next_button_ = new views::ImageButton(this); |
| 152 close_button_ = new views::ImageButton(this); | 152 close_button_ = new views::ImageButton(this); |
| 153 } | 153 } |
| 154 | 154 |
| 155 find_previous_button_->set_id(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON); | |
| 155 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); | 156 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); |
|
msw
2016/02/03 19:58:02
nit: remove FIND_PREVIOUS_TAG and FIND_NEXT_TAG, u
Mario Pistrich
2016/02/03 20:41:59
Done.
| |
| 156 find_previous_button_->SetFocusable(true); | 157 find_previous_button_->SetFocusable(true); |
| 157 find_previous_button_->set_request_focus_on_press(false); | 158 find_previous_button_->set_request_focus_on_press(false); |
| 158 find_previous_button_->SetTooltipText( | 159 find_previous_button_->SetTooltipText( |
| 159 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); | 160 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); |
| 160 find_previous_button_->SetAccessibleName( | 161 find_previous_button_->SetAccessibleName( |
| 161 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); | 162 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); |
| 162 AddChildView(find_previous_button_); | 163 AddChildView(find_previous_button_); |
| 163 | 164 |
| 165 find_next_button_->set_id(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON); | |
| 164 find_next_button_->set_tag(FIND_NEXT_TAG); | 166 find_next_button_->set_tag(FIND_NEXT_TAG); |
| 165 find_next_button_->SetFocusable(true); | 167 find_next_button_->SetFocusable(true); |
| 166 find_next_button_->set_request_focus_on_press(false); | 168 find_next_button_->set_request_focus_on_press(false); |
| 167 find_next_button_->SetTooltipText( | 169 find_next_button_->SetTooltipText( |
| 168 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); | 170 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); |
| 169 find_next_button_->SetAccessibleName( | 171 find_next_button_->SetAccessibleName( |
| 170 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); | 172 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); |
| 171 AddChildView(find_next_button_); | 173 AddChildView(find_next_button_); |
| 172 | 174 |
| 173 close_button_->set_tag(CLOSE_TAG); | 175 close_button_->set_tag(CLOSE_TAG); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 switch (sender->tag()) { | 427 switch (sender->tag()) { |
| 426 case FIND_PREVIOUS_TAG: | 428 case FIND_PREVIOUS_TAG: |
| 427 case FIND_NEXT_TAG: | 429 case FIND_NEXT_TAG: |
| 428 if (!find_text_->text().empty()) { | 430 if (!find_text_->text().empty()) { |
| 429 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents( | 431 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents( |
| 430 find_bar_host()->GetFindBarController()->web_contents()); | 432 find_bar_host()->GetFindBarController()->web_contents()); |
| 431 find_tab_helper->StartFinding(find_text_->text(), | 433 find_tab_helper->StartFinding(find_text_->text(), |
| 432 sender->tag() == FIND_NEXT_TAG, | 434 sender->tag() == FIND_NEXT_TAG, |
| 433 false); // Not case sensitive. | 435 false); // Not case sensitive. |
| 434 } | 436 } |
| 435 // Move focus to the find textfield. | 437 |
| 436 find_text_->RequestFocus(); | 438 if (event.IsMouseEvent()) { |
| 439 // Move focus to the find textfield. | |
| 440 find_text_->RequestFocus(); | |
| 441 } | |
| 437 break; | 442 break; |
| 438 case CLOSE_TAG: | 443 case CLOSE_TAG: |
| 439 find_bar_host()->GetFindBarController()->EndFindSession( | 444 find_bar_host()->GetFindBarController()->EndFindSession( |
| 440 FindBarController::kKeepSelectionOnPage, | 445 FindBarController::kKeepSelectionOnPage, |
| 441 FindBarController::kKeepResultsInFindBox); | 446 FindBarController::kKeepResultsInFindBox); |
| 442 break; | 447 break; |
| 443 default: | 448 default: |
| 444 NOTREACHED() << L"Unknown button"; | 449 NOTREACHED() << L"Unknown button"; |
| 445 break; | 450 break; |
| 446 } | 451 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 // sent for a lot more things than just the user nulling out the search | 599 // sent for a lot more things than just the user nulling out the search |
| 595 // terms. See http://crbug.com/45372. | 600 // terms. See http://crbug.com/45372. |
| 596 Profile* profile = | 601 Profile* profile = |
| 597 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 602 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 598 FindBarState* find_bar_state = FindBarStateFactory::GetForProfile(profile); | 603 FindBarState* find_bar_state = FindBarStateFactory::GetForProfile(profile); |
| 599 find_bar_state->set_last_prepopulate_text(base::string16()); | 604 find_bar_state->set_last_prepopulate_text(base::string16()); |
| 600 } | 605 } |
| 601 } | 606 } |
| 602 | 607 |
| 603 void FindBarView::UpdateMatchCountAppearance(bool no_match) { | 608 void FindBarView::UpdateMatchCountAppearance(bool no_match) { |
| 604 bool enable_buttons = !match_count_text_->text().empty() && !no_match; | 609 // Enable the buttons if there is a match or if there is a match count text |
| 610 // set (from a prepopulated view). | |
| 611 bool enable_buttons = !match_count_text_->text().empty() || !no_match; | |
|
msw
2016/02/03 19:58:02
This change seems unrelated; why is it part of thi
Mario Pistrich
2016/02/03 20:41:59
I changed this so that the focus is not moved to t
msw
2016/02/03 21:43:34
Sorry, when/how is focus moved to the close button
Mario Pistrich
2016/02/03 23:32:54
I should have described the reason of the change m
msw
2016/02/04 00:35:20
Hmm, it's too bad that the complexity of this desi
| |
| 605 find_previous_button_->SetEnabled(enable_buttons); | 612 find_previous_button_->SetEnabled(enable_buttons); |
| 606 find_next_button_->SetEnabled(enable_buttons); | 613 find_next_button_->SetEnabled(enable_buttons); |
| 607 | 614 |
| 608 if (ui::MaterialDesignController::IsModeMaterial()) | 615 if (ui::MaterialDesignController::IsModeMaterial()) |
| 609 return; | 616 return; |
| 610 | 617 |
| 611 if (no_match) { | 618 if (no_match) { |
| 612 match_count_text_->SetBackgroundColor(kBackgroundColorNoMatch); | 619 match_count_text_->SetBackgroundColor(kBackgroundColorNoMatch); |
| 613 match_count_text_->SetEnabledColor(kTextColorNoMatch); | 620 match_count_text_->SetEnabledColor(kTextColorNoMatch); |
| 614 } else { | 621 } else { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 SkColor text_color = | 664 SkColor text_color = |
| 658 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); | 665 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 659 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); | 666 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); |
| 660 separator_->SetColor(SkColorSetA(text_color, 0x26)); | 667 separator_->SetColor(SkColorSetA(text_color, 0x26)); |
| 661 } | 668 } |
| 662 | 669 |
| 663 SkColor FindBarView::GetTextColorForIcon() { | 670 SkColor FindBarView::GetTextColorForIcon() { |
| 664 return GetNativeTheme()->GetSystemColor( | 671 return GetNativeTheme()->GetSystemColor( |
| 665 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 672 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 666 } | 673 } |
| OLD | NEW |