OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 #endif | 1015 #endif |
1016 } | 1016 } |
1017 | 1017 |
1018 std::string LocationBarView::GetClassName() const { | 1018 std::string LocationBarView::GetClassName() const { |
1019 return kViewClassName; | 1019 return kViewClassName; |
1020 } | 1020 } |
1021 | 1021 |
1022 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1022 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1023 const views::KeyEvent& event) { | 1023 const views::KeyEvent& event) { |
1024 #if defined(OS_WIN) | 1024 #if defined(OS_WIN) |
1025 bool views_omnibox = views::Widget::IsPureViews(); | |
1026 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { | 1025 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { |
1027 if (HasValidSuggestText()) { | 1026 if (location_entry_->model()->popup_model()->IsOpen()) { |
1028 // Return true so that the edit sees the tab and commits the suggestion. | 1027 // Return true so that the edit sees the tab and moves the selection. |
1029 return true; | 1028 return true; |
1030 } | 1029 } |
1031 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { | 1030 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { |
1032 // Return true so the edit gets the tab event and enters keyword mode. | 1031 // Return true so the edit gets the tab event and enters keyword mode. |
1033 return true; | 1032 return true; |
1034 } | 1033 } |
1035 | 1034 |
1036 #if !defined(USE_AURA) | |
1037 // If the caret is not at the end, then tab moves the caret to the end. | |
1038 if (!views_omnibox && !GetOmniboxViewWin()->IsCaretAtEnd()) | |
1039 return true; | |
1040 #endif | |
1041 | |
1042 // Tab while showing instant commits instant immediately. | 1035 // Tab while showing instant commits instant immediately. |
1043 // Return true so that focus traversal isn't attempted. The edit ends | 1036 // Return true so that focus traversal isn't attempted. The edit ends |
1044 // up doing nothing in this case. | 1037 // up doing nothing in this case. |
1045 if (location_entry_->model()->AcceptCurrentInstantPreview()) | 1038 if (location_entry_->model()->AcceptCurrentInstantPreview()) |
1046 return true; | 1039 return true; |
1047 } | 1040 } |
1048 | 1041 |
1049 #if !defined(USE_AURA) | 1042 #if !defined(USE_AURA) |
1050 if (!views_omnibox) | 1043 if (!views::Widget::IsPureViews()) |
1051 return GetOmniboxViewWin()->SkipDefaultKeyEventProcessing(event); | 1044 return GetOmniboxViewWin()->SkipDefaultKeyEventProcessing(event); |
1052 #endif | 1045 #endif |
1053 NOTIMPLEMENTED(); | 1046 NOTIMPLEMENTED(); |
1054 return false; | 1047 return false; |
1055 #else | 1048 #else |
1056 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in | 1049 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in |
1057 // src/ui/views/focus/focus_manager.cc for details. | 1050 // src/ui/views/focus/focus_manager.cc for details. |
1058 return false; | 1051 return false; |
1059 #endif | 1052 #endif |
1060 } | 1053 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 !suggested_text_view_->GetText().empty(); | 1242 !suggested_text_view_->GetText().empty(); |
1250 } | 1243 } |
1251 | 1244 |
1252 #if !defined(USE_AURA) | 1245 #if !defined(USE_AURA) |
1253 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1246 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1254 CHECK(!views::Widget::IsPureViews()); | 1247 CHECK(!views::Widget::IsPureViews()); |
1255 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1248 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1256 } | 1249 } |
1257 #endif | 1250 #endif |
1258 #endif | 1251 #endif |
OLD | NEW |