| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 - (IBAction)nextResult:(id)sender { | 87 - (IBAction)nextResult:(id)sender { |
| 88 if (findBarBridge_) | 88 if (findBarBridge_) |
| 89 findBarBridge_->GetFindBarController()->tab_contents()->StartFinding( | 89 findBarBridge_->GetFindBarController()->tab_contents()->StartFinding( |
| 90 base::SysNSStringToUTF16([findText_ stringValue]), | 90 base::SysNSStringToUTF16([findText_ stringValue]), |
| 91 true, false); | 91 true, false); |
| 92 } | 92 } |
| 93 | 93 |
| 94 - (void)findPboardUpdated:(NSNotification*)notification { | 94 - (void)findPboardUpdated:(NSNotification*)notification { |
| 95 if (suppressPboardUpdateActions_) |
| 96 return; |
| 95 [self prepopulateText:[[FindPasteboard sharedInstance] findText] | 97 [self prepopulateText:[[FindPasteboard sharedInstance] findText] |
| 96 stopSearch:YES]; | 98 stopSearch:YES]; |
| 97 } | 99 } |
| 98 | 100 |
| 99 // Positions the find bar container view in the correct location based on the | 101 // Positions the find bar container view in the correct location based on the |
| 100 // current state of the window. The find bar container is always positioned one | 102 // current state of the window. The find bar container is always positioned one |
| 101 // pixel above the infobar container. Note that we are using the infobar | 103 // pixel above the infobar container. Note that we are using the infobar |
| 102 // container location as a proxy for the toolbar location, but we cannot | 104 // container location as a proxy for the toolbar location, but we cannot |
| 103 // position based on the toolbar because the toolbar is not always present (for | 105 // position based on the toolbar because the toolbar is not always present (for |
| 104 // example in fullscreen windows). | 106 // example in fullscreen windows). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 125 - (void)controlTextDidChange:(NSNotification *)aNotification { | 127 - (void)controlTextDidChange:(NSNotification *)aNotification { |
| 126 if (!findBarBridge_) | 128 if (!findBarBridge_) |
| 127 return; | 129 return; |
| 128 | 130 |
| 129 TabContents* tab_contents = | 131 TabContents* tab_contents = |
| 130 findBarBridge_->GetFindBarController()->tab_contents(); | 132 findBarBridge_->GetFindBarController()->tab_contents(); |
| 131 if (!tab_contents) | 133 if (!tab_contents) |
| 132 return; | 134 return; |
| 133 | 135 |
| 134 NSString* findText = [findText_ stringValue]; | 136 NSString* findText = [findText_ stringValue]; |
| 137 suppressPboardUpdateActions_ = YES; |
| 135 [[FindPasteboard sharedInstance] setFindText:findText]; | 138 [[FindPasteboard sharedInstance] setFindText:findText]; |
| 139 suppressPboardUpdateActions_ = NO; |
| 136 | 140 |
| 137 if ([findText length] > 0) { | 141 if ([findText length] > 0) { |
| 138 tab_contents->StartFinding(base::SysNSStringToUTF16(findText), true, false); | 142 tab_contents->StartFinding(base::SysNSStringToUTF16(findText), true, false); |
| 139 } else { | 143 } else { |
| 140 // The textbox is empty so we reset. | 144 // The textbox is empty so we reset. |
| 141 tab_contents->StopFinding(true); // true = clear selection on page. | 145 tab_contents->StopFinding(true); // true = clear selection on page. |
| 142 [self updateUIForFindResult:tab_contents->find_result() | 146 [self updateUIForFindResult:tab_contents->find_result() |
| 143 withText:string16()]; | 147 withText:string16()]; |
| 144 } | 148 } |
| 145 } | 149 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 372 } |
| 369 } | 373 } |
| 370 | 374 |
| 371 // Has to happen after |ClearResults()| above. | 375 // Has to happen after |ClearResults()| above. |
| 372 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; | 376 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; |
| 373 [previousButton_ setEnabled:buttonsEnabled]; | 377 [previousButton_ setEnabled:buttonsEnabled]; |
| 374 [nextButton_ setEnabled:buttonsEnabled]; | 378 [nextButton_ setEnabled:buttonsEnabled]; |
| 375 } | 379 } |
| 376 | 380 |
| 377 @end | 381 @end |
| OLD | NEW |