| 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 // The location bar needs to repaint without a focus ring. | 870 // The location bar needs to repaint without a focus ring. |
| 874 if (ui::MaterialDesignController::IsModeMaterial()) | 871 if (ui::MaterialDesignController::IsModeMaterial()) |
| 875 location_bar_view_->SchedulePaint(); | 872 location_bar_view_->SchedulePaint(); |
| 876 } | 873 } |
| 877 | 874 |
| 878 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { | 875 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
| 879 if (command_id == IDS_APP_PASTE) | 876 if (command_id == IDS_APP_PASTE) |
| 880 return !read_only() && !GetClipboardText().empty(); | 877 return !read_only() && !GetClipboardText().empty(); |
| 881 if (command_id == IDS_PASTE_AND_GO) | 878 if (command_id == IDS_PASTE_AND_GO) |
| 882 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); | 879 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); |
| 883 // TODO(treib): Completely remove IDS_SHOW_URL. crbug.com/627747 | |
| 884 if (command_id == IDS_SHOW_URL) | |
| 885 return false; | |
| 886 return Textfield::IsCommandIdEnabled(command_id) || | 880 return Textfield::IsCommandIdEnabled(command_id) || |
| 887 location_bar_view_->command_updater()->IsCommandEnabled(command_id); | 881 location_bar_view_->command_updater()->IsCommandEnabled(command_id); |
| 888 } | 882 } |
| 889 | 883 |
| 890 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { | 884 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { |
| 891 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); | 885 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); |
| 892 } | 886 } |
| 893 | 887 |
| 894 void OmniboxViewViews::DoInsertChar(base::char16 ch) { | 888 void OmniboxViewViews::DoInsertChar(base::char16 ch) { |
| 895 // If |insert_char_time_| is not null, there's a pending insert char operation | 889 // If |insert_char_time_| is not null, there's a pending insert char operation |
| (...skipping 194 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 |