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

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

Issue 192008: [Mac] Implement Paste and Go/Search. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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
Index: chrome/browser/cocoa/autocomplete_text_field_editor.mm
===================================================================
--- chrome/browser/cocoa/autocomplete_text_field_editor.mm (revision 26600)
+++ chrome/browser/cocoa/autocomplete_text_field_editor.mm (working copy)
@@ -4,8 +4,9 @@
#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
+#include "app/l10n_util_mac.h"
#include "base/string_util.h"
-#include "base/sys_string_conversions.h"
+#include "grit/generated_resources.h"
@implementation AutocompleteTextFieldEditor
@@ -45,6 +46,12 @@
}
}
+- (void)pasteAndGo:sender {
+ id delegate = [self delegate];
+ if ([delegate respondsToSelector:@selector(textDidPasteAndGo:)])
+ [delegate textDidPasteAndGo:self];
+}
+
// We have rich text, but it shouldn't be modified by the user, so
// don't update the font panel. In theory, -setUsesFontPanel: should
// accomplish this, but that gets called frequently with YES when
@@ -58,4 +65,32 @@
- (void)updateRuler {
}
+- (NSMenu*)menuForEvent:(NSEvent*)event {
+ NSMenu* menu = [[[NSMenu alloc] initWithTitle:@"TITLE"] autorelease];
+ [menu insertItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_CUT)
+ action:@selector(cut:)
+ keyEquivalent:@"" atIndex:0];
+ [menu insertItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_COPY)
+ action:@selector(copy:)
+ keyEquivalent:@"" atIndex:1];
+ [menu insertItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_PASTE)
+ action:@selector(paste:)
+ keyEquivalent:@"" atIndex:2];
+
+ // Paste and go/search.
+ id delegate = [self delegate];
+
+ if ([delegate respondsToSelector:@selector(textPasteActionString:)]) {
+ NSString* label = [delegate textPasteActionString:self];
+ // TODO(rohitrao): If the clipboard is empty, should we show a greyed-out
+ // "Paste and Go" or nothing at all?
+ if (label) {
+ [menu insertItemWithTitle:label action:@selector(pasteAndGo:)
+ keyEquivalent:@"" atIndex:3];
+ }
+ }
+
+ return menu;
+}
+
@end
Property changes on: chrome/browser/cocoa/autocomplete_text_field_editor.mm
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698