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

Side by Side Diff: components/omnibox/keyword_provider.cc

Issue 836213002: Assume all providers may give zero suggest responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation issue in athena Created 5 years, 11 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
« no previous file with comments | « components/omnibox/keyword_provider.h ('k') | components/omnibox/keyword_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/omnibox/keyword_provider.h" 5 #include "components/omnibox/keyword_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 const base::string16& text, 192 const base::string16& text,
193 const base::string16& keyword, 193 const base::string16& keyword,
194 const AutocompleteInput& input) { 194 const AutocompleteInput& input) {
195 // A verbatim match is allowed to be the default match. 195 // A verbatim match is allowed to be the default match.
196 return CreateAutocompleteMatch( 196 return CreateAutocompleteMatch(
197 GetTemplateURLService()->GetTemplateURLForKeyword(keyword), input, 197 GetTemplateURLService()->GetTemplateURLForKeyword(keyword), input,
198 keyword.length(), SplitReplacementStringFromInput(text, true), true, 0); 198 keyword.length(), SplitReplacementStringFromInput(text, true), true, 0);
199 } 199 }
200 200
201 void KeywordProvider::Start(const AutocompleteInput& input, 201 void KeywordProvider::Start(const AutocompleteInput& input,
202 bool minimal_changes) { 202 bool minimal_changes,
203 bool called_due_to_focus) {
203 // This object ensures we end keyword mode if we exit the function without 204 // This object ensures we end keyword mode if we exit the function without
204 // toggling keyword mode to on. 205 // toggling keyword mode to on.
205 ScopedEndExtensionKeywordMode keyword_mode_toggle(extensions_delegate_.get()); 206 ScopedEndExtensionKeywordMode keyword_mode_toggle(extensions_delegate_.get());
206 207
207 matches_.clear(); 208 matches_.clear();
208 209
209 if (!minimal_changes) { 210 if (!minimal_changes) {
210 done_ = true; 211 done_ = true;
211 212
212 // Input has changed. Increment the input ID so that we can discard any 213 // Input has changed. Increment the input ID so that we can discard any
213 // stale extension suggestions that may be incoming. 214 // stale extension suggestions that may be incoming.
214 if (extensions_delegate_) 215 if (extensions_delegate_)
215 extensions_delegate_->IncrementInputId(); 216 extensions_delegate_->IncrementInputId();
216 } 217 }
217 218
219 if (called_due_to_focus)
220 return;
221
218 // Split user input into a keyword and some query input. 222 // Split user input into a keyword and some query input.
219 // 223 //
220 // We want to suggest keywords even when users have started typing URLs, on 224 // We want to suggest keywords even when users have started typing URLs, on
221 // the assumption that they might not realize they no longer need to go to a 225 // the assumption that they might not realize they no longer need to go to a
222 // site to be able to search it. So we call CleanUserInputKeyword() to strip 226 // site to be able to search it. So we call CleanUserInputKeyword() to strip
223 // any initial scheme and/or "www.". NOTE: Any heuristics or UI used to 227 // any initial scheme and/or "www.". NOTE: Any heuristics or UI used to
224 // automatically/manually create keywords will need to be in sync with 228 // automatically/manually create keywords will need to be in sync with
225 // whatever we do here! 229 // whatever we do here!
226 // 230 //
227 // TODO(pkasting): http://crbug/347744 If someday we remember usage frequency 231 // TODO(pkasting): http://crbug/347744 If someday we remember usage frequency
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 ACMatchClassification::NONE, &match->contents_class); 466 ACMatchClassification::NONE, &match->contents_class);
463 } 467 }
464 } 468 }
465 469
466 TemplateURLService* KeywordProvider::GetTemplateURLService() const { 470 TemplateURLService* KeywordProvider::GetTemplateURLService() const {
467 // Make sure the model is loaded. This is cheap and quickly bails out if 471 // Make sure the model is loaded. This is cheap and quickly bails out if
468 // the model is already loaded. 472 // the model is already loaded.
469 model_->Load(); 473 model_->Load();
470 return model_; 474 return model_;
471 } 475 }
OLDNEW
« no previous file with comments | « components/omnibox/keyword_provider.h ('k') | components/omnibox/keyword_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698