Index: chrome/browser/autocomplete/search_provider.h |
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h |
index e8c07d5f7b1e5133048c686a6ffa6f2139f52b24..d05d09edcdf6dd804d5b92288c6597cfc238b8e8 100644 |
--- a/chrome/browser/autocomplete/search_provider.h |
+++ b/chrome/browser/autocomplete/search_provider.h |
@@ -18,6 +18,7 @@ |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/memory/scoped_vector.h" |
#include "base/time/time.h" |
#include "base/timer/timer.h" |
#include "chrome/browser/autocomplete/autocomplete_input.h" |
@@ -29,6 +30,7 @@ |
class Profile; |
class SearchProviderTest; |
+class SuggestionDeletionHandler; |
class TemplateURLService; |
namespace base { |
@@ -58,6 +60,9 @@ class SearchProvider : public AutocompleteProvider, |
// ID used in creating URLFetcher for keyword provider's suggest results. |
static const int kKeywordProviderURLFetcherID; |
+ // ID used in creating URLFetcher for deleting suggestion results. |
+ static const int kDeletionURLFetcherID; |
+ |
SearchProvider(AutocompleteProviderListener* listener, Profile* profile); |
// Returns an AutocompleteMatch with the given |autocomplete_provider|, |
@@ -103,6 +108,7 @@ class SearchProvider : public AutocompleteProvider, |
// AutocompleteProvider: |
virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
+ virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; |
virtual void ResetSession() OVERRIDE; |
bool field_trial_triggered_in_session() const { |
@@ -125,6 +131,10 @@ class SearchProvider : public AutocompleteProvider, |
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); |
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
+ FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, |
+ TestDeleteMatch_HasDeletionUrlSuccess); |
+ FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, |
+ TestDeleteMatch_HasDeletionUrlFailure); |
FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); |
FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); |
FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); |
@@ -233,6 +243,7 @@ class SearchProvider : public AutocompleteProvider, |
const string16& match_contents, |
const string16& annotation, |
const std::string& suggest_query_params, |
+ const std::string& deletion_url, |
bool from_keyword_provider, |
int relevance, |
bool relevance_from_server, |
@@ -245,6 +256,7 @@ class SearchProvider : public AutocompleteProvider, |
const std::string& suggest_query_params() const { |
return suggest_query_params_; |
} |
+ const std::string& deletion_url() const { return deletion_url_; } |
bool should_prefetch() const { return should_prefetch_; } |
// Result: |
@@ -268,6 +280,11 @@ class SearchProvider : public AutocompleteProvider, |
// Optional additional parameters to be added to the search URL. |
std::string suggest_query_params_; |
+ // Optional deletion URL provided with suggestions. Fetching this URL |
+ // should result in some reasonable deletion behaviour on the server, |
+ // e.g. deleting this term out of a user's server-side search history. |
+ std::string deletion_url_; |
+ |
// Should this result be prefetched? |
bool should_prefetch_; |
}; |
@@ -371,6 +388,14 @@ class SearchProvider : public AutocompleteProvider, |
// net::URLFetcherDelegate: |
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
+ // This gets called when we have requested a suggestion deletion from the |
+ // server to handle the results of the deletion. |
+ void OnDeletionComplete(bool success, |
+ SuggestionDeletionHandler* handler); |
+ |
+ // Removes the deleted match from the list of |matches_|. |
+ void DeleteMatchFromMatches(const AutocompleteMatch& match); |
+ |
// Called when timer_ expires. |
void Run(); |
@@ -487,7 +512,7 @@ class SearchProvider : public AutocompleteProvider, |
// Gets the relevance score for the keyword verbatim result. |
// |relevance_from_server| is handled as in GetVerbatimRelevance(). |
- // TODO(mpearson): Refactor so this duplication isn't necesary or |
+ // TODO(mpearson): Refactor so this duplication isn't necessary or |
// restructure so one static function takes all the parameters it needs |
// (rather than looking at internal state). |
int GetKeywordVerbatimRelevance(bool* relevance_from_server) const; |
@@ -518,6 +543,7 @@ class SearchProvider : public AutocompleteProvider, |
const string16& query_string, |
int accepted_suggestion, |
const std::string& suggest_query_params, |
+ const std::string& deletion_url, |
MatchMap* map); |
// Returns an AutocompleteMatch for a navigational suggestion. |
@@ -582,6 +608,9 @@ class SearchProvider : public AutocompleteProvider, |
// prefetching. |
static const char kSuggestMetadataKey[]; |
+ // Used to store a deletion request url for server-provided suggestions. |
+ static const char kDeletionUrlKey[]; |
+ |
// These are the values for the above keys. |
static const char kTrue[]; |
static const char kFalse[]; |
@@ -618,6 +647,11 @@ class SearchProvider : public AutocompleteProvider, |
Results default_results_; |
Results keyword_results_; |
+ // Each deletion handler in this vector corresponds to an outstanding request |
+ // that a server delete a personalized suggestion. Making this a ScopedVector |
+ // causes us to auto-cancel all such requests on shutdown. |
+ ScopedVector<SuggestionDeletionHandler> deletion_handlers_; |
+ |
// Whether a field trial, if any, has triggered in the most recent |
// autocomplete query. This field is set to false in Start() and may be set |
// to true if either the default provider or keyword provider has completed |