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 due_to_user_inactivity) { |
321 done_ = true; | 322 done_ = true; |
322 if (extensions_delegate_) | 323 // Only end an extension's request if the user did something to explicitly |
| 324 // cancel it; mere inactivity shouldn't terminate long-running extension |
| 325 // operations since the user likely explicitly requested them. |
| 326 if (extensions_delegate_ && !due_to_user_inactivity) |
323 extensions_delegate_->MaybeEndExtensionKeywordMode(); | 327 extensions_delegate_->MaybeEndExtensionKeywordMode(); |
324 } | 328 } |
325 | 329 |
326 KeywordProvider::~KeywordProvider() {} | 330 KeywordProvider::~KeywordProvider() {} |
327 | 331 |
328 // static | 332 // static |
329 bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input, | 333 bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input, |
330 base::string16* keyword, | 334 base::string16* keyword, |
331 base::string16* remaining_input) { | 335 base::string16* remaining_input) { |
332 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 336 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); | 470 ACMatchClassification::NONE, &match->contents_class); |
467 } | 471 } |
468 } | 472 } |
469 | 473 |
470 TemplateURLService* KeywordProvider::GetTemplateURLService() const { | 474 TemplateURLService* KeywordProvider::GetTemplateURLService() const { |
471 // Make sure the model is loaded. This is cheap and quickly bails out if | 475 // Make sure the model is loaded. This is cheap and quickly bails out if |
472 // the model is already loaded. | 476 // the model is already loaded. |
473 model_->Load(); | 477 model_->Load(); |
474 return model_; | 478 return model_; |
475 } | 479 } |
OLD | NEW |