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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 location_bar_view_->Layout(); | 769 location_bar_view_->Layout(); |
770 } | 770 } |
771 | 771 |
772 void OmniboxViewViews::OnBlur() { | 772 void OmniboxViewViews::OnBlur() { |
773 // Save the user's existing selection to restore it later. | 773 // Save the user's existing selection to restore it later. |
774 saved_selection_for_focus_change_ = GetSelectedRange(); | 774 saved_selection_for_focus_change_ = GetSelectedRange(); |
775 | 775 |
776 views::Textfield::OnBlur(); | 776 views::Textfield::OnBlur(); |
777 model()->OnWillKillFocus(); | 777 model()->OnWillKillFocus(); |
778 | 778 |
779 // If ZeroSuggest is active, we may have refused to show an update to the | 779 // If ZeroSuggest is active, and there is evidence that there is a text |
780 // underlying permanent URL that happened while the popup was open, so | 780 // update to show, revert to ensure that update is shown now. Otherwise, |
781 // revert to ensure that update is shown now. Otherwise, make sure to call | 781 // at least call CloseOmniboxPopup(), so that if ZeroSuggest is in the |
782 // CloseOmniboxPopup() unconditionally, so that if ZeroSuggest is in the midst | 782 // midst of running but hasn't yet opened the popup, it will be halted. |
783 // of running but hasn't yet opened the popup, it will be halted. | 783 // If we fully reverted in this case, we'd lose the cursor/highlight |
784 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen()) | 784 // information saved above. |
| 785 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen() && |
| 786 text() != model()->PermanentText()) |
785 RevertAll(); | 787 RevertAll(); |
786 else | 788 else |
787 CloseOmniboxPopup(); | 789 CloseOmniboxPopup(); |
788 | 790 |
789 // Tell the model to reset itself. | 791 // Tell the model to reset itself. |
790 model()->OnKillFocus(); | 792 model()->OnKillFocus(); |
791 | 793 |
792 // Make sure the beginning of the text is visible. | 794 // Make sure the beginning of the text is visible. |
793 SelectRange(gfx::Range(0)); | 795 SelectRange(gfx::Range(0)); |
794 | 796 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1066 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1065 | 1067 |
1066 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1068 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1067 | 1069 |
1068 // Minor note: We use IDC_ for command id here while the underlying textfield | 1070 // Minor note: We use IDC_ for command id here while the underlying textfield |
1069 // is using IDS_ for all its command ids. This is because views cannot depend | 1071 // is using IDS_ for all its command ids. This is because views cannot depend |
1070 // on IDC_ for now. | 1072 // on IDC_ for now. |
1071 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1073 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1072 IDS_EDIT_SEARCH_ENGINES); | 1074 IDS_EDIT_SEARCH_ENGINES); |
1073 } | 1075 } |
OLD | NEW |