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

Side by Side Diff: chrome/browser/autocomplete/zero_suggest_provider.h

Issue 23621037: Send URLs on non-zero prefix suggest requests also. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file contains the zero-suggest autocomplete provider. This experimental 5 // This file contains the zero-suggest autocomplete provider. This experimental
6 // provider is invoked when the user focuses in the omnibox prior to editing, 6 // provider is invoked when the user focuses in the omnibox prior to editing,
7 // and generates search query suggestions based on the current URL. To enable 7 // and generates search query suggestions based on the current URL. To enable
8 // this provider, point --experimental-zero-suggest-url-prefix at an 8 // this provider, point --experimental-zero-suggest-url-prefix at an
9 // appropriate suggestion service. 9 // appropriate suggestion service.
10 // 10 //
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Sets |field_trial_triggered_| to false. 67 // Sets |field_trial_triggered_| to false.
68 virtual void ResetSession() OVERRIDE; 68 virtual void ResetSession() OVERRIDE;
69 69
70 // net::URLFetcherDelegate 70 // net::URLFetcherDelegate
71 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 71 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
72 72
73 // Initiates a new fetch for the given |url| of classification 73 // Initiates a new fetch for the given |url| of classification
74 // |page_classification|. |permanent_text| is the omnibox text 74 // |page_classification|. |permanent_text| is the omnibox text
75 // for the current page. 75 // for the current page.
76 void StartZeroSuggest( 76 void StartZeroSuggest(
77 const GURL& url, 77 const GURL& curent_page_url,
78 AutocompleteInput::PageClassification page_classification, 78 AutocompleteInput::PageClassification page_classification,
79 const string16& permanent_text); 79 const string16& permanent_text);
80 80
81 bool field_trial_triggered_in_session() const { 81 bool field_trial_triggered_in_session() const {
82 return field_trial_triggered_in_session_; 82 return field_trial_triggered_in_session_;
83 } 83 }
84 84
85 private: 85 private:
86 ZeroSuggestProvider(AutocompleteProviderListener* listener, 86 ZeroSuggestProvider(AutocompleteProviderListener* listener,
87 Profile* profile); 87 Profile* profile);
88 88
89 virtual ~ZeroSuggestProvider(); 89 virtual ~ZeroSuggestProvider();
90 90
91 bool ShouldRunZeroSuggest(
92 const GURL& url,
93 AutocompleteInput::PageClassification page_classification) const;
94
95 // Whether the URL can get Zero Suggest. For example, don't send the URL of
96 // non-Google HTTPS requests because it may contain sensitive information.
97 bool ShouldSendURL(
98 const GURL& url,
99 AutocompleteInput::PageClassification page_classification) const;
100
101 // The 4 functions below (that take classes defined in SearchProvider as 91 // The 4 functions below (that take classes defined in SearchProvider as
102 // arguments) were copied and trimmed from SearchProvider. 92 // arguments) were copied and trimmed from SearchProvider.
103 // TODO(hfung): Refactor them into a new base class common to both 93 // TODO(hfung): Refactor them into a new base class common to both
104 // ZeroSuggestProvider and SearchProvider. 94 // ZeroSuggestProvider and SearchProvider.
105 95
106 // From the OpenSearch formatted response |root_val|, populate query 96 // From the OpenSearch formatted response |root_val|, populate query
107 // suggestions into |suggest_results|, navigation suggestions into 97 // suggestions into |suggest_results|, navigation suggestions into
108 // |navigation_results|, and the verbatim relevance score into 98 // |navigation_results|, and the verbatim relevance score into
109 // |verbatim_relevance|. 99 // |verbatim_relevance|.
110 void FillResults(const base::Value& root_val, 100 void FillResults(const base::Value& root_val,
(...skipping 17 matching lines...) Expand all
128 AutocompleteMatch::Type type, 118 AutocompleteMatch::Type type,
129 const TemplateURL* template_url, 119 const TemplateURL* template_url,
130 const string16& query_string, 120 const string16& query_string,
131 int accepted_suggestion, 121 int accepted_suggestion,
132 SearchProvider::MatchMap* map); 122 SearchProvider::MatchMap* map);
133 123
134 // Returns an AutocompleteMatch for a navigational suggestion |navigation|. 124 // Returns an AutocompleteMatch for a navigational suggestion |navigation|.
135 AutocompleteMatch NavigationToMatch( 125 AutocompleteMatch NavigationToMatch(
136 const SearchProvider::NavigationResult& navigation); 126 const SearchProvider::NavigationResult& navigation);
137 127
138 // Fetches zero-suggest suggestions for |current_query_|. 128 // Fetches zero-suggest suggestions by sending a request using |suggest_url|.
139 void Run(); 129 void Run(const GURL& suggest_url);
140 130
141 // Parses results from the zero-suggest server and updates results. 131 // Parses results from the zero-suggest server and updates results.
142 void ParseSuggestResults(const base::Value& root_val); 132 void ParseSuggestResults(const base::Value& root_val);
143 133
144 // Converts the parsed results to a set of AutocompleteMatches and adds them 134 // Converts the parsed results to a set of AutocompleteMatches and adds them
145 // to |matches_|. Also update the histograms for how many results were 135 // to |matches_|. Also update the histograms for how many results were
146 // received. 136 // received.
147 void ConvertResultsToAutocompleteMatches(); 137 void ConvertResultsToAutocompleteMatches();
148 138
149 // Returns an AutocompleteMatch for the current URL. The match should be in 139 // Returns an AutocompleteMatch for the current URL. The match should be in
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 186
197 history::MostVisitedURLList most_visited_urls_; 187 history::MostVisitedURLList most_visited_urls_;
198 188
199 // For callbacks that may be run after destruction. 189 // For callbacks that may be run after destruction.
200 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; 190 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_;
201 191
202 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); 192 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider);
203 }; 193 };
204 194
205 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ 195 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698