| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const std::vector<AutocompleteProvider*>& providers); | 70 const std::vector<AutocompleteProvider*>& providers); |
| 71 | 71 |
| 72 // Called when the user presses up or down. |count| is a repeat count, | 72 // Called when the user presses up or down. |count| is a repeat count, |
| 73 // negative for moving up, positive for moving down. Returns true if Instant | 73 // negative for moving up, positive for moving down. Returns true if Instant |
| 74 // handled the key press. | 74 // handled the key press. |
| 75 bool OnUpOrDownKeyPressed(int count); | 75 bool OnUpOrDownKeyPressed(int count); |
| 76 | 76 |
| 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 is in search mode and can be committed. |
| 81 bool IsCurrent() const; | 81 bool IsCurrentSearch() const; |
| 82 | 82 |
| 83 // If the preview is showing search results, commits the preview, calling | 83 // If the preview is showing search results, or navigating, commits the |
| 84 // CommitInstant() on the browser, and returns true. Else, returns false. | 84 // preview, calling CommitInstant() on the browser, and returns true. Else, |
| 85 // returns false. |
| 85 bool CommitIfCurrent(InstantCommitType type); | 86 bool CommitIfCurrent(InstantCommitType type); |
| 86 | 87 |
| 87 // The omnibox has lost focus. Commit or discard the preview accordingly. | 88 // The omnibox has lost focus. Commit or discard the preview accordingly. |
| 88 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | 89 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
| 89 | 90 |
| 90 // The omnibox has gained focus. Preload the default search engine, in | 91 // The omnibox has gained focus. Preload the default search engine, in |
| 91 // anticipation of the user typing a query. | 92 // anticipation of the user typing a query. |
| 92 void OmniboxGotFocus(); | 93 void OmniboxGotFocus(); |
| 93 | 94 |
| 94 // The search mode in the active tab has changed. Pass the message down to | 95 // The search mode in the active tab has changed. Pass the message down to |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // the preview, usually because a prerendered page was navigated to. | 139 // the preview, usually because a prerendered page was navigated to. |
| 139 void SwappedWebContents(); | 140 void SwappedWebContents(); |
| 140 | 141 |
| 141 // Invoked by InstantLoader when the preview gains focus, usually due to the | 142 // Invoked by InstantLoader when the preview gains focus, usually due to the |
| 142 // user clicking on it. | 143 // user clicking on it. |
| 143 void InstantLoaderContentsFocused(); | 144 void InstantLoaderContentsFocused(); |
| 144 | 145 |
| 145 // Invoked by the InstantLoader when its RenderView crashes. | 146 // Invoked by the InstantLoader when its RenderView crashes. |
| 146 void InstantLoaderRenderViewGone(); | 147 void InstantLoaderRenderViewGone(); |
| 147 | 148 |
| 149 // Invoked by InstantLoader when the instant page is about to navigate. |
| 150 void InstantLoaderAboutToNavigateMainFrame(const GURL& url); |
| 151 |
| 148 private: | 152 private: |
| 149 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | 153 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); |
| 150 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | 154 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); |
| 151 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); | 155 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); |
| 152 | 156 |
| 153 // Creates a new loader if necessary, using the instant_url property of the | 157 // 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 | 158 // |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 | 159 // time the loader was created). Returns false if the |template_url| doesn't |
| 156 // have a valid Instant URL; true otherwise. | 160 // have a valid Instant URL; true otherwise. |
| 157 bool ResetLoader(const TemplateURL* template_url, | 161 bool ResetLoader(const TemplateURL* template_url, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 283 |
| 280 // Whether to allow the preview to show search suggestions. In general, the | 284 // Whether to allow the preview to show search suggestions. In general, the |
| 281 // preview is allowed to show search suggestions whenever |search_mode_| is | 285 // preview is allowed to show search suggestions whenever |search_mode_| is |
| 282 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 286 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
| 283 bool allow_preview_to_show_search_suggestions_; | 287 bool allow_preview_to_show_search_suggestions_; |
| 284 | 288 |
| 285 DISALLOW_COPY_AND_ASSIGN(InstantController); | 289 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 286 }; | 290 }; |
| 287 | 291 |
| 288 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 292 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |