Chromium Code Reviews| 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? |
|
Peter Kasting
2012/09/11 21:52:59
Yes (since you use logic identical to this a numbe
dominich
2012/09/12 15:23:09
I explained in an earlier revision that it's not a
|
| +bool OmniboxViewMac::ShouldAddCopyURL() { |
| + return !model()->user_input_in_progress() && |
| + toolbar_model()->WouldReplaceSearchURLWithSearchTerms(); |
| +} |
| + |
| bool OmniboxViewMac::CanPasteAndGo() { |
| return model()->CanPasteAndGo(GetClipboardText()); |
| } |