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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 #endif | 1041 #endif |
1042 } | 1042 } |
1043 | 1043 |
1044 std::string LocationBarView::GetClassName() const { | 1044 std::string LocationBarView::GetClassName() const { |
1045 return kViewClassName; | 1045 return kViewClassName; |
1046 } | 1046 } |
1047 | 1047 |
1048 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1048 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1049 const views::KeyEvent& event) { | 1049 const views::KeyEvent& event) { |
1050 #if defined(OS_WIN) | 1050 #if defined(OS_WIN) |
1051 bool views_omnibox = views::Widget::IsPureViews(); | |
1052 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { | 1051 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { |
1053 if (HasValidSuggestText()) { | 1052 if (location_entry_->model()->popup_model()->IsOpen()) { |
1054 // Return true so that the edit sees the tab and commits the suggestion. | 1053 // Return true so that the edit sees the tab and moves the selection. |
1055 return true; | 1054 return true; |
1056 } | 1055 } |
| 1056 |
1057 if (keyword_hint_view_->IsVisible() && !event.IsShiftDown()) { | 1057 if (keyword_hint_view_->IsVisible() && !event.IsShiftDown()) { |
1058 // Return true so the edit gets the tab event and enters keyword mode. | 1058 // Return true so the edit gets the tab event and enters keyword mode. |
1059 return true; | 1059 return true; |
1060 } | 1060 } |
1061 | 1061 |
1062 #if !defined(USE_AURA) | |
1063 // If the caret is not at the end, then tab moves the caret to the end. | |
1064 if (!views_omnibox && !GetOmniboxViewWin()->IsCaretAtEnd()) | |
1065 return true; | |
1066 #endif | |
1067 | |
1068 // Tab while showing instant commits instant immediately. | 1062 // Tab while showing instant commits instant immediately. |
1069 // Return true so that focus traversal isn't attempted. The edit ends | 1063 // Return true so that focus traversal isn't attempted. The edit ends |
1070 // up doing nothing in this case. | 1064 // up doing nothing in this case. |
1071 if (location_entry_->model()->AcceptCurrentInstantPreview()) | 1065 if (location_entry_->model()->AcceptCurrentInstantPreview()) |
1072 return true; | 1066 return true; |
1073 } | 1067 } |
1074 | 1068 |
1075 #if !defined(USE_AURA) | 1069 #if !defined(USE_AURA) |
1076 if (!views_omnibox) | 1070 if (!views::Widget::IsPureViews()) |
1077 return GetOmniboxViewWin()->SkipDefaultKeyEventProcessing(event); | 1071 return GetOmniboxViewWin()->SkipDefaultKeyEventProcessing(event); |
1078 #endif | 1072 #endif |
1079 NOTIMPLEMENTED(); | 1073 NOTIMPLEMENTED(); |
1080 return false; | 1074 return false; |
1081 #else | 1075 #else |
1082 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in | 1076 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in |
1083 // src/views/focus/focus_manager.cc for details. | 1077 // src/views/focus/focus_manager.cc for details. |
1084 return false; | 1078 return false; |
1085 #endif | 1079 #endif |
1086 } | 1080 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 !suggested_text_view_->GetText().empty(); | 1269 !suggested_text_view_->GetText().empty(); |
1276 } | 1270 } |
1277 | 1271 |
1278 #if !defined(USE_AURA) | 1272 #if !defined(USE_AURA) |
1279 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1273 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1280 CHECK(!views::Widget::IsPureViews()); | 1274 CHECK(!views::Widget::IsPureViews()); |
1281 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1275 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1282 } | 1276 } |
1283 #endif | 1277 #endif |
1284 #endif | 1278 #endif |
OLD | NEW |