OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" // IDC_* | 9 #include "chrome/app/chrome_command_ids.h" // IDC_* |
10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
14 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 14 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
15 #import "content/browser/find_pasteboard.h" | |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util_mac.h" | 17 #include "ui/base/l10n/l10n_util_mac.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // When too much data is put into a single-line text field, things get | 21 // When too much data is put into a single-line text field, things get |
21 // janky due to the cost of computing the blink rect. Sometimes users | 22 // janky due to the cost of computing the blink rect. Sometimes users |
22 // accidentally paste large amounts, so place a limit on what will be | 23 // accidentally paste large amounts, so place a limit on what will be |
23 // accepted. | 24 // accepted. |
24 // | 25 // |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 | 466 |
466 - (void)mouseDown:(NSEvent*)theEvent { | 467 - (void)mouseDown:(NSEvent*)theEvent { |
467 // Close the popup before processing the event. | 468 // Close the popup before processing the event. |
468 AutocompleteTextFieldObserver* observer = [self observer]; | 469 AutocompleteTextFieldObserver* observer = [self observer]; |
469 if (observer) | 470 if (observer) |
470 observer->ClosePopup(); | 471 observer->ClosePopup(); |
471 | 472 |
472 [super mouseDown:theEvent]; | 473 [super mouseDown:theEvent]; |
473 } | 474 } |
474 | 475 |
476 - (BOOL)validateMenuItem:(NSMenuItem*)item { | |
477 if ([item action] == @selector(copyToFindPboard:)) | |
478 return [self selectedRange].length > 0; | |
479 return YES; | |
Avi (use Gerrit)
2011/09/24 11:45:04
return [super validateMenuItem:item]? Otherwise co
| |
480 } | |
481 | |
482 - (void)copyToFindPboard:(id)sender { | |
483 NSRange selectedRange = [self selectedRange]; | |
484 if (selectedRange.length == 0) | |
485 return; | |
486 NSAttributedString* selection = | |
487 [self attributedSubstringForProposedRange:selectedRange | |
488 actualRange:NULL]; | |
489 if (!selection) | |
490 return; | |
491 | |
492 [[FindPasteboard sharedInstance] setFindText:[selection string]]; | |
Scott Hess - ex-Googler
2011/09/24 15:37:27
There are times I find myself not entirely convinc
| |
493 } | |
494 | |
475 @end | 495 @end |
OLD | NEW |