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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_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/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "chrome/browser/autocomplete/autocomplete_types.h" | 14 #include "chrome/browser/autocomplete/autocomplete_types.h" |
15 #include "chrome/common/metrics/proto/omnibox_event.pb.h" | 15 #include "chrome/common/metrics/proto/omnibox_event.pb.h" |
16 | 16 |
17 class AutocompleteInput; | 17 class AutocompleteInput; |
18 struct AutocompleteMatch; | 18 struct AutocompleteMatch; |
19 class AutocompleteProviderListener; | 19 class AutocompleteProviderListener; |
20 class GURL; | 20 class GURL; |
21 class Profile; | 21 class Profile; |
22 | 22 |
| 23 // The AutocompleteProviders each return different kinds of matches, |
| 24 // such as history or search matches. These matches are given |
| 25 // "relevance" scores. Higher scores are better matches than lower |
| 26 // scores. The relevance scores and classes providing the respective |
| 27 // matches are as listed below. |
| 28 // |
| 29 // IMPORTANT CAVEAT: The tables below are NOT COMPLETE. Developers |
| 30 // often forget to keep these tables in sync with the code when they |
| 31 // change scoring algorithms or add new providers. For example, |
| 32 // neither the HistoryQuickProvider (which is a provider that appears |
| 33 // often) nor the ShortcutsProvider are listed here. For the best |
| 34 // idea of how scoring works and what providers are affecting which |
| 35 // queries, play with chrome://omnibox/ for a while. While the tables |
| 36 // below may have some utility, nothing compares with first-hand |
| 37 // investigation and experience. |
| 38 // |
| 39 // UNKNOWN input type: |
| 40 // --------------------------------------------------------------------|----- |
| 41 // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 |
| 42 // Extension App (exact match) | 1425 |
| 43 // HistoryURL (good exact or inline autocomplete matches, some inexact)| 1410++ |
| 44 // HistoryURL (intranet url never visited match, some inexact matches) | 1400++ |
| 45 // Search Primary Provider (past query in history within 2 days) | 1399** |
| 46 // Search Primary Provider (what you typed) | 1300 |
| 47 // HistoryURL (what you typed, some inexact matches) | 1200++ |
| 48 // Extension App (inexact match) | 1175*~ |
| 49 // Keyword (substituting, exact match) | 1100 |
| 50 // Search Primary Provider (past query in history older than 2 days) | 1050-- |
| 51 // HistoryContents (any match in title of starred page) | 1000++ |
| 52 // HistoryURL (some inexact matches) | 900++ |
| 53 // Search Primary Provider (navigational suggestion) | 800++ |
| 54 // HistoryContents (any match in title of nonstarred page) | 700++ |
| 55 // Search Primary Provider (suggestion) | 600++ |
| 56 // Built-in | 575++ |
| 57 // HistoryContents (any match in body of starred page) | 550++ |
| 58 // HistoryContents (any match in body of nonstarred page) | 500++ |
| 59 // Keyword (inexact match) | 450 |
| 60 // Search Secondary Provider (what you typed) | 250 |
| 61 // Search Secondary Provider (past query in history) | 200-- |
| 62 // Search Secondary Provider (navigational suggestion) | 150++ |
| 63 // Search Secondary Provider (suggestion) | 100++ |
| 64 // |
| 65 // REQUESTED_URL input type: |
| 66 // --------------------------------------------------------------------|----- |
| 67 // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 |
| 68 // Extension App (exact match) | 1425 |
| 69 // HistoryURL (good exact or inline autocomplete matches, some inexact)| 1410++ |
| 70 // HistoryURL (intranet url never visited match, some inexact matches) | 1400++ |
| 71 // Search Primary Provider (past query in history within 2 days) | 1399** |
| 72 // HistoryURL (what you typed, some inexact matches) | 1200++ |
| 73 // Extension App (inexact match) | 1175*~ |
| 74 // Search Primary Provider (what you typed) | 1150 |
| 75 // Keyword (substituting, exact match) | 1100 |
| 76 // Search Primary Provider (past query in history older than 2 days) | 1050-- |
| 77 // HistoryContents (any match in title of starred page) | 1000++ |
| 78 // HistoryURL (some inexact matches) | 900++ |
| 79 // Search Primary Provider (navigational suggestion) | 800++ |
| 80 // HistoryContents (any match in title of nonstarred page) | 700++ |
| 81 // Search Primary Provider (suggestion) | 600++ |
| 82 // Built-in | 575++ |
| 83 // HistoryContents (any match in body of starred page) | 550++ |
| 84 // HistoryContents (any match in body of nonstarred page) | 500++ |
| 85 // Keyword (inexact match) | 450 |
| 86 // Search Secondary Provider (what you typed) | 250 |
| 87 // Search Secondary Provider (past query in history) | 200-- |
| 88 // Search Secondary Provider (navigational suggestion) | 150++ |
| 89 // Search Secondary Provider (suggestion) | 100++ |
| 90 // |
| 91 // URL input type: |
| 92 // --------------------------------------------------------------------|----- |
| 93 // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 |
| 94 // Extension App (exact match) | 1425 |
| 95 // HistoryURL (good exact or inline autocomplete matches, some inexact)| 1410++ |
| 96 // HistoryURL (intranet url never visited match, some inexact matches) | 1400++ |
| 97 // HistoryURL (what you typed, some inexact matches) | 1200++ |
| 98 // Extension App (inexact match) | 1175*~ |
| 99 // Keyword (substituting, exact match) | 1100 |
| 100 // HistoryURL (some inexact matches) | 900++ |
| 101 // Search Primary Provider (what you typed) | 850 |
| 102 // Search Primary Provider (navigational suggestion) | 800++ |
| 103 // Search Primary Provider (past query in history) | 750-- |
| 104 // Keyword (inexact match) | 700 |
| 105 // Built-in | 575++ |
| 106 // Search Primary Provider (suggestion) | 300++ |
| 107 // Search Secondary Provider (what you typed) | 250 |
| 108 // Search Secondary Provider (past query in history) | 200-- |
| 109 // Search Secondary Provider (navigational suggestion) | 150++ |
| 110 // Search Secondary Provider (suggestion) | 100++ |
| 111 // |
| 112 // QUERY input type: |
| 113 // --------------------------------------------------------------------|----- |
| 114 // Search Primary or Secondary (past query in history within 2 days) | 1599** |
| 115 // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 |
| 116 // Keyword (substituting, exact match) | 1450 |
| 117 // Extension App (exact match) | 1425 |
| 118 // Search Primary Provider (past query in history within 2 days) | 1399** |
| 119 // Search Primary Provider (what you typed) | 1300 |
| 120 // Extension App (inexact match) | 1175*~ |
| 121 // Search Primary Provider (past query in history older than 2 days) | 1050-- |
| 122 // HistoryContents (any match in title of starred page) | 1000++ |
| 123 // HistoryURL (inexact match) | 900++ |
| 124 // Search Primary Provider (navigational suggestion) | 800++ |
| 125 // HistoryContents (any match in title of nonstarred page) | 700++ |
| 126 // Search Primary Provider (suggestion) | 600++ |
| 127 // HistoryContents (any match in body of starred page) | 550++ |
| 128 // HistoryContents (any match in body of nonstarred page) | 500++ |
| 129 // Keyword (inexact match) | 450 |
| 130 // Search Secondary Provider (what you typed) | 250 |
| 131 // Search Secondary Provider (past query in history) | 200-- |
| 132 // Search Secondary Provider (navigational suggestion) | 150++ |
| 133 // Search Secondary Provider (suggestion) | 100++ |
| 134 // |
| 135 // FORCED_QUERY input type: |
| 136 // --------------------------------------------------------------------|----- |
| 137 // Extension App (exact match on title only, not url) | 1425 |
| 138 // Search Primary Provider (past query in history within 2 days) | 1399** |
| 139 // Search Primary Provider (what you typed) | 1300 |
| 140 // Extension App (inexact match on title only, not url) | 1175*~ |
| 141 // Search Primary Provider (past query in history older than 2 days) | 1050-- |
| 142 // HistoryContents (any match in title of starred page) | 1000++ |
| 143 // Search Primary Provider (navigational suggestion) | 800++ |
| 144 // HistoryContents (any match in title of nonstarred page) | 700++ |
| 145 // Search Primary Provider (suggestion) | 600++ |
| 146 // HistoryContents (any match in body of starred page) | 550++ |
| 147 // HistoryContents (any match in body of nonstarred page) | 500++ |
| 148 // |
| 149 // (A search keyword is a keyword with a replacement string; a bookmark keyword |
| 150 // is a keyword with no replacement string, that is, a shortcut for a URL.) |
| 151 // |
| 152 // There are two possible providers for search suggestions. If the user has |
| 153 // typed a keyword, then the primary provider is the keyword provider and the |
| 154 // secondary provider is the default provider. If the user has not typed a |
| 155 // keyword, then the primary provider corresponds to the default provider. |
| 156 // |
| 157 // Search providers may supply relevance values along with their results to be |
| 158 // used in place of client-side calculated values. |
| 159 // |
| 160 // The value column gives the ranking returned from the various providers. |
| 161 // ++: a series of matches with relevance from n up to (n + max_matches). |
| 162 // --: relevance score falls off over time (discounted 50 points @ 15 minutes, |
| 163 // 450 points @ two weeks) |
| 164 // **: relevance score falls off over two days (discounted 99 points after two |
| 165 // days). |
| 166 // *~: Partial matches get a score on a sliding scale from about 575-1125 based |
| 167 // on how many times the URL for the Extension App has been typed and how |
| 168 // many of the letters match. |
| 169 // |
23 // A single result provider for the autocomplete system. Given user input, the | 170 // A single result provider for the autocomplete system. Given user input, the |
24 // provider decides what (if any) matches to return, their relevance, and their | 171 // provider decides what (if any) matches to return, their relevance, and their |
25 // classifications. | 172 // classifications. |
26 class AutocompleteProvider | 173 class AutocompleteProvider |
27 : public base::RefCountedThreadSafe<AutocompleteProvider> { | 174 : public base::RefCountedThreadSafe<AutocompleteProvider> { |
28 public: | 175 public: |
29 | 176 |
30 AutocompleteProvider(AutocompleteProviderListener* listener, | 177 AutocompleteProvider(AutocompleteProviderListener* listener, |
31 Profile* profile, | 178 Profile* profile, |
32 const char* name); | 179 const char* name); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 bool done_; | 265 bool done_; |
119 | 266 |
120 // The name of this provider. Used for logging. | 267 // The name of this provider. Used for logging. |
121 std::string name_; | 268 std::string name_; |
122 | 269 |
123 private: | 270 private: |
124 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); | 271 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); |
125 }; | 272 }; |
126 | 273 |
127 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ | 274 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ |
OLD | NEW |