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

Unified Diff: chrome/browser/history/shortcuts_database.h

Issue 200493006: Move the ShortcutsBackend from history to autocomplete so that it can fully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/shortcuts_backend_unittest.cc ('k') | chrome/browser/history/shortcuts_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/shortcuts_database.h
===================================================================
--- chrome/browser/history/shortcuts_database.h (revision 257281)
+++ chrome/browser/history/shortcuts_database.h (working copy)
@@ -13,7 +13,6 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
-#include "chrome/browser/history/shortcuts_backend.h"
#include "sql/connection.h"
#include "url/gurl.h"
@@ -39,23 +38,69 @@
// number_of_hits Number of times that the entry has been selected.
class ShortcutsDatabase : public base::RefCountedThreadSafe<ShortcutsDatabase> {
public:
- typedef std::map<std::string, ShortcutsBackend::Shortcut> GuidToShortcutMap;
+ // The following struct encapsulates one previously selected omnibox shortcut.
+ struct Shortcut {
+ // The fields of an AutocompleteMatch that we preserve in a shortcut.
+ struct MatchCore {
+ MatchCore(const base::string16& fill_into_edit,
+ const GURL& destination_url,
+ const base::string16& contents,
+ const std::string& contents_class,
+ const base::string16& description,
+ const std::string& description_class,
+ int transition,
+ int type,
+ const base::string16& keyword);
+ ~MatchCore();
+ base::string16 fill_into_edit;
+ GURL destination_url;
+ base::string16 contents;
+ // For both contents_class and description_class, we strip MATCH
+ // classifications; the ShortcutsProvider will re-mark MATCH regions based
+ // on the user's current typing.
+ std::string contents_class;
+ base::string16 description;
+ std::string description_class;
+ int transition;
+ int type;
+ base::string16 keyword;
+ };
+
+ Shortcut(const std::string& id,
+ const base::string16& text,
+ const MatchCore& match_core,
+ const base::Time& last_access_time,
+ int number_of_hits);
+ // Required for STL, we don't use this directly.
+ Shortcut();
+ ~Shortcut();
+
+ std::string id; // Unique guid for the shortcut.
+ base::string16 text; // The user's original input string.
+ MatchCore match_core;
+ base::Time last_access_time; // Last time shortcut was selected.
+ int number_of_hits; // How many times shortcut was selected.
+ };
+
+ typedef std::vector<std::string> ShortcutIDs;
+ typedef std::map<std::string, Shortcut> GuidToShortcutMap;
+
explicit ShortcutsDatabase(const base::FilePath& database_path);
bool Init();
// Adds the ShortcutsProvider::Shortcut to the database.
- bool AddShortcut(const ShortcutsBackend::Shortcut& shortcut);
+ bool AddShortcut(const Shortcut& shortcut);
// Updates timing and selection count for the ShortcutsProvider::Shortcut.
- bool UpdateShortcut(const ShortcutsBackend::Shortcut& shortcut);
+ bool UpdateShortcut(const Shortcut& shortcut);
- // Deletes the ShortcutsProvider::Shortcuts with the id.
- bool DeleteShortcutsWithIds(const std::vector<std::string>& shortcut_ids);
+ // Deletes the ShortcutsProvider::Shortcuts with these IDs.
+ bool DeleteShortcutsWithIDs(const ShortcutIDs& shortcut_ids);
// Deletes the ShortcutsProvider::Shortcuts with the url.
- bool DeleteShortcutsWithUrl(const std::string& shortcut_url_spec);
+ bool DeleteShortcutsWithURL(const std::string& shortcut_url_spec);
// Deletes all of the ShortcutsProvider::Shortcuts.
bool DeleteAllShortcuts();
@@ -69,7 +114,7 @@
FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, AddShortcut);
FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, UpdateShortcut);
FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithIds);
- FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithUrl);
+ FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithURL);
FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, LoadShortcuts);
virtual ~ShortcutsDatabase();
« no previous file with comments | « chrome/browser/history/shortcuts_backend_unittest.cc ('k') | chrome/browser/history/shortcuts_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698