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

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

Issue 6652008: Implemented substring matching within page titles. Fixed bug where URL was be... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_quick_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/autocomplete/autocomplete_match.h"
11 #include "chrome/browser/autocomplete/history_provider.h" 12 #include "chrome/browser/autocomplete/history_provider.h"
12 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
13 #include "chrome/browser/history/in_memory_url_index.h" 14 #include "chrome/browser/history/in_memory_url_index.h"
14 15
15 class Profile; 16 class Profile;
17 class TermMatches;
16 18
17 namespace history { 19 namespace history {
18 class HistoryBackend; 20 class HistoryBackend;
19 } // namespace history 21 } // namespace history
20 22
21 // This class is an autocomplete provider (a pseudo-internal component of 23 // This class is an autocomplete provider (a pseudo-internal component of
22 // the history system) which quickly (and synchronously) provides matching 24 // the history system) which quickly (and synchronously) provides matching
23 // results from recently or frequently visited sites in the profile's 25 // results from recently or frequently visited sites in the profile's
24 // history. 26 // history.
25 class HistoryQuickProvider : public HistoryProvider { 27 class HistoryQuickProvider : public HistoryProvider {
26 public: 28 public:
27 HistoryQuickProvider(ACProviderListener* listener, Profile* profile); 29 HistoryQuickProvider(ACProviderListener* listener, Profile* profile);
28 30
29 ~HistoryQuickProvider(); 31 ~HistoryQuickProvider();
30 32
31 // AutocompleteProvider. |minimal_changes| is ignored since there 33 // AutocompleteProvider. |minimal_changes| is ignored since there
32 // is no asynch completion performed. 34 // is no asynch completion performed.
33 virtual void Start(const AutocompleteInput& input, 35 virtual void Start(const AutocompleteInput& input,
34 bool minimal_changes) OVERRIDE; 36 bool minimal_changes) OVERRIDE;
35 37
36 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; 38 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
37 39
38 // Performs the autocomplete matching and scoring. 40 // Performs the autocomplete matching and scoring.
39 void DoAutocomplete(); 41 void DoAutocomplete();
40 42
41 private: 43 private:
42 friend class HistoryQuickProviderTest; 44 friend class HistoryQuickProviderTest;
45 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans);
43 46
44 AutocompleteMatch QuickMatchToACMatch( 47 AutocompleteMatch QuickMatchToACMatch(
45 const history::ScoredHistoryMatch& history_match, 48 const history::ScoredHistoryMatch& history_match,
46 MatchType match_type,
47 size_t match_number); 49 size_t match_number);
48 50
49 // Breaks a string down into individual words and return as a vector with
50 // the individual words in their original order.
51 static history::InMemoryURLIndex::String16Vector WordVectorFromString16(
52 const string16& uni_string);
53
54 // Determines the relevance for some input, given its type and which match it 51 // Determines the relevance for some input, given its type and which match it
55 // is. If |match_type| is NORMAL, |match_number| is a number 52 // is. If |match_type| is NORMAL, |match_number| is a number
56 // [0, kMaxSuggestions) indicating the relevance of the match (higher == more 53 // [0, kMaxSuggestions) indicating the relevance of the match (higher == more
57 // relevant). For other values of |match_type|, |match_number| is ignored. 54 // relevant). For other values of |match_type|, |match_number| is ignored.
58 static int CalculateRelevance(int raw_score, 55 static int CalculateRelevance(int raw_score,
59 AutocompleteInput::Type input_type, 56 AutocompleteInput::Type input_type,
60 MatchType match_type, 57 MatchType match_type,
61 size_t match_number); 58 size_t match_number);
62 59
63 // Returns the index that should be used for history lookups. 60 // Returns the index that should be used for history lookups.
64 history::InMemoryURLIndex* GetIndex(); 61 history::InMemoryURLIndex* GetIndex();
65 62
63 // Fill and return an ACMatchClassifications structure given the term
64 // matches (|matches|) to highlight where terms were found. |adjust| is
65 // subtracted form each offset and is used to account for any leading
66 // 'http://' in the potential result.
67 static ACMatchClassifications SpansFromTermMatch(
68 const history::TermMatches& matches,
69 size_t text_length,
70 size_t adjust);
71
66 // Only for use in unittests. Takes ownership of |index|. 72 // Only for use in unittests. Takes ownership of |index|.
67 void SetIndexForTesting(history::InMemoryURLIndex* index); 73 void SetIndexForTesting(history::InMemoryURLIndex* index);
68 AutocompleteInput autocomplete_input_; 74 AutocompleteInput autocomplete_input_;
69 bool trim_http_;
70 std::string languages_; 75 std::string languages_;
71 76
72 // Only used for testing. 77 // Only used for testing.
73 scoped_ptr<history::InMemoryURLIndex> index_for_testing_; 78 scoped_ptr<history::InMemoryURLIndex> index_for_testing_;
74 }; 79 };
75 80
76 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ 81 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698