Chromium Code Reviews| 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..7336727f89c49d0701cabcdda80edbe896c445bd 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. |
| + virtual void OnDeletionComplete(bool success, |
|
Peter Kasting
2013/11/27 21:58:19
Remove "virtual" on these next two functions. (No
Maria
2013/11/28 00:17:03
Done.
|
| + SuggestionDeletionHandler* handler); |
| + |
| + // Removes the deleted match from the list of |matches_|. |
| + virtual 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,9 @@ class SearchProvider : public AutocompleteProvider, |
| Results default_results_; |
| Results keyword_results_; |
| + // A vector of all deletion handlers that are currently in progress. |
|
Peter Kasting
2013/11/27 21:58:19
Nit: How about:
Each deletion handler in this vec
Maria
2013/11/28 00:17:03
Done.
|
| + ScopedVector<SuggestionDeletionHandler> deletion_handlers_; |
|
Peter Kasting
2013/11/27 21:58:19
Nit: This should probably be a typedef.
Maria
2013/11/28 00:17:03
Not sure I understand the reason to typedef this w
Peter Kasting
2013/11/28 00:44:17
Because it's not the only place. OnDeletionComple
|
| + |
| // 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 |