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 | 14 |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "chrome/browser/ui/search/instant_tab.h" | 18 #include "chrome/browser/ui/search/instant_tab.h" |
19 #include "chrome/common/search/search_types.h" | 19 #include "chrome/common/search/search_types.h" |
20 | 20 |
21 class BrowserInstantController; | 21 class BrowserInstantController; |
22 class GURL; | 22 class GURL; |
23 class InstantService; | 23 class InstantService; |
24 class Profile; | 24 class Profile; |
25 struct EmbeddedSearchRequestParams; | 25 struct EmbeddedSearchRequestParams; |
Peter Kasting
2016/09/02 20:40:59
Nit: This forward-decl is no longer necessary
Marc Treib
2016/09/05 12:11:16
Done.
| |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 class WebContents; | 28 class WebContents; |
29 } | 29 } |
30 | 30 |
31 // InstantController drives Chrome Instant, i.e., the browser implementation of | 31 // InstantController drives Chrome Instant, i.e., the browser implementation of |
32 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). | 32 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). |
33 // | 33 // |
34 // In extended mode, InstantController maintains and coordinates an InstantTab. | 34 // In extended mode, InstantController maintains and coordinates an InstantTab. |
35 // An InstantTab instance points to the currently active tab, if it supports the | 35 // An InstantTab instance points to the currently active tab, if it supports the |
36 // Embedded Search API. InstantTab is backed by a WebContents and it does not | 36 // Embedded Search API. InstantTab is backed by a WebContents and it does not |
37 // own that WebContents. | 37 // own that WebContents. |
38 // | 38 // |
39 // InstantController is owned by Browser via BrowserInstantController. | 39 // InstantController is owned by Browser via BrowserInstantController. |
40 class InstantController : public InstantTab::Delegate { | 40 class InstantController : public InstantTab::Delegate { |
41 public: | 41 public: |
42 explicit InstantController(BrowserInstantController* browser); | 42 explicit InstantController(BrowserInstantController* browser); |
43 ~InstantController() override; | 43 ~InstantController() override; |
44 | 44 |
45 // Called if the browser is navigating to a search URL for |search_terms| with | |
46 // search-term-replacement enabled. If |instant_tab_| can be used to process | |
47 // the search, this does so and returns true. Else, returns false. | |
48 bool SubmitQuery(const base::string16& search_terms, | |
49 const EmbeddedSearchRequestParams& params); | |
50 | |
51 // The search mode in the active tab has changed. Bind |instant_tab_| if the | 45 // The search mode in the active tab has changed. Bind |instant_tab_| if the |
52 // |new_mode| reflects an Instant search results page. | 46 // |new_mode| reflects an Instant search results page. |
53 void SearchModeChanged(const SearchMode& old_mode, | 47 void SearchModeChanged(const SearchMode& old_mode, |
54 const SearchMode& new_mode); | 48 const SearchMode& new_mode); |
55 | 49 |
56 // The user switched tabs. Bind |instant_tab_| if the newly active tab is an | 50 // The user switched tabs. Bind |instant_tab_| if the newly active tab is an |
57 // Instant search results page. | 51 // Instant search results page. |
58 void ActiveTabChanged(); | 52 void ActiveTabChanged(); |
59 | 53 |
60 // Used by BrowserInstantController to notify InstantController about the | 54 // Used by BrowserInstantController to notify InstantController about the |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 // The search model mode for the active tab. | 117 // The search model mode for the active tab. |
124 SearchMode search_mode_; | 118 SearchMode search_mode_; |
125 | 119 |
126 // List of events and their timestamps, useful in debugging Instant behaviour. | 120 // List of events and their timestamps, useful in debugging Instant behaviour. |
127 mutable std::list<std::pair<int64_t, std::string>> debug_events_; | 121 mutable std::list<std::pair<int64_t, std::string>> debug_events_; |
128 | 122 |
129 DISALLOW_COPY_AND_ASSIGN(InstantController); | 123 DISALLOW_COPY_AND_ASSIGN(InstantController); |
130 }; | 124 }; |
131 | 125 |
132 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ | 126 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ |
OLD | NEW |