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 9b63da08e3a272b5da17be58024c1696f08b85f3..7bd6db08782c1554566ba7864818d45f83ba6189 100644 |
| --- a/chrome/browser/autocomplete/search_provider.h |
| +++ b/chrome/browser/autocomplete/search_provider.h |
| @@ -58,6 +58,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 +106,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 +129,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 +241,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 +254,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 +278,10 @@ class SearchProvider : public AutocompleteProvider, |
| // Optional additional parameters to be added to the search URL. |
| std::string suggest_query_params_; |
| + // Optional deletion url provided with psuggest results to delete a |
|
Peter Kasting
2013/11/23 00:08:43
Nit: Don't use "psuggest" in code (not a well-unde
Maria
2013/11/26 02:36:27
Done.
|
| + // particular suggestion from personal history. |
| + std::string deletion_url_; |
| + |
| // Should this result be prefetched? |
| bool should_prefetch_; |
| }; |
| @@ -349,6 +363,21 @@ class SearchProvider : public AutocompleteProvider, |
| DISALLOW_COPY_AND_ASSIGN(Results); |
| }; |
| + class SuggestionDeletionHandler : public net::URLFetcherDelegate { |
|
Peter Kasting
2013/11/23 00:08:43
Declare this class in the .cc file, since nothing
Maria
2013/11/26 02:36:27
Since I added a ScopedVector<SuggestionDeletionHan
Peter Kasting
2013/11/26 02:46:22
You can just forward-declare for that, you don't n
Maria
2013/11/27 02:18:06
Done.
|
| + public: |
| + SuggestionDeletionHandler(); |
| + virtual void StartRequest(const std::string& deletion_url, Profile* profile, |
|
Peter Kasting
2013/11/23 00:08:43
Nit: One arg per line
Is this an override? If so
Maria
2013/11/26 02:36:27
Done with args. this is not an override.
Peter Kasting
2013/11/26 02:46:22
Why is it virtual then?
|
| + const base::Callback<void(bool)>& callback); |
| + private: |
|
Peter Kasting
2013/11/23 00:08:43
Nit: Blank line above this
Maria
2013/11/26 02:36:27
Done.
|
| + // The class takes care of deleting itself when it's done. |
|
Peter Kasting
2013/11/23 00:08:43
Nit: This kind of comment should either be stated
Maria
2013/11/26 02:36:27
Done.
|
| + virtual ~SuggestionDeletionHandler(); |
| + virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
|
Peter Kasting
2013/11/23 00:08:43
Nit: Again, put a blank line and a parent-class co
Maria
2013/11/26 02:36:27
Done.
|
| + scoped_ptr<net::URLFetcher> deletion_fetcher_; |
|
Peter Kasting
2013/11/23 00:08:43
Nit: Blank line above this
Maria
2013/11/26 02:36:27
Done.
|
| + base::Callback<void(bool)> callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SuggestionDeletionHandler); |
| + }; |
| + |
| virtual ~SearchProvider(); |
| // Removes non-inlineable results until either the top result can inline |
| @@ -371,6 +400,12 @@ class SearchProvider : public AutocompleteProvider, |
| // net::URLFetcherDelegate: |
| virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| + // Callback for deletion request |
|
Peter Kasting
2013/11/23 00:08:43
Nit: This comment is too vague, and doesn't have t
Maria
2013/11/26 02:36:27
Done.
|
| + virtual void OnDeletionComplete(bool success); |
| + |
| + // Removes the deleted match from the list of matches. |
|
Peter Kasting
2013/11/23 00:08:43
Nit: ...from |matches_|.
Maria
2013/11/26 02:36:27
Done.
|
| + virtual void DeleteMatchFromMatches(const AutocompleteMatch& match); |
| + |
| // Called when timer_ expires. |
| void Run(); |
| @@ -517,6 +552,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. |
| @@ -581,6 +617,9 @@ class SearchProvider : public AutocompleteProvider, |
| // prefetching. |
| static const char kSuggestMetadataKey[]; |
| + // Used to store a deletion request url for psuggest autocomplete matches. |
|
Peter Kasting
2013/11/23 00:08:43
Nit: Don't use "psuggest"; try "for server-provide
Maria
2013/11/26 02:36:27
Done.
|
| + static const char kDeletionUrlKey[]; |
| + |
| // These are the values for the above keys. |
| static const char kTrue[]; |
| static const char kFalse[]; |