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

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

Issue 372017: Fix various problems with inline autocomplete and URLs that change length dur... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_HISTORY_URL_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
7 7
8 #include <vector> 8 #include <vector>
9 #include <deque> 9 #include <deque>
10 10
11 #include "chrome/browser/autocomplete/autocomplete.h" 11 #include "chrome/browser/autocomplete/autocomplete.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // requests on the database (which hold a reference to us). Normally, these 128 // requests on the database (which hold a reference to us). Normally, these
129 // messages get flushed for each thread. We do a round trip from main, to 129 // messages get flushed for each thread. We do a round trip from main, to
130 // history, back to main while holding a reference. If the main thread 130 // history, back to main while holding a reference. If the main thread
131 // completes before the history thread, the message to delegate back to the 131 // completes before the history thread, the message to delegate back to the
132 // main thread will not run and the reference will leak. Therefore, don't do 132 // main thread will not run and the reference will leak. Therefore, don't do
133 // anything on destruction. 133 // anything on destruction.
134 class HistoryURLProvider : public AutocompleteProvider { 134 class HistoryURLProvider : public AutocompleteProvider {
135 public: 135 public:
136 HistoryURLProvider(ACProviderListener* listener, Profile* profile) 136 HistoryURLProvider(ACProviderListener* listener, Profile* profile)
137 : AutocompleteProvider(listener, profile, "HistoryURL"), 137 : AutocompleteProvider(listener, profile, "HistoryURL"),
138 history_service_(NULL),
139 prefixes_(GetPrefixes()), 138 prefixes_(GetPrefixes()),
140 params_(NULL) { 139 params_(NULL) {
141 } 140 }
142 141
143 #ifdef UNIT_TEST 142 #ifdef UNIT_TEST
144 HistoryURLProvider(ACProviderListener* listener, 143 HistoryURLProvider(ACProviderListener* listener,
145 HistoryService* history_service) 144 Profile* profile,
146 : AutocompleteProvider(listener, NULL, "History"), 145 const std::wstring& languages)
147 history_service_(history_service), 146 : AutocompleteProvider(listener, profile, "History"),
148 prefixes_(GetPrefixes()), 147 prefixes_(GetPrefixes()),
149 params_(NULL) { 148 params_(NULL),
149 languages_(languages) {
150 } 150 }
151 #endif 151 #endif
152 // no destructor (see note above) 152 // no destructor (see note above)
153 153
154 // AutocompleteProvider 154 // AutocompleteProvider
155 virtual void Start(const AutocompleteInput& input, 155 virtual void Start(const AutocompleteInput& input,
156 bool minimal_changes); 156 bool minimal_changes);
157 virtual void Stop(); 157 virtual void Stop();
158 virtual void DeleteMatch(const AutocompleteMatch& match); 158 virtual void DeleteMatch(const AutocompleteMatch& match);
159 159
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 HistoryMatches* matches, 372 HistoryMatches* matches,
373 size_t source_index, 373 size_t source_index,
374 const std::vector<GURL>& remove) const; 374 const std::vector<GURL>& remove) const;
375 375
376 // Converts a line from the database into an autocomplete match for display. 376 // Converts a line from the database into an autocomplete match for display.
377 AutocompleteMatch HistoryMatchToACMatch(HistoryURLProviderParams* params, 377 AutocompleteMatch HistoryMatchToACMatch(HistoryURLProviderParams* params,
378 const HistoryMatch& history_match, 378 const HistoryMatch& history_match,
379 MatchType match_type, 379 MatchType match_type,
380 size_t match_number); 380 size_t match_number);
381 381
382 // This is only non-null for testing, otherwise the HistoryService from the
383 // Profile is used.
384 HistoryService* history_service_;
385
386 // Prefixes to try appending to user input when looking for a match. 382 // Prefixes to try appending to user input when looking for a match.
387 const Prefixes prefixes_; 383 const Prefixes prefixes_;
388 384
389 // Params for the current query. The provider should not free this directly; 385 // Params for the current query. The provider should not free this directly;
390 // instead, it is passed as a parameter through the history backend, and the 386 // instead, it is passed as a parameter through the history backend, and the
391 // parameter itself is freed once it's no longer needed. The only reason we 387 // parameter itself is freed once it's no longer needed. The only reason we
392 // keep this member is so we can set the cancel bit on it. 388 // keep this member is so we can set the cancel bit on it.
393 HistoryURLProviderParams* params_; 389 HistoryURLProviderParams* params_;
390
391 // Only used by unittests; if non-empty, overrides accept-languages in the
392 // profile's pref system.
393 std::wstring languages_;
394 }; 394 };
395 395
396 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ 396 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.cc ('k') | chrome/browser/autocomplete/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698