[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / autocomplete / autocomplete_classifier.h
blobc78fe0ea2014ecf09c69357e6ba8a4cec18e42a5
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/autocomplete/autocomplete_input.h"
13 #include "components/keyed_service/core/keyed_service.h"
15 class AutocompleteController;
16 struct AutocompleteMatch;
17 class GURL;
18 class Profile;
20 class AutocompleteClassifier : public KeyedService {
21 public:
22 // Bitmap of AutocompleteProvider::Type values describing the default set of
23 // providers queried for the omnibox. Intended to be passed to
24 // AutocompleteController().
25 static const int kDefaultOmniboxProviders;
27 explicit AutocompleteClassifier(Profile* profile);
28 virtual ~AutocompleteClassifier();
30 // Given some string |text| that the user wants to use for navigation,
31 // determines how it should be interpreted.
32 // |prefer_keyword| should be true the when keyword UI is onscreen; see
33 // comments on AutocompleteController::Start().
34 // |allow_exact_keyword_match| should be true when treating the string as a
35 // potential keyword search is valid; see
36 // AutocompleteInput::allow_exact_keyword_match().
37 // |page_classification| gives information about the context (e.g., is the
38 // user on a search results page doing search term replacement); this may
39 // be useful in deciding how the input should be interpreted.
40 // |match| should be a non-NULL outparam that will be set to the default
41 // match for this input, if any (for invalid input, there will be no default
42 // match, and |match| will be left unchanged). |alternate_nav_url| is a
43 // possibly-NULL outparam that, if non-NULL, will be set to the navigational
44 // URL (if any) in case of an accidental search; see comments on
45 // AutocompleteResult::alternate_nav_url_ in autocomplete.h.
46 void Classify(const base::string16& text,
47 bool prefer_keyword,
48 bool allow_exact_keyword_match,
49 AutocompleteInput::PageClassification page_classification,
50 AutocompleteMatch* match,
51 GURL* alternate_nav_url);
53 private:
54 // KeyedService:
55 virtual void Shutdown() OVERRIDE;
57 scoped_ptr<AutocompleteController> controller_;
59 // Are we currently in Classify? Used to verify Classify isn't invoked
60 // recursively, since this can corrupt state and cause crashes.
61 bool inside_classify_;
63 DISALLOW_IMPLICIT_CONSTRUCTORS(AutocompleteClassifier);
66 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_