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/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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 #endif | 1010 #endif |
1011 } | 1011 } |
1012 | 1012 |
1013 std::string LocationBarView::GetClassName() const { | 1013 std::string LocationBarView::GetClassName() const { |
1014 return kViewClassName; | 1014 return kViewClassName; |
1015 } | 1015 } |
1016 | 1016 |
1017 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1017 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1018 const views::KeyEvent& event) { | 1018 const views::KeyEvent& event) { |
1019 #if defined(OS_WIN) | 1019 #if defined(OS_WIN) |
1020 bool views_omnibox = views::Widget::IsPureViews(); | |
1021 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { | 1020 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { |
1022 if (HasValidSuggestText()) { | 1021 if (location_entry_->model()->popup_model()->IsOpen()) { |
1023 // Return true so that the edit sees the tab and commits the suggestion. | 1022 // Return true so that the edit sees the tab and moves the selection. |
1024 return true; | 1023 return true; |
1025 } | 1024 } |
1026 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { | 1025 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { |
1027 // Return true so the edit gets the tab event and enters keyword mode. | 1026 // Return true so the edit gets the tab event and enters keyword mode. |
1028 return true; | 1027 return true; |
1029 } | 1028 } |
1030 | 1029 |
1031 #if !defined(USE_AURA) | |
1032 // If the caret is not at the end, then tab moves the caret to the end. | |
1033 if (!views_omnibox && !GetOmniboxViewWin()->IsCaretAtEnd()) | |
1034 return true; | |
1035 #endif | |
1036 | |
1037 // Tab while showing instant commits instant immediately. | 1030 // Tab while showing instant commits instant immediately. |
1038 // Return true so that focus traversal isn't attempted. The edit ends | 1031 // Return true so that focus traversal isn't attempted. The edit ends |
1039 // up doing nothing in this case. | 1032 // up doing nothing in this case. |
1040 if (location_entry_->model()->AcceptCurrentInstantPreview()) | 1033 if (location_entry_->model()->AcceptCurrentInstantPreview()) |
1041 return true; | 1034 return true; |
1042 } | 1035 } |
1043 | 1036 |
1044 #if !defined(USE_AURA) | 1037 #if !defined(USE_AURA) |
1045 if (!views_omnibox) | 1038 if (!views::Widget::IsPureViews()) |
1046 return GetOmniboxViewWin()->SkipDefaultKeyEventProcessing(event); | 1039 return GetOmniboxViewWin()->SkipDefaultKeyEventProcessing(event); |
1047 #endif | 1040 #endif |
1048 NOTIMPLEMENTED(); | 1041 NOTIMPLEMENTED(); |
1049 return false; | 1042 return false; |
1050 #else | 1043 #else |
1051 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in | 1044 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in |
1052 // src/ui/views/focus/focus_manager.cc for details. | 1045 // src/ui/views/focus/focus_manager.cc for details. |
1053 return false; | 1046 return false; |
1054 #endif | 1047 #endif |
1055 } | 1048 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 !suggested_text_view_->GetText().empty(); | 1236 !suggested_text_view_->GetText().empty(); |
1244 } | 1237 } |
1245 | 1238 |
1246 #if !defined(USE_AURA) | 1239 #if !defined(USE_AURA) |
1247 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1240 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1248 CHECK(!views::Widget::IsPureViews()); | 1241 CHECK(!views::Widget::IsPureViews()); |
1249 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1242 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1250 } | 1243 } |
1251 #endif | 1244 #endif |
1252 #endif | 1245 #endif |
OLD | NEW |