| 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..28d336fb4b23af8aa6305e6a203611567ea12a07 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 {
|
| @@ -114,6 +120,9 @@ class SearchProvider : public AutocompleteProvider,
|
| current_page_url_ = current_page_url;
|
| }
|
|
|
| + protected:
|
| + virtual ~SearchProvider();
|
| +
|
| private:
|
| // TODO(hfung): Remove ZeroSuggestProvider as a friend class after
|
| // refactoring common code to a new base class.
|
| @@ -125,6 +134,7 @@ 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);
|
| 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_;
|
| };
|
| @@ -313,6 +330,7 @@ class SearchProvider : public AutocompleteProvider,
|
| typedef std::vector<history::KeywordSearchTermVisit> HistoryResults;
|
| typedef std::pair<string16, std::string> MatchKey;
|
| typedef std::map<MatchKey, AutocompleteMatch> MatchMap;
|
| + typedef ScopedVector<SuggestionDeletionHandler> SuggestionDeletionHandlers;
|
|
|
| // A simple structure bundling most of the information (including
|
| // both SuggestResults and NavigationResults) returned by a call to
|
| @@ -349,8 +367,6 @@ class SearchProvider : public AutocompleteProvider,
|
| DISALLOW_COPY_AND_ASSIGN(Results);
|
| };
|
|
|
| - virtual ~SearchProvider();
|
| -
|
| // Removes non-inlineable results until either the top result can inline
|
| // autocomplete the current input or verbatim outscores the top result.
|
| static void RemoveStaleResults(const string16& input,
|
| @@ -371,6 +387,19 @@ 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);
|
| +
|
| + // Records in UMA whether the deletion request resulted in success.
|
| + // This is virtual so test code can override it to check that we
|
| + // correctly handle the request result.
|
| + virtual void RecordDeletionResult(bool success);
|
| +
|
| + // Removes the deleted match from the list of |matches_|.
|
| + void DeleteMatchFromMatches(const AutocompleteMatch& match);
|
| +
|
| // Called when timer_ expires.
|
| void Run();
|
|
|
| @@ -487,7 +516,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 +547,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 +612,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 +651,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.
|
| + SuggestionDeletionHandlers 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
|
|
|