OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/timer.h" | 17 #include "base/timer.h" |
18 #include "chrome/browser/instant/instant_api_wrapper.h" | |
18 #include "chrome/browser/instant/instant_commit_type.h" | 19 #include "chrome/browser/instant/instant_commit_type.h" |
19 #include "chrome/browser/instant/instant_model.h" | 20 #include "chrome/browser/instant/instant_model.h" |
20 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
21 #include "chrome/common/instant_types.h" | 22 #include "chrome/common/instant_types.h" |
22 #include "chrome/common/search_types.h" | 23 #include "chrome/common/search_types.h" |
23 #include "content/public/common/page_transition_types.h" | 24 #include "content/public/common/page_transition_types.h" |
24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
25 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
27 | 28 |
28 struct AutocompleteMatch; | 29 struct AutocompleteMatch; |
29 class AutocompleteProvider; | 30 class AutocompleteProvider; |
30 class InstantLoader; | 31 class InstantNTP; |
32 class InstantOverlay; | |
31 class InstantTab; | 33 class InstantTab; |
32 class TemplateURL; | 34 class TemplateURL; |
33 | 35 |
34 namespace chrome { | 36 namespace chrome { |
35 class BrowserInstantController; | 37 class BrowserInstantController; |
36 } | 38 } |
37 | 39 |
38 namespace content { | 40 namespace content { |
39 class WebContents; | 41 class WebContents; |
40 } | 42 } |
41 | 43 |
42 // InstantController maintains a WebContents that is intended to give a preview | 44 // InstantController drives Chrome Instant, i.e., the browser implementation of |
43 // of search suggestions and results. InstantController is owned by Browser via | 45 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). It |
44 // BrowserInstantController. | 46 // maintains a WebContents used to show search suggestions and results in an |
45 class InstantController { | 47 // overlay and a WebContents used for the New Tab page. InstantController is |
48 // owned by Browser via BrowserInstantController. | |
49 class InstantController : public InstantAPIWrapper::Receiver { | |
46 public: | 50 public: |
47 // The URL for the local omnibox popup. | 51 // The URL for the local omnibox popup. |
48 static const char* kLocalOmniboxPopupURL; | 52 static const char* kLocalOmniboxPopupURL; |
49 | 53 |
50 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the | 54 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the |
51 // instant URL and is only applicable if |extended_enabled| is true. | 55 // instant URL and is only applicable if |extended_enabled| is true. |
52 InstantController(chrome::BrowserInstantController* browser, | 56 InstantController(chrome::BrowserInstantController* browser, |
53 bool extended_enabled, | 57 bool extended_enabled, |
54 bool use_local_preview_only); | 58 bool use_local_preview_only); |
55 ~InstantController(); | 59 ~InstantController(); |
56 | 60 |
57 // Invoked as the user types into the omnibox. |user_text| is what the user | 61 // Invoked as the user types into the omnibox. |user_text| is what the user |
58 // has typed. |full_text| is what the omnibox is showing. These may differ if | 62 // has typed. |full_text| is what the omnibox is showing. These may differ if |
59 // the user typed only some text, and the rest was inline autocompleted. If | 63 // the user typed only some text, and the rest was inline autocompleted. If |
60 // |verbatim| is true, search results are shown for the exact omnibox text, | 64 // |verbatim| is true, search results are shown for the exact omnibox text, |
61 // rather than the best guess as to what the user means. Returns true if the | 65 // rather than the best guess as to what the user means. Returns true if the |
62 // update is accepted (i.e., if |match| is a search rather than a URL). | 66 // update is accepted (i.e., if |match| is a search rather than a URL). |
63 // |is_keyword_search| is true if keyword searching is in effect. | 67 // |is_keyword_search| is true if keyword searching is in effect. |
64 bool Update(const AutocompleteMatch& match, | 68 bool Update(const AutocompleteMatch& match, |
65 const string16& user_text, | 69 const string16& user_text, |
66 const string16& full_text, | 70 const string16& full_text, |
67 size_t selection_start, | 71 size_t selection_start, |
68 size_t selection_end, | 72 size_t selection_end, |
69 bool verbatim, | 73 bool verbatim, |
70 bool user_input_in_progress, | 74 bool user_input_in_progress, |
71 bool omnibox_popup_is_open, | 75 bool omnibox_popup_is_open, |
72 bool escape_pressed, | 76 bool escape_pressed, |
73 bool is_keyword_search); | 77 bool is_keyword_search); |
74 | 78 |
79 // Releases and returns the NTP WebContents. May be NULL. Loads a new | |
80 // WebContents for the NTP. | |
81 content::WebContents* ReleaseNTPContents(); | |
82 | |
75 // Sets the bounds of the omnibox popup, in screen coordinates. | 83 // Sets the bounds of the omnibox popup, in screen coordinates. |
76 void SetPopupBounds(const gfx::Rect& bounds); | 84 void SetPopupBounds(const gfx::Rect& bounds); |
77 | 85 |
78 // Sets the start and end margins of the omnibox text area. | 86 // Sets the start and end margins of the omnibox text area. |
79 void SetMarginSize(int start, int end); | 87 void SetMarginSize(int start, int end); |
80 | 88 |
81 // Send autocomplete results from |providers| to the preview page. | 89 // Send autocomplete results from |providers| to the preview page. |
82 void HandleAutocompleteResults( | 90 void HandleAutocompleteResults( |
83 const std::vector<AutocompleteProvider*>& providers); | 91 const std::vector<AutocompleteProvider*>& providers); |
84 | 92 |
(...skipping 13 matching lines...) Expand all Loading... | |
98 bool CommitIfPossible(InstantCommitType type); | 106 bool CommitIfPossible(InstantCommitType type); |
99 | 107 |
100 // Called to indicate that the omnibox focus state changed with the given | 108 // Called to indicate that the omnibox focus state changed with the given |
101 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to | 109 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to |
102 // the view gaining focus. | 110 // the view gaining focus. |
103 void OmniboxFocusChanged(OmniboxFocusState focus_state, | 111 void OmniboxFocusChanged(OmniboxFocusState focus_state, |
104 OmniboxFocusChangeReason reason, | 112 OmniboxFocusChangeReason reason, |
105 gfx::NativeView view_gaining_focus); | 113 gfx::NativeView view_gaining_focus); |
106 | 114 |
107 // The search mode in the active tab has changed. Pass the message down to | 115 // The search mode in the active tab has changed. Pass the message down to |
108 // the loader which will notify the renderer. Create |instant_tab_| if the | 116 // the overlay which will notify the renderer. Create |instant_tab_| if the |
109 // |new_mode| reflects an Instant search results page. | 117 // |new_mode| reflects an Instant search results page. |
110 void SearchModeChanged(const chrome::search::Mode& old_mode, | 118 void SearchModeChanged(const chrome::search::Mode& old_mode, |
111 const chrome::search::Mode& new_mode); | 119 const chrome::search::Mode& new_mode); |
112 | 120 |
113 // The user switched tabs. Hide the preview. Create |instant_tab_| if the | 121 // The user switched tabs. Hide the preview. Create |instant_tab_| if the |
114 // newly active tab is an Instant search results page. | 122 // newly active tab is an Instant search results page. |
115 void ActiveTabChanged(); | 123 void ActiveTabChanged(); |
116 | 124 |
117 // The user is about to switch tabs. Commit the preview if needed. | 125 // The user is about to switch tabs. Commit the preview if needed. |
118 void TabDeactivated(content::WebContents* contents); | 126 void TabDeactivated(content::WebContents* contents); |
119 | 127 |
120 // Sets whether Instant should show result previews. | 128 // Sets whether Instant should show result previews. |
121 void SetInstantEnabled(bool instant_enabled); | 129 void SetInstantEnabled(bool instant_enabled); |
122 | 130 |
123 // The theme has changed. Pass the message to the preview page. | 131 // The theme has changed. Pass the message to the preview page. |
124 void ThemeChanged(const ThemeBackgroundInfo& theme_info); | 132 void ThemeChanged(const ThemeBackgroundInfo& theme_info); |
125 | 133 |
126 // The theme area height has changed. Pass the message to the preview page. | 134 // The theme area height has changed. Pass the message to the preview page. |
127 void ThemeAreaHeightChanged(int height); | 135 void ThemeAreaHeightChanged(int height); |
128 | 136 |
129 // Returns the transition type of the last AutocompleteMatch passed to Update. | 137 // Returns the transition type of the last AutocompleteMatch passed to Update. |
130 content::PageTransition last_transition_type() const { | 138 content::PageTransition last_transition_type() const { |
131 return last_transition_type_; | 139 return last_transition_type_; |
132 } | 140 } |
133 | 141 |
134 const InstantModel* model() const { return &model_; } | 142 const InstantModel* model() const { return &model_; } |
135 | 143 |
136 // Invoked by the page when it has suggested text. | 144 // Invoked by InstantOverlay when it has swapped a different WebContents into |
137 void SetSuggestions(const content::WebContents* contents, | 145 // the preview, usually because a prerendered page was navigated to. |
138 const std::vector<InstantSuggestion>& suggestions); | 146 void SwappedOverlayWebContents(); |
139 | 147 |
140 // Invoked by the page when its support for the Instant API is determined. | 148 // Invoked by InstantOverlay when the preview gains focus, usually due to the |
141 void InstantSupportDetermined(const content::WebContents* contents, | 149 // user clicking on it. |
142 bool supports_instant); | 150 void InstantOverlayContentsFocused(); |
143 | 151 |
144 // Invoked by InstantLoader to request that the preview be shown. | 152 // Called when the |ntp_| might be stale. If it's actually state, the |ntp_| |
Jered
2013/01/14 18:22:34
state -> stale
samarth
2013/01/22 15:59:06
Done.
| |
145 void ShowInstantPreview(InstantShownReason reason, | 153 // is deleted and recreated. |
146 int height, | 154 void OnStaleNTP(); |
147 InstantSizeUnits units); | |
148 | 155 |
149 // Invoked by InstantLoader to request the browser to start capturing user key | 156 // Called when the |overlay_| might be stale. If it's actually stale, and the |
150 // strokes. | 157 // omnibox doesn't have focus, and the preview isn't showing, the |overlay_| |
151 void StartCapturingKeyStrokes(); | 158 // is deleted and recreated. Else the refresh is skipped. |
152 | 159 void OnStaleOverlay(); |
153 // Invoked by InstantLoader to request the browser to stop capturing user key | |
154 // strokes. | |
155 void StopCapturingKeyStrokes(); | |
156 | |
157 // Invoked by InstantLoader when it has swapped a different WebContents into | |
158 // the preview, usually because a prerendered page was navigated to. | |
159 void SwappedWebContents(); | |
160 | |
161 // Invoked by InstantLoader when the preview gains focus, usually due to the | |
162 // user clicking on it. | |
163 void InstantLoaderContentsFocused(); | |
164 | |
165 // Invoked by the InstantLoader when its RenderView crashes. | |
166 void InstantLoaderRenderViewGone(); | |
167 | |
168 // Invoked by InstantLoader when the instant page is about to navigate. | |
169 void InstantLoaderAboutToNavigateMainFrame(const GURL& url); | |
170 | |
171 // Invoked by the InstantLoader when the instant page wants to navigate to | |
172 // the speicfied URL. | |
173 void NavigateToURL(const GURL& url, content::PageTransition transition); | |
174 | 160 |
175 private: | 161 private: |
176 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | 162 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); |
177 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | 163 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); |
178 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); | 164 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); |
179 | 165 |
166 // Overridden from InstantAPIWrapper::Receiver. | |
167 virtual void InstantSupportDetermined( | |
168 const content::WebContents* contents, | |
169 bool supports_instant) OVERRIDE; | |
170 virtual void InstantPageRenderViewGone( | |
171 const content::WebContents* contents) OVERRIDE; | |
172 virtual void InstantPageAboutToNavigateMainFrame( | |
173 const content::WebContents* contents, | |
174 const GURL& url) OVERRIDE; | |
175 virtual void SetSuggestions( | |
176 const content::WebContents* contents, | |
177 const std::vector<InstantSuggestion>& suggestions) OVERRIDE; | |
178 virtual void ShowInstantPreview( | |
179 const content::WebContents* contents, | |
180 InstantShownReason reason, | |
181 int height, | |
182 InstantSizeUnits units) OVERRIDE; | |
183 virtual void StartCapturingKeyStrokes( | |
184 const content::WebContents* contents) OVERRIDE; | |
185 virtual void StopCapturingKeyStrokes(content::WebContents* contents) OVERRIDE; | |
186 virtual void NavigateToURL( | |
187 const content::WebContents* contents, | |
188 const GURL& url, | |
189 content::PageTransition transition) OVERRIDE; | |
190 | |
180 // Helper for OmniboxFocusChanged. Commit or discard the preview. | 191 // Helper for OmniboxFocusChanged. Commit or discard the preview. |
181 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | 192 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
182 | 193 |
183 // Creates a new loader if necessary, using the instant_url property of the | 194 // Creates a new NTP, using the instant_url property of the |template_url|. |
195 bool ResetNTP(); | |
196 | |
197 // Creates a new overlay if necessary, using the instant_url property of the | |
184 // |template_url| (for example, if the Instant URL has changed since the last | 198 // |template_url| (for example, if the Instant URL has changed since the last |
185 // time the loader was created). If |fallback_to_local| is true will use | 199 // time the overlay was created). If |fallback_to_local| is true will use |
186 // kLocalOmniboxPopupURL as the fallback url (in extended mode) in case | 200 // kLocalOmniboxPopupURL as the fallback url (in extended mode) in case |
187 // the |template_url| doesn't have a valid Instant URL. Returns true if an | 201 // the |template_url| doesn't have a valid Instant URL. Returns true if an |
188 // instant URL could be determined. | 202 // instant URL could be determined. |
189 bool ResetLoader(const TemplateURL* template_url, | 203 bool ResetOverlay(const TemplateURL* template_url, |
190 const content::WebContents* active_tab, | 204 const content::WebContents* active_tab, |
191 bool fallback_to_local); | 205 bool fallback_to_local); |
192 | 206 |
193 // Ensures that the |loader_| uses the default Instant URL, recreating it if | 207 // Ensures that the |overlay_| uses the default Instant URL, recreating it if |
194 // necessary, and returns true. Returns false if the Instant URL could not be | 208 // necessary, and returns true. Returns false if the Instant URL could not be |
195 // determined or the active tab is NULL (browser is shutting down). | 209 // determined or the active tab is NULL (browser is shutting down). |
196 bool CreateDefaultLoader(); | 210 bool CreateDefaultOverlay(); |
197 | 211 |
198 // Called when the |loader_| might be stale. If it's actually stale, and the | 212 // Called by Update() to ensure we have an Instant page that can process |
199 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is | 213 // |match|. Returns true if we should continue with the Update(). |
200 // deleted and recreated. Else the refresh is skipped. | 214 bool ResetOverlayForMatch(const AutocompleteMatch& match); |
201 void OnStaleLoader(); | |
202 | 215 |
203 // If the active tab is an Instant search results page, sets |instant_tab_| to | 216 // If the active tab is an Instant search results page, sets |instant_tab_| to |
204 // point to it. Else, deletes any existing |instant_tab_|. | 217 // point to it. Else, deletes any existing |instant_tab_|. |
205 void ResetInstantTab(); | 218 void ResetInstantTab(); |
206 | 219 |
207 // Called by Update() to ensure we have an Instant page that can process | |
208 // |match|. Returns true if we should continue with the Update(). | |
209 bool ResetLoaderForMatch(const AutocompleteMatch& match); | |
210 | |
211 // Hide the preview. Also sends an onchange event (with blank query) to the | 220 // Hide the preview. Also sends an onchange event (with blank query) to the |
212 // preview, telling it to clear out results for any old queries. | 221 // preview, telling it to clear out results for any old queries. |
213 void HideLoader(); | 222 void HideOverlay(); |
214 | 223 |
215 // Like HideLoader(), but doesn't call OnStaleLoader(). Use HideLoader() | 224 // Like HideOverlay(), but doesn't call OnStaleOverlay(). Use HideOverlay() |
216 // unless you are going to call loader_.reset() yourself subsequently. | 225 // unless you are going to call overlay_.reset() yourself subsequently. |
217 void HideInternal(); | 226 void HideInternal(); |
218 | 227 |
219 // Counterpart to HideLoader(). Asks the |browser_| to display the preview | 228 // Counterpart to HideOverlay(). Asks the |browser_| to display the preview |
220 // with the given |height|. | 229 // with the given |height|. |
221 void ShowLoader(InstantShownReason reason, | 230 void ShowOverlay(InstantShownReason reason, |
222 int height, | 231 int height, |
223 InstantSizeUnits units); | 232 InstantSizeUnits units); |
224 | 233 |
225 // Send the omnibox popup bounds to the page. | 234 // Send the omnibox popup bounds to the page. |
226 void SendPopupBoundsToPage(); | 235 void SendPopupBoundsToPage(); |
227 | 236 |
228 // If |template_url| is a valid TemplateURL for use with Instant, fills in | 237 // If |template_url| is a valid TemplateURL for use with Instant, fills in |
229 // |instant_url| and returns true; returns false otherwise. | 238 // |instant_url| and returns true; returns false otherwise. |
230 // Note: If the command-line switch kInstantURL is set, this method uses its | 239 // Note: If the command-line switch kInstantURL is set, this method uses its |
231 // value for |instant_url| and returns true without examining |template_url|. | 240 // value for |instant_url| and returns true without examining |template_url|. |
232 bool GetInstantURL(const TemplateURL* template_url, | 241 bool GetInstantURL(const TemplateURL* template_url, |
233 std::string* instant_url) const; | 242 std::string* instant_url) const; |
234 | 243 |
244 // Add |url| to the blacklist. | |
245 void AddToBlacklist(const std::string& url); | |
246 | |
247 // Remove |url| from the blacklist. | |
248 void RemoveFromBlacklist(const std::string& url); | |
249 | |
235 chrome::BrowserInstantController* const browser_; | 250 chrome::BrowserInstantController* const browser_; |
236 | 251 |
237 // Whether the extended API and regular API are enabled. If both are false, | 252 // Whether the extended API and regular API are enabled. If both are false, |
238 // Instant is effectively disabled. | 253 // Instant is effectively disabled. |
239 const bool extended_enabled_; | 254 const bool extended_enabled_; |
240 bool instant_enabled_; | 255 bool instant_enabled_; |
241 | 256 |
242 // If true, the instant URL is set to kLocalOmniboxPopupURL. | 257 // If true, the instant URL is set to kLocalOmniboxPopupURL. |
243 const bool use_local_preview_only_; | 258 const bool use_local_preview_only_; |
244 | 259 |
245 // The state of the preview page, i.e., the page owned by |loader_|. Ignored | 260 // The state of the preview page, i.e., the page owned by |overlay_|. Ignored |
246 // if |instant_tab_| is in use. | 261 // if |instant_tab_| is in use. |
247 InstantModel model_; | 262 InstantModel model_; |
248 | 263 |
249 // The preview WebContents. | 264 // WebContents used to show search suggestions and results in an overlay. |
250 scoped_ptr<InstantLoader> loader_; | 265 scoped_ptr<InstantOverlay> overlay_; |
251 | 266 |
252 // A committed WebContents that supports Instant. If non-NULL, the |loader_| | 267 // WebContents used for New Tab Pages. |
253 // is guaranteed to be hidden and messages will be sent to this instead. | 268 scoped_ptr<InstantNTP> ntp_; |
269 | |
270 // A committed WebContents that supports SearchBoxAPI via the | |
271 // InstantClient::Delegate interface. If non-NULL, the |overlay_| is | |
Jered
2013/01/14 18:22:34
InstantClient -> InstantAPIWrapper
samarth
2013/01/22 15:59:06
Done.
| |
272 // guaranteed to be hidden and messages will be sent to this instead. | |
254 scoped_ptr<InstantTab> instant_tab_; | 273 scoped_ptr<InstantTab> instant_tab_; |
255 | 274 |
256 // The most recent full_text passed to Update(). If empty, we'll not accept | 275 // The most recent full_text passed to Update(). If empty, we'll not accept |
257 // search suggestions from |loader_| or |instant_tab_|. | 276 // search suggestions from |overlay_| or |instant_tab_|. |
258 string16 last_omnibox_text_; | 277 string16 last_omnibox_text_; |
259 | 278 |
260 // True if the last Update() had an inline autocompletion. Used only to make | 279 // True if the last Update() had an inline autocompletion. Used only to make |
261 // sure that we don't accidentally suggest gray text suggestion in that case. | 280 // sure that we don't accidentally suggest gray text suggestion in that case. |
262 bool last_omnibox_text_has_inline_autocompletion_; | 281 bool last_omnibox_text_has_inline_autocompletion_; |
263 | 282 |
264 // The most recent verbatim passed to Update(). Used only to ensure that we | 283 // The most recent verbatim passed to Update(). Used only to ensure that we |
265 // don't accidentally suggest an inline autocompletion. | 284 // don't accidentally suggest an inline autocompletion. |
266 bool last_verbatim_; | 285 bool last_verbatim_; |
267 | 286 |
(...skipping 22 matching lines...) Expand all Loading... | |
290 | 309 |
291 // Size of the start-edge omnibox text area margin. | 310 // Size of the start-edge omnibox text area margin. |
292 int start_margin_; | 311 int start_margin_; |
293 | 312 |
294 // Size of the end-edge omnibox text area margin. | 313 // Size of the end-edge omnibox text area margin. |
295 int end_margin_; | 314 int end_margin_; |
296 | 315 |
297 // Timer used to update the bounds of the omnibox popup. | 316 // Timer used to update the bounds of the omnibox popup. |
298 base::OneShotTimer<InstantController> update_bounds_timer_; | 317 base::OneShotTimer<InstantController> update_bounds_timer_; |
299 | 318 |
300 // Timer used to ensure that the Instant page does not get too stale. | |
301 base::OneShotTimer<InstantController> stale_loader_timer_; | |
302 | |
303 // For each key K => value N, the map says that we found that the search | 319 // For each key K => value N, the map says that we found that the search |
304 // engine identified by Instant URL K didn't support the Instant API, or | 320 // engine identified by Instant URL K didn't support the Instant API, or |
305 // caused RenderView crashes in each of the last N times that we loaded it. | 321 // caused RenderView crashes in each of the last N times that we loaded it. |
306 // If an Instant URL isn't present in the map at all or has a value 0, | 322 // If an Instant URL isn't present in the map at all or has a value 0, |
307 // it means that search engine supports the Instant API (or we assume it does, | 323 // it means that search engine supports the Instant API (or we assume it does, |
308 // since we haven't determined it doesn't) and it did not cause a crash. | 324 // since we haven't determined it doesn't) and it did not cause a crash. |
309 std::map<std::string, int> blacklisted_urls_; | 325 std::map<std::string, int> blacklisted_urls_; |
310 | 326 |
311 // Search terms extraction (for autocomplete history matches) doesn't work | 327 // Search terms extraction (for autocomplete history matches) doesn't work |
312 // on Instant URLs. So, whenever the user commits an Instant search, we add | 328 // on Instant URLs. So, whenever the user commits an Instant search, we add |
313 // an equivalent non-Instant search URL to history, so that the search shows | 329 // an equivalent non-Instant search URL to history, so that the search shows |
314 // up in autocomplete history matches. | 330 // up in autocomplete history matches. |
315 // TODO(sreeram): Remove when http://crbug.com/155373 is fixed. | 331 // TODO(sreeram): Remove when http://crbug.com/155373 is fixed. |
316 GURL url_for_history_; | 332 GURL url_for_history_; |
317 | 333 |
318 // The timestamp at which query editing began. This value is used when the | 334 // The timestamp at which query editing began. This value is used when the |
319 // preview is showed and cleared when the preview is hidden. | 335 // preview is showed and cleared when the preview is hidden. |
320 base::Time first_interaction_time_; | 336 base::Time first_interaction_time_; |
321 | 337 |
322 // Whether to allow the preview to show search suggestions. In general, the | 338 // Whether to allow the preview to show search suggestions. In general, the |
323 // preview is allowed to show search suggestions whenever |search_mode_| is | 339 // preview is allowed to show search suggestions whenever |search_mode_| is |
324 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 340 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
325 bool allow_preview_to_show_search_suggestions_; | 341 bool allow_preview_to_show_search_suggestions_; |
326 | 342 |
327 DISALLOW_COPY_AND_ASSIGN(InstantController); | 343 DISALLOW_COPY_AND_ASSIGN(InstantController); |
328 }; | 344 }; |
329 | 345 |
330 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 346 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |