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> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // The preview WebContents. May be NULL. InstantController retains ownership. | 77 // The preview WebContents. May be NULL. InstantController retains ownership. |
78 content::WebContents* GetPreviewContents() const; | 78 content::WebContents* GetPreviewContents() const; |
79 | 79 |
80 // Returns true if the Instant preview can be committed now. | 80 // Returns true if the Instant preview can be committed now. |
81 bool IsCurrent() const; | 81 bool IsCurrent() const; |
82 | 82 |
83 // If the preview is showing search results, commits the preview, calling | 83 // If the preview is showing search results, commits the preview, calling |
84 // CommitInstant() on the browser, and returns true. Else, returns false. | 84 // CommitInstant() on the browser, and returns true. Else, returns false. |
85 bool CommitIfCurrent(InstantCommitType type); | 85 bool CommitIfCurrent(InstantCommitType type); |
86 | 86 |
87 // The omnibox has lost focus. Commit or discard the preview accordingly. | 87 // Called to indicate that the omnibox focus state changed with the given |
88 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | 88 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to |
89 | 89 // the view gaining focus. |
90 // The omnibox has gained focus. Preload the default search engine, in | 90 void OmniboxFocusChanged(OmniboxFocusState focus_state, |
91 // anticipation of the user typing a query. | 91 OmniboxFocusChangeReason reason, |
92 void OmniboxGotFocus(); | 92 gfx::NativeView view_gaining_focus); |
93 | 93 |
94 // The search mode in the active tab has changed. Pass the message down to | 94 // The search mode in the active tab has changed. Pass the message down to |
95 // the loader which will notify the renderer. Create |instant_tab_| if the | 95 // the loader which will notify the renderer. Create |instant_tab_| if the |
96 // |new_mode| reflects an Instant search results page. | 96 // |new_mode| reflects an Instant search results page. |
97 void SearchModeChanged(const chrome::search::Mode& old_mode, | 97 void SearchModeChanged(const chrome::search::Mode& old_mode, |
98 const chrome::search::Mode& new_mode); | 98 const chrome::search::Mode& new_mode); |
99 | 99 |
100 // The user switched tabs. Hide the preview. Create |instant_tab_| if the | 100 // The user switched tabs. Hide the preview. Create |instant_tab_| if the |
101 // newly active tab is an Instant search results page. | 101 // newly active tab is an Instant search results page. |
102 void ActiveTabChanged(); | 102 void ActiveTabChanged(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void InstantLoaderContentsFocused(); | 143 void InstantLoaderContentsFocused(); |
144 | 144 |
145 // Invoked by the InstantLoader when its RenderView crashes. | 145 // Invoked by the InstantLoader when its RenderView crashes. |
146 void InstantLoaderRenderViewGone(); | 146 void InstantLoaderRenderViewGone(); |
147 | 147 |
148 private: | 148 private: |
149 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | 149 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); |
150 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | 150 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); |
151 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); | 151 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); |
152 | 152 |
| 153 // Helper for OmniboxFocusChanged. Commit or discard the preview. |
| 154 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
| 155 |
153 // Creates a new loader if necessary, using the instant_url property of the | 156 // Creates a new loader if necessary, using the instant_url property of the |
154 // |template_url| (for example, if the Instant URL has changed since the last | 157 // |template_url| (for example, if the Instant URL has changed since the last |
155 // time the loader was created). Returns false if the |template_url| doesn't | 158 // time the loader was created). Returns false if the |template_url| doesn't |
156 // have a valid Instant URL; true otherwise. | 159 // have a valid Instant URL; true otherwise. |
157 bool ResetLoader(const TemplateURL* template_url, | 160 bool ResetLoader(const TemplateURL* template_url, |
158 const content::WebContents* active_tab); | 161 const content::WebContents* active_tab); |
159 | 162 |
160 // Ensures that the |loader_| uses the default Instant URL, recreating it if | 163 // Ensures that the |loader_| uses the default Instant URL, recreating it if |
161 // necessary, and returns true. Returns false if the Instant URL could not be | 164 // necessary, and returns true. Returns false if the Instant URL could not be |
162 // determined or the active tab is NULL (browser is shutting down). | 165 // determined or the active tab is NULL (browser is shutting down). |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // the user has typed. | 236 // the user has typed. |
234 InstantSuggestion last_suggestion_; | 237 InstantSuggestion last_suggestion_; |
235 | 238 |
236 // See comments on the getter above. | 239 // See comments on the getter above. |
237 content::PageTransition last_transition_type_; | 240 content::PageTransition last_transition_type_; |
238 | 241 |
239 // True if the last match passed to Update() was a search (versus a URL). | 242 // True if the last match passed to Update() was a search (versus a URL). |
240 // Used to ensure that the preview page is committable. | 243 // Used to ensure that the preview page is committable. |
241 bool last_match_was_search_; | 244 bool last_match_was_search_; |
242 | 245 |
243 // True if the omnibox is focused, false otherwise. | 246 // Omnibox focus state. |
244 bool is_omnibox_focused_; | 247 OmniboxFocusState omnibox_focus_state_; |
245 | 248 |
246 // The search model mode for the active tab. | 249 // The search model mode for the active tab. |
247 chrome::search::Mode search_mode_; | 250 chrome::search::Mode search_mode_; |
248 | 251 |
249 // Current omnibox bounds. | 252 // Current omnibox bounds. |
250 gfx::Rect omnibox_bounds_; | 253 gfx::Rect omnibox_bounds_; |
251 | 254 |
252 // Last bounds passed to the page. | 255 // Last bounds passed to the page. |
253 gfx::Rect last_omnibox_bounds_; | 256 gfx::Rect last_omnibox_bounds_; |
254 | 257 |
(...skipping 24 matching lines...) Expand all Loading... |
279 | 282 |
280 // Whether to allow the preview to show search suggestions. In general, the | 283 // Whether to allow the preview to show search suggestions. In general, the |
281 // preview is allowed to show search suggestions whenever |search_mode_| is | 284 // preview is allowed to show search suggestions whenever |search_mode_| is |
282 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 285 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
283 bool allow_preview_to_show_search_suggestions_; | 286 bool allow_preview_to_show_search_suggestions_; |
284 | 287 |
285 DISALLOW_COPY_AND_ASSIGN(InstantController); | 288 DISALLOW_COPY_AND_ASSIGN(InstantController); |
286 }; | 289 }; |
287 | 290 |
288 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 291 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |