OLD | NEW |
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/keyword_provider.h" | 5 #include "chrome/browser/autocomplete/keyword_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( | 430 AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( |
431 TemplateURLService* model, | 431 TemplateURLService* model, |
432 const string16& keyword, | 432 const string16& keyword, |
433 const AutocompleteInput& input, | 433 const AutocompleteInput& input, |
434 size_t prefix_length, | 434 size_t prefix_length, |
435 const string16& remaining_input, | 435 const string16& remaining_input, |
436 int relevance) { | 436 int relevance) { |
437 DCHECK(model); | 437 DCHECK(model); |
438 // Get keyword data from data store. | 438 // Get keyword data from data store. |
439 const TemplateURL* element( | 439 const TemplateURL* element = model->GetTemplateURLForKeyword(keyword); |
440 model->GetTemplateURLForKeyword(keyword)); | |
441 DCHECK(element && !element->url().empty()); | 440 DCHECK(element && !element->url().empty()); |
442 const bool supports_replacement = element->url_ref().SupportsReplacement(); | 441 const bool supports_replacement = element->url_ref().SupportsReplacement(); |
443 | 442 |
444 // Create an edit entry of "[keyword] [remaining input]". This is helpful | 443 // Create an edit entry of "[keyword] [remaining input]". This is helpful |
445 // even when [remaining input] is empty, as the user can select the popup | 444 // even when [remaining input] is empty, as the user can select the popup |
446 // choice and immediately begin typing in query input. | 445 // choice and immediately begin typing in query input. |
447 const bool keyword_complete = (prefix_length == keyword.length()); | 446 const bool keyword_complete = (prefix_length == keyword.length()); |
448 if (relevance < 0) { | 447 if (relevance < 0) { |
449 relevance = | 448 relevance = |
450 CalculateRelevance(input.type(), keyword_complete, | 449 CalculateRelevance(input.type(), keyword_complete, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 580 } |
582 | 581 |
583 void KeywordProvider::MaybeEndExtensionKeywordMode() { | 582 void KeywordProvider::MaybeEndExtensionKeywordMode() { |
584 if (!current_keyword_extension_id_.empty()) { | 583 if (!current_keyword_extension_id_.empty()) { |
585 ExtensionOmniboxEventRouter::OnInputCancelled( | 584 ExtensionOmniboxEventRouter::OnInputCancelled( |
586 profile_, current_keyword_extension_id_); | 585 profile_, current_keyword_extension_id_); |
587 | 586 |
588 current_keyword_extension_id_.clear(); | 587 current_keyword_extension_id_.clear(); |
589 } | 588 } |
590 } | 589 } |
OLD | NEW |