| 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_UI_SEARCH_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // | 37 // |
| 38 // In extended mode, InstantController maintains and coordinates an InstantTab | 38 // In extended mode, InstantController maintains and coordinates an InstantTab |
| 39 // instance of InstantPage. An InstantTab instance points to the currently | 39 // instance of InstantPage. An InstantTab instance points to the currently |
| 40 // active tab, if it supports the Embedded Search API. InstantTab is backed by a | 40 // active tab, if it supports the Embedded Search API. InstantTab is backed by a |
| 41 // WebContents and it does not own that WebContents. | 41 // WebContents and it does not own that WebContents. |
| 42 // | 42 // |
| 43 // InstantController is owned by Browser via BrowserInstantController. | 43 // InstantController is owned by Browser via BrowserInstantController. |
| 44 class InstantController : public InstantPage::Delegate { | 44 class InstantController : public InstantPage::Delegate { |
| 45 public: | 45 public: |
| 46 explicit InstantController(BrowserInstantController* browser); | 46 explicit InstantController(BrowserInstantController* browser); |
| 47 virtual ~InstantController(); | 47 ~InstantController() override; |
| 48 | 48 |
| 49 // Called if the browser is navigating to a search URL for |search_terms| with | 49 // Called if the browser is navigating to a search URL for |search_terms| with |
| 50 // search-term-replacement enabled. If |instant_tab_| can be used to process | 50 // search-term-replacement enabled. If |instant_tab_| can be used to process |
| 51 // the search, this does so and returns true. Else, returns false. | 51 // the search, this does so and returns true. Else, returns false. |
| 52 bool SubmitQuery(const base::string16& search_terms); | 52 bool SubmitQuery(const base::string16& search_terms); |
| 53 | 53 |
| 54 // The search mode in the active tab has changed. Bind |instant_tab_| if the | 54 // The search mode in the active tab has changed. Bind |instant_tab_| if the |
| 55 // |new_mode| reflects an Instant search results page. | 55 // |new_mode| reflects an Instant search results page. |
| 56 void SearchModeChanged(const SearchMode& old_mode, | 56 void SearchModeChanged(const SearchMode& old_mode, |
| 57 const SearchMode& new_mode); | 57 const SearchMode& new_mode); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, | 107 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, |
| 108 SearchDoesntReuseInstantTabWithoutSupport); | 108 SearchDoesntReuseInstantTabWithoutSupport); |
| 109 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, | 109 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, |
| 110 TypedSearchURLDoesntReuseInstantTab); | 110 TypedSearchURLDoesntReuseInstantTab); |
| 111 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, | 111 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, |
| 112 DispatchMVChangeEventWhileNavigatingBackToNTP); | 112 DispatchMVChangeEventWhileNavigatingBackToNTP); |
| 113 | 113 |
| 114 // Overridden from InstantPage::Delegate: | 114 // Overridden from InstantPage::Delegate: |
| 115 // TODO(shishir): We assume that the WebContent's current RenderViewHost is | 115 // TODO(shishir): We assume that the WebContent's current RenderViewHost is |
| 116 // the RenderViewHost being created which is not always true. Fix this. | 116 // the RenderViewHost being created which is not always true. Fix this. |
| 117 virtual void InstantSupportDetermined( | 117 void InstantSupportDetermined(const content::WebContents* contents, |
| 118 const content::WebContents* contents, | 118 bool supports_instant) override; |
| 119 bool supports_instant) override; | 119 void InstantPageAboutToNavigateMainFrame(const content::WebContents* contents, |
| 120 virtual void InstantPageAboutToNavigateMainFrame( | 120 const GURL& url) override; |
| 121 const content::WebContents* contents, | |
| 122 const GURL& url) override; | |
| 123 | 121 |
| 124 // Helper function to navigate the given contents to the local fallback | 122 // Helper function to navigate the given contents to the local fallback |
| 125 // Instant URL and trim the history correctly. | 123 // Instant URL and trim the history correctly. |
| 126 void RedirectToLocalNTP(content::WebContents* contents); | 124 void RedirectToLocalNTP(content::WebContents* contents); |
| 127 | 125 |
| 128 // Helper for OmniboxFocusChanged. Commit or discard the overlay. | 126 // Helper for OmniboxFocusChanged. Commit or discard the overlay. |
| 129 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | 127 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
| 130 | 128 |
| 131 // If the active tab is an Instant search results page, sets |instant_tab_| to | 129 // If the active tab is an Instant search results page, sets |instant_tab_| to |
| 132 // point to it. Else, deletes any existing |instant_tab_|. | 130 // point to it. Else, deletes any existing |instant_tab_|. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 146 // The search model mode for the active tab. | 144 // The search model mode for the active tab. |
| 147 SearchMode search_mode_; | 145 SearchMode search_mode_; |
| 148 | 146 |
| 149 // List of events and their timestamps, useful in debugging Instant behaviour. | 147 // List of events and their timestamps, useful in debugging Instant behaviour. |
| 150 mutable std::list<std::pair<int64, std::string> > debug_events_; | 148 mutable std::list<std::pair<int64, std::string> > debug_events_; |
| 151 | 149 |
| 152 DISALLOW_COPY_AND_ASSIGN(InstantController); | 150 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 153 }; | 151 }; |
| 154 | 152 |
| 155 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ | 153 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ |
| OLD | NEW |