OLD | NEW |
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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 [[FindPasteboard sharedInstance] setFindText:findText]; | 205 [[FindPasteboard sharedInstance] setFindText:findText]; |
206 } | 206 } |
207 | 207 |
208 if ([findText length] > 0) { | 208 if ([findText length] > 0) { |
209 findTabHelper-> | 209 findTabHelper-> |
210 StartFinding(base::SysNSStringToUTF16(findText), true, false); | 210 StartFinding(base::SysNSStringToUTF16(findText), true, false); |
211 } else { | 211 } else { |
212 // The textbox is empty so we reset. | 212 // The textbox is empty so we reset. |
213 findTabHelper->StopFinding(FindBarController::kClearSelectionOnPage); | 213 findTabHelper->StopFinding(FindBarController::kClearSelectionOnPage); |
214 [self updateUIForFindResult:findTabHelper->find_result() | 214 [self updateUIForFindResult:findTabHelper->find_result() |
215 withText:string16()]; | 215 withText:base::string16()]; |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 // NSControl delegate method | 219 // NSControl delegate method |
220 - (BOOL)control:(NSControl*)control | 220 - (BOOL)control:(NSControl*)control |
221 textView:(NSTextView*)textView | 221 textView:(NSTextView*)textView |
222 doCommandBySelector:(SEL)command { | 222 doCommandBySelector:(SEL)command { |
223 if (command == @selector(insertNewline:)) { | 223 if (command == @selector(insertNewline:)) { |
224 // Pressing Return | 224 // Pressing Return |
225 NSEvent* event = [NSApp currentEvent]; | 225 NSEvent* event = [NSApp currentEvent]; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 BOOL buttonsEnabled = [[findText_ stringValue] length] > 0 ? YES : NO; | 376 BOOL buttonsEnabled = [[findText_ stringValue] length] > 0 ? YES : NO; |
377 [previousButton_ setEnabled:buttonsEnabled]; | 377 [previousButton_ setEnabled:buttonsEnabled]; |
378 [nextButton_ setEnabled:buttonsEnabled]; | 378 [nextButton_ setEnabled:buttonsEnabled]; |
379 [[findText_ findBarTextFieldCell] clearResults]; | 379 [[findText_ findBarTextFieldCell] clearResults]; |
380 } | 380 } |
381 } | 381 } |
382 | 382 |
383 - (void)clearResults:(const FindNotificationDetails&)results { | 383 - (void)clearResults:(const FindNotificationDetails&)results { |
384 // Just call updateUIForFindResult, which will take care of clearing | 384 // Just call updateUIForFindResult, which will take care of clearing |
385 // the search text and the results label. | 385 // the search text and the results label. |
386 [self updateUIForFindResult:results withText:string16()]; | 386 [self updateUIForFindResult:results withText:base::string16()]; |
387 } | 387 } |
388 | 388 |
389 - (void)updateUIForFindResult:(const FindNotificationDetails&)result | 389 - (void)updateUIForFindResult:(const FindNotificationDetails&)result |
390 withText:(const base::string16&)findText { | 390 withText:(const base::string16&)findText { |
391 // If we don't have any results and something was passed in, then | 391 // If we don't have any results and something was passed in, then |
392 // that means someone pressed Cmd-G while the Find box was | 392 // that means someone pressed Cmd-G while the Find box was |
393 // closed. In that case we need to repopulate the Find box with what | 393 // closed. In that case we need to repopulate the Find box with what |
394 // was passed in. | 394 // was passed in. |
395 if ([[findText_ stringValue] length] == 0 && !findText.empty()) { | 395 if ([[findText_ stringValue] length] == 0 && !findText.empty()) { |
396 [findText_ setStringValue:base::SysUTF16ToNSString(findText)]; | 396 [findText_ setStringValue:base::SysUTF16ToNSString(findText)]; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 621 } |
622 | 622 |
623 - (BrowserWindowController*)browserWindowController { | 623 - (BrowserWindowController*)browserWindowController { |
624 if (!browser_) | 624 if (!browser_) |
625 return nil; | 625 return nil; |
626 return [BrowserWindowController | 626 return [BrowserWindowController |
627 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; | 627 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; |
628 } | 628 } |
629 | 629 |
630 @end | 630 @end |
OLD | NEW |