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 <list> | |
9 #include <map> | |
10 #include <string> | |
11 #include <utility> | |
12 #include <vector> | 8 #include <vector> |
13 | 9 |
14 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
15 #include "base/gtest_prod_util.h" | |
16 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
17 #include "base/string16.h" | 12 #include "base/string16.h" |
18 #include "base/time.h" | |
19 #include "base/timer.h" | |
20 #include "chrome/browser/history/history_types.h" | |
21 #include "chrome/browser/instant/instant_commit_type.h" | 13 #include "chrome/browser/instant/instant_commit_type.h" |
22 #include "chrome/browser/instant/instant_overlay_model.h" | |
23 #include "chrome/browser/instant/instant_page.h" | 14 #include "chrome/browser/instant/instant_page.h" |
24 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 15 #include "chrome/common/omnibox_types.h" |
25 #include "chrome/common/instant_types.h" | |
26 #include "chrome/common/search_types.h" | |
27 #include "content/public/browser/notification_observer.h" | |
28 #include "content/public/browser/notification_registrar.h" | |
29 #include "content/public/common/page_transition_types.h" | |
30 #include "googleurl/src/gurl.h" | |
31 #include "ui/base/window_open_disposition.h" | |
32 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
33 #include "ui/gfx/rect.h" | |
34 | 17 |
35 struct AutocompleteMatch; | 18 struct AutocompleteMatch; |
36 class AutocompleteProvider; | 19 class AutocompleteProvider; |
37 class InstantNTP; | 20 class InstantOverlayModel; |
38 class InstantOverlay; | 21 class InstantOverlayModelObserver; |
39 class InstantTab; | 22 class Profile; |
40 class TemplateURL; | |
41 | 23 |
42 namespace chrome { | 24 namespace chrome { |
43 class BrowserInstantController; | 25 class BrowserInstantController; |
44 } | 26 } |
45 | 27 |
28 namespace chrome { | |
29 namespace search { | |
30 struct Mode; | |
31 } | |
32 } | |
33 | |
46 namespace content { | 34 namespace content { |
47 class WebContents; | 35 class WebContents; |
48 } | 36 } |
49 | 37 |
50 // Macro used for logging debug events. |message| should be a std::string. | 38 namespace gfx { |
51 #define LOG_INSTANT_DEBUG_EVENT(controller, message) \ | 39 class Rect; |
52 controller->LogDebugEvent(message) | 40 } |
53 | 41 |
54 // InstantController drives Chrome Instant, i.e., the browser implementation of | 42 // InstantController drives Chrome Instant, i.e., the browser implementation of |
55 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). | 43 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). |
56 // | 44 // |
57 // In extended mode, InstantController maintains and coordinates three | 45 // There are two concrete modes of operation: Regular (InstantControllerImpl) |
58 // instances of InstantPage: | 46 // and Extended (InstantControllerExtendedImpl). |
59 // (1) An InstantOverlay instance that is used to show search suggestions and | |
60 // results in an overlay over a non-search page. | |
61 // (2) An InstantNTP instance which is a preloaded search page that will be | |
62 // swapped-in the next time the user navigates to the New Tab Page. It is | |
63 // never shown to the user in an uncommitted state. | |
64 // (3) An InstantTab instance which points to the currently active tab, if it | |
65 // supports the Embedded Search API. | |
66 // | 47 // |
67 // All three are backed by a WebContents. InstantOverlay and InstantNTP own | 48 // In both modes, InstantController can show an overlay WebContents as the user |
68 // their corresponding WebContents; InstantTab does not. In non-extended mode, | 49 // types in the omnibox. In extended mode, InstantController can also use the |
69 // only an InstantOverlay instance is kept. | 50 // current active tab to drive the display of search suggestions and results. |
70 // | 51 // |
71 // InstantController is owned by Browser via BrowserInstantController. | 52 // InstantController is owned by Browser via BrowserInstantController. |
72 class InstantController : public InstantPage::Delegate, | 53 class InstantController : public InstantPage::Delegate { |
73 public content::NotificationObserver { | |
74 public: | 54 public: |
75 InstantController(chrome::BrowserInstantController* browser, | 55 // Creates and returns a new InstantController object. |
76 bool extended_enabled); | 56 static scoped_ptr<InstantController> Create( |
57 chrome::BrowserInstantController* browser, | |
58 Profile* profile); | |
59 | |
60 InstantController(); | |
Jered
2013/03/26 16:36:42
Make this protected.
| |
77 virtual ~InstantController(); | 61 virtual ~InstantController(); |
78 | 62 |
79 // Invoked as the user types into the omnibox. |user_text| is what the user | 63 // -------------------------------------------------------------------------- |
80 // has typed. |full_text| is what the omnibox is showing. These may differ if | 64 // The OmniboxEditModel delivers the following events as the user interacts |
81 // the user typed only some text, and the rest was inline autocompleted. If | 65 // with the omnibox. |
82 // |verbatim| is true, search results are shown for the exact omnibox text, | |
83 // rather than the best guess as to what the user means. Returns true if the | |
84 // update is accepted (i.e., if |match| is a search rather than a URL). | |
85 // |is_keyword_search| is true if keyword searching is in effect. | |
86 bool Update(const AutocompleteMatch& match, | |
87 const string16& user_text, | |
88 const string16& full_text, | |
89 size_t selection_start, | |
90 size_t selection_end, | |
91 bool verbatim, | |
92 bool user_input_in_progress, | |
93 bool omnibox_popup_is_open, | |
94 bool escape_pressed, | |
95 bool is_keyword_search); | |
96 | 66 |
97 // Releases and returns the NTP WebContents. May be NULL. Loads a new | 67 // Called in most cases where the omnibox text has changed. |
98 // WebContents for the NTP. | 68 virtual bool Update(const AutocompleteMatch& match, |
99 scoped_ptr<content::WebContents> ReleaseNTPContents() WARN_UNUSED_RESULT; | 69 const string16& user_text, |
70 const string16& full_text, | |
71 size_t selection_start, | |
72 size_t selection_end, | |
73 bool verbatim, | |
74 bool user_input_in_progress, | |
75 bool omnibox_popup_is_open, | |
76 bool escape_pressed, | |
77 bool is_keyword_search) = 0; | |
100 | 78 |
101 // Sets the bounds of the omnibox popup, in screen coordinates. | 79 // Called when the autocomplete system has new results for the current text. |
102 void SetPopupBounds(const gfx::Rect& bounds); | 80 virtual void HandleAutocompleteResults( |
81 const std::vector<AutocompleteProvider*>& providers) = 0; | |
103 | 82 |
104 // Sets the stored start-edge margin and width of the omnibox. | 83 // Called when the user wants to traverse the suggestions list. |count| is |
105 void SetOmniboxBounds(const gfx::Rect& bounds); | 84 // positive to indicate moving down, negative for moving up. |
85 virtual bool OnUpOrDownKeyPressed(int count) = 0; | |
106 | 86 |
107 // Send autocomplete results from |providers| to the overlay page. | 87 // Called when the user hits Escape after traversing the suggestions list. |
108 void HandleAutocompleteResults( | 88 virtual void OnCancel(const AutocompleteMatch& match, |
109 const std::vector<AutocompleteProvider*>& providers); | 89 const string16& full_text) = 0; |
110 | 90 |
111 // Called when the user presses up or down. |count| is a repeat count, | 91 // -------------------------------------------------------------------------- |
112 // negative for moving up, positive for moving down. Returns true if Instant | 92 // Methods dealing with the overlay, its model and the NTP. |
113 // handled the key press. | |
114 bool OnUpOrDownKeyPressed(int count); | |
115 | 93 |
116 // Called when the user has arrowed into the suggestions but wants to cancel, | 94 virtual bool IsOverlayingSearchResults() const = 0; |
117 // typically by pressing ESC. The omnibox text is expected to have been | |
118 // reverted to |full_text| by the OmniboxEditModel prior to calling this. | |
119 // |match| is the match reverted to. | |
120 void OnCancel(const AutocompleteMatch& match, | |
121 const string16& full_text); | |
122 | 95 |
123 // The overlay WebContents. May be NULL. InstantController retains ownership. | 96 virtual content::WebContents* GetOverlayContents() const = 0; |
124 content::WebContents* GetOverlayContents() const; | |
125 | 97 |
126 // Returns true if Instant is showing a search results overlay. Returns false | 98 virtual const InstantOverlayModel* model() const = 0; |
Jered
2013/03/26 16:36:42
model() -> GetModel()
| |
127 // if the overlay is not showing, or if it's showing only suggestions. | |
128 bool IsOverlayingSearchResults() const; | |
129 | 99 |
130 // If the overlay is showing search results, commits the overlay, calling | 100 virtual void AddOverlayModelObserver( |
131 // CommitInstant() on the browser, and returns true. Else, returns false. | 101 InstantOverlayModelObserver* observer) = 0; |
132 bool CommitIfPossible(InstantCommitType type); | |
133 | 102 |
134 // Called to indicate that the omnibox focus state changed with the given | 103 virtual void RemoveOverlayModelObserver( |
135 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to | 104 InstantOverlayModelObserver* observer) = 0; |
136 // the view gaining focus. | |
137 void OmniboxFocusChanged(OmniboxFocusState focus_state, | |
138 OmniboxFocusChangeReason reason, | |
139 gfx::NativeView view_gaining_focus); | |
140 | 105 |
141 // The search mode in the active tab has changed. Pass the message down to | 106 virtual bool CommitIfPossible(InstantCommitType type) = 0; |
142 // the overlay which will notify the renderer. Create |instant_tab_| if the | |
143 // |new_mode| reflects an Instant search results page. | |
144 void SearchModeChanged(const chrome::search::Mode& old_mode, | |
145 const chrome::search::Mode& new_mode); | |
146 | 107 |
147 // The user switched tabs. Hide the overlay. Create |instant_tab_| if the | 108 virtual scoped_ptr<content::WebContents> ReleaseNTPContents() = 0; |
148 // newly active tab is an Instant search results page. | |
149 void ActiveTabChanged(); | |
150 | 109 |
151 // The user is about to switch tabs. Commit the overlay if needed. | 110 // -------------------------------------------------------------------------- |
152 void TabDeactivated(content::WebContents* contents); | 111 // Information about the omnibox. |
153 | 112 |
154 // Sets whether Instant should show result overlays. |use_local_overlay_only| | 113 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0; |
155 // will force the use of kLocalOmniboxPopupURL as the Instant URL and is only | |
156 // applicable if |extended_enabled_| is true. | |
157 void SetInstantEnabled(bool instant_enabled, bool use_local_overlay_only); | |
158 | 114 |
159 // The theme has changed. Pass the message to the overlay page. | 115 virtual void SetOmniboxBounds(const gfx::Rect& bounds) = 0; |
160 void ThemeChanged(const ThemeBackgroundInfo& theme_info); | |
161 | 116 |
162 // Called when someone else swapped in a different contents in the |overlay_|. | 117 // -------------------------------------------------------------------------- |
163 void SwappedOverlayContents(); | 118 // Events sent as the user stops (or starts) interacting with the omnibox. |
164 | 119 |
165 // Called when contents for |overlay_| received focus. | 120 virtual void OmniboxFocusChanged(OmniboxFocusState state, |
166 void FocusedOverlayContents(); | 121 OmniboxFocusChangeReason reason, |
122 gfx::NativeView view_gaining_focus) = 0; | |
167 | 123 |
168 // Called when the |overlay_| might be stale. If it's actually stale, and the | 124 virtual void TabDeactivated(content::WebContents* contents) = 0; |
169 // omnibox doesn't have focus, and the overlay isn't showing, the |overlay_| | |
170 // is deleted and recreated. Else the refresh is skipped. | |
171 void ReloadOverlayIfStale(); | |
172 | 125 |
173 // Adds a new event to |debug_events_| and also DVLOG's it. Ensures that | 126 virtual void SearchModeChanged(const chrome::search::Mode& old_mode, |
174 // |debug_events_| doesn't get too large. | 127 const chrome::search::Mode& new_mode) = 0; |
175 void LogDebugEvent(const std::string& info) const; | |
176 | 128 |
177 // Resets list of debug events. | 129 virtual void ActiveTabChanged() = 0; |
178 void ClearDebugEvents(); | |
179 | 130 |
180 // See comments for |debug_events_| below. | 131 // -------------------------------------------------------------------------- |
181 const std::list<std::pair<int64, std::string> >& debug_events() { | 132 // Calls from InstantOverlay. Not for general use. |
182 return debug_events_; | |
183 } | |
184 | 133 |
185 // Returns the transition type of the last AutocompleteMatch passed to Update. | 134 virtual void SwappedOverlayContents() = 0; |
186 content::PageTransition last_transition_type() const { | |
187 return last_transition_type_; | |
188 } | |
189 | 135 |
190 // Non-const for Add/RemoveObserver only. Other model changes should only | 136 virtual void FocusedOverlayContents() = 0; |
191 // happen through the InstantController interface. | |
192 InstantOverlayModel* model() { return &model_; } | |
193 | 137 |
194 private: | 138 private: |
195 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | |
196 FRIEND_TEST_ALL_PREFIXES(InstantTest, SetWithTemplateURL); | |
197 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | |
198 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefresh); | |
199 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ExtendedModeIsOn); | |
200 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, MostVisited); | |
201 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, OmniboxFocusLoadsInstant); | |
202 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, | |
203 OmniboxTextUponFocusedCommittedSERP); | |
204 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, | |
205 MiddleClickOnSuggestionOpensInNewTab); | |
206 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, NTPIsPreloaded); | |
207 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInNewTab); | |
208 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInSameTab); | |
209 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); | |
210 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, UnrelatedSiteInstance); | |
211 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, | |
212 OmniboxCommitsWhenShownFullHeight); | |
213 | |
214 // Overridden from content::NotificationObserver: | |
215 virtual void Observe(int type, | |
216 const content::NotificationSource& source, | |
217 const content::NotificationDetails& details) OVERRIDE; | |
218 | |
219 // Overridden from InstantPage::Delegate: | |
220 // TODO(shishir): We assume that the WebContent's current RenderViewHost is | |
221 // the RenderViewHost being created which is not always true. Fix this. | |
222 virtual void InstantPageRenderViewCreated( | |
223 const content::WebContents* contents) OVERRIDE; | |
224 virtual void InstantSupportDetermined( | |
225 const content::WebContents* contents, | |
226 bool supports_instant) OVERRIDE; | |
227 virtual void InstantPageRenderViewGone( | |
228 const content::WebContents* contents) OVERRIDE; | |
229 virtual void InstantPageAboutToNavigateMainFrame( | |
230 const content::WebContents* contents, | |
231 const GURL& url) OVERRIDE; | |
232 virtual void SetSuggestions( | |
233 const content::WebContents* contents, | |
234 const std::vector<InstantSuggestion>& suggestions) OVERRIDE; | |
235 virtual void ShowInstantOverlay( | |
236 const content::WebContents* contents, | |
237 InstantShownReason reason, | |
238 int height, | |
239 InstantSizeUnits units) OVERRIDE; | |
240 virtual void FocusOmnibox(const content::WebContents* contents) OVERRIDE; | |
241 virtual void StartCapturingKeyStrokes( | |
242 const content::WebContents* contents) OVERRIDE; | |
243 virtual void StopCapturingKeyStrokes(content::WebContents* contents) OVERRIDE; | |
244 virtual void NavigateToURL( | |
245 const content::WebContents* contents, | |
246 const GURL& url, | |
247 content::PageTransition transition, | |
248 WindowOpenDisposition disposition) OVERRIDE; | |
249 | |
250 // Invoked by the InstantLoader when the Instant page wants to delete a | |
251 // Most Visited item. | |
252 virtual void DeleteMostVisitedItem(const GURL& url) OVERRIDE; | |
253 | |
254 // Invoked by the InstantLoader when the Instant page wants to undo a | |
255 // Most Visited deletion. | |
256 virtual void UndoMostVisitedDeletion(const GURL& url) OVERRIDE; | |
257 | |
258 // Invoked by the InstantLoader when the Instant page wants to undo all | |
259 // Most Visited deletions. | |
260 virtual void UndoAllMostVisitedDeletions() OVERRIDE; | |
261 | |
262 // Helper for OmniboxFocusChanged. Commit or discard the overlay. | |
263 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | |
264 | |
265 // Creates a new NTP, using the instant_url property of the default | |
266 // TemplateURL. | |
267 void ResetNTP(); | |
268 | |
269 // Ensures that |overlay_| uses the Instant URL returned by GetInstantURL(), | |
270 // creating a new overlay if necessary. In extended mode, will fallback to | |
271 // using the kLocalOmniboxPopupURL as the Instant URL in case GetInstantURL() | |
272 // returns false. Returns true if an Instant URL could be determined. | |
273 // For |ignore_blacklist| look at comments in |GetInstantURL|. | |
274 bool EnsureOverlayIsCurrent(bool ignore_blacklist); | |
275 | |
276 // Recreates the |overlay_| with |instant_url|. Note that |overlay_| is | |
277 // deleted in this call. | |
278 void CreateOverlay(const std::string& instant_url, | |
279 const content::WebContents* active_tab); | |
280 | |
281 // If the |overlay_| being used is in fallback mode, it will be switched back | |
282 // to the remote overlay if the overlay is not showing and the omnibox does | |
283 // not have focus. | |
284 void MaybeSwitchToRemoteOverlay(); | |
285 | |
286 // If the active tab is an Instant search results page, sets |instant_tab_| to | |
287 // point to it. Else, deletes any existing |instant_tab_|. | |
288 void ResetInstantTab(); | |
289 | |
290 // Hide the overlay. Also sends an onchange event (with blank query) to the | |
291 // overlay, telling it to clear out results for any old queries. | |
292 void HideOverlay(); | |
293 | |
294 // Like HideOverlay(), but doesn't call OnStaleOverlay(). Use HideOverlay() | |
295 // unless you are going to call overlay_.reset() yourself subsequently. | |
296 void HideInternal(); | |
297 | |
298 // Counterpart to HideOverlay(). Asks the |browser_| to display the overlay | |
299 // with the given |height| in |units|. | |
300 void ShowOverlay(InstantShownReason reason, | |
301 int height, | |
302 InstantSizeUnits units); | |
303 | |
304 // Send the omnibox popup bounds to the page. | |
305 void SendPopupBoundsToPage(); | |
306 | |
307 // Determines the Instant URL based on a number of factors: | |
308 // If |extended_enabled_|: | |
309 // - If |use_local_overlay_only_| is true return kLocalOmniboxPopupURL, else | |
310 // - If the Instant URL is specified by command line, returns it, else | |
311 // - If the default Instant URL is present returns it. | |
312 // If !|extended_enabled_|: | |
313 // - If the Instant URL is specified by command line, returns it, else | |
314 // - If the default Instant URL is present returns it. | |
315 // | |
316 // If |ignore_blacklist| is set to true, Instant URLs are not filtered through | |
317 // the blacklist. | |
318 // | |
319 // Returns true if a valid Instant URL could be found that is not blacklisted. | |
320 bool GetInstantURL(Profile* profile, | |
321 bool ignore_blacklist, | |
322 std::string* instant_url) const; | |
323 | |
324 // Adds the URL for the page to the blacklist. Deletes the contents held and | |
325 // recreates a new page. | |
326 void BlacklistAndResetOverlay(); | |
327 void BlacklistAndResetNTP(); | |
328 | |
329 // Removes |url| from the blacklist. | |
330 void RemoveFromBlacklist(const std::string& url); | |
331 | |
332 InstantOverlay* overlay() const { return overlay_.get(); } | |
333 InstantTab* instant_tab() const { return instant_tab_.get(); } | |
334 InstantNTP* ntp() const { return ntp_.get(); } | |
335 | |
336 // Begin listening to change notifications from TopSites and fire off an | |
337 // initial request for most visited items. | |
338 void StartListeningToMostVisitedChanges(); | |
339 | |
340 // Fire off an async request for most visited items to the TopNav code. | |
341 void RequestMostVisitedItems(); | |
342 | |
343 // Called when we get new most visited items from the TopNav code, | |
344 // registered as an async callback. Parses them and sends them to the | |
345 // renderer via SendMostVisitedItems. | |
346 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); | |
347 | |
348 // Sends a collection of MostVisitedItems to the renderer process via | |
349 // the appropriate InstantPage subclass. | |
350 void SendMostVisitedItems(const std::vector<MostVisitedItem>& items); | |
351 | |
352 chrome::BrowserInstantController* const browser_; | |
353 | |
354 // Whether the extended API and regular API are enabled. If both are false, | |
355 // Instant is effectively disabled. | |
356 const bool extended_enabled_; | |
357 bool instant_enabled_; | |
358 | |
359 // If true, the Instant URL is set to kLocalOmniboxPopupURL. | |
360 bool use_local_overlay_only_; | |
361 | |
362 // The state of the overlay page, i.e., the page owned by |overlay_|. Ignored | |
363 // if |instant_tab_| is in use. | |
364 InstantOverlayModel model_; | |
365 | |
366 // The three instances of InstantPage maintained by InstantController as | |
367 // described above. All three may be non-NULL in extended mode. If | |
368 // |instant_tab_| is not NULL, then |overlay_| is guaranteed to be hidden and | |
369 // messages will be sent to |instant_tab_| instead. | |
370 // | |
371 // In non-extended mode, only |overlay_| is ever non-NULL. | |
372 scoped_ptr<InstantOverlay> overlay_; | |
373 scoped_ptr<InstantNTP> ntp_; | |
374 scoped_ptr<InstantTab> instant_tab_; | |
375 | |
376 // The most recent full_text passed to Update(). If empty, we'll not accept | |
377 // search suggestions from |overlay_| or |instant_tab_|. | |
378 string16 last_omnibox_text_; | |
379 | |
380 // True if the last Update() had an inline autocompletion. Used only to make | |
381 // sure that we don't accidentally suggest gray text suggestion in that case. | |
382 bool last_omnibox_text_has_inline_autocompletion_; | |
383 | |
384 // The most recent verbatim passed to Update(). Used only to ensure that we | |
385 // don't accidentally suggest an inline autocompletion. | |
386 bool last_verbatim_; | |
387 | |
388 // The most recent suggestion received from the page, minus any prefix that | |
389 // the user has typed. | |
390 InstantSuggestion last_suggestion_; | |
391 | |
392 // See comments on the getter above. | |
393 content::PageTransition last_transition_type_; | |
394 | |
395 // True if the last match passed to Update() was a search (versus a URL). | |
396 // Used to ensure that the overlay page is committable. | |
397 bool last_match_was_search_; | |
398 | |
399 // Omnibox focus state. | |
400 OmniboxFocusState omnibox_focus_state_; | |
401 | |
402 // The search model mode for the active tab. | |
403 chrome::search::Mode search_mode_; | |
404 | |
405 // Current omnibox popup bounds. | |
406 gfx::Rect popup_bounds_; | |
407 | |
408 // Last popup bounds passed to the page. | |
409 gfx::Rect last_popup_bounds_; | |
410 | |
411 // The start-edge margin and width of the omnibox, used by the page to align | |
412 // its suggestions with the omnibox. | |
413 gfx::Rect omnibox_bounds_; | |
414 | |
415 // Timer used to update the bounds of the omnibox popup. | |
416 base::OneShotTimer<InstantController> update_bounds_timer_; | |
417 | |
418 // For each key K => value N, the map says that we found that the search | |
419 // engine identified by Instant URL K didn't support the Instant API, or | |
420 // caused RenderView crashes in each of the last N times that we loaded it. | |
421 // If an Instant URL isn't present in the map at all or has a value 0, | |
422 // it means that search engine supports the Instant API (or we assume it does, | |
423 // since we haven't determined it doesn't) and it did not cause a crash. | |
424 std::map<std::string, int> blacklisted_urls_; | |
425 | |
426 // Search terms extraction (for autocomplete history matches) doesn't work | |
427 // on Instant URLs. So, whenever the user commits an Instant search, we add | |
428 // an equivalent non-Instant search URL to history, so that the search shows | |
429 // up in autocomplete history matches. | |
430 // TODO(sreeram): Remove when http://crbug.com/155373 is fixed. | |
431 GURL url_for_history_; | |
432 | |
433 // The timestamp at which query editing began. This value is used when the | |
434 // overlay is showed and cleared when the overlay is hidden. | |
435 base::Time first_interaction_time_; | |
436 | |
437 // Whether to allow the overlay to show search suggestions. In general, the | |
438 // overlay is allowed to show search suggestions whenever |search_mode_| is | |
439 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | |
440 bool allow_overlay_to_show_search_suggestions_; | |
441 | |
442 // List of events and their timestamps, useful in debugging Instant behaviour. | |
443 mutable std::list<std::pair<int64, std::string> > debug_events_; | |
444 | |
445 // Used for Top Sites async retrieval. | |
446 base::WeakPtrFactory<InstantController> weak_ptr_factory_; | |
447 | |
448 // Used to get notifications about Most Visted changes. | |
449 content::NotificationRegistrar registrar_; | |
450 | |
451 DISALLOW_COPY_AND_ASSIGN(InstantController); | 139 DISALLOW_COPY_AND_ASSIGN(InstantController); |
452 }; | 140 }; |
453 | 141 |
454 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 142 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |