| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // selection lest restoring it fights with the "select all" action. It's | 669 // selection lest restoring it fights with the "select all" action. It's |
| 670 // possible to later set select_all_on_mouse_release_ back to false, but | 670 // possible to later set select_all_on_mouse_release_ back to false, but |
| 671 // that happens for things like dragging, which are cases where having | 671 // that happens for things like dragging, which are cases where having |
| 672 // invalidated this saved selection is still OK. | 672 // invalidated this saved selection is still OK. |
| 673 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); | 673 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); |
| 674 } | 674 } |
| 675 return views::Textfield::OnMousePressed(event); | 675 return views::Textfield::OnMousePressed(event); |
| 676 } | 676 } |
| 677 | 677 |
| 678 bool OmniboxViewViews::OnMouseDragged(const ui::MouseEvent& event) { | 678 bool OmniboxViewViews::OnMouseDragged(const ui::MouseEvent& event) { |
| 679 if (ExceededDragThreshold(event.location() - last_click_location())) | 679 if (ExceededDragThreshold(gfx::ToFlooredPoint(event.location()) - |
| 680 last_click_location())) |
| 680 select_all_on_mouse_release_ = false; | 681 select_all_on_mouse_release_ = false; |
| 681 return views::Textfield::OnMouseDragged(event); | 682 return views::Textfield::OnMouseDragged(event); |
| 682 } | 683 } |
| 683 | 684 |
| 684 void OmniboxViewViews::OnMouseReleased(const ui::MouseEvent& event) { | 685 void OmniboxViewViews::OnMouseReleased(const ui::MouseEvent& event) { |
| 685 views::Textfield::OnMouseReleased(event); | 686 views::Textfield::OnMouseReleased(event); |
| 686 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { | 687 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { |
| 687 // When the user has clicked and released to give us focus, select all | 688 // When the user has clicked and released to give us focus, select all |
| 688 // unless we're omitting the URL (in which case refining an existing query | 689 // unless we're omitting the URL (in which case refining an existing query |
| 689 // is common enough that we do click-to-place-cursor). | 690 // is common enough that we do click-to-place-cursor). |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 menu_contents->InsertItemWithStringIdAt( | 1042 menu_contents->InsertItemWithStringIdAt( |
| 1042 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1043 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 // Minor note: We use IDC_ for command id here while the underlying textfield | 1046 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1046 // is using IDS_ for all its command ids. This is because views cannot depend | 1047 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1047 // on IDC_ for now. | 1048 // on IDC_ for now. |
| 1048 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1049 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1049 IDS_EDIT_SEARCH_ENGINES); | 1050 IDS_EDIT_SEARCH_ENGINES); |
| 1050 } | 1051 } |
| OLD | NEW |