Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); | 762 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); |
| 763 DCHECK(paste_position >= 0); | 763 DCHECK(paste_position >= 0); |
| 764 menu_contents->InsertItemWithStringIdAt( | 764 menu_contents->InsertItemWithStringIdAt( |
| 765 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 765 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 766 } | 766 } |
| 767 | 767 |
| 768 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { | 768 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
| 769 if (command_id == IDS_PASTE_AND_GO) | 769 if (command_id == IDS_PASTE_AND_GO) |
| 770 return model()->CanPasteAndGo(GetClipboardText()); | 770 return model()->CanPasteAndGo(GetClipboardText()); |
| 771 if (command_id == IDC_COPY_URL) { | 771 if (command_id == IDC_COPY_URL) { |
| 772 return toolbar_model()->WouldReplaceSearchURLWithSearchTerms() && | 772 return toolbar_model()->GetSearchTermType() != |
|
Peter Kasting
2013/04/25 19:42:54
Nit: Odd indenting; how about:
return !model(
sail
2013/04/25 22:18:46
Done.
| |
| 773 !model()->user_input_in_progress(); | 773 ToolbarModel::SEARCH_TERM_NONE && |
| 774 !model()->user_input_in_progress(); | |
| 774 } | 775 } |
| 775 return command_updater()->IsCommandEnabled(command_id); | 776 return command_updater()->IsCommandEnabled(command_id); |
| 776 } | 777 } |
| 777 | 778 |
| 778 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { | 779 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { |
| 779 return command_id == IDS_PASTE_AND_GO; | 780 return command_id == IDS_PASTE_AND_GO; |
| 780 } | 781 } |
| 781 | 782 |
| 782 string16 OmniboxViewViews::GetLabelForCommandId(int command_id) const { | 783 string16 OmniboxViewViews::GetLabelForCommandId(int command_id) const { |
| 783 if (command_id == IDS_PASTE_AND_GO) { | 784 if (command_id == IDS_PASTE_AND_GO) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 903 const string16 text(GetClipboardText()); | 904 const string16 text(GetClipboardText()); |
| 904 if (!text.empty()) { | 905 if (!text.empty()) { |
| 905 // Record this paste, so we can do different behavior. | 906 // Record this paste, so we can do different behavior. |
| 906 model()->on_paste(); | 907 model()->on_paste(); |
| 907 // Force a Paste operation to trigger the text_changed code in | 908 // Force a Paste operation to trigger the text_changed code in |
| 908 // OnAfterPossibleChange(), even if identical contents are pasted. | 909 // OnAfterPossibleChange(), even if identical contents are pasted. |
| 909 text_before_change_.clear(); | 910 text_before_change_.clear(); |
| 910 ReplaceSelection(text); | 911 ReplaceSelection(text); |
| 911 } | 912 } |
| 912 } | 913 } |
| OLD | NEW |