Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 11034019: Cursor jumps to end of omnibox when activating keyword mode via inserted space (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Patch Rebased Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // pressed, even though maybe it isn't any more. There is no obvious 879 // pressed, even though maybe it isn't any more. There is no obvious
880 // right answer here :( 880 // right answer here :(
881 } 881 }
882 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text), 882 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text),
883 save_original_selection); 883 save_original_selection);
884 return; 884 return;
885 } 885 }
886 886
887 bool call_controller_onchanged = true; 887 bool call_controller_onchanged = true;
888 inline_autocomplete_text_ = text; 888 inline_autocomplete_text_ = text;
889 if (view_->OnInlineAutocompleteTextMaybeChanged( 889
890 DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), 890 if (keyword_state_changed && KeywordIsSelected()) {
891 DisplayTextFromUserText(user_text_).length())) 891 // If we reach here, the user most likely entered keyword mode by inserting
892 // a space between a keyword name and a search string (as pressing space or
893 // tab after the keyword name alone would have been be handled in
894 // MaybeAcceptKeywordBySpace() by calling AcceptKeyword(), which won't reach
895 // here). In this case, we don't want to call
896 // OnInlineAutocompleteTextMaybeChanged() as normal, because that will
897 // correctly change the text (to the search string alone) but move the caret
898 // to the end of the string; instead we want the caret at the start of the
899 // search string since that's where it was in the original input. So we set
900 // the text and caret position directly.
901 //
902 // It may also be possible to reach here if we're reverting from having
903 // temporary text back to a default match that's a keyword search, but in
904 // that case the RevertTemporaryText() call below will reset the caret or
905 // selection correctly so the caret positioning we do here won't matter.
906 view_->SetWindowTextAndCaretPos(DisplayTextFromUserText(user_text_), 0,
907 false, false);
908 } else if (view_->OnInlineAutocompleteTextMaybeChanged(
909 DisplayTextFromUserText(user_text_ + inline_autocomplete_text_),
910 DisplayTextFromUserText(user_text_).length())) {
892 call_controller_onchanged = false; 911 call_controller_onchanged = false;
912 }
893 913
894 // If |has_temporary_text_| is true, then we previously had a manual selection 914 // If |has_temporary_text_| is true, then we previously had a manual selection
895 // but now don't (or |destination_for_temporary_text_change| would have been 915 // but now don't (or |destination_for_temporary_text_change| would have been
896 // non-NULL). This can happen when deleting the selected item in the popup. 916 // non-NULL). This can happen when deleting the selected item in the popup.
897 // In this case, we've already reverted the popup to the default match, so we 917 // In this case, we've already reverted the popup to the default match, so we
898 // need to revert ourselves as well. 918 // need to revert ourselves as well.
899 if (has_temporary_text_) { 919 if (has_temporary_text_) {
900 RevertTemporaryText(false); 920 RevertTemporaryText(false);
901 call_controller_onchanged = false; 921 call_controller_onchanged = false;
902 } 922 }
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1288 }
1269 1289
1270 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1290 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1271 const string16& text, 1291 const string16& text,
1272 AutocompleteMatch* match, 1292 AutocompleteMatch* match,
1273 GURL* alternate_nav_url) const { 1293 GURL* alternate_nav_url) const {
1274 DCHECK(match); 1294 DCHECK(match);
1275 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1295 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1276 string16(), false, false, match, alternate_nav_url); 1296 string16(), false, false, match, alternate_nav_url);
1277 } 1297 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698