| 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_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 void FindBarView::UpdateForResult(const FindNotificationDetails& result, | 179 void FindBarView::UpdateForResult(const FindNotificationDetails& result, |
| 180 const string16& find_text) { | 180 const string16& find_text) { |
| 181 bool have_valid_range = | 181 bool have_valid_range = |
| 182 result.number_of_matches() != -1 && result.active_match_ordinal() != -1; | 182 result.number_of_matches() != -1 && result.active_match_ordinal() != -1; |
| 183 | 183 |
| 184 // http://crbug.com/34970: some IMEs get confused if we change the text | 184 // http://crbug.com/34970: some IMEs get confused if we change the text |
| 185 // composed by them. To avoid this problem, we should check the IME status and | 185 // composed by them. To avoid this problem, we should check the IME status and |
| 186 // update the text only when the IME is not composing text. | 186 // update the text only when the IME is not composing text. |
| 187 if (find_text_->text() != find_text && !find_text_->IsIMEComposing()) { | 187 if (find_text_->text() != find_text && !find_text_->IsIMEComposing()) { |
| 188 find_text_->SetText(find_text); | 188 find_text_->SetText(find_text); |
| 189 find_text_->SelectAll(); | 189 find_text_->SelectAll(true); |
| 190 } | 190 } |
| 191 | 191 |
| 192 if (find_text.empty() || !have_valid_range) { | 192 if (find_text.empty() || !have_valid_range) { |
| 193 // If there was no text entered, we don't show anything in the result count | 193 // If there was no text entered, we don't show anything in the result count |
| 194 // area. | 194 // area. |
| 195 ClearMatchCount(); | 195 ClearMatchCount(); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 match_count_text_->SetText(l10n_util::GetStringFUTF16(IDS_FIND_IN_PAGE_COUNT, | 199 match_count_text_->SetText(l10n_util::GetStringFUTF16(IDS_FIND_IN_PAGE_COUNT, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 213 void FindBarView::ClearMatchCount() { | 213 void FindBarView::ClearMatchCount() { |
| 214 match_count_text_->SetText(string16()); | 214 match_count_text_->SetText(string16()); |
| 215 UpdateMatchCountAppearance(false); | 215 UpdateMatchCountAppearance(false); |
| 216 Layout(); | 216 Layout(); |
| 217 SchedulePaint(); | 217 SchedulePaint(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void FindBarView::SetFocusAndSelection(bool select_all) { | 220 void FindBarView::SetFocusAndSelection(bool select_all) { |
| 221 find_text_->RequestFocus(); | 221 find_text_->RequestFocus(); |
| 222 if (select_all && !find_text_->text().empty()) | 222 if (select_all && !find_text_->text().empty()) |
| 223 find_text_->SelectAll(); | 223 find_text_->SelectAll(true); |
| 224 } | 224 } |
| 225 | 225 |
| 226 /////////////////////////////////////////////////////////////////////////////// | 226 /////////////////////////////////////////////////////////////////////////////// |
| 227 // FindBarView, views::View overrides: | 227 // FindBarView, views::View overrides: |
| 228 | 228 |
| 229 void FindBarView::OnPaint(gfx::Canvas* canvas) { | 229 void FindBarView::OnPaint(gfx::Canvas* canvas) { |
| 230 // Paint drop down bar border and background. | 230 // Paint drop down bar border and background. |
| 231 DropdownBarView::OnPaint(canvas); | 231 DropdownBarView::OnPaint(canvas); |
| 232 | 232 |
| 233 // Then we draw the background image for the Find Textfield. We start by | 233 // Then we draw the background image for the Find Textfield. We start by |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 FindBarView::SearchTextfieldView::SearchTextfieldView() { | 471 FindBarView::SearchTextfieldView::SearchTextfieldView() { |
| 472 } | 472 } |
| 473 | 473 |
| 474 FindBarView::SearchTextfieldView::~SearchTextfieldView() { | 474 FindBarView::SearchTextfieldView::~SearchTextfieldView() { |
| 475 } | 475 } |
| 476 | 476 |
| 477 void FindBarView::SearchTextfieldView::RequestFocus() { | 477 void FindBarView::SearchTextfieldView::RequestFocus() { |
| 478 if (HasFocus()) | 478 if (HasFocus()) |
| 479 return; | 479 return; |
| 480 views::View::RequestFocus(); | 480 views::View::RequestFocus(); |
| 481 SelectAll(); | 481 SelectAll(true); |
| 482 } | 482 } |
| 483 | 483 |
| 484 FindBarHost* FindBarView::find_bar_host() const { | 484 FindBarHost* FindBarView::find_bar_host() const { |
| 485 return static_cast<FindBarHost*>(host()); | 485 return static_cast<FindBarHost*>(host()); |
| 486 } | 486 } |
| 487 | 487 |
| 488 void FindBarView::OnThemeChanged() { | 488 void FindBarView::OnThemeChanged() { |
| 489 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 489 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 490 if (GetThemeProvider()) { | 490 if (GetThemeProvider()) { |
| 491 close_button_->SetBackground( | 491 close_button_->SetBackground( |
| 492 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), | 492 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), |
| 493 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), | 493 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), |
| 494 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); | 494 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); |
| 495 } | 495 } |
| 496 } | 496 } |
| OLD | NEW |