Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 if (matches.size() > kMaxMatches) | 310 if (matches.size() > kMaxMatches) |
| 311 matches.erase(matches.begin() + kMaxMatches, matches.end()); | 311 matches.erase(matches.begin() + kMaxMatches, matches.end()); |
| 312 for (TemplateURLService::TemplateURLVector::const_iterator i( | 312 for (TemplateURLService::TemplateURLVector::const_iterator i( |
| 313 matches.begin()); i != matches.end(); ++i) { | 313 matches.begin()); i != matches.end(); ++i) { |
| 314 matches_.push_back(CreateAutocompleteMatch( | 314 matches_.push_back(CreateAutocompleteMatch( |
| 315 *i, input, keyword.length(), remaining_input, false, -1)); | 315 *i, input, keyword.length(), remaining_input, false, -1)); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 void KeywordProvider::Stop(bool clear_cached_results) { | 320 void KeywordProvider::Stop(bool clear_cached_results, |
| 321 bool user_inactivity_timer) { | |
| 321 done_ = true; | 322 done_ = true; |
| 322 if (extensions_delegate_) | 323 // Only end an extensions request if the user did something explicitly |
|
Peter Kasting
2015/03/05 23:27:28
Nit: extension's; explicitly to -> to explicitly
Mark P
2015/03/06 21:24:34
Did both.
| |
| 324 // to cancel it; the inactivity timer does not count. | |
|
Peter Kasting
2015/03/05 23:27:28
Nit: does not count -> shouldn't terminate long-ru
Mark P
2015/03/06 21:24:34
Done (with minor edits).
| |
| 325 if (extensions_delegate_ && !user_inactivity_timer) | |
| 323 extensions_delegate_->MaybeEndExtensionKeywordMode(); | 326 extensions_delegate_->MaybeEndExtensionKeywordMode(); |
| 324 } | 327 } |
| 325 | 328 |
| 326 KeywordProvider::~KeywordProvider() {} | 329 KeywordProvider::~KeywordProvider() {} |
| 327 | 330 |
| 328 // static | 331 // static |
| 329 bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input, | 332 bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input, |
| 330 base::string16* keyword, | 333 base::string16* keyword, |
| 331 base::string16* remaining_input) { | 334 base::string16* remaining_input) { |
| 332 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 335 if ((input.type() == metrics::OmniboxInputType::INVALID) || |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 ACMatchClassification::NONE, &match->contents_class); | 469 ACMatchClassification::NONE, &match->contents_class); |
| 467 } | 470 } |
| 468 } | 471 } |
| 469 | 472 |
| 470 TemplateURLService* KeywordProvider::GetTemplateURLService() const { | 473 TemplateURLService* KeywordProvider::GetTemplateURLService() const { |
| 471 // Make sure the model is loaded. This is cheap and quickly bails out if | 474 // Make sure the model is loaded. This is cheap and quickly bails out if |
| 472 // the model is already loaded. | 475 // the model is already loaded. |
| 473 model_->Load(); | 476 model_->Load(); |
| 474 return model_; | 477 return model_; |
| 475 } | 478 } |
| OLD | NEW |