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/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 // pressed, even though maybe it isn't any more. There is no obvious | 876 // pressed, even though maybe it isn't any more. There is no obvious |
877 // right answer here :( | 877 // right answer here :( |
878 } | 878 } |
879 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text), | 879 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text), |
880 save_original_selection); | 880 save_original_selection); |
881 return; | 881 return; |
882 } | 882 } |
883 | 883 |
884 bool call_controller_onchanged = true; | 884 bool call_controller_onchanged = true; |
885 inline_autocomplete_text_ = text; | 885 inline_autocomplete_text_ = text; |
886 if (view_->OnInlineAutocompleteTextMaybeChanged( | 886 |
887 DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), | 887 // Keyword search mode can be activated if the text before the inserted space |
888 DisplayTextFromUserText(user_text_).length())) | 888 // matches a keyword. The position of the cursor should be retained after |
889 // keyword mode is activated and it should be at the left of the 'search' | |
890 // string. The window text should be set after stripping the keyword string | |
891 // and the inserted space. And to set the caret at the left of the search | |
892 // string to maintain the old position, it needs to be set to 0. | |
Peter Kasting
2012/10/03 17:08:12
Thanks for adding comments here.
I wonder if we c
Joe Thomas
2012/10/03 18:04:59
This looks a lot better than the comments that I a
| |
893 if (keyword_state_changed && KeywordIsSelected()) | |
Peter Kasting
2012/10/03 17:08:12
Nit: {} needed on both arms, as one arm's body is
Joe Thomas
2012/10/03 18:04:59
Done.
| |
894 view_->SetWindowTextAndCaretPos(DisplayTextFromUserText(user_text_), 0, | |
895 false, false); | |
896 else if (view_->OnInlineAutocompleteTextMaybeChanged( | |
897 DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), | |
898 DisplayTextFromUserText(user_text_).length())) | |
889 call_controller_onchanged = false; | 899 call_controller_onchanged = false; |
890 | 900 |
891 // If |has_temporary_text_| is true, then we previously had a manual selection | 901 // If |has_temporary_text_| is true, then we previously had a manual selection |
892 // but now don't (or |destination_for_temporary_text_change| would have been | 902 // but now don't (or |destination_for_temporary_text_change| would have been |
893 // non-NULL). This can happen when deleting the selected item in the popup. | 903 // non-NULL). This can happen when deleting the selected item in the popup. |
894 // In this case, we've already reverted the popup to the default match, so we | 904 // In this case, we've already reverted the popup to the default match, so we |
895 // need to revert ourselves as well. | 905 // need to revert ourselves as well. |
896 if (has_temporary_text_) { | 906 if (has_temporary_text_) { |
897 RevertTemporaryText(false); | 907 RevertTemporaryText(false); |
898 call_controller_onchanged = false; | 908 call_controller_onchanged = false; |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 } | 1275 } |
1266 | 1276 |
1267 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1277 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
1268 const string16& text, | 1278 const string16& text, |
1269 AutocompleteMatch* match, | 1279 AutocompleteMatch* match, |
1270 GURL* alternate_nav_url) const { | 1280 GURL* alternate_nav_url) const { |
1271 DCHECK(match); | 1281 DCHECK(match); |
1272 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1282 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
1273 string16(), false, false, match, alternate_nav_url); | 1283 string16(), false, false, match, alternate_nav_url); |
1274 } | 1284 } |
OLD | NEW |