| 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/gtk/find_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/find_bar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 24 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 25 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 25 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 26 #include "chrome/browser/ui/gtk/custom_button.h" | 26 #include "chrome/browser/ui/gtk/custom_button.h" |
| 27 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 27 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 28 #include "chrome/browser/ui/gtk/gtk_util.h" | 28 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 29 #include "chrome/browser/ui/gtk/nine_box.h" | 29 #include "chrome/browser/ui/gtk/nine_box.h" |
| 30 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 30 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
| 31 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 31 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
| 32 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 32 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 33 #include "chrome/browser/ui/gtk/view_id_util.h" | 33 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 34 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 34 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 35 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
| 36 #include "content/public/browser/native_web_keyboard_event.h" | 36 #include "content/public/browser/native_web_keyboard_event.h" |
| 37 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
| 38 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
| 39 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
| 42 #include "grit/ui_resources_standard.h" | 42 #include "grit/ui_resources_standard.h" |
| 43 #include "ui/base/gtk/gtk_floating_container.h" | 43 #include "ui/base/gtk/gtk_floating_container.h" |
| 44 #include "ui/base/gtk/gtk_hig_constants.h" | 44 #include "ui/base/gtk/gtk_hig_constants.h" |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 return UTF8ToUTF16(contents); | 581 return UTF8ToUTF16(contents); |
| 582 } | 582 } |
| 583 | 583 |
| 584 int FindBarGtk::GetWidth() { | 584 int FindBarGtk::GetWidth() { |
| 585 GtkAllocation allocation; | 585 GtkAllocation allocation; |
| 586 gtk_widget_get_allocation(container_, &allocation); | 586 gtk_widget_get_allocation(container_, &allocation); |
| 587 return allocation.width; | 587 return allocation.width; |
| 588 } | 588 } |
| 589 | 589 |
| 590 void FindBarGtk::FindEntryTextInContents(bool forward_search) { | 590 void FindBarGtk::FindEntryTextInContents(bool forward_search) { |
| 591 TabContentsWrapper* tab_contents = find_bar_controller_->tab_contents(); | 591 TabContents* tab_contents = find_bar_controller_->tab_contents(); |
| 592 if (!tab_contents) | 592 if (!tab_contents) |
| 593 return; | 593 return; |
| 594 FindTabHelper* find_tab_helper = tab_contents->find_tab_helper(); | 594 FindTabHelper* find_tab_helper = tab_contents->find_tab_helper(); |
| 595 | 595 |
| 596 std::string new_contents(gtk_entry_get_text(GTK_ENTRY(text_entry_))); | 596 std::string new_contents(gtk_entry_get_text(GTK_ENTRY(text_entry_))); |
| 597 | 597 |
| 598 if (new_contents.length() > 0) { | 598 if (new_contents.length() > 0) { |
| 599 find_tab_helper->StartFinding(UTF8ToUTF16(new_contents), forward_search, | 599 find_tab_helper->StartFinding(UTF8ToUTF16(new_contents), forward_search, |
| 600 false); // Not case sensitive. | 600 false); // Not case sensitive. |
| 601 } else { | 601 } else { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 case GDK_End: | 666 case GDK_End: |
| 667 if ((event->state & gtk_accelerator_get_default_mod_mask()) == | 667 if ((event->state & gtk_accelerator_get_default_mod_mask()) == |
| 668 GDK_CONTROL_MASK) { | 668 GDK_CONTROL_MASK) { |
| 669 break; | 669 break; |
| 670 } | 670 } |
| 671 // Fall through. | 671 // Fall through. |
| 672 default: | 672 default: |
| 673 return false; | 673 return false; |
| 674 } | 674 } |
| 675 | 675 |
| 676 TabContentsWrapper* contents = find_bar_controller_->tab_contents(); | 676 TabContents* contents = find_bar_controller_->tab_contents(); |
| 677 if (!contents) | 677 if (!contents) |
| 678 return false; | 678 return false; |
| 679 | 679 |
| 680 content::RenderViewHost* render_view_host = | 680 content::RenderViewHost* render_view_host = |
| 681 contents->web_contents()->GetRenderViewHost(); | 681 contents->web_contents()->GetRenderViewHost(); |
| 682 | 682 |
| 683 // Make sure we don't have a text field element interfering with keyboard | 683 // Make sure we don't have a text field element interfering with keyboard |
| 684 // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom". | 684 // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom". |
| 685 render_view_host->ClearFocusedNode(); | 685 render_view_host->ClearFocusedNode(); |
| 686 | 686 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 return FALSE; // Continue propagation. | 1001 return FALSE; // Continue propagation. |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { | 1004 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { |
| 1005 g_signal_handlers_disconnect_by_func( | 1005 g_signal_handlers_disconnect_by_func( |
| 1006 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), | 1006 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), |
| 1007 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); | 1007 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); |
| 1008 | 1008 |
| 1009 return FALSE; // Continue propagation. | 1009 return FALSE; // Continue propagation. |
| 1010 } | 1010 } |
| OLD | NEW |