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 "base/mac_util.h" | 7 #include "base/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/find_bar_controller.h" | 9 #include "chrome/browser/find_bar_controller.h" |
10 #include "chrome/browser/cocoa/browser_window_cocoa.h" | 10 #include "chrome/browser/cocoa/browser_window_cocoa.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 [findBarView_ setFrame:[self hiddenFindBarFrame]]; | 69 [findBarView_ setFrame:[self hiddenFindBarFrame]]; |
70 | 70 |
71 // Stopping the search requires a findbar controller, which isn't valid yet | 71 // Stopping the search requires a findbar controller, which isn't valid yet |
72 // during setup. Furthermore, there is no active search yet anyway. | 72 // during setup. Furthermore, there is no active search yet anyway. |
73 [self prepopulateText:[[FindPasteboard sharedInstance] findText] | 73 [self prepopulateText:[[FindPasteboard sharedInstance] findText] |
74 stopSearch:NO]; | 74 stopSearch:NO]; |
75 } | 75 } |
76 | 76 |
77 - (IBAction)close:(id)sender { | 77 - (IBAction)close:(id)sender { |
78 if (findBarBridge_) | 78 if (findBarBridge_) |
79 findBarBridge_->GetFindBarController()->EndFindSession(); | 79 findBarBridge_->GetFindBarController()->EndFindSession( |
| 80 FindBarController::kKeepSelection); |
80 } | 81 } |
81 | 82 |
82 - (IBAction)previousResult:(id)sender { | 83 - (IBAction)previousResult:(id)sender { |
83 if (findBarBridge_) | 84 if (findBarBridge_) |
84 findBarBridge_->GetFindBarController()->tab_contents()->StartFinding( | 85 findBarBridge_->GetFindBarController()->tab_contents()->StartFinding( |
85 base::SysNSStringToUTF16([findText_ stringValue]), | 86 base::SysNSStringToUTF16([findText_ stringValue]), |
86 false, false); | 87 false, false); |
87 } | 88 } |
88 | 89 |
89 - (IBAction)nextResult:(id)sender { | 90 - (IBAction)nextResult:(id)sender { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 NSString* findText = [findText_ stringValue]; | 130 NSString* findText = [findText_ stringValue]; |
130 suppressPboardUpdateActions_ = YES; | 131 suppressPboardUpdateActions_ = YES; |
131 [[FindPasteboard sharedInstance] setFindText:findText]; | 132 [[FindPasteboard sharedInstance] setFindText:findText]; |
132 suppressPboardUpdateActions_ = NO; | 133 suppressPboardUpdateActions_ = NO; |
133 | 134 |
134 if ([findText length] > 0) { | 135 if ([findText length] > 0) { |
135 tab_contents->StartFinding(base::SysNSStringToUTF16(findText), true, false); | 136 tab_contents->StartFinding(base::SysNSStringToUTF16(findText), true, false); |
136 } else { | 137 } else { |
137 // The textbox is empty so we reset. | 138 // The textbox is empty so we reset. |
138 tab_contents->StopFinding(true); // true = clear selection on page. | 139 tab_contents->StopFinding(FindBarController::kClearSelection); |
139 [self updateUIForFindResult:tab_contents->find_result() | 140 [self updateUIForFindResult:tab_contents->find_result() |
140 withText:string16()]; | 141 withText:string16()]; |
141 } | 142 } |
142 } | 143 } |
143 | 144 |
144 // NSControl delegate method | 145 // NSControl delegate method |
145 - (BOOL)control:(NSControl*)control | 146 - (BOOL)control:(NSControl*)control |
146 textView:(NSTextView*)textView | 147 textView:(NSTextView*)textView |
147 doCommandBySelector:(SEL)command { | 148 doCommandBySelector:(SEL)command { |
148 if (command == @selector(insertNewline:)) { | 149 if (command == @selector(insertNewline:)) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 350 |
350 - (void)prepopulateText:(NSString*)text stopSearch:(BOOL)stopSearch{ | 351 - (void)prepopulateText:(NSString*)text stopSearch:(BOOL)stopSearch{ |
351 [self setFindText:text]; | 352 [self setFindText:text]; |
352 | 353 |
353 // End the find session, hide the "x of y" text and disable the | 354 // End the find session, hide the "x of y" text and disable the |
354 // buttons, but do not close the find bar or raise the window here. | 355 // buttons, but do not close the find bar or raise the window here. |
355 if (stopSearch && findBarBridge_) { | 356 if (stopSearch && findBarBridge_) { |
356 TabContents* contents = | 357 TabContents* contents = |
357 findBarBridge_->GetFindBarController()->tab_contents(); | 358 findBarBridge_->GetFindBarController()->tab_contents(); |
358 if (contents) { | 359 if (contents) { |
359 contents->StopFinding(true); | 360 contents->StopFinding(FindBarController::kClearSelection); |
360 findBarBridge_->ClearResults(contents->find_result()); | 361 findBarBridge_->ClearResults(contents->find_result()); |
361 } | 362 } |
362 } | 363 } |
363 | 364 |
364 // Has to happen after |ClearResults()| above. | 365 // Has to happen after |ClearResults()| above. |
365 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; | 366 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; |
366 [previousButton_ setEnabled:buttonsEnabled]; | 367 [previousButton_ setEnabled:buttonsEnabled]; |
367 [nextButton_ setEnabled:buttonsEnabled]; | 368 [nextButton_ setEnabled:buttonsEnabled]; |
368 } | 369 } |
369 | 370 |
370 @end | 371 @end |
OLD | NEW |