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 // at least call CloseOmniboxPopup(), so that if ZeroSuggest is in the |
778 // CloseOmniboxPopup() unconditionally, so that if ZeroSuggest is in the midst | 778 // midst of running but hasn't yet opened the popup, it will be halted. |
779 // of running but hasn't yet opened the popup, it will be halted. | 779 // If we fully reverted in this case, we'd lose the cursor/highlight |
780 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen()) | 780 // information saved above. |
| 781 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen() && |
| 782 text() != model()->PermanentText()) |
781 RevertAll(); | 783 RevertAll(); |
782 else | 784 else |
783 CloseOmniboxPopup(); | 785 CloseOmniboxPopup(); |
784 | 786 |
785 // Tell the model to reset itself. | 787 // Tell the model to reset itself. |
786 model()->OnKillFocus(); | 788 model()->OnKillFocus(); |
787 | 789 |
788 // Make sure the beginning of the text is visible. | 790 // Make sure the beginning of the text is visible. |
789 SelectRange(gfx::Range(0)); | 791 SelectRange(gfx::Range(0)); |
790 | 792 |
(...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); | 1060 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1059 | 1061 |
1060 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1062 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1061 | 1063 |
1062 // Minor note: We use IDC_ for command id here while the underlying textfield | 1064 // 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 | 1065 // is using IDS_ for all its command ids. This is because views cannot depend |
1064 // on IDC_ for now. | 1066 // on IDC_ for now. |
1065 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1067 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1066 IDS_EDIT_SEARCH_ENGINES); | 1068 IDS_EDIT_SEARCH_ENGINES); |
1067 } | 1069 } |
OLD | NEW |