| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/cocoa/find_bar_bridge.h" | 5 #include "chrome/browser/cocoa/find_bar_bridge.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" | 8 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" |
| 9 | 9 |
| 10 // static |
| 11 bool FindBarBridge::disable_animations_during_testing_ = false; |
| 12 |
| 10 FindBarBridge::FindBarBridge() | 13 FindBarBridge::FindBarBridge() |
| 11 : find_bar_controller_(NULL) { | 14 : find_bar_controller_(NULL) { |
| 12 cocoa_controller_.reset([[FindBarCocoaController alloc] init]); | 15 cocoa_controller_ = [[FindBarCocoaController alloc] init]; |
| 13 [cocoa_controller_ setFindBarBridge:this]; | 16 [cocoa_controller_ setFindBarBridge:this]; |
| 14 } | 17 } |
| 15 | 18 |
| 16 FindBarBridge::~FindBarBridge() { | 19 FindBarBridge::~FindBarBridge() { |
| 20 [cocoa_controller_ release]; |
| 17 } | 21 } |
| 18 | 22 |
| 19 void FindBarBridge::Show(bool animate) { | 23 void FindBarBridge::Show(bool animate) { |
| 20 [cocoa_controller_ showFindBar:(animate ? YES : NO)]; | 24 bool really_animate = animate && !disable_animations_during_testing_; |
| 25 [cocoa_controller_ showFindBar:(really_animate ? YES : NO)]; |
| 21 } | 26 } |
| 22 | 27 |
| 23 void FindBarBridge::Hide(bool animate) { | 28 void FindBarBridge::Hide(bool animate) { |
| 24 [cocoa_controller_ hideFindBar:(animate ? YES : NO)]; | 29 bool really_animate = animate && !disable_animations_during_testing_; |
| 30 [cocoa_controller_ hideFindBar:(really_animate ? YES : NO)]; |
| 25 } | 31 } |
| 26 | 32 |
| 27 void FindBarBridge::SetFocusAndSelection() { | 33 void FindBarBridge::SetFocusAndSelection() { |
| 28 [cocoa_controller_ setFocusAndSelection]; | 34 [cocoa_controller_ setFocusAndSelection]; |
| 29 } | 35 } |
| 30 | 36 |
| 31 void FindBarBridge::ClearResults(const FindNotificationDetails& results) { | 37 void FindBarBridge::ClearResults(const FindNotificationDetails& results) { |
| 32 [cocoa_controller_ clearResults:results]; | 38 [cocoa_controller_ clearResults:results]; |
| 33 } | 39 } |
| 34 | 40 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 // http://crbug.com/22036 | 62 // http://crbug.com/22036 |
| 57 } | 63 } |
| 58 | 64 |
| 59 void FindBarBridge::StopAnimation() { | 65 void FindBarBridge::StopAnimation() { |
| 60 [cocoa_controller_ stopAnimation]; | 66 [cocoa_controller_ stopAnimation]; |
| 61 } | 67 } |
| 62 | 68 |
| 63 void FindBarBridge::RestoreSavedFocus() { | 69 void FindBarBridge::RestoreSavedFocus() { |
| 64 [cocoa_controller_ restoreSavedFocus]; | 70 [cocoa_controller_ restoreSavedFocus]; |
| 65 } | 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 *position = gfx::Point(0, 0); |
| 77 |
| 78 NSWindow* window = [[cocoa_controller_ view] window]; |
| 79 bool window_visible = [window isVisible] ? true : false; |
| 80 *fully_visible = window_visible && |
| 81 [cocoa_controller_ isFindBarVisible] && |
| 82 ![cocoa_controller_ isFindBarAnimating]; |
| 83 |
| 84 return window_visible; |
| 85 } |
| OLD | NEW |