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

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

Issue 9689085: Clean up ShortcutsProvider and related classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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
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_SHORTCUTS_PROVIDER_SHORTCUT_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_SHORTCUT_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/string16.h"
14 #include "base/time.h"
15 #include "chrome/browser/autocomplete/autocomplete_match.h"
16 #include "googleurl/src/gurl.h"
17
18 namespace shortcuts_provider {
19
20 // The following struct encapsulates one previously selected omnibox shortcut.
21 struct Shortcut {
22 Shortcut(const string16& text,
23 const GURL& url,
24 const string16& contents,
25 const ACMatchClassifications& contents_class,
26 const string16& description,
27 const ACMatchClassifications& description_class);
28 // This constructor is used for creation of the structure from DB data.
29 Shortcut(const std::string& id,
30 const string16& text,
31 const string16& url,
32 const string16& contents,
33 const string16& contents_class,
34 const string16& description,
35 const string16& description_class,
36 int64 time_of_last_access,
37 int number_of_hits);
38 // Required for STL, we don't use this directly.
39 Shortcut();
40 ~Shortcut();
41
42 string16 contents_class_as_str() const;
43 string16 description_class_as_str() const;
44
45 std::string id; // Unique guid for the shortcut.
46 string16 text; // The user's original input string.
47 GURL url; // The corresponding destination URL.
48
49 // Contents and description from the original match, along with their
50 // corresponding markup. We need these in order to correctly mark which
51 // parts are URLs, dim, etc. However, we strip all MATCH classifications
52 // from these since we'll mark the matching portions ourselves as we match
53 // the user's current typing against these Shortcuts.
54 string16 contents;
55 ACMatchClassifications contents_class;
56 string16 description;
57 ACMatchClassifications description_class;
58
59 base::Time last_access_time; // Last time shortcut was selected.
60 int number_of_hits; // How many times shortcut was selected.
61 };
62
63 // Maps the original match (|text| in the Shortcut) to Shortcut for quick
64 // search.
65 typedef std::multimap<string16, Shortcut> ShortcutMap;
66
67 // Quick access guid maps - first one for loading, the second one is a shadow
68 // map for access.
69 typedef std::map<std::string, Shortcut> GuidToShortcutMap;
70 typedef std::map<std::string, ShortcutMap::iterator> GuidToShortcutsIteratorMap;
71
72 // Helpers dealing with database update.
73 // Converts spans vector to comma-separated string.
74 string16 SpansToString(const ACMatchClassifications& value);
75 // Coverts comma-separated unsigned integer values into spans vector.
76 ACMatchClassifications SpansFromString(const string16& value);
77
78 // Helper for initialization and update.
79 // Adds match at the end if and only if its style is different from the last
80 // match.
81 void AddLastMatchIfNeeded(ACMatchClassifications* matches,
82 size_t position,
83 int style);
84 } // namespace shortcuts_provider
85
86 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_SHORTCUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698