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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | |
15 | 14 |
16 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
17 #include "base/macros.h" | 16 #include "base/macros.h" |
18 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
19 #include "chrome/browser/ui/search/instant_page.h" | 18 #include "chrome/browser/ui/search/instant_page.h" |
20 #include "chrome/common/search/search_types.h" | 19 #include "chrome/common/search/search_types.h" |
21 #include "ui/gfx/native_widget_types.h" | |
22 | 20 |
23 class BrowserInstantController; | 21 class BrowserInstantController; |
24 class GURL; | 22 class GURL; |
25 class InstantService; | 23 class InstantService; |
26 class InstantTab; | 24 class InstantTab; |
27 class Profile; | 25 class Profile; |
28 struct EmbeddedSearchRequestParams; | 26 struct EmbeddedSearchRequestParams; |
29 | 27 |
30 namespace content { | 28 namespace content { |
31 class WebContents; | 29 class WebContents; |
32 } | 30 } |
33 | 31 |
34 // Macro used for logging debug events. |message| should be a std::string. | |
35 #define LOG_INSTANT_DEBUG_EVENT(controller, message) \ | |
36 controller->LogDebugEvent(message) | |
37 | |
38 // InstantController drives Chrome Instant, i.e., the browser implementation of | 32 // InstantController drives Chrome Instant, i.e., the browser implementation of |
39 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). | 33 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). |
40 // | 34 // |
41 // In extended mode, InstantController maintains and coordinates an InstantTab | 35 // In extended mode, InstantController maintains and coordinates an InstantTab |
42 // instance of InstantPage. An InstantTab instance points to the currently | 36 // instance of InstantPage. An InstantTab instance points to the currently |
43 // active tab, if it supports the Embedded Search API. InstantTab is backed by a | 37 // active tab, if it supports the Embedded Search API. InstantTab is backed by a |
44 // WebContents and it does not own that WebContents. | 38 // WebContents and it does not own that WebContents. |
45 // | 39 // |
46 // InstantController is owned by Browser via BrowserInstantController. | 40 // InstantController is owned by Browser via BrowserInstantController. |
47 class InstantController : public InstantPage::Delegate { | 41 class InstantController : public InstantPage::Delegate { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 DispatchMVChangeEventWhileNavigatingBackToNTP); | 108 DispatchMVChangeEventWhileNavigatingBackToNTP); |
115 | 109 |
116 // Overridden from InstantPage::Delegate: | 110 // Overridden from InstantPage::Delegate: |
117 // TODO(shishir): We assume that the WebContent's current RenderViewHost is | 111 // TODO(shishir): We assume that the WebContent's current RenderViewHost is |
118 // the RenderViewHost being created which is not always true. Fix this. | 112 // the RenderViewHost being created which is not always true. Fix this. |
119 void InstantSupportDetermined(const content::WebContents* contents, | 113 void InstantSupportDetermined(const content::WebContents* contents, |
120 bool supports_instant) override; | 114 bool supports_instant) override; |
121 void InstantPageAboutToNavigateMainFrame(const content::WebContents* contents, | 115 void InstantPageAboutToNavigateMainFrame(const content::WebContents* contents, |
122 const GURL& url) override; | 116 const GURL& url) override; |
123 | 117 |
124 // Helper function to navigate the given contents to the local fallback | |
125 // Instant URL and trim the history correctly. | |
126 void RedirectToLocalNTP(content::WebContents* contents); | |
127 | |
128 // Helper for OmniboxFocusChanged. Commit or discard the overlay. | |
129 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | |
130 | |
131 // If the active tab is an Instant search results page, sets |instant_tab_| to | 118 // If the active tab is an Instant search results page, sets |instant_tab_| to |
132 // point to it. Else, deletes any existing |instant_tab_|. | 119 // point to it. Else, deletes any existing |instant_tab_|. |
133 void ResetInstantTab(); | 120 void ResetInstantTab(); |
134 | 121 |
135 // Sends theme info, omnibox bounds, etc. down to the Instant tab. | 122 // Sends theme info and most visited items to the Instant tab. |
136 void UpdateInfoForInstantTab(); | 123 void UpdateInfoForInstantTab(); |
137 | 124 |
138 // Returns the InstantService for the browser profile. | 125 // Returns the InstantService for the browser profile. |
139 InstantService* GetInstantService() const; | 126 InstantService* GetInstantService() const; |
140 | 127 |
141 BrowserInstantController* const browser_; | 128 BrowserInstantController* const browser_; |
142 | 129 |
143 // The instance of InstantPage maintained by InstantController. | 130 // The instance of InstantPage maintained by InstantController. |
144 std::unique_ptr<InstantTab> instant_tab_; | 131 std::unique_ptr<InstantTab> instant_tab_; |
145 | 132 |
146 // The search model mode for the active tab. | 133 // The search model mode for the active tab. |
147 SearchMode search_mode_; | 134 SearchMode search_mode_; |
148 | 135 |
149 // List of events and their timestamps, useful in debugging Instant behaviour. | 136 // List of events and their timestamps, useful in debugging Instant behaviour. |
150 mutable std::list<std::pair<int64_t, std::string>> debug_events_; | 137 mutable std::list<std::pair<int64_t, std::string>> debug_events_; |
151 | 138 |
152 DISALLOW_COPY_AND_ASSIGN(InstantController); | 139 DISALLOW_COPY_AND_ASSIGN(InstantController); |
153 }; | 140 }; |
154 | 141 |
155 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ | 142 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ |
OLD | NEW |