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

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

Issue 10913262: Implement Bookmark Autocomplete Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_
7
8 #include <string>
9
10 #include "chrome/browser/autocomplete/autocomplete_input.h"
11 #include "chrome/browser/autocomplete/autocomplete_match.h"
12 #include "chrome/browser/autocomplete/autocomplete_provider.h"
13 #include "chrome/browser/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/history/snippet.h"
15
16 class BookmarkModel;
17 class Profile;
18
19 // This class is an autocomplete provider which quickly (and synchronously)
20 // provides autocomplete suggestions based on the titles of bookmarks. Page
21 // titles, URLs, and typed and visit counts of the bookmarks are not taken into
22 // consideration as those factors will have been used by the
23 // HistoryQuickProvider in identifying suggestions.
24 class BookmarkProvider : public AutocompleteProvider {
25 public:
26 BookmarkProvider(AutocompleteProviderListener* listener, Profile* profile);
27
28 // AutocompleteProvider. |minimal_changes| is ignored since there is no
29 // asynch completion performed.
Mark P 2012/10/08 22:51:59 |minimal_changes| is not ignored. Please comment
mrossetti 2012/10/10 02:26:42 Great catch! Thanks! On 2012/10/08 22:51:59, Mar
30 virtual void Start(const AutocompleteInput& input,
31 bool minimal_changes) OVERRIDE;
32
33 // Sets the BookmarkModel for unit tests.
34 void set_bookmark_model_for_testing(BookmarkModel* bookmark_model) {
35 bookmark_model_ = bookmark_model;
36 }
37
38 private:
39 virtual ~BookmarkProvider();
40
41 // Performs the actual matching of |input| over the bookmarks and fills in
42 // |matches_|. If |best_match| then only suggest the single best match,
43 // otherwise suggest the top |kMaxMatches| matches.
44 void DoAutocomplete(const AutocompleteInput& input, bool best_match);
45
46 // Calculates a relevance for |title_match|, converts it to an
47 // AutocompleteMatch and returns the converted match.
48 AutocompleteMatch TitleMatchToACMatch(
49 const bookmark_utils::TitleMatch& title_match);
50
51 // Converts |positions| into ACMatchClassifications and returns the
52 // classifications. |text_length| is used to determine the need to add an
53 // 'unhighlighted' classification span so the tail of the source string
54 // properly highlighted.
55 static ACMatchClassifications ClassificationsFromMatch(
56 const Snippet::MatchPositions& positions,
57 size_t text_length);
58
59 BookmarkModel* bookmark_model_;
60
61 // Languages used during the URL formatting.
62 std::string languages_;
63
64 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider);
65 };
66
67 #endif // CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698