| OLD | NEW | 
 | (Empty) | 
|   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. |  | 
|   4  |  | 
|   5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ |  | 
|   6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ |  | 
|   7  |  | 
|   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 "components/keyed_service/core/keyed_service.h" |  | 
|  13 #include "components/metrics/proto/omnibox_event.pb.h" |  | 
|  14 #include "components/omnibox/autocomplete_scheme_classifier.h" |  | 
|  15  |  | 
|  16 class AutocompleteController; |  | 
|  17 struct AutocompleteMatch; |  | 
|  18 class GURL; |  | 
|  19  |  | 
|  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; |  | 
|  26  |  | 
|  27   AutocompleteClassifier( |  | 
|  28       scoped_ptr<AutocompleteController> controller_, |  | 
|  29       scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier); |  | 
|  30   ~AutocompleteClassifier() override; |  | 
|  31  |  | 
|  32   // Given some string |text| that the user wants to use for navigation, |  | 
|  33   // determines how it should be interpreted. |  | 
|  34   // |prefer_keyword| should be true the when keyword UI is onscreen; see |  | 
|  35   // comments on AutocompleteController::Start(). |  | 
|  36   // |allow_exact_keyword_match| should be true when treating the string as a |  | 
|  37   // potential keyword search is valid; see |  | 
|  38   // AutocompleteInput::allow_exact_keyword_match(). |  | 
|  39   // |page_classification| gives information about the context (e.g., is the |  | 
|  40   // user on a search results page doing search term replacement); this may |  | 
|  41   // be useful in deciding how the input should be interpreted. |  | 
|  42   // |match| should be a non-NULL outparam that will be set to the default |  | 
|  43   // match for this input, if any (for invalid input, there will be no default |  | 
|  44   // match, and |match| will be left unchanged).  |alternate_nav_url| is a |  | 
|  45   // possibly-NULL outparam that, if non-NULL, will be set to the navigational |  | 
|  46   // URL (if any) in case of an accidental search; see comments on |  | 
|  47   // AutocompleteResult::alternate_nav_url_ in autocomplete.h. |  | 
|  48   void Classify(const base::string16& text, |  | 
|  49                 bool prefer_keyword, |  | 
|  50                 bool allow_exact_keyword_match, |  | 
|  51                 metrics::OmniboxEventProto::PageClassification |  | 
|  52                     page_classification, |  | 
|  53                 AutocompleteMatch* match, |  | 
|  54                 GURL* alternate_nav_url); |  | 
|  55  |  | 
|  56  private: |  | 
|  57   // KeyedService: |  | 
|  58   void Shutdown() override; |  | 
|  59  |  | 
|  60   scoped_ptr<AutocompleteController> controller_; |  | 
|  61   scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier_; |  | 
|  62  |  | 
|  63   // Are we currently in Classify? Used to verify Classify isn't invoked |  | 
|  64   // recursively, since this can corrupt state and cause crashes. |  | 
|  65   bool inside_classify_; |  | 
|  66  |  | 
|  67   DISALLOW_IMPLICIT_CONSTRUCTORS(AutocompleteClassifier); |  | 
|  68 }; |  | 
|  69  |  | 
|  70 #endif  // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_H_ |  | 
| OLD | NEW |