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

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

Issue 8364001: Strip special characters in extension omnibox suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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) 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 // 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 // For more information on the autocomplete system in general, including how 11 // For more information on the autocomplete system in general, including how
12 // the autocomplete controller and autocomplete providers work, see 12 // the autocomplete controller and autocomplete providers work, see
13 // chrome/browser/autocomplete.h. 13 // chrome/browser/autocomplete.h.
14 14
15 #ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ 15 #ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
16 #define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ 16 #define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
17 #pragma once 17 #pragma once
18 18
19 #include <string> 19 #include <string>
20 #include <vector>
20 21
22 #include "base/gtest_prod_util.h"
21 #include "chrome/browser/autocomplete/autocomplete.h" 23 #include "chrome/browser/autocomplete/autocomplete.h"
22 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
24 26
27 struct ExtensionOmniboxSuggestion;
25 class Profile; 28 class Profile;
26 class TemplateURL; 29 class TemplateURL;
27 class TemplateURLService; 30 class TemplateURLService;
28 31
29 // Autocomplete provider for keyword input. 32 // Autocomplete provider for keyword input.
30 // 33 //
31 // After construction, the autocomplete controller repeatedly calls Start() 34 // After construction, the autocomplete controller repeatedly calls Start()
32 // with some user input, each time expecting to receive a small set of the best 35 // with some user input, each time expecting to receive a small set of the best
33 // matches (either synchronously or asynchronously). 36 // matches (either synchronously or asynchronously).
34 // 37 //
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Creates a fully marked-up AutocompleteMatch from the user's input. 126 // Creates a fully marked-up AutocompleteMatch from the user's input.
124 // If |relevance| is negative, calculate a relevance based on heuristics. 127 // If |relevance| is negative, calculate a relevance based on heuristics.
125 AutocompleteMatch CreateAutocompleteMatch( 128 AutocompleteMatch CreateAutocompleteMatch(
126 TemplateURLService* model, 129 TemplateURLService* model,
127 const string16& keyword, 130 const string16& keyword,
128 const AutocompleteInput& input, 131 const AutocompleteInput& input,
129 size_t prefix_length, 132 size_t prefix_length,
130 const string16& remaining_input, 133 const string16& remaining_input,
131 int relevance); 134 int relevance);
132 135
136 // Creates an AutocompleteMatch from an extension omnibox suggestion.
137 AutocompleteMatch CreateAutocompleteMatchFromSuggestion(
Peter Kasting 2011/10/25 20:37:07 Nit: Same comments.
Alexei Svitkine (slow) 2011/10/25 21:37:16 Same reply as to the other one.
138 TemplateURLService* model,
139 const string16& keyword,
140 const AutocompleteInput& input,
141 const ExtensionOmniboxSuggestion& suggestion,
142 int relevance);
143
133 void EnterExtensionKeywordMode(const std::string& extension_id); 144 void EnterExtensionKeywordMode(const std::string& extension_id);
134 void MaybeEndExtensionKeywordMode(); 145 void MaybeEndExtensionKeywordMode();
135 146
136 // content::NotificationObserver interface. 147 // content::NotificationObserver interface.
137 virtual void Observe(int type, 148 virtual void Observe(int type,
138 const content::NotificationSource& source, 149 const content::NotificationSource& source,
139 const content::NotificationDetails& details); 150 const content::NotificationDetails& details);
140 151
141 // Model for the keywords. This is only non-null when testing, otherwise the 152 // Model for the keywords. This is only non-null when testing, otherwise the
142 // TemplateURLService from the Profile is used. 153 // TemplateURLService from the Profile is used.
(...skipping 11 matching lines...) Expand all
154 // We remember the last suggestions we've received from the extension in case 165 // We remember the last suggestions we've received from the extension in case
155 // we need to reset our matches without asking the extension again. 166 // we need to reset our matches without asking the extension again.
156 std::vector<AutocompleteMatch> extension_suggest_matches_; 167 std::vector<AutocompleteMatch> extension_suggest_matches_;
157 168
158 // If non-empty, holds the ID of the extension whose keyword is currently in 169 // If non-empty, holds the ID of the extension whose keyword is currently in
159 // the URL bar while the autocomplete popup is open. 170 // the URL bar while the autocomplete popup is open.
160 std::string current_keyword_extension_id_; 171 std::string current_keyword_extension_id_;
161 172
162 content::NotificationRegistrar registrar_; 173 content::NotificationRegistrar registrar_;
163 174
175 FRIEND_TEST_ALL_PREFIXES(KeywordProviderTest, SuggestionMatchSanitize);
176
164 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); 177 DISALLOW_COPY_AND_ASSIGN(KeywordProvider);
165 }; 178 };
166 179
167 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ 180 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698