Chromium Code Reviews| Index: chrome/browser/autocomplete/history_provider.cc |
| diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc |
| index bbc2fe52565e8869144b26b11ab7de5d15185595..6d0af1e4942a74c5d85b58736031aebfd192a48c 100644 |
| --- a/chrome/browser/autocomplete/history_provider.cc |
| +++ b/chrome/browser/autocomplete/history_provider.cc |
| @@ -8,7 +8,11 @@ |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| +#include "chrome/browser/autocomplete/autocomplete.h" |
| +#include "chrome/browser/autocomplete/autocomplete_match.h" |
| +#include "chrome/browser/history/history.h" |
| #include "chrome/browser/net/url_fixer_upper.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/url_constants.h" |
| #include "googleurl/src/url_util.h" |
| @@ -18,6 +22,43 @@ HistoryProvider::HistoryProvider(ACProviderListener* listener, |
| : AutocompleteProvider(listener, profile, name) { |
| } |
| +void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { |
| + DCHECK(done_); |
| + DCHECK(profile_); |
| + DCHECK(match.deletable); |
| + |
| + HistoryService* const history_service = |
| + profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
|
brettw
2010/12/16 17:55:14
This should be indented 2 more spaces, like it was
|
| + |
| + // Delete the match from the history DB. |
| + GURL selected_url(match.destination_url); |
| + if (!history_service || !selected_url.is_valid()) { |
| + 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 == selected_url && i->type == match.type) { |
| + found = true; |
| + if (i->is_history_what_you_typed_match) { |
| + // We can't get rid of the What You Typed match, but we can make it |
| + // look like it has no backing data. |
| + i->deletable = false; |
| + i->description.clear(); |
| + i->description_class.clear(); |
| + } else { |
| + matches_.erase(i); |
| + } |
| + break; |
| + } |
| + } |
| + DCHECK(found) << "Asked to delete a URL that isn't in our set of matches"; |
| + listener_->OnProviderUpdate(true); |
| +} |
| + |
| // static |
| std::wstring HistoryProvider::FixupUserInput(const AutocompleteInput& input) { |
| const std::wstring& input_text = input.text(); |