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 deb9b2d6ef362d65c0bd8b97d6b8273cd378325a..de6b35f43b0c25c40853c36fd8ab24f58d0145f4 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 |
@@ -96,6 +96,13 @@ BOOL ThePasteboardIsTooDamnBig() { |
[self delete:nil]; |
} |
+- (void)copyURL:(id)sender { |
+ AutocompleteTextFieldObserver* observer = [self observer]; |
+ DCHECK(observer); |
+ if (observer && observer->CanCopy()) |
dhollowa
2012/09/05 21:22:34
nit: No need to handle DCHECK failure. Prefer: if
dominich
2012/09/05 21:30:54
Done.
|
+ observer->CopyURLToPasteboard([NSPasteboard generalPasteboard]); |
+} |
+ |
// This class assumes that the delegate is an AutocompleteTextField. |
// Enforce that assumption. |
- (AutocompleteTextField*)delegate { |
@@ -208,10 +215,24 @@ BOOL ThePasteboardIsTooDamnBig() { |
[menu addItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_COPY) |
action:@selector(copy:) |
keyEquivalent:@""]; |
+ |
+ if ([self isEditable]) { |
+ // Copy URL if the URL has been replaced by the Extended Instant API. |
+ AutocompleteTextFieldObserver* observer = [self observer]; |
+ DCHECK(observer); |
+ if (observer && observer->ShouldAddCopyURL()) { |
dhollowa
2012/09/05 21:22:34
nit: No need to handle DCHECK failure. Prefer: if
dominich
2012/09/05 21:30:54
Done.
|
+ NSString* label = l10n_util::GetNSStringWithFixup(IDS_COPY_URL_MAC); |
+ [menu addItemWithTitle:label |
+ action:@selector(copyURL:) |
+ keyEquivalent:@""]; |
+ } |
+ } |
+ |
[menu addItemWithTitle:l10n_util::GetNSStringWithFixup(IDS_PASTE) |
action:@selector(paste:) |
keyEquivalent:@""]; |
+ |
dhollowa
2012/09/05 21:22:34
nit: remove extra line.
dominich
2012/09/05 21:30:54
Done.
|
// TODO(shess): If the control is not editable, should we show a |
// greyed-out "Paste and Go"? |
if ([self isEditable]) { |