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

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

Issue 11262015: Remove unused / unnecessary stuff from Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove SuggestedTextView entirely Created 8 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 (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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // There may be no providers during testing; guard against that. 188 // There may be no providers during testing; guard against that.
189 if (search_provider) 189 if (search_provider)
190 search_provider->FinalizeInstantQuery(input_text, suggestion); 190 search_provider->FinalizeInstantQuery(input_text, suggestion);
191 } 191 }
192 } 192 }
193 193
194 void OmniboxEditModel::SetInstantSuggestion( 194 void OmniboxEditModel::SetInstantSuggestion(
195 const InstantSuggestion& suggestion) { 195 const InstantSuggestion& suggestion) {
196 switch (suggestion.behavior) { 196 switch (suggestion.behavior) {
197 case INSTANT_COMPLETE_NOW: 197 case INSTANT_COMPLETE_NOW:
198 view_->SetInstantSuggestion(string16(), false); 198 view_->SetInstantSuggestion(string16());
199 if (!suggestion.text.empty()) 199 if (!suggestion.text.empty())
200 FinalizeInstantQuery(view_->GetText(), suggestion, false); 200 FinalizeInstantQuery(view_->GetText(), suggestion, false);
201 break; 201 break;
202 202
203 case INSTANT_COMPLETE_DELAYED:
204 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type);
205 // Starts out as gray text (i.e., INSTANT_COMPLETE_NEVER) and animates to
206 // completed blue text by way of CommitSuggestedText().
207 view_->SetInstantSuggestion(suggestion.text, true);
208 break;
209
210 case INSTANT_COMPLETE_NEVER: 203 case INSTANT_COMPLETE_NEVER:
211 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); 204 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type);
212 view_->SetInstantSuggestion(suggestion.text, false); 205 view_->SetInstantSuggestion(suggestion.text);
213 break; 206 break;
214 207
215 case INSTANT_COMPLETE_REPLACE: 208 case INSTANT_COMPLETE_REPLACE:
216 view_->SetInstantSuggestion(string16(), false); 209 view_->SetInstantSuggestion(string16());
217 has_temporary_text_ = true; 210 has_temporary_text_ = true;
218 is_temporary_text_set_by_instant_ = true; 211 is_temporary_text_set_by_instant_ = true;
219 view_->SetWindowTextAndCaretPos(suggestion.text, suggestion.text.size(), 212 view_->SetWindowTextAndCaretPos(suggestion.text, suggestion.text.size(),
220 false, false); 213 false, false);
221 break; 214 break;
222 } 215 }
223 } 216 }
224 217
225 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { 218 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) {
226 if (!controller_->GetInstant()) 219 if (!controller_->GetInstant())
227 return false; 220 return false;
228 221
229 const string16 suggestion = view_->GetInstantSuggestion(); 222 const string16 suggestion = view_->GetInstantSuggestion();
230 if (suggestion.empty()) 223 if (suggestion.empty())
231 return false; 224 return false;
232 225
233 // Assume delayed commits are always search suggestions. 226 // Assume that the gray text we are committing is a search suggestion.
234 FinalizeInstantQuery(view_->GetText(), 227 FinalizeInstantQuery(view_->GetText(),
235 InstantSuggestion(suggestion, 228 InstantSuggestion(suggestion,
236 INSTANT_COMPLETE_NOW, 229 INSTANT_COMPLETE_NOW,
237 INSTANT_SUGGESTION_SEARCH), 230 INSTANT_SUGGESTION_SEARCH),
238 skip_inline_autocomplete); 231 skip_inline_autocomplete);
239 return true; 232 return true;
240 } 233 }
241 234
242 bool OmniboxEditModel::AcceptCurrentInstantPreview() { 235 bool OmniboxEditModel::AcceptCurrentInstantPreview() {
243 InstantController* instant = controller_->GetInstant(); 236 InstantController* instant = controller_->GetInstant();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 DoPreconnect(current_match); 278 DoPreconnect(current_match);
286 break; 279 break;
287 case AutocompleteActionPredictor::ACTION_NONE: 280 case AutocompleteActionPredictor::ACTION_NONE:
288 break; 281 break;
289 default: 282 default:
290 NOTREACHED() << "Unexpected recommended action: " << recommended_action; 283 NOTREACHED() << "Unexpected recommended action: " << recommended_action;
291 break; 284 break;
292 } 285 }
293 286
294 // Hide any suggestions we might be showing. 287 // Hide any suggestions we might be showing.
295 view_->SetInstantSuggestion(string16(), false); 288 view_->SetInstantSuggestion(string16());
296 289
297 // No need to wait any longer for instant. 290 // No need to wait any longer for instant.
298 FinalizeInstantQuery(string16(), InstantSuggestion(), false); 291 FinalizeInstantQuery(string16(), InstantSuggestion(), false);
299 } 292 }
300 293
301 controller_->OnChanged(); 294 controller_->OnChanged();
302 } 295 }
303 296
304 void OmniboxEditModel::GetDataForURLExport(GURL* url, 297 void OmniboxEditModel::GetDataForURLExport(GURL* url,
305 string16* title, 298 string16* title,
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 } 1291 }
1299 1292
1300 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1293 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1301 const string16& text, 1294 const string16& text,
1302 AutocompleteMatch* match, 1295 AutocompleteMatch* match,
1303 GURL* alternate_nav_url) const { 1296 GURL* alternate_nav_url) const {
1304 DCHECK(match); 1297 DCHECK(match);
1305 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1298 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1306 string16(), false, false, match, alternate_nav_url); 1299 string16(), false, false, match, alternate_nav_url);
1307 } 1300 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698