| 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_host.h" | 5 #include "chrome/browser/ui/views/find_bar_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 10 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 10 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 find_bar_controller_(NULL) { | 39 find_bar_controller_(NULL) { |
| 40 FindBarView* find_bar_view = new FindBarView(this); | 40 FindBarView* find_bar_view = new FindBarView(this); |
| 41 Init(browser_view->find_bar_host_view(), find_bar_view, find_bar_view); | 41 Init(browser_view->find_bar_host_view(), find_bar_view, find_bar_view); |
| 42 } | 42 } |
| 43 | 43 |
| 44 FindBarHost::~FindBarHost() { | 44 FindBarHost::~FindBarHost() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool FindBarHost::MaybeForwardKeyEventToWebpage( | 47 bool FindBarHost::MaybeForwardKeyEventToWebpage( |
| 48 const ui::KeyEvent& key_event) { | 48 const ui::KeyEvent& key_event) { |
| 49 if (!ShouldForwardKeyEventToWebpageNative(key_event)) { | |
| 50 // Native implementation says not to forward these events. | |
| 51 return false; | |
| 52 } | |
| 53 | |
| 54 switch (key_event.key_code()) { | 49 switch (key_event.key_code()) { |
| 55 case ui::VKEY_DOWN: | 50 case ui::VKEY_DOWN: |
| 56 case ui::VKEY_UP: | 51 case ui::VKEY_UP: |
| 57 case ui::VKEY_PRIOR: | 52 case ui::VKEY_PRIOR: |
| 58 case ui::VKEY_NEXT: | 53 case ui::VKEY_NEXT: |
| 59 break; | 54 break; |
| 60 case ui::VKEY_HOME: | 55 case ui::VKEY_HOME: |
| 61 case ui::VKEY_END: | 56 case ui::VKEY_END: |
| 62 if (key_event.IsControlDown()) | 57 if (key_event.IsControlDown()) |
| 63 break; | 58 break; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 149 |
| 155 // We now need to check if the window is obscuring the search results. | 150 // We now need to check if the window is obscuring the search results. |
| 156 MoveWindowIfNecessary(result.selection_rect(), false); | 151 MoveWindowIfNecessary(result.selection_rect(), false); |
| 157 | 152 |
| 158 // Once we find a match we no longer want to keep track of what had | 153 // Once we find a match we no longer want to keep track of what had |
| 159 // focus. EndFindSession will then set the focus to the page content. | 154 // focus. EndFindSession will then set the focus to the page content. |
| 160 if (result.number_of_matches() > 0) | 155 if (result.number_of_matches() > 0) |
| 161 ResetFocusTracker(); | 156 ResetFocusTracker(); |
| 162 } | 157 } |
| 163 | 158 |
| 159 void FindBarHost::AudibleAlert() { |
| 160 #if defined(OS_WIN) |
| 161 MessageBeep(MB_OK); |
| 162 #endif |
| 163 } |
| 164 |
| 164 bool FindBarHost::IsFindBarVisible() { | 165 bool FindBarHost::IsFindBarVisible() { |
| 165 return DropdownBarHost::IsVisible(); | 166 return DropdownBarHost::IsVisible(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void FindBarHost::RestoreSavedFocus() { | 169 void FindBarHost::RestoreSavedFocus() { |
| 169 if (focus_tracker() == NULL) { | 170 if (focus_tracker() == NULL) { |
| 170 // TODO(brettw): Focus() should be on WebContentsView. | 171 // TODO(brettw): Focus() should be on WebContentsView. |
| 171 find_bar_controller_->web_contents()->Focus(); | 172 find_bar_controller_->web_contents()->Focus(); |
| 172 } else { | 173 } else { |
| 173 focus_tracker()->FocusLastFocusedExternalView(); | 174 focus_tracker()->FocusLastFocusedExternalView(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 358 |
| 358 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
| 359 // private: | 360 // private: |
| 360 | 361 |
| 361 void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) { | 362 void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) { |
| 362 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); | 363 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); |
| 363 gfx::Rect webcontents_rect = | 364 gfx::Rect webcontents_rect = |
| 364 find_bar_controller_->web_contents()->GetViewBounds(); | 365 find_bar_controller_->web_contents()->GetViewBounds(); |
| 365 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); | 366 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); |
| 366 } | 367 } |
| OLD | NEW |