| 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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 } | 1182 } |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { | 1185 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { |
| 1186 InstantController* instant = controller_->GetInstant(); | 1186 InstantController* instant = controller_->GetInstant(); |
| 1187 if (!instant || in_revert_) | 1187 if (!instant || in_revert_) |
| 1188 return false; | 1188 return false; |
| 1189 | 1189 |
| 1190 // The two pieces of text we want to send Instant, viz., what the user has | 1190 // The two pieces of text we want to send Instant, viz., what the user has |
| 1191 // typed, and the full omnibox text including any inline autocompletion. | 1191 // typed, and the full omnibox text including any inline autocompletion. |
| 1192 string16 user_text = user_text_; | 1192 string16 user_text = has_temporary_text_ ? |
| 1193 string16 full_text = user_text_ + inline_autocomplete_text_; | 1193 match.fill_into_edit : DisplayTextFromUserText(user_text_); |
| 1194 | 1194 string16 full_text = view_->GetText(); |
| 1195 // If there's temporary text, that overrides the user_text. In this case, we | |
| 1196 // should ignore any inline_autocomplete_text_, because it won't be visible. | |
| 1197 if (has_temporary_text_) | |
| 1198 user_text = full_text = CurrentMatch().fill_into_edit; | |
| 1199 | |
| 1200 // Remove keyword if we're in keyword mode. | |
| 1201 user_text = DisplayTextFromUserText(user_text); | |
| 1202 full_text = DisplayTextFromUserText(full_text); | |
| 1203 | 1195 |
| 1204 // Remove "?" if we're in forced query mode. | 1196 // Remove "?" if we're in forced query mode. |
| 1205 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | 1197 AutocompleteInput::RemoveForcedQueryStringIfNecessary( |
| 1206 autocomplete_controller_->input().type(), &user_text); | 1198 autocomplete_controller_->input().type(), &user_text); |
| 1207 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | 1199 AutocompleteInput::RemoveForcedQueryStringIfNecessary( |
| 1208 autocomplete_controller_->input().type(), &full_text); | 1200 autocomplete_controller_->input().type(), &full_text); |
| 1209 | 1201 |
| 1210 return instant->Update(match, user_text, full_text, UseVerbatimInstant(), | 1202 return instant->Update(match, user_text, full_text, UseVerbatimInstant(), |
| 1211 user_input_in_progress_, popup_->IsOpen()); | 1203 user_input_in_progress_, popup_->IsOpen()); |
| 1212 } | 1204 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 } | 1263 } |
| 1272 | 1264 |
| 1273 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1265 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1274 const string16& text, | 1266 const string16& text, |
| 1275 AutocompleteMatch* match, | 1267 AutocompleteMatch* match, |
| 1276 GURL* alternate_nav_url) const { | 1268 GURL* alternate_nav_url) const { |
| 1277 DCHECK(match); | 1269 DCHECK(match); |
| 1278 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1270 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1279 string16(), false, false, match, alternate_nav_url); | 1271 string16(), false, false, match, alternate_nav_url); |
| 1280 } | 1272 } |
| OLD | NEW |