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

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

Issue 207047: [Mac] Convert Omnibox paste-and-go to use AutocompleteTextFieldObserver. (Closed)
Patch Set: Oops - remove test before its time. 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
diff --git a/chrome/browser/cocoa/autocomplete_text_field_editor.mm b/chrome/browser/cocoa/autocomplete_text_field_editor.mm
index 6516e4bfd320e32a7e81734f1d0eb1cd1cab8b7f..9cefff91a5f7006e0c9825d62dacff94155a1d98 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_editor.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_editor.mm
@@ -56,9 +56,11 @@
}
- (void)pasteAndGo:sender {
- id delegate = [self delegate];
- if ([delegate respondsToSelector:@selector(textDidPasteAndGo:)])
- [delegate textDidPasteAndGo:self];
+ AutocompleteTextFieldObserver* observer = [self observer];
+ DCHECK(observer);
+ if (observer) {
+ observer->OnPasteAndGo();
+ }
}
// We have rich text, but it shouldn't be modified by the user, so
@@ -76,26 +78,29 @@
- (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];
+ [menu addItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_CUT)
+ action:@selector(cut:)
+ keyEquivalent:@""];
+ [menu addItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_COPY)
+ action:@selector(copy:)
+ keyEquivalent:@""];
+ [menu addItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_PASTE)
+ action:@selector(paste:)
+ keyEquivalent:@""];
// Paste and go/search.
- id delegate = [self delegate];
+ AutocompleteTextFieldObserver* observer = [self observer];
+ DCHECK(observer);
+ if (observer && observer->CanPasteAndGo()) {
+ const int string_id = observer->GetPasteActionStringId();
+ NSString* label = l10n_util::GetNSStringWithFixup(string_id);
- 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?
+ // 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];
+ [menu addItemWithTitle:label
+ action:@selector(pasteAndGo:)
+ keyEquivalent:@""];
}
}
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_editor.h ('k') | chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698