Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/ui/views/find_bar_host.cc

Issue 2848883005: Test FindBar audible alerts. (Closed)
Patch Set: Address Scott's comment. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
(...skipping 11 matching lines...) Expand all
22 #include "ui/views/widget/root_view.h" 22 #include "ui/views/widget/root_view.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 24
25 using content::NativeWebKeyboardEvent; 25 using content::NativeWebKeyboardEvent;
26 26
27 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
28 // FindBarHost, public: 28 // FindBarHost, public:
29 29
30 FindBarHost::FindBarHost(BrowserView* browser_view) 30 FindBarHost::FindBarHost(BrowserView* browser_view)
31 : DropdownBarHost(browser_view), 31 : DropdownBarHost(browser_view),
32 find_bar_controller_(NULL) { 32 find_bar_controller_(NULL),
33 audible_alerts_(0) {
33 FindBarView* find_bar_view = new FindBarView(this); 34 FindBarView* find_bar_view = new FindBarView(this);
34 Init(browser_view->find_bar_host_view(), find_bar_view, find_bar_view); 35 Init(browser_view->find_bar_host_view(), find_bar_view, find_bar_view);
35 } 36 }
36 37
37 FindBarHost::~FindBarHost() { 38 FindBarHost::~FindBarHost() {
38 } 39 }
39 40
40 bool FindBarHost::MaybeForwardKeyEventToWebpage( 41 bool FindBarHost::MaybeForwardKeyEventToWebpage(
41 const ui::KeyEvent& key_event) { 42 const ui::KeyEvent& key_event) {
42 switch (key_event.key_code()) { 43 switch (key_event.key_code()) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // We now need to check if the window is obscuring the search results. 139 // We now need to check if the window is obscuring the search results.
139 MoveWindowIfNecessary(result.selection_rect()); 140 MoveWindowIfNecessary(result.selection_rect());
140 141
141 // Once we find a match we no longer want to keep track of what had 142 // Once we find a match we no longer want to keep track of what had
142 // focus. EndFindSession will then set the focus to the page content. 143 // focus. EndFindSession will then set the focus to the page content.
143 if (result.number_of_matches() > 0) 144 if (result.number_of_matches() > 0)
144 ResetFocusTracker(); 145 ResetFocusTracker();
145 } 146 }
146 147
147 void FindBarHost::AudibleAlert() { 148 void FindBarHost::AudibleAlert() {
149 ++audible_alerts_;
148 #if defined(OS_WIN) 150 #if defined(OS_WIN)
149 MessageBeep(MB_OK); 151 MessageBeep(MB_OK);
150 #endif 152 #endif
151 } 153 }
152 154
153 bool FindBarHost::IsFindBarVisible() { 155 bool FindBarHost::IsFindBarVisible() {
154 return DropdownBarHost::IsVisible(); 156 return DropdownBarHost::IsVisible();
155 } 157 }
156 158
157 void FindBarHost::RestoreSavedFocus() { 159 void FindBarHost::RestoreSavedFocus() {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 240 }
239 241
240 base::string16 FindBarHost::GetMatchCountText() { 242 base::string16 FindBarHost::GetMatchCountText() {
241 return find_bar_view()->GetMatchCountText(); 243 return find_bar_view()->GetMatchCountText();
242 } 244 }
243 245
244 int FindBarHost::GetWidth() { 246 int FindBarHost::GetWidth() {
245 return view()->width(); 247 return view()->width();
246 } 248 }
247 249
250 size_t FindBarHost::GetAudibleAlertCount() {
251 return audible_alerts_;
252 }
253
248 //////////////////////////////////////////////////////////////////////////////// 254 ////////////////////////////////////////////////////////////////////////////////
249 // Overridden from DropdownBarHost: 255 // Overridden from DropdownBarHost:
250 256
251 gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { 257 gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
252 // Find the area we have to work with (after accounting for scrollbars, etc). 258 // Find the area we have to work with (after accounting for scrollbars, etc).
253 gfx::Rect widget_bounds; 259 gfx::Rect widget_bounds;
254 GetWidgetBounds(&widget_bounds); 260 GetWidgetBounds(&widget_bounds);
255 if (widget_bounds.IsEmpty()) 261 if (widget_bounds.IsEmpty())
256 return gfx::Rect(); 262 return gfx::Rect();
257 263
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 347
342 //////////////////////////////////////////////////////////////////////////////// 348 ////////////////////////////////////////////////////////////////////////////////
343 // private: 349 // private:
344 350
345 void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) { 351 void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) {
346 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); 352 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen();
347 gfx::Rect webcontents_rect = 353 gfx::Rect webcontents_rect =
348 find_bar_controller_->web_contents()->GetViewBounds(); 354 find_bar_controller_->web_contents()->GetViewBounds();
349 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); 355 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y());
350 } 356 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698