Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 if (in_revert_) | 1119 if (in_revert_) |
| 1120 return false; | 1120 return false; |
| 1121 | 1121 |
| 1122 InstantController* instant = controller_->GetInstant(); | 1122 InstantController* instant = controller_->GetInstant(); |
| 1123 | 1123 |
| 1124 if (!instant) | 1124 if (!instant) |
| 1125 return false; | 1125 return false; |
| 1126 | 1126 |
| 1127 if (user_input_in_progress_ && popup_->IsOpen()) { | 1127 if (user_input_in_progress_ && popup_->IsOpen()) { |
| 1128 // The two pieces of text we want to send Instant, viz., what the user has | 1128 // The two pieces of text we want to send Instant, viz., what the user has |
| 1129 // typed, and any inline autocomplete suggestion. | 1129 // typed, and the full omnibox text including any inline autocompletion. |
| 1130 string16 user_text = user_text_; | 1130 string16 user_text = user_text_; |
| 1131 *suggested_text = inline_autocomplete_text_; | 1131 string16 full_text = user_text_ + inline_autocomplete_text_; |
| 1132 | 1132 |
| 1133 // If there's temporary text, that overrides the user_text. In this case, we | 1133 // If there's temporary text, that overrides the user_text. In this case, we |
| 1134 // should ignore any inline_autocomplete_text_, because it won't be visible. | 1134 // should ignore any inline_autocomplete_text_, because it won't be visible. |
| 1135 if (has_temporary_text_) { | 1135 if (has_temporary_text_) { |
|
Peter Kasting
2012/08/24 22:27:19
Nit: Remove {}
sreeram
2012/08/24 23:09:55
Done.
| |
| 1136 user_text = CurrentMatch().fill_into_edit; | 1136 user_text = full_text = CurrentMatch().fill_into_edit; |
| 1137 suggested_text->clear(); | |
| 1138 } | 1137 } |
| 1139 | 1138 |
| 1140 // Remove any keywords and "?" prefix. | 1139 // Remove keyword if we're in keyword mode. |
| 1141 user_text = DisplayTextFromUserText(user_text); | 1140 user_text = DisplayTextFromUserText(user_text); |
| 1141 full_text = DisplayTextFromUserText(full_text); | |
| 1142 | |
| 1143 // Remove "?" if we're in forced query mode. | |
| 1142 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | 1144 AutocompleteInput::RemoveForcedQueryStringIfNecessary( |
| 1143 autocomplete_controller_->input().type(), &user_text); | 1145 autocomplete_controller_->input().type(), &user_text); |
| 1146 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | |
| 1147 autocomplete_controller_->input().type(), &full_text); | |
| 1144 | 1148 |
| 1145 return instant->Update(match, user_text, UseVerbatimInstant(), | 1149 return instant->Update(match, user_text, full_text, UseVerbatimInstant(), |
| 1146 suggested_text, complete_behavior); | 1150 suggested_text, complete_behavior); |
| 1147 } | 1151 } |
| 1148 | 1152 |
| 1149 // It's possible DoInstant() was called due to an OnChanged() event from the | 1153 // It's possible DoInstant() was called due to an OnChanged() event from the |
| 1150 // omnibox view if the user clicked the renderer while IME composition was | 1154 // omnibox view if the user clicked the renderer while IME composition was |
| 1151 // active. In that case we still want to commit on mouse up, so don't call | 1155 // active. In that case we still want to commit on mouse up, so don't call |
| 1152 // Hide(). | 1156 // Hide(). |
| 1153 if (!instant->commit_on_pointer_release()) | 1157 if (!instant->commit_on_pointer_release()) |
| 1154 instant->Hide(); | 1158 instant->Hide(); |
| 1159 | |
|
Peter Kasting
2012/08/24 22:27:19
NIt: Don't really need this new line
sreeram
2012/08/24 23:09:55
Done.
| |
| 1155 return false; | 1160 return false; |
| 1156 } | 1161 } |
| 1157 | 1162 |
| 1158 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { | 1163 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { |
| 1159 // Do not prerender if the destination URL is the same as the current URL. | 1164 // Do not prerender if the destination URL is the same as the current URL. |
| 1160 if (match.destination_url == PermanentURL()) | 1165 if (match.destination_url == PermanentURL()) |
| 1161 return; | 1166 return; |
| 1162 // It's possible the tab strip does not have an active tab contents, for | 1167 // It's possible the tab strip does not have an active tab contents, for |
| 1163 // instance if the tab has been closed or on return from a sleep state | 1168 // instance if the tab has been closed or on return from a sleep state |
| 1164 // (http://crbug.com/105689) | 1169 // (http://crbug.com/105689) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1216 } | 1221 } |
| 1217 | 1222 |
| 1218 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1223 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1219 const string16& text, | 1224 const string16& text, |
| 1220 AutocompleteMatch* match, | 1225 AutocompleteMatch* match, |
| 1221 GURL* alternate_nav_url) const { | 1226 GURL* alternate_nav_url) const { |
| 1222 DCHECK(match); | 1227 DCHECK(match); |
| 1223 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1228 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1224 string16(), false, false, match, alternate_nav_url); | 1229 string16(), false, false, match, alternate_nav_url); |
| 1225 } | 1230 } |
| OLD | NEW |