Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/autocomplete/keyword_provider.h

Issue 319523005: Omnibox: Combine Two Input Type Enums into One (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This file contains the keyword autocomplete provider. The keyword provider 5 // This file contains the keyword autocomplete provider. The keyword provider
6 // is responsible for remembering/suggesting user "search keyword queries" 6 // is responsible for remembering/suggesting user "search keyword queries"
7 // (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An 7 // (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An
8 // instance of it gets created and managed by the autocomplete controller. 8 // instance of it gets created and managed by the autocomplete controller.
9 // KeywordProvider uses a TemplateURLService to find the set of keywords. 9 // KeywordProvider uses a TemplateURLService to find the set of keywords.
10 10
11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ 11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
12 #define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ 12 #define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "chrome/browser/autocomplete/autocomplete_input.h" 19 #include "chrome/browser/autocomplete/autocomplete_input.h"
20 #include "chrome/browser/autocomplete/autocomplete_provider.h" 20 #include "chrome/browser/autocomplete/autocomplete_provider.h"
21 #include "components/metrics/proto/omnibox_input_type.pb.h"
21 22
22 class KeywordExtensionsDelegate; 23 class KeywordExtensionsDelegate;
23 class Profile; 24 class Profile;
24 class TemplateURL; 25 class TemplateURL;
25 class TemplateURLService; 26 class TemplateURLService;
26 27
27 // Autocomplete provider for keyword input. 28 // Autocomplete provider for keyword input.
28 // 29 //
29 // After construction, the autocomplete controller repeatedly calls Start() 30 // After construction, the autocomplete controller repeatedly calls Start()
30 // with some user input, each time expecting to receive a small set of the best 31 // with some user input, each time expecting to receive a small set of the best
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Leading whitespace in |*remaining_input| will be trimmed. 108 // Leading whitespace in |*remaining_input| will be trimmed.
108 static bool ExtractKeywordFromInput(const AutocompleteInput& input, 109 static bool ExtractKeywordFromInput(const AutocompleteInput& input,
109 base::string16* keyword, 110 base::string16* keyword,
110 base::string16* remaining_input); 111 base::string16* remaining_input);
111 112
112 // Determines the relevance for some input, given its type, whether the user 113 // Determines the relevance for some input, given its type, whether the user
113 // typed the complete keyword, and whether the user is in "prefer keyword 114 // typed the complete keyword, and whether the user is in "prefer keyword
114 // matches" mode, and whether the keyword supports replacement. 115 // matches" mode, and whether the keyword supports replacement.
115 // If |allow_exact_keyword_match| is false, the relevance for complete 116 // If |allow_exact_keyword_match| is false, the relevance for complete
116 // keywords that support replacements is degraded. 117 // keywords that support replacements is degraded.
117 static int CalculateRelevance(AutocompleteInput::Type type, 118 static int CalculateRelevance(metrics::OmniboxInputType::Type type,
118 bool complete, 119 bool complete,
119 bool support_replacement, 120 bool support_replacement,
120 bool prefer_keyword, 121 bool prefer_keyword,
121 bool allow_exact_keyword_match); 122 bool allow_exact_keyword_match);
122 123
123 // Creates a fully marked-up AutocompleteMatch from the user's input. 124 // Creates a fully marked-up AutocompleteMatch from the user's input.
124 // If |relevance| is negative, calculate a relevance based on heuristics. 125 // If |relevance| is negative, calculate a relevance based on heuristics.
125 AutocompleteMatch CreateAutocompleteMatch( 126 AutocompleteMatch CreateAutocompleteMatch(
126 const TemplateURL* template_url, 127 const TemplateURL* template_url,
127 const AutocompleteInput& input, 128 const AutocompleteInput& input,
(...skipping 15 matching lines...) Expand all
143 TemplateURLService* model_; 144 TemplateURLService* model_;
144 145
145 // Delegate to handle the extensions-only logic for KeywordProvider. 146 // Delegate to handle the extensions-only logic for KeywordProvider.
146 // NULL when extensions are not enabled. May be NULL for tests. 147 // NULL when extensions are not enabled. May be NULL for tests.
147 scoped_ptr<KeywordExtensionsDelegate> extensions_delegate_; 148 scoped_ptr<KeywordExtensionsDelegate> extensions_delegate_;
148 149
149 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); 150 DISALLOW_COPY_AND_ASSIGN(KeywordProvider);
150 }; 151 };
151 152
152 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ 153 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider_unittest.cc ('k') | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698