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

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

Issue 10915069: Add Copy URL option to Omnibox context menu when URL is replaced by Instant Extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile fixes Created 8 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/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]) {

Powered by Google App Engine
This is Rietveld 408576698