| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 } | 529 } |
| 530 | 530 |
| 531 gfx::NativeView OmniboxViewViews::GetNativeView() const { | 531 gfx::NativeView OmniboxViewViews::GetNativeView() const { |
| 532 return GetWidget()->GetNativeView(); | 532 return GetWidget()->GetNativeView(); |
| 533 } | 533 } |
| 534 | 534 |
| 535 gfx::NativeView OmniboxViewViews::GetRelativeWindowForPopup() const { | 535 gfx::NativeView OmniboxViewViews::GetRelativeWindowForPopup() const { |
| 536 return GetWidget()->GetTopLevelWidget()->GetNativeView(); | 536 return GetWidget()->GetTopLevelWidget()->GetNativeView(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void OmniboxViewViews::SetGrayTextAutocompletion(const base::string16& input) { | |
| 540 if (location_bar_view_) | |
| 541 location_bar_view_->SetGrayTextAutocompletion(input); | |
| 542 } | |
| 543 | |
| 544 base::string16 OmniboxViewViews::GetGrayTextAutocompletion() const { | |
| 545 return location_bar_view_ ? | |
| 546 location_bar_view_->GetGrayTextAutocompletion() : base::string16(); | |
| 547 } | |
| 548 | |
| 549 int OmniboxViewViews::GetWidth() const { | 539 int OmniboxViewViews::GetWidth() const { |
| 550 return location_bar_view_ ? location_bar_view_->width() : 0; | 540 return location_bar_view_ ? location_bar_view_->width() : 0; |
| 551 } | 541 } |
| 552 | 542 |
| 553 bool OmniboxViewViews::IsImeShowingPopup() const { | 543 bool OmniboxViewViews::IsImeShowingPopup() const { |
| 554 #if defined(OS_CHROMEOS) | 544 #if defined(OS_CHROMEOS) |
| 555 return ime_candidate_window_open_; | 545 return ime_candidate_window_open_; |
| 556 #else | 546 #else |
| 557 return GetInputMethod() ? GetInputMethod()->IsCandidatePopupOpen() : false; | 547 return GetInputMethod() ? GetInputMethod()->IsCandidatePopupOpen() : false; |
| 558 #endif | 548 #endif |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 break; | 950 break; |
| 961 case ui::VKEY_BACK: | 951 case ui::VKEY_BACK: |
| 962 // No extra handling is needed in keyword search mode, if there is a | 952 // No extra handling is needed in keyword search mode, if there is a |
| 963 // non-empty selection, or if the cursor is not leading the text. | 953 // non-empty selection, or if the cursor is not leading the text. |
| 964 if (model()->is_keyword_hint() || model()->keyword().empty() || | 954 if (model()->is_keyword_hint() || model()->keyword().empty() || |
| 965 HasSelection() || GetCursorPosition() != 0) | 955 HasSelection() || GetCursorPosition() != 0) |
| 966 return false; | 956 return false; |
| 967 model()->ClearKeyword(); | 957 model()->ClearKeyword(); |
| 968 return true; | 958 return true; |
| 969 | 959 |
| 970 // Handle the right-arrow key for LTR text and the left-arrow key for RTL | |
| 971 // text if there is gray text that needs to be committed. | |
| 972 case ui::VKEY_RIGHT: | |
| 973 if (GetCursorPosition() == text().length() && | |
| 974 GetTextDirection() == base::i18n::LEFT_TO_RIGHT) { | |
| 975 return model()->CommitSuggestedText(); | |
| 976 } | |
| 977 break; | |
| 978 case ui::VKEY_LEFT: | |
| 979 if (GetCursorPosition() == text().length() && | |
| 980 GetTextDirection() == base::i18n::RIGHT_TO_LEFT) { | |
| 981 return model()->CommitSuggestedText(); | |
| 982 } | |
| 983 break; | |
| 984 | |
| 985 default: | 960 default: |
| 986 break; | 961 break; |
| 987 } | 962 } |
| 988 | 963 |
| 989 return HandleEarlyTabActions(event); | 964 return HandleEarlyTabActions(event); |
| 990 } | 965 } |
| 991 | 966 |
| 992 void OmniboxViewViews::OnBeforeUserAction(views::Textfield* sender) { | 967 void OmniboxViewViews::OnBeforeUserAction(views::Textfield* sender) { |
| 993 OnBeforePossibleChange(); | 968 OnBeforePossibleChange(); |
| 994 } | 969 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1061 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1087 | 1062 |
| 1088 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1063 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1089 | 1064 |
| 1090 // 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 |
| 1091 // 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 |
| 1092 // on IDC_ for now. | 1067 // on IDC_ for now. |
| 1093 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1068 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1094 IDS_EDIT_SEARCH_ENGINES); | 1069 IDS_EDIT_SEARCH_ENGINES); |
| 1095 } | 1070 } |
| OLD | NEW |