Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1448)

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm

Issue 8043015: mac: Support "Use Selection for Find" when omnibox is focused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
index 2d0c43d99f670be3c63eb6511f370ec3153e33cd..8cc1491a084c646697148478ea6c516dc0bb79e3 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
@@ -12,6 +12,7 @@
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
+#import "content/browser/find_pasteboard.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -472,4 +473,23 @@ BOOL ThePasteboardIsTooDamnBig() {
[super mouseDown:theEvent];
}
+- (BOOL)validateMenuItem:(NSMenuItem*)item {
+ if ([item action] == @selector(copyToFindPboard:))
+ return [self selectedRange].length > 0;
+ return [super validateMenuItem:item];
+}
+
+- (void)copyToFindPboard:(id)sender {
+ NSRange selectedRange = [self selectedRange];
+ if (selectedRange.length == 0)
+ return;
+ NSAttributedString* selection =
+ [self attributedSubstringForProposedRange:selectedRange
+ actualRange:NULL];
+ if (!selection)
+ return;
+
+ [[FindPasteboard sharedInstance] setFindText:[selection string]];
+}
+
@end
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698