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

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

Issue 68103008: Hide IME autocompletion when Omnibox popup closes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 } 1013 }
1014 1014
1015 // Handle changes to temporary text. 1015 // Handle changes to temporary text.
1016 if (destination_for_temporary_text_change != NULL) { 1016 if (destination_for_temporary_text_change != NULL) {
1017 const bool save_original_selection = !has_temporary_text_; 1017 const bool save_original_selection = !has_temporary_text_;
1018 if (save_original_selection) { 1018 if (save_original_selection) {
1019 // Save the original selection and URL so it can be reverted later. 1019 // Save the original selection and URL so it can be reverted later.
1020 has_temporary_text_ = true; 1020 has_temporary_text_ = true;
1021 original_url_ = *destination_for_temporary_text_change; 1021 original_url_ = *destination_for_temporary_text_change;
1022 inline_autocomplete_text_.clear(); 1022 inline_autocomplete_text_.clear();
1023 view_->OnInlineAutocompleteTextCleared();
1023 } 1024 }
1024 if (control_key_state_ == DOWN_WITHOUT_CHANGE) { 1025 if (control_key_state_ == DOWN_WITHOUT_CHANGE) {
1025 // Arrowing around the popup cancels control-enter. 1026 // Arrowing around the popup cancels control-enter.
1026 control_key_state_ = DOWN_WITH_CHANGE; 1027 control_key_state_ = DOWN_WITH_CHANGE;
1027 // Now things are a bit screwy: the desired_tld has changed, but if we 1028 // Now things are a bit screwy: the desired_tld has changed, but if we
1028 // update the popup, the new order of entries won't match the old, so the 1029 // update the popup, the new order of entries won't match the old, so the
1029 // user's selection gets screwy; and if we don't update the popup, and the 1030 // user's selection gets screwy; and if we don't update the popup, and the
1030 // user reverts, then the selected item will be as if control is still 1031 // user reverts, then the selected item will be as if control is still
1031 // pressed, even though maybe it isn't any more. There is no obvious 1032 // pressed, even though maybe it isn't any more. There is no obvious
1032 // right answer here :( 1033 // right answer here :(
1033 } 1034 }
1034 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text), 1035 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text),
1035 save_original_selection, true); 1036 save_original_selection, true);
1036 return; 1037 return;
1037 } 1038 }
1038 1039
1039 bool call_controller_onchanged = true; 1040 bool call_controller_onchanged = true;
1040 inline_autocomplete_text_ = text; 1041 inline_autocomplete_text_ = text;
1042 if (inline_autocomplete_text_.empty())
1043 view_->OnInlineAutocompleteTextCleared();
1041 1044
1042 string16 user_text = user_input_in_progress_ ? user_text_ : permanent_text_; 1045 string16 user_text = user_input_in_progress_ ? user_text_ : permanent_text_;
1043 if (keyword_state_changed && KeywordIsSelected()) { 1046 if (keyword_state_changed && KeywordIsSelected()) {
1044 // If we reach here, the user most likely entered keyword mode by inserting 1047 // If we reach here, the user most likely entered keyword mode by inserting
1045 // a space between a keyword name and a search string (as pressing space or 1048 // a space between a keyword name and a search string (as pressing space or
1046 // tab after the keyword name alone would have been be handled in 1049 // tab after the keyword name alone would have been be handled in
1047 // MaybeAcceptKeywordBySpace() by calling AcceptKeyword(), which won't reach 1050 // MaybeAcceptKeywordBySpace() by calling AcceptKeyword(), which won't reach
1048 // here). In this case, we don't want to call 1051 // here). In this case, we don't want to call
1049 // OnInlineAutocompleteTextMaybeChanged() as normal, because that will 1052 // OnInlineAutocompleteTextMaybeChanged() as normal, because that will
1050 // correctly change the text (to the search string alone) but move the caret 1053 // correctly change the text (to the search string alone) but move the caret
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1214 }
1212 1215
1213 bool OmniboxEditModel::query_in_progress() const { 1216 bool OmniboxEditModel::query_in_progress() const {
1214 return !autocomplete_controller()->done(); 1217 return !autocomplete_controller()->done();
1215 } 1218 }
1216 1219
1217 void OmniboxEditModel::InternalSetUserText(const string16& text) { 1220 void OmniboxEditModel::InternalSetUserText(const string16& text) {
1218 user_text_ = text; 1221 user_text_ = text;
1219 just_deleted_text_ = false; 1222 just_deleted_text_ = false;
1220 inline_autocomplete_text_.clear(); 1223 inline_autocomplete_text_.clear();
1224 view_->OnInlineAutocompleteTextCleared();
1221 } 1225 }
1222 1226
1223 bool OmniboxEditModel::KeywordIsSelected() const { 1227 bool OmniboxEditModel::KeywordIsSelected() const {
1224 return !is_keyword_hint_ && !keyword_.empty(); 1228 return !is_keyword_hint_ && !keyword_.empty();
1225 } 1229 }
1226 1230
1227 void OmniboxEditModel::ClearPopupKeywordMode() const { 1231 void OmniboxEditModel::ClearPopupKeywordMode() const {
1228 omnibox_controller_->ClearPopupKeywordMode(); 1232 omnibox_controller_->ClearPopupKeywordMode();
1229 } 1233 }
1230 1234
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 instant->OmniboxFocusChanged(state, reason, NULL); 1394 instant->OmniboxFocusChanged(state, reason, NULL);
1391 1395
1392 // Update state and notify view if the omnibox has focus and the caret 1396 // Update state and notify view if the omnibox has focus and the caret
1393 // visibility changed. 1397 // visibility changed.
1394 const bool was_caret_visible = is_caret_visible(); 1398 const bool was_caret_visible = is_caret_visible();
1395 focus_state_ = state; 1399 focus_state_ = state;
1396 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1400 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1397 is_caret_visible() != was_caret_visible) 1401 is_caret_visible() != was_caret_visible)
1398 view_->ApplyCaretVisibility(); 1402 view_->ApplyCaretVisibility();
1399 } 1403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698