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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 views::Textfield::AboutToRequestFocusFromTabTraversal(reverse); | 810 views::Textfield::AboutToRequestFocusFromTabTraversal(reverse); |
811 } | 811 } |
812 | 812 |
813 bool OmniboxViewViews::SkipDefaultKeyEventProcessing( | 813 bool OmniboxViewViews::SkipDefaultKeyEventProcessing( |
814 const ui::KeyEvent& event) { | 814 const ui::KeyEvent& event) { |
815 if (views::FocusManager::IsTabTraversalKeyEvent(event) && | 815 if (views::FocusManager::IsTabTraversalKeyEvent(event) && |
816 ((model()->is_keyword_hint() && !event.IsShiftDown()) || | 816 ((model()->is_keyword_hint() && !event.IsShiftDown()) || |
817 model()->popup_model()->IsOpen())) { | 817 model()->popup_model()->IsOpen())) { |
818 return true; | 818 return true; |
819 } | 819 } |
| 820 if (event.key_code() == ui::VKEY_ESCAPE) |
| 821 return model()->WillHandleEscapeKey(); |
820 return Textfield::SkipDefaultKeyEventProcessing(event); | 822 return Textfield::SkipDefaultKeyEventProcessing(event); |
821 } | 823 } |
822 | 824 |
823 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { | 825 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { |
824 state->role = ui::AX_ROLE_TEXT_FIELD; | 826 state->role = ui::AX_ROLE_TEXT_FIELD; |
825 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); | 827 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); |
826 state->value = GetText(); | 828 state->value = GetText(); |
827 | 829 |
828 base::string16::size_type entry_start; | 830 base::string16::size_type entry_start; |
829 base::string16::size_type entry_end; | 831 base::string16::size_type entry_end; |
(...skipping 22 matching lines...) Expand all Loading... |
852 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); | 854 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); |
853 } | 855 } |
854 } | 856 } |
855 | 857 |
856 void OmniboxViewViews::OnBlur() { | 858 void OmniboxViewViews::OnBlur() { |
857 // Save the user's existing selection to restore it later. | 859 // Save the user's existing selection to restore it later. |
858 saved_selection_for_focus_change_ = GetSelectedRange(); | 860 saved_selection_for_focus_change_ = GetSelectedRange(); |
859 | 861 |
860 views::Textfield::OnBlur(); | 862 views::Textfield::OnBlur(); |
861 model()->OnWillKillFocus(); | 863 model()->OnWillKillFocus(); |
862 CloseOmniboxPopup(); | 864 |
| 865 // If ZeroSuggest is active, we may have refused to show an update to the |
| 866 // underlying permanent URL that happened while the popup was open, so |
| 867 // revert to ensure that update is shown now. Otherwise, make sure to call |
| 868 // CloseOmniboxPopup() unconditionally, so that if ZeroSuggest is in the midst |
| 869 // of running but hasn't yet opened the popup, it will be halted. |
| 870 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen()) |
| 871 RevertAll(); |
| 872 else |
| 873 CloseOmniboxPopup(); |
863 | 874 |
864 // Tell the model to reset itself. | 875 // Tell the model to reset itself. |
865 model()->OnKillFocus(); | 876 model()->OnKillFocus(); |
866 | 877 |
867 // Make sure the beginning of the text is visible. | 878 // Make sure the beginning of the text is visible. |
868 SelectRange(gfx::Range(0)); | 879 SelectRange(gfx::Range(0)); |
869 } | 880 } |
870 | 881 |
871 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { | 882 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
872 if (command_id == IDS_APP_PASTE) | 883 if (command_id == IDS_APP_PASTE) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 menu_contents->InsertItemWithStringIdAt( | 1061 menu_contents->InsertItemWithStringIdAt( |
1051 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1062 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
1052 } | 1063 } |
1053 | 1064 |
1054 // Minor note: We use IDC_ for command id here while the underlying textfield | 1065 // Minor note: We use IDC_ for command id here while the underlying textfield |
1055 // is using IDS_ for all its command ids. This is because views cannot depend | 1066 // is using IDS_ for all its command ids. This is because views cannot depend |
1056 // on IDC_ for now. | 1067 // on IDC_ for now. |
1057 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1068 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1058 IDS_EDIT_SEARCH_ENGINES); | 1069 IDS_EDIT_SEARCH_ENGINES); |
1059 } | 1070 } |
OLD | NEW |