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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.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: rebase 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/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..61694da9d7d081bc2bd9ec0379e0454790aaab6c 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 (!ShouldEnableCopyURL()) {
+ 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(ShouldEnableCopyURL());
+
+ 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,15 @@ void OmniboxViewMac::OnPaste() {
}
}
+// TODO(dominich): Move to OmniboxView base class? Currently this is defined on
+// the AutocompleteTextFieldObserver but the logic is shared between all
+// platforms. Some refactor might be necessary to simplify this. Or at least
+// this method could call the OmniboxView version.
+bool OmniboxViewMac::ShouldEnableCopyURL() {
+ return !model()->user_input_in_progress() &&
+ toolbar_model()->WouldReplaceSearchURLWithSearchTerms();
+}
+
bool OmniboxViewMac::CanPasteAndGo() {
return model()->CanPasteAndGo(GetClipboardText());
}
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698