| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) { | 347 void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) { |
| 348 // In the base class, touch text selection is deactivated when a command is | 348 // In the base class, touch text selection is deactivated when a command is |
| 349 // executed. Since we are not always calling the base class implementation | 349 // executed. Since we are not always calling the base class implementation |
| 350 // here, we need to deactivate touch text selection here, too. | 350 // here, we need to deactivate touch text selection here, too. |
| 351 DestroyTouchSelection(); | 351 DestroyTouchSelection(); |
| 352 switch (command_id) { | 352 switch (command_id) { |
| 353 // These commands don't invoke the popup via OnBefore/AfterPossibleChange(). | 353 // These commands don't invoke the popup via OnBefore/AfterPossibleChange(). |
| 354 case IDS_PASTE_AND_GO: | 354 case IDS_PASTE_AND_GO: |
| 355 model()->PasteAndGo(GetClipboardText()); | 355 model()->PasteAndGo(GetClipboardText()); |
| 356 return; | 356 return; |
| 357 case IDS_SHOW_URL: | |
| 358 controller()->ShowURL(); | |
| 359 return; | |
| 360 case IDC_EDIT_SEARCH_ENGINES: | 357 case IDC_EDIT_SEARCH_ENGINES: |
| 361 location_bar_view_->command_updater()->ExecuteCommand(command_id); | 358 location_bar_view_->command_updater()->ExecuteCommand(command_id); |
| 362 return; | 359 return; |
| 363 | 360 |
| 364 // These commands do invoke the popup. | 361 // These commands do invoke the popup. |
| 365 case IDS_APP_PASTE: | 362 case IDS_APP_PASTE: |
| 366 ExecuteTextEditCommand(ui::TextEditCommand::PASTE); | 363 ExecuteTextEditCommand(ui::TextEditCommand::PASTE); |
| 367 return; | 364 return; |
| 368 default: | 365 default: |
| 369 if (Textfield::IsCommandIdEnabled(command_id)) { | 366 if (Textfield::IsCommandIdEnabled(command_id)) { |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 // The location bar needs to repaint without a focus ring. | 802 // The location bar needs to repaint without a focus ring. |
| 806 if (ui::MaterialDesignController::IsModeMaterial()) | 803 if (ui::MaterialDesignController::IsModeMaterial()) |
| 807 location_bar_view_->SchedulePaint(); | 804 location_bar_view_->SchedulePaint(); |
| 808 } | 805 } |
| 809 | 806 |
| 810 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { | 807 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
| 811 if (command_id == IDS_APP_PASTE) | 808 if (command_id == IDS_APP_PASTE) |
| 812 return !read_only() && !GetClipboardText().empty(); | 809 return !read_only() && !GetClipboardText().empty(); |
| 813 if (command_id == IDS_PASTE_AND_GO) | 810 if (command_id == IDS_PASTE_AND_GO) |
| 814 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); | 811 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); |
| 815 // TODO(treib): Completely remove IDS_SHOW_URL. crbug.com/627747 | |
| 816 if (command_id == IDS_SHOW_URL) | |
| 817 return false; | |
| 818 return Textfield::IsCommandIdEnabled(command_id) || | 812 return Textfield::IsCommandIdEnabled(command_id) || |
| 819 location_bar_view_->command_updater()->IsCommandEnabled(command_id); | 813 location_bar_view_->command_updater()->IsCommandEnabled(command_id); |
| 820 } | 814 } |
| 821 | 815 |
| 822 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { | 816 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { |
| 823 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); | 817 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); |
| 824 } | 818 } |
| 825 | 819 |
| 826 void OmniboxViewViews::DoInsertChar(base::char16 ch) { | 820 void OmniboxViewViews::DoInsertChar(base::char16 ch) { |
| 827 // If |insert_char_time_| is not null, there's a pending insert char operation | 821 // If |insert_char_time_| is not null, there's a pending insert char operation |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1084 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1091 | 1085 |
| 1092 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1086 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1093 | 1087 |
| 1094 // Minor note: We use IDC_ for command id here while the underlying textfield | 1088 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1095 // is using IDS_ for all its command ids. This is because views cannot depend | 1089 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1096 // on IDC_ for now. | 1090 // on IDC_ for now. |
| 1097 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1091 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1098 IDS_EDIT_SEARCH_ENGINES); | 1092 IDS_EDIT_SEARCH_ENGINES); |
| 1099 } | 1093 } |
| OLD | NEW |