Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: chrome/browser/autocomplete/search_provider.h

Issue 54203008: Store xsrf token received with psuggest results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove match from matches_ when deletion is requested Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8333c428af18bca88c28039b2ea4bfc1ab3a4925 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
+ // particular suggestion from personal history.
+ std::string deletion_url_;
+
// Should this result be prefetched?
bool should_prefetch_;
};
@@ -349,6 +363,20 @@ class SearchProvider : public AutocompleteProvider,
DISALLOW_COPY_AND_ASSIGN(Results);
};
+ class SuggestionDeletionHandler : public net::URLFetcherDelegate {
+ public:
+ SuggestionDeletionHandler();
+ virtual ~SuggestionDeletionHandler();
+ virtual void StartRequest(const std::string& deletion_url, Profile* profile,
+ const base::Callback<void(bool)>& callback);
+ private:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
Anuj 2013/11/21 17:27:52 Probably an empty line is needed - here between me
+ scoped_ptr<net::URLFetcher> deletion_fetcher_;
+ 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 +399,12 @@ class SearchProvider : public AutocompleteProvider,
// net::URLFetcherDelegate:
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+ // Callback for deletion request
+ virtual void OnDeletionComplete(bool success);
+
+ // Removes the deleted match from the list of matches.
+ virtual void DeleteMatchFromMatches(const AutocompleteMatch& match);
+
// Called when timer_ expires.
void Run();
@@ -517,6 +551,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 +616,9 @@ class SearchProvider : public AutocompleteProvider,
// prefetching.
static const char kSuggestMetadataKey[];
+ // Used to store a deletion request url for psuggest autocomplete matches.
+ static const char kDeletionUrlKey[];
+
// These are the values for the above keys.
static const char kTrue[];
static const char kFalse[];
@@ -613,6 +651,9 @@ class SearchProvider : public AutocompleteProvider,
scoped_ptr<net::URLFetcher> keyword_fetcher_;
scoped_ptr<net::URLFetcher> default_fetcher_;
+ // A handler for making requests to delete personalized suggestions.
+ scoped_ptr<SuggestionDeletionHandler> deletion_handler_;
+
// Results from the default and keyword search providers.
Results default_results_;
Results keyword_results_;
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | chrome/browser/autocomplete/search_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698