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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

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/views/omnibox/omnibox_view_win.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index d620d9ee9b3a1e038b8a06b9d8433b7e712a5fa3..d83024a2c5c4546cd3e4a8fa7e2f9cda833c8b4d 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -1015,6 +1015,23 @@ int OmniboxViewWin::OnPerformDropImpl(const ui::DropTargetEvent& event,
return ui::DragDropTypes::DRAG_NONE;
}
+bool OmniboxViewWin::ShouldAddCopyURL() const {
Peter Kasting 2012/09/05 22:32:58 Nit: I'm fine with inlining this into IsCommandIdE
dominich 2012/09/05 23:35:34 Done.
+ return !!CanCopy() &&
+ !model()->user_input_in_progress() &&
+ toolbar_model()->WouldReplaceSearchURLWithSearchTerms();
+}
+
+void OmniboxViewWin::CopyURL() {
+ const string16& text = toolbar_model()->GetText(false);
+ const GURL& url = toolbar_model()->GetURL();
+
+ ui::ScopedClipboardWriter scw(g_browser_process->clipboard(),
+ ui::Clipboard::BUFFER_STANDARD);
+ scw.WriteText(text);
+ scw.WriteBookmark(text, url.spec());
+ scw.WriteHyperlink(net::EscapeForHTML(text), url.spec());
Peter Kasting 2012/09/05 22:32:58 Don't call WriteHyperlink (see https://chromiumcod
dominich 2012/09/05 23:35:34 Done.
+}
+
bool OmniboxViewWin::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
ui::KeyboardCode key = event.key_code();
// We don't process ALT + numpad digit as accelerators, they are used for
@@ -1084,6 +1101,7 @@ bool OmniboxViewWin::IsCommandIdEnabled(int command_id) const {
case IDS_UNDO: return !!CanUndo();
case IDC_CUT: return !!CanCut();
case IDC_COPY: return !!CanCopy();
+ case IDC_COPY_URL: return ShouldAddCopyURL();
case IDC_PASTE: return !!CanPaste();
case IDS_PASTE_AND_GO: return model()->CanPasteAndGo(GetClipboardText());
case IDS_SELECT_ALL: return !!CanSelectAll();
@@ -1137,6 +1155,10 @@ void OmniboxViewWin::ExecuteCommand(int command_id) {
Copy();
break;
+ case IDC_COPY_URL:
+ CopyURL();
+ break;
+
case IDC_PASTE:
Paste();
break;

Powered by Google App Engine
This is Rietveld 408576698