OLD | NEW |
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 view_->SetInstantSuggestion(string16()); | 204 view_->SetInstantSuggestion(string16()); |
205 if (!suggestion.text.empty()) | 205 if (!suggestion.text.empty()) |
206 FinalizeInstantQuery(view_->GetText(), suggestion, false); | 206 FinalizeInstantQuery(view_->GetText(), suggestion, false); |
207 break; | 207 break; |
208 | 208 |
209 case INSTANT_COMPLETE_NEVER: | 209 case INSTANT_COMPLETE_NEVER: |
210 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); | 210 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); |
211 view_->SetInstantSuggestion(suggestion.text); | 211 view_->SetInstantSuggestion(suggestion.text); |
212 break; | 212 break; |
213 | 213 |
214 case INSTANT_COMPLETE_REPLACE: | 214 case INSTANT_COMPLETE_REPLACE: { |
| 215 const bool save_original_selection = !has_temporary_text_; |
215 view_->SetInstantSuggestion(string16()); | 216 view_->SetInstantSuggestion(string16()); |
216 has_temporary_text_ = true; | 217 has_temporary_text_ = true; |
217 is_temporary_text_set_by_instant_ = true; | 218 is_temporary_text_set_by_instant_ = true; |
218 view_->SetWindowTextAndCaretPos(suggestion.text, suggestion.text.size(), | 219 // Instant suggestions are never a keyword. |
219 false, false); | 220 keyword_ = string16(); |
| 221 is_keyword_hint_ = false; |
| 222 view_->OnTemporaryTextMaybeChanged(suggestion.text, |
| 223 save_original_selection); |
220 break; | 224 break; |
| 225 } |
221 } | 226 } |
222 } | 227 } |
223 | 228 |
224 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { | 229 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { |
225 if (!controller_->GetInstant()) | 230 if (!controller_->GetInstant()) |
226 return false; | 231 return false; |
227 | 232 |
228 const string16 suggestion = view_->GetInstantSuggestion(); | 233 const string16 suggestion = view_->GetInstantSuggestion(); |
229 if (suggestion.empty()) | 234 if (suggestion.empty()) |
230 return false; | 235 return false; |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 instant->OmniboxFocusChanged(state, reason, NULL); | 1342 instant->OmniboxFocusChanged(state, reason, NULL); |
1338 | 1343 |
1339 // Update state and notify view if the omnibox has focus and the caret | 1344 // Update state and notify view if the omnibox has focus and the caret |
1340 // visibility changed. | 1345 // visibility changed. |
1341 const bool was_caret_visible = is_caret_visible(); | 1346 const bool was_caret_visible = is_caret_visible(); |
1342 focus_state_ = state; | 1347 focus_state_ = state; |
1343 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1348 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1344 is_caret_visible() != was_caret_visible) | 1349 is_caret_visible() != was_caret_visible) |
1345 view_->ApplyCaretVisibility(); | 1350 view_->ApplyCaretVisibility(); |
1346 } | 1351 } |
OLD | NEW |