| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // Invoked by InstantLoader when the preview gains focus, usually due to the | 141 // Invoked by InstantLoader when the preview gains focus, usually due to the |
| 142 // user clicking on it. | 142 // user clicking on it. |
| 143 void InstantLoaderContentsFocused(); | 143 void InstantLoaderContentsFocused(); |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | 146 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); |
| 147 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | 147 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); |
| 148 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); | 148 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); |
| 149 | 149 |
| 150 // Helper for OmniboxFocusChanged. Commit or discard the preview. |
| 151 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
| 152 |
| 150 // Creates a new loader if necessary, using the instant_url property of the | 153 // Creates a new loader if necessary, using the instant_url property of the |
| 151 // |template_url| (for example, if the Instant URL has changed since the last | 154 // |template_url| (for example, if the Instant URL has changed since the last |
| 152 // time the loader was created). Returns false if the |template_url| doesn't | 155 // time the loader was created). Returns false if the |template_url| doesn't |
| 153 // have a valid Instant URL; true otherwise. | 156 // have a valid Instant URL; true otherwise. |
| 154 bool ResetLoader(const TemplateURL* template_url, | 157 bool ResetLoader(const TemplateURL* template_url, |
| 155 const content::WebContents* active_tab); | 158 const content::WebContents* active_tab); |
| 156 | 159 |
| 157 // Ensures that the |loader_| uses the default Instant URL, recreating it if | 160 // Ensures that the |loader_| uses the default Instant URL, recreating it if |
| 158 // necessary, and returns true. Returns false if the Instant URL could not be | 161 // necessary, and returns true. Returns false if the Instant URL could not be |
| 159 // determined or the active tab is NULL (browser is shutting down). | 162 // determined or the active tab is NULL (browser is shutting down). |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // the user has typed. | 233 // the user has typed. |
| 231 InstantSuggestion last_suggestion_; | 234 InstantSuggestion last_suggestion_; |
| 232 | 235 |
| 233 // See comments on the getter above. | 236 // See comments on the getter above. |
| 234 content::PageTransition last_transition_type_; | 237 content::PageTransition last_transition_type_; |
| 235 | 238 |
| 236 // True if the last match passed to Update() was a search (versus a URL). | 239 // True if the last match passed to Update() was a search (versus a URL). |
| 237 // Used to ensure that the preview page is committable. | 240 // Used to ensure that the preview page is committable. |
| 238 bool last_match_was_search_; | 241 bool last_match_was_search_; |
| 239 | 242 |
| 240 // True if the omnibox is focused, false otherwise. | 243 // Omnibox focus state. |
| 241 bool is_omnibox_focused_; | 244 OmniboxFocusState omnibox_focus_state_; |
| 242 | 245 |
| 243 // The search model mode for the active tab. | 246 // The search model mode for the active tab. |
| 244 chrome::search::Mode search_mode_; | 247 chrome::search::Mode search_mode_; |
| 245 | 248 |
| 246 // Current omnibox bounds. | 249 // Current omnibox bounds. |
| 247 gfx::Rect omnibox_bounds_; | 250 gfx::Rect omnibox_bounds_; |
| 248 | 251 |
| 249 // Last bounds passed to the page. | 252 // Last bounds passed to the page. |
| 250 gfx::Rect last_omnibox_bounds_; | 253 gfx::Rect last_omnibox_bounds_; |
| 251 | 254 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 275 | 278 |
| 276 // Whether to allow the preview to show search suggestions. In general, the | 279 // Whether to allow the preview to show search suggestions. In general, the |
| 277 // preview is allowed to show search suggestions whenever |search_mode_| is | 280 // preview is allowed to show search suggestions whenever |search_mode_| is |
| 278 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 281 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
| 279 bool allow_preview_to_show_search_suggestions_; | 282 bool allow_preview_to_show_search_suggestions_; |
| 280 | 283 |
| 281 DISALLOW_COPY_AND_ASSIGN(InstantController); | 284 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 282 }; | 285 }; |
| 283 | 286 |
| 284 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 287 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |