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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
765 location_bar_view_->Layout(); | 765 location_bar_view_->Layout(); |
766 } | 766 } |
767 | 767 |
768 void OmniboxViewViews::OnBlur() { | 768 void OmniboxViewViews::OnBlur() { |
769 // Save the user's existing selection to restore it later. | 769 // Save the user's existing selection to restore it later. |
770 saved_selection_for_focus_change_ = GetSelectedRange(); | 770 saved_selection_for_focus_change_ = GetSelectedRange(); |
771 | 771 |
772 views::Textfield::OnBlur(); | 772 views::Textfield::OnBlur(); |
773 model()->OnWillKillFocus(); | 773 model()->OnWillKillFocus(); |
774 | 774 |
775 // If ZeroSuggest is active, we may have refused to show an update to the | 775 // If ZeroSuggest is active, and there is evidence that there is a text |
776 // underlying permanent URL that happened while the popup was open, so | 776 // update to show, revert to ensure that update is shown now. Otherwise, |
777 // revert to ensure that update is shown now. Otherwise, make sure to call | 777 // make sure to call CloseOmniboxPopup() unconditionally, so that if |
778 // CloseOmniboxPopup() unconditionally, so that if ZeroSuggest is in the midst | 778 // ZeroSuggest is in the midst of running but hasn't yet opened the popup, |
779 // of running but hasn't yet opened the popup, it will be halted. | 779 // it will be halted. |
Peter Kasting
2017/04/10 23:04:13
Nit: Maybe something in this comment should talk a
Kevin Bailey
2017/04/11 14:12:41
It seems to me that number the cases of calling Re
Peter Kasting
2017/04/11 20:04:39
Right. My point is that, to a reader, it's not im
Kevin Bailey
2017/04/12 14:57:03
There are a dozen things that revert does addition
| |
780 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen()) | 780 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen() && |
781 text() != model()->PermanentText()) | |
781 RevertAll(); | 782 RevertAll(); |
782 else | 783 else |
783 CloseOmniboxPopup(); | 784 CloseOmniboxPopup(); |
784 | 785 |
785 // Tell the model to reset itself. | 786 // Tell the model to reset itself. |
786 model()->OnKillFocus(); | 787 model()->OnKillFocus(); |
787 | 788 |
788 // Make sure the beginning of the text is visible. | 789 // Make sure the beginning of the text is visible. |
789 SelectRange(gfx::Range(0)); | 790 SelectRange(gfx::Range(0)); |
790 | 791 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1058 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1059 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1059 | 1060 |
1060 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1061 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1061 | 1062 |
1062 // Minor note: We use IDC_ for command id here while the underlying textfield | 1063 // Minor note: We use IDC_ for command id here while the underlying textfield |
1063 // is using IDS_ for all its command ids. This is because views cannot depend | 1064 // is using IDS_ for all its command ids. This is because views cannot depend |
1064 // on IDC_ for now. | 1065 // on IDC_ for now. |
1065 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1066 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1066 IDS_EDIT_SEARCH_ENGINES); | 1067 IDS_EDIT_SEARCH_ENGINES); |
1067 } | 1068 } |
OLD | NEW |