Chromium Code Reviews| 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 de46181bb1a875f1735245f9c239c11cbf1cfbd6..4c80c1bcb54f94602cc9923108919b7c028dbf57 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() && | 
| 
 
Peter Kasting
2012/09/06 00:01:46
So here you've elected to only insert the command
 
dominich
2012/09/06 17:50:25
Done.
Except on cocoa, which already has the diff
 
 | 
| + !model()->user_input_in_progress()) { | 
| + int copy_position = menu_contents->GetIndexOfCommandId(IDS_APP_COPY); | 
| + if (copy_position >= 0) | 
| 
 
Peter Kasting
2012/09/05 22:32:58
Nit: {} (also please fix the conditional just belo
 
dominich
2012/09/05 23:35:34
I don't know of any cases, but I also don't know o
 
Peter Kasting
2012/09/06 00:01:46
You hit on the reason I'm worried -- it's not the
 
dominich
2012/09/06 17:50:25
Done.
 
 | 
| + 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; | 
| 
 
Peter Kasting
2012/09/05 22:32:58
Nit: Shorter:
  if (command_id == IDS_PASTE_AND_G
 
dominich
2012/09/05 23:35:34
Done.
 
 | 
| } | 
| + 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); | 
| 
 
Peter Kasting
2012/09/05 22:32:58
I suggest factoring out the end of OnAfterCutOrCop
 
dominich
2012/09/05 23:35:34
Done.
 
 | 
| + scw.WriteText(text); | 
| + scw.WriteBookmark(text, url.spec()); | 
| + scw.WriteHyperlink(net::EscapeForHTML(text), url.spec()); | 
| +} |