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

Unified Diff: chrome/browser/autocomplete/history_contents_provider.cc

Issue 5774004: Make HistoryContentsProvider results deletable (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Revising a couple checks & DCHECKS Created 10 years 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/autocomplete/history_contents_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/history_contents_provider.cc
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc
index 5b14a3be4568f0d19351b4f2c77c1991974e14e8..dafe073635187d536ff527a7a415f6b89a0c1642 100644
--- a/chrome/browser/autocomplete/history_contents_provider.cc
+++ b/chrome/browser/autocomplete/history_contents_provider.cc
@@ -151,6 +151,36 @@ void HistoryContentsProvider::Stop() {
have_results_ = false;
}
+void HistoryContentsProvider::DeleteMatch(const AutocompleteMatch& match) {
+ DCHECK(done_);
+ DCHECK(match.deletable);
+ DCHECK(profile_);
+
+ // Delete the match from the history DB.
+ HistoryService* const history_service =
+ profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+
+ GURL selected_url(match.destination_url);
+ if (!history_service || !selected_url.is_valid()) {
brettw 2010/12/15 22:24:11 This code is copied and pasted from the HistoryURL
msw 2010/12/16 01:38:26 How about using base class HistoryProvider?
+ NOTREACHED() << "Can't delete requested URL";
+ return;
+ }
+ history_service->DeleteURL(selected_url);
+
+ // Delete the match from the current set of matches.
+ bool found = false;
+ for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
+ if (i->destination_url == match.destination_url && i->type == match.type) {
+ found = true;
+ matches_.erase(i);
+ break;
+ }
+ }
+ DCHECK(found) << "Asked to delete a URL that isn't in our set of matches";
+
+ listener_->OnProviderUpdate(true);
+}
+
HistoryContentsProvider::~HistoryContentsProvider() {
}
@@ -222,7 +252,7 @@ AutocompleteMatch HistoryContentsProvider::ResultToMatch(
int score) {
// TODO(sky): if matched title highlight matching words in title.
// Also show star in popup.
- AutocompleteMatch match(this, score, false, MatchInTitle(result) ?
+ AutocompleteMatch match(this, score, true, MatchInTitle(result) ?
AutocompleteMatch::HISTORY_TITLE : AutocompleteMatch::HISTORY_BODY);
match.contents = StringForURLDisplay(result.url(), true, trim_http_);
match.fill_into_edit =
« no previous file with comments | « chrome/browser/autocomplete/history_contents_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698