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 <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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 | 691 |
| 692 if (HasTextBeingDragged()) | 692 if (HasTextBeingDragged()) |
| 693 CloseOmniboxPopup(); | 693 CloseOmniboxPopup(); |
| 694 | 694 |
| 695 return views::Textfield::OnMouseDragged(event); | 695 return views::Textfield::OnMouseDragged(event); |
| 696 } | 696 } |
| 697 | 697 |
| 698 void OmniboxViewViews::OnMouseReleased(const ui::MouseEvent& event) { | 698 void OmniboxViewViews::OnMouseReleased(const ui::MouseEvent& event) { |
| 699 views::Textfield::OnMouseReleased(event); | 699 views::Textfield::OnMouseReleased(event); |
| 700 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { | 700 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { |
| 701 // When the user has clicked and released to give us focus, select all | 701 // When the user has clicked and released to give us focus, select all. |
|
Peter Kasting
2016/08/13 05:03:44
Nit: Move this comment above the line above, and t
Marc Treib
2016/08/16 12:00:17
Done.
| |
| 702 // unless we're omitting the URL (in which case refining an existing query | 702 if (select_all_on_mouse_release_) { |
| 703 // is common enough that we do click-to-place-cursor). | |
| 704 if (select_all_on_mouse_release_ && | |
| 705 !controller()->GetToolbarModel()->WouldReplaceURL()) { | |
| 706 // Select all in the reverse direction so as not to scroll the caret | 703 // Select all in the reverse direction so as not to scroll the caret |
| 707 // into view and shift the contents jarringly. | 704 // into view and shift the contents jarringly. |
| 708 SelectAll(true); | 705 SelectAll(true); |
| 709 } | 706 } |
| 710 } | 707 } |
| 711 select_all_on_mouse_release_ = false; | 708 select_all_on_mouse_release_ = false; |
| 712 } | 709 } |
| 713 | 710 |
| 714 bool OmniboxViewViews::OnKeyPressed(const ui::KeyEvent& event) { | 711 bool OmniboxViewViews::OnKeyPressed(const ui::KeyEvent& event) { |
| 715 // Skip processing of [Alt]+<num-pad digit> Unicode alt key codes. | 712 // Skip processing of [Alt]+<num-pad digit> Unicode alt key codes. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 // The location bar needs to repaint without a focus ring. | 874 // The location bar needs to repaint without a focus ring. |
| 878 if (ui::MaterialDesignController::IsModeMaterial()) | 875 if (ui::MaterialDesignController::IsModeMaterial()) |
| 879 location_bar_view_->SchedulePaint(); | 876 location_bar_view_->SchedulePaint(); |
| 880 } | 877 } |
| 881 | 878 |
| 882 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { | 879 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
| 883 if (command_id == IDS_APP_PASTE) | 880 if (command_id == IDS_APP_PASTE) |
| 884 return !read_only() && !GetClipboardText().empty(); | 881 return !read_only() && !GetClipboardText().empty(); |
| 885 if (command_id == IDS_PASTE_AND_GO) | 882 if (command_id == IDS_PASTE_AND_GO) |
| 886 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); | 883 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); |
| 884 // TODO(treib): Completely remove IDS_SHOW_URL. crbug.com/627747 | |
| 887 if (command_id == IDS_SHOW_URL) | 885 if (command_id == IDS_SHOW_URL) |
| 888 return controller()->GetToolbarModel()->WouldReplaceURL(); | 886 return false; |
| 889 return Textfield::IsCommandIdEnabled(command_id) || | 887 return Textfield::IsCommandIdEnabled(command_id) || |
| 890 location_bar_view_->command_updater()->IsCommandEnabled(command_id); | 888 location_bar_view_->command_updater()->IsCommandEnabled(command_id); |
| 891 } | 889 } |
| 892 | 890 |
| 893 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { | 891 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { |
| 894 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); | 892 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); |
| 895 } | 893 } |
| 896 | 894 |
| 897 void OmniboxViewViews::DoInsertChar(base::char16 ch) { | 895 void OmniboxViewViews::DoInsertChar(base::char16 ch) { |
| 898 // If |insert_char_time_| is not null, there's a pending insert char operation | 896 // 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... | |
| 1093 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1091 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1094 | 1092 |
| 1095 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1093 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1096 | 1094 |
| 1097 // Minor note: We use IDC_ for command id here while the underlying textfield | 1095 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1098 // is using IDS_ for all its command ids. This is because views cannot depend | 1096 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1099 // on IDC_ for now. | 1097 // on IDC_ for now. |
| 1100 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1098 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1101 IDS_EDIT_SEARCH_ENGINES); | 1099 IDS_EDIT_SEARCH_ENGINES); |
| 1102 } | 1100 } |
| OLD | NEW |