Chromium Code Reviews| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_; | |
|
sky
2013/01/11 00:15:57
nit: use {} since you're adding a variable only fo
beaudoin
2013/01/13 20:02:39
Done.
| |
| 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; |
| 221 } | 225 } |
| 222 } | 226 } |
| 223 | 227 |
| 224 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { | 228 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { |
| 225 if (!controller_->GetInstant()) | 229 if (!controller_->GetInstant()) |
| 226 return false; | 230 return false; |
| 227 | 231 |
| 228 const string16 suggestion = view_->GetInstantSuggestion(); | 232 const string16 suggestion = view_->GetInstantSuggestion(); |
| 229 if (suggestion.empty()) | 233 if (suggestion.empty()) |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 instant->OmniboxFocusChanged(state, reason, NULL); | 1341 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1338 | 1342 |
| 1339 // Update state and notify view if the omnibox has focus and the caret | 1343 // Update state and notify view if the omnibox has focus and the caret |
| 1340 // visibility changed. | 1344 // visibility changed. |
| 1341 const bool was_caret_visible = is_caret_visible(); | 1345 const bool was_caret_visible = is_caret_visible(); |
| 1342 focus_state_ = state; | 1346 focus_state_ = state; |
| 1343 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1347 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1344 is_caret_visible() != was_caret_visible) | 1348 is_caret_visible() != was_caret_visible) |
| 1345 view_->ApplyCaretVisibility(); | 1349 view_->ApplyCaretVisibility(); |
| 1346 } | 1350 } |
| OLD | NEW |