Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
index 29bf3a05ae477606e9e9ca498375a16e1bfd93ed..c05282657b8303c03d274022ea62639e1cebcd5d 100644 |
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
@@ -825,10 +825,14 @@ void OmniboxViewMac::CopyToPasteboard(NSPasteboard* pb) { |
string16 text = base::SysNSStringToUTF16( |
[[field_ stringValue] substringWithRange:selection]); |
+ // Copy the URL unless this is the search URL and it's being replaced by the |
+ // Extended Instant API. |
GURL url; |
bool write_url = false; |
- model()->AdjustTextForCopy(selection.location, IsSelectAll(), &text, &url, |
- &write_url); |
+ if (!ShouldAddCopyURL()) { |
+ model()->AdjustTextForCopy(selection.location, IsSelectAll(), &text, &url, |
+ &write_url); |
+ } |
NSString* nstext = base::SysUTF16ToNSString(text); |
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; |
@@ -840,6 +844,21 @@ void OmniboxViewMac::CopyToPasteboard(NSPasteboard* pb) { |
} |
} |
+void OmniboxViewMac::CopyURLToPasteboard(NSPasteboard* pb) { |
+ DCHECK(CanCopy()); |
+ DCHECK(ShouldAddCopyURL()); |
+ |
+ string16 text = toolbar_model()->GetText(false); |
+ GURL url = toolbar_model()->GetURL(); |
+ |
+ NSString* nstext = base::SysUTF16ToNSString(text); |
+ [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; |
+ [pb setString:nstext forType:NSStringPboardType]; |
+ |
+ [pb declareURLPasteboardWithAdditionalTypes:[NSArray array] owner:nil]; |
+ [pb setDataForURL:base::SysUTF8ToNSString(url.spec()) title:nstext]; |
+} |
+ |
void OmniboxViewMac::OnPaste() { |
// This code currently expects |field_| to be focussed. |
DCHECK([field_ currentEditor]); |
@@ -872,6 +891,12 @@ void OmniboxViewMac::OnPaste() { |
} |
} |
+// TODO(dominich): Move to OmniboxView base class? |
+bool OmniboxViewMac::ShouldAddCopyURL() { |
+ return !model()->user_input_in_progress() && |
+ toolbar_model()->WouldReplaceSearchURLWithSearchTerms(); |
+} |
+ |
bool OmniboxViewMac::CanPasteAndGo() { |
return model()->CanPasteAndGo(GetClipboardText()); |
} |