| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/cocoa/find_bar_bridge.h" | |
| 6 | |
| 7 #include "base/sys_string_conversions.h" | |
| 8 #import "chrome/browser/ui/cocoa/find_bar_cocoa_controller.h" | |
| 9 | |
| 10 // static | |
| 11 bool FindBarBridge::disable_animations_during_testing_ = false; | |
| 12 | |
| 13 FindBarBridge::FindBarBridge() | |
| 14 : find_bar_controller_(NULL) { | |
| 15 cocoa_controller_ = [[FindBarCocoaController alloc] init]; | |
| 16 [cocoa_controller_ setFindBarBridge:this]; | |
| 17 } | |
| 18 | |
| 19 FindBarBridge::~FindBarBridge() { | |
| 20 [cocoa_controller_ release]; | |
| 21 } | |
| 22 | |
| 23 void FindBarBridge::Show(bool animate) { | |
| 24 bool really_animate = animate && !disable_animations_during_testing_; | |
| 25 [cocoa_controller_ showFindBar:(really_animate ? YES : NO)]; | |
| 26 } | |
| 27 | |
| 28 void FindBarBridge::Hide(bool animate) { | |
| 29 bool really_animate = animate && !disable_animations_during_testing_; | |
| 30 [cocoa_controller_ hideFindBar:(really_animate ? YES : NO)]; | |
| 31 } | |
| 32 | |
| 33 void FindBarBridge::SetFocusAndSelection() { | |
| 34 [cocoa_controller_ setFocusAndSelection]; | |
| 35 } | |
| 36 | |
| 37 void FindBarBridge::ClearResults(const FindNotificationDetails& results) { | |
| 38 [cocoa_controller_ clearResults:results]; | |
| 39 } | |
| 40 | |
| 41 void FindBarBridge::SetFindText(const string16& find_text) { | |
| 42 [cocoa_controller_ setFindText:base::SysUTF16ToNSString(find_text)]; | |
| 43 } | |
| 44 | |
| 45 void FindBarBridge::UpdateUIForFindResult(const FindNotificationDetails& result, | |
| 46 const string16& find_text) { | |
| 47 [cocoa_controller_ updateUIForFindResult:result withText:find_text]; | |
| 48 } | |
| 49 | |
| 50 void FindBarBridge::AudibleAlert() { | |
| 51 // Beep beep, beep beep, Yeah! | |
| 52 NSBeep(); | |
| 53 } | |
| 54 | |
| 55 bool FindBarBridge::IsFindBarVisible() { | |
| 56 return [cocoa_controller_ isFindBarVisible] ? true : false; | |
| 57 } | |
| 58 | |
| 59 void FindBarBridge::MoveWindowIfNecessary(const gfx::Rect& selection_rect, | |
| 60 bool no_redraw) { | |
| 61 // http://crbug.com/11084 | |
| 62 // http://crbug.com/22036 | |
| 63 } | |
| 64 | |
| 65 void FindBarBridge::StopAnimation() { | |
| 66 [cocoa_controller_ stopAnimation]; | |
| 67 } | |
| 68 | |
| 69 void FindBarBridge::RestoreSavedFocus() { | |
| 70 [cocoa_controller_ restoreSavedFocus]; | |
| 71 } | |
| 72 | |
| 73 bool FindBarBridge::GetFindBarWindowInfo(gfx::Point* position, | |
| 74 bool* fully_visible) { | |
| 75 // TODO(rohitrao): Return the proper position. http://crbug.com/22036 | |
| 76 if (position) | |
| 77 *position = gfx::Point(0, 0); | |
| 78 | |
| 79 NSWindow* window = [[cocoa_controller_ view] window]; | |
| 80 bool window_visible = [window isVisible] ? true : false; | |
| 81 if (fully_visible) { | |
| 82 *fully_visible = window_visible && | |
| 83 [cocoa_controller_ isFindBarVisible] && | |
| 84 ![cocoa_controller_ isFindBarAnimating]; | |
| 85 } | |
| 86 return window_visible; | |
| 87 } | |
| 88 | |
| 89 string16 FindBarBridge::GetFindText() { | |
| 90 // This function is currently only used in Windows and Linux specific browser | |
| 91 // tests (testing prepopulate values that Mac's don't rely on), but if we add | |
| 92 // more tests that are non-platform specific, we need to flesh out this | |
| 93 // function. | |
| 94 NOTIMPLEMENTED(); | |
| 95 return string16(); | |
| 96 } | |
| 97 | |
| 98 string16 FindBarBridge::GetFindSelectedText() { | |
| 99 // This function is currently only used in Windows and Linux specific browser | |
| 100 // tests (testing prepopulate values that Mac's don't rely on), but if we add | |
| 101 // more tests that are non-platform specific, we need to flesh out this | |
| 102 // function. | |
| 103 NOTIMPLEMENTED(); | |
| 104 return string16(); | |
| 105 } | |
| 106 | |
| 107 string16 FindBarBridge::GetMatchCountText() { | |
| 108 // This function is currently only used in Windows and Linux specific browser | |
| 109 // tests (testing prepopulate values that Mac's don't rely on), but if we add | |
| 110 // more tests that are non-platform specific, we need to flesh out this | |
| 111 // function. | |
| 112 NOTIMPLEMENTED(); | |
| 113 return string16(); | |
| 114 } | |
| OLD | NEW |