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

Side by Side Diff: chrome/browser/autocomplete/history_quick_provider.cc

Issue 226283009: Make AutocompleteInput::Parse() more strict: return QUERY for all inputs that (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 8 months 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/autocomplete/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int url_what_you_typed_match_score = -1; // undefined 117 int url_what_you_typed_match_score = -1; // undefined
118 // These are necessary (but not sufficient) conditions for the omnibox 118 // These are necessary (but not sufficient) conditions for the omnibox
119 // input to be a URL-what-you-typed match. The username test checks that 119 // input to be a URL-what-you-typed match. The username test checks that
120 // either the username does not exist (a regular URL such as http://site/) 120 // either the username does not exist (a regular URL such as http://site/)
121 // or, if the username exists (http://user@site/), there must be either 121 // or, if the username exists (http://user@site/), there must be either
122 // a password or a port. Together these exclude pure username@site 122 // a password or a port. Together these exclude pure username@site
123 // inputs because these are likely to be an e-mail address. HistoryURL 123 // inputs because these are likely to be an e-mail address. HistoryURL
124 // provider won't promote the URL-what-you-typed match to first 124 // provider won't promote the URL-what-you-typed match to first
125 // for these inputs. 125 // for these inputs.
126 const bool can_have_url_what_you_typed_match_first = 126 const bool can_have_url_what_you_typed_match_first =
127 autocomplete_input_.canonicalized_url().is_valid() &&
128 (autocomplete_input_.type() != AutocompleteInput::QUERY) && 127 (autocomplete_input_.type() != AutocompleteInput::QUERY) &&
129 (autocomplete_input_.type() != AutocompleteInput::FORCED_QUERY) &&
Mark P 2014/04/25 02:59:20 Why did you remove this?
Mark P 2014/04/25 03:00:29 Nevermind, I see that we wouldn't reach here in FO
130 (!autocomplete_input_.parts().username.is_nonempty() || 128 (!autocomplete_input_.parts().username.is_nonempty() ||
131 autocomplete_input_.parts().password.is_nonempty() || 129 autocomplete_input_.parts().password.is_nonempty() ||
132 autocomplete_input_.parts().path.is_nonempty()); 130 autocomplete_input_.parts().path.is_nonempty());
133 if (can_have_url_what_you_typed_match_first) { 131 if (can_have_url_what_you_typed_match_first) {
134 HistoryService* const history_service = 132 HistoryService* const history_service =
135 HistoryServiceFactory::GetForProfile(profile_, 133 HistoryServiceFactory::GetForProfile(profile_,
136 Profile::EXPLICIT_ACCESS); 134 Profile::EXPLICIT_ACCESS);
137 // We expect HistoryService to be available. In case it's not, 135 // We expect HistoryService to be available. In case it's not,
138 // (e.g., due to Profile corruption) we let HistoryQuick provider 136 // (e.g., due to Profile corruption) we let HistoryQuick provider
139 // completions (which may be available because it's a different 137 // completions (which may be available because it's a different
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (index_for_testing_.get()) 307 if (index_for_testing_.get())
310 return index_for_testing_.get(); 308 return index_for_testing_.get();
311 309
312 HistoryService* const history_service = 310 HistoryService* const history_service =
313 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 311 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
314 if (!history_service) 312 if (!history_service)
315 return NULL; 313 return NULL;
316 314
317 return history_service->InMemoryIndex(); 315 return history_service->InMemoryIndex();
318 } 316 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_input_unittest.cc ('k') | chrome/browser/autocomplete/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698