| Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc
|
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
|
| index 0207bf15ff990ae38b7fc2152c08cf26785f2819..8ab01303f91195d2331f4b37e06b085479f8ccff 100644
|
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
|
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
|
| @@ -798,6 +798,14 @@ void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {
|
| menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
|
| IDS_EDIT_SEARCH_ENGINES);
|
|
|
| + if (toolbar_model()->WouldReplaceSearchURLWithSearchTerms() &&
|
| + !model()->user_input_in_progress()) {
|
| + int copy_position = menu_contents->GetIndexOfCommandId(IDS_APP_COPY);
|
| + if (copy_position >= 0)
|
| + menu_contents->InsertItemWithStringIdAt(
|
| + copy_position + 1, IDC_COPY_URL, IDS_COPY_URL);
|
| + }
|
| +
|
| int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE);
|
| if (paste_position >= 0)
|
| menu_contents->InsertItemWithStringIdAt(
|
| @@ -830,6 +838,11 @@ void OmniboxViewViews::ExecuteCommand(int command_id) {
|
| return;
|
| }
|
|
|
| + if (command_id == IDS_COPY_URL) {
|
| + CopyURL();
|
| + return;
|
| + }
|
| +
|
| command_updater()->ExecuteCommand(command_id);
|
| }
|
|
|
| @@ -905,3 +918,13 @@ string16 OmniboxViewViews::GetSelectedText() const {
|
| // TODO(oshima): Support instant, IME.
|
| return textfield_->GetSelectedText();
|
| }
|
| +
|
| +void OmniboxViewViews::CopyURL() {
|
| + const string16& text = toolbar_model()->GetText(false);
|
| + const GURL& url = toolbar_model()->GetURL();
|
| + ui::Clipboard* cb = views::ViewsDelegate::views_delegate->GetClipboard();
|
| + ui::ScopedClipboardWriter scw(cb, ui::Clipboard::BUFFER_STANDARD);
|
| + scw.WriteText(text);
|
| + scw.WriteBookmark(text, url.spec());
|
| + scw.WriteHyperlink(net::EscapeForHTML(text), url.spec());
|
| +}
|
|
|