OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete_classifier.h" | 5 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 9 #include "chrome/browser/autocomplete/autocomplete_match.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 | 11 |
12 AutocompleteClassifier::AutocompleteClassifier(Profile* profile) | 12 AutocompleteClassifier::AutocompleteClassifier(Profile* profile) |
13 : controller_(new AutocompleteController(profile, NULL)), | 13 : controller_(new AutocompleteController(profile, NULL)), |
14 inside_classify_(false) { | 14 inside_classify_(false) { |
15 } | 15 } |
16 | 16 |
17 AutocompleteClassifier::~AutocompleteClassifier() { | 17 AutocompleteClassifier::~AutocompleteClassifier() { |
18 } | 18 } |
19 | 19 |
20 void AutocompleteClassifier::Classify(const string16& text, | 20 void AutocompleteClassifier::Classify(const string16& text, |
21 const string16& desired_tld, | 21 const string16& desired_tld, |
| 22 bool prefer_keyword, |
22 bool allow_exact_keyword_match, | 23 bool allow_exact_keyword_match, |
23 AutocompleteMatch* match, | 24 AutocompleteMatch* match, |
24 GURL* alternate_nav_url) { | 25 GURL* alternate_nav_url) { |
25 DCHECK(!inside_classify_); | 26 DCHECK(!inside_classify_); |
26 AutoReset<bool> reset(&inside_classify_, true); | 27 AutoReset<bool> reset(&inside_classify_, true); |
27 controller_->Start(text, desired_tld, true, false, allow_exact_keyword_match, | 28 controller_->Start(text, desired_tld, true, prefer_keyword, |
28 AutocompleteInput::BEST_MATCH); | 29 allow_exact_keyword_match, AutocompleteInput::BEST_MATCH); |
29 DCHECK(controller_->done()); | 30 DCHECK(controller_->done()); |
30 const AutocompleteResult& result = controller_->result(); | 31 const AutocompleteResult& result = controller_->result(); |
31 if (result.empty()) { | 32 if (result.empty()) { |
32 if (alternate_nav_url) | 33 if (alternate_nav_url) |
33 *alternate_nav_url = GURL(); | 34 *alternate_nav_url = GURL(); |
34 return; | 35 return; |
35 } | 36 } |
36 | 37 |
37 DCHECK(result.default_match() != result.end()); | 38 DCHECK(result.default_match() != result.end()); |
38 *match = *result.default_match(); | 39 *match = *result.default_match(); |
39 if (alternate_nav_url) | 40 if (alternate_nav_url) |
40 *alternate_nav_url = result.alternate_nav_url(); | 41 *alternate_nav_url = result.alternate_nav_url(); |
41 } | 42 } |
OLD | NEW |