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

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: More comments taken care of Created 7 years 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 e8c07d5f7b1e5133048c686a6ffa6f2139f52b24..d39b1b8f4995cbdee7795c2c5e29b089af435598 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,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 +246,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 +259,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 +283,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 +333,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 +370,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 +390,17 @@ 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.
Peter Kasting 2013/12/03 00:33:51 Nit: Maybe add "This is virtual so test code can o
Peter Kasting 2013/12/03 01:47:50 Did you decide this wasn't worth doing?
Maria 2013/12/03 01:55:20 Done.
+ 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 +517,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 +548,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 +613,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 +652,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
« 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