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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
15 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 15 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | 16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" |
17 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 17 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
20 #include "chrome/browser/ui/view_ids.h" | 20 #include "chrome/browser/ui/view_ids.h" |
21 #include "chrome/browser/ui/views/find_bar_host.h" | 21 #include "chrome/browser/ui/views/find_bar_host.h" |
22 #include "chrome/browser/ui/views/frame/browser_view.h" | 22 #include "chrome/browser/ui/views/frame/browser_view.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
25 #include "grit/ui_resources.h" | 25 #include "grit/ui_resources.h" |
26 #include "third_party/skia/include/effects/SkGradientShader.h" | 26 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 27 #include "ui/base/event.h" |
27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
30 #include "ui/views/controls/button/image_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
31 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
32 #include "ui/views/controls/textfield/textfield.h" | 33 #include "ui/views/controls/textfield/textfield.h" |
33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
34 | 35 |
35 // The amount of whitespace to have before the find button. | 36 // The amount of whitespace to have before the find button. |
36 static const int kWhiteSpaceAfterMatchCountLabel = 1; | 37 static const int kWhiteSpaceAfterMatchCountLabel = 1; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 // sent for a lot more things than just the user nulling out the search | 414 // sent for a lot more things than just the user nulling out the search |
414 // terms. See http://crbug.com/45372. | 415 // terms. See http://crbug.com/45372. |
415 FindBarState* find_bar_state = | 416 FindBarState* find_bar_state = |
416 FindBarStateFactory::GetForProfile( | 417 FindBarStateFactory::GetForProfile( |
417 controller->tab_contents()->profile()); | 418 controller->tab_contents()->profile()); |
418 find_bar_state->set_last_prepopulate_text(string16()); | 419 find_bar_state->set_last_prepopulate_text(string16()); |
419 } | 420 } |
420 } | 421 } |
421 | 422 |
422 bool FindBarView::HandleKeyEvent(views::Textfield* sender, | 423 bool FindBarView::HandleKeyEvent(views::Textfield* sender, |
423 const views::KeyEvent& key_event) { | 424 const ui::KeyEvent& key_event) { |
424 // If the dialog is not visible, there is no reason to process keyboard input. | 425 // If the dialog is not visible, there is no reason to process keyboard input. |
425 if (!host()->IsVisible()) | 426 if (!host()->IsVisible()) |
426 return false; | 427 return false; |
427 | 428 |
428 if (find_bar_host()->MaybeForwardKeyEventToWebpage(key_event)) | 429 if (find_bar_host()->MaybeForwardKeyEventToWebpage(key_event)) |
429 return true; // Handled, we are done! | 430 return true; // Handled, we are done! |
430 | 431 |
431 if (key_event.key_code() == ui::VKEY_RETURN) { | 432 if (key_event.key_code() == ui::VKEY_RETURN) { |
432 // Pressing Return/Enter starts the search (unless text box is empty). | 433 // Pressing Return/Enter starts the search (unless text box is empty). |
433 string16 find_string = find_text_->text(); | 434 string16 find_string = find_text_->text(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 488 |
488 void FindBarView::OnThemeChanged() { | 489 void FindBarView::OnThemeChanged() { |
489 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 490 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
490 if (GetThemeProvider()) { | 491 if (GetThemeProvider()) { |
491 close_button_->SetBackground( | 492 close_button_->SetBackground( |
492 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), | 493 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), |
493 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), | 494 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), |
494 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); | 495 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); |
495 } | 496 } |
496 } | 497 } |
OLD | NEW |