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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 | 14 |
15 class AutocompleteController; | 15 class AutocompleteController; |
16 struct AutocompleteMatch; | 16 struct AutocompleteMatch; |
17 class GURL; | 17 class GURL; |
18 class Profile; | 18 class Profile; |
19 | 19 |
20 class AutocompleteClassifier { | 20 class AutocompleteClassifier { |
21 public: | 21 public: |
22 explicit AutocompleteClassifier(Profile* profile); | 22 explicit AutocompleteClassifier(Profile* profile); |
23 virtual ~AutocompleteClassifier(); | 23 virtual ~AutocompleteClassifier(); |
24 | 24 |
25 // Given some string |text| that the user wants to use for navigation, | 25 // Given some string |text| that the user wants to use for navigation, |
26 // determines how it should be interpreted. |desired_tld| is the user's | 26 // determines how it should be interpreted. |desired_tld| is the user's |
27 // desired TLD, if any; see AutocompleteInput::desired_tld(). | 27 // desired TLD, if any; see AutocompleteInput::desired_tld(). |
| 28 // |prefer_keyword| should be true the when keyword UI is onscreen; see |
| 29 // comments on AutocompleteController::Start(). |
28 // |allow_exact_keyword_match| should be true when treating the string as a | 30 // |allow_exact_keyword_match| should be true when treating the string as a |
29 // potential keyword search is valid; see | 31 // potential keyword search is valid; see |
30 // AutocompleteInput::allow_exact_keyword_match(). |match| should be a | 32 // AutocompleteInput::allow_exact_keyword_match(). |match| should be a |
31 // non-NULL outparam that will be set to the default match for this input, if | 33 // non-NULL outparam that will be set to the default match for this input, if |
32 // any (for invalid input, there will be no default match, and |match| will be | 34 // any (for invalid input, there will be no default match, and |match| will be |
33 // left unchanged). |alternate_nav_url| is a possibly-NULL outparam that, if | 35 // left unchanged). |alternate_nav_url| is a possibly-NULL outparam that, if |
34 // non-NULL, will be set to the navigational URL (if any) in case of an | 36 // non-NULL, will be set to the navigational URL (if any) in case of an |
35 // accidental search; see comments on | 37 // accidental search; see comments on |
36 // AutocompleteResult::alternate_nav_url_ in autocomplete.h. | 38 // AutocompleteResult::alternate_nav_url_ in autocomplete.h. |
37 void Classify(const string16& text, | 39 void Classify(const string16& text, |
38 const string16& desired_tld, | 40 const string16& desired_tld, |
| 41 bool prefer_keyword, |
39 bool allow_exact_keyword_match, | 42 bool allow_exact_keyword_match, |
40 AutocompleteMatch* match, | 43 AutocompleteMatch* match, |
41 GURL* alternate_nav_url); | 44 GURL* alternate_nav_url); |
42 | 45 |
43 private: | 46 private: |
44 scoped_ptr<AutocompleteController> controller_; | 47 scoped_ptr<AutocompleteController> controller_; |
45 | 48 |
46 // Are we currently in Classify? Used to verify Classify isn't invoked | 49 // Are we currently in Classify? Used to verify Classify isn't invoked |
47 // recursively, since this can corrupt state and cause crashes. | 50 // recursively, since this can corrupt state and cause crashes. |
48 bool inside_classify_; | 51 bool inside_classify_; |
49 | 52 |
50 DISALLOW_IMPLICIT_CONSTRUCTORS(AutocompleteClassifier); | 53 DISALLOW_IMPLICIT_CONSTRUCTORS(AutocompleteClassifier); |
51 }; | 54 }; |
52 | 55 |
53 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ | 56 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ |
OLD | NEW |