OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PAGE_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ |
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 struct LoadCommittedDetails; | 26 struct LoadCommittedDetails; |
27 class WebContents; | 27 class WebContents; |
28 } | 28 } |
29 | 29 |
30 namespace gfx { | 30 namespace gfx { |
31 class Rect; | 31 class Rect; |
32 } | 32 } |
33 | 33 |
34 // InstantPage is used to exchange messages with a page that implements the | 34 // InstantPage is used to exchange messages with a page that implements the |
35 // Instant/Embedded Search API (http://dev.chromium.org/embeddedsearch). | 35 // Instant/Embedded Search API (http://dev.chromium.org/embeddedsearch). |
36 // InstantPage is not used directly but via one of its derived classes: | 36 // InstantPage is not used directly but via one of its derived classes, |
37 // InstantOverlay, InstantNTP and InstantTab. | 37 // InstantNTP and InstantTab. |
38 class InstantPage : public content::WebContentsObserver, | 38 class InstantPage : public content::WebContentsObserver, |
39 public SearchModelObserver { | 39 public SearchModelObserver { |
40 public: | 40 public: |
41 // InstantPage calls its delegate in response to messages received from the | 41 // InstantPage calls its delegate in response to messages received from the |
42 // page. Each method is called with the |contents| corresponding to the page | 42 // page. Each method is called with the |contents| corresponding to the page |
43 // we are observing. | 43 // we are observing. |
44 class Delegate { | 44 class Delegate { |
45 public: | 45 public: |
46 // Called when a RenderView is created, so that state can be initialized. | 46 // Called when a RenderView is created, so that state can be initialized. |
47 virtual void InstantPageRenderViewCreated( | 47 virtual void InstantPageRenderViewCreated( |
48 const content::WebContents* contents) = 0; | 48 const content::WebContents* contents) = 0; |
49 | 49 |
50 // Called upon determination of Instant API support. Either in response to | 50 // Called upon determination of Instant API support. Either in response to |
51 // the page loading or because we received some other message. | 51 // the page loading or because we received some other message. |
52 virtual void InstantSupportDetermined(const content::WebContents* contents, | 52 virtual void InstantSupportDetermined(const content::WebContents* contents, |
53 bool supports_instant) = 0; | 53 bool supports_instant) = 0; |
54 | 54 |
55 // Called when the underlying RenderView crashed. | 55 // Called when the underlying RenderView crashed. |
56 virtual void InstantPageRenderViewGone( | 56 virtual void InstantPageRenderViewGone( |
57 const content::WebContents* contents) = 0; | 57 const content::WebContents* contents) = 0; |
58 | 58 |
59 // Called when the page is about to navigate to |url|. | 59 // Called when the page is about to navigate to |url|. |
60 virtual void InstantPageAboutToNavigateMainFrame( | 60 virtual void InstantPageAboutToNavigateMainFrame( |
61 const content::WebContents* contents, | 61 const content::WebContents* contents, |
62 const GURL& url) = 0; | 62 const GURL& url) = 0; |
63 | 63 |
64 // Called when the page has suggestions. Usually in response to Update(), | |
65 // SendAutocompleteResults() or UpOrDownKeyPressed(). | |
66 virtual void SetSuggestions( | |
67 const content::WebContents* contents, | |
68 const std::vector<InstantSuggestion>& suggestions) = 0; | |
69 | |
70 // Called when the page wants to be shown. Usually in response to Update() | |
71 // or SendAutocompleteResults(). | |
72 virtual void ShowInstantOverlay(const content::WebContents* contents, | |
73 int height, | |
74 InstantSizeUnits units) = 0; | |
75 | |
76 // Called when the page shows suggestions for logging purposes, regardless | |
77 // of whether the page is processing the call. | |
78 virtual void LogDropdownShown() = 0; | |
79 | |
80 // Called when the page wants the omnibox to be focused. |state| specifies | 64 // Called when the page wants the omnibox to be focused. |state| specifies |
81 // the omnibox focus state. | 65 // the omnibox focus state. |
82 virtual void FocusOmnibox(const content::WebContents* contents, | 66 virtual void FocusOmnibox(const content::WebContents* contents, |
83 OmniboxFocusState state) = 0; | 67 OmniboxFocusState state) = 0; |
84 | 68 |
85 // Called when the page wants to navigate to |url|. Usually used by the | 69 // Called when the page wants to navigate to |url|. Usually used by the |
86 // page to navigate to privileged destinations (e.g. chrome:// URLs) or to | 70 // page to navigate to privileged destinations (e.g. chrome:// URLs) or to |
87 // navigate to URLs that are hidden from the page using Restricted IDs (rid | 71 // navigate to URLs that are hidden from the page using Restricted IDs (rid |
88 // in the API). | 72 // in the API). |
89 virtual void NavigateToURL(const content::WebContents* contents, | 73 virtual void NavigateToURL(const content::WebContents* contents, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // NULL, which effectively stops all communication. | 126 // NULL, which effectively stops all communication. |
143 void SetContents(content::WebContents* web_contents); | 127 void SetContents(content::WebContents* web_contents); |
144 | 128 |
145 Delegate* delegate() const { return delegate_; } | 129 Delegate* delegate() const { return delegate_; } |
146 | 130 |
147 // These functions are called before processing messages received from the | 131 // These functions are called before processing messages received from the |
148 // page. By default, all messages are handled, but any derived classes may | 132 // page. By default, all messages are handled, but any derived classes may |
149 // choose to ignore some or all of the received messages by overriding these | 133 // choose to ignore some or all of the received messages by overriding these |
150 // methods. | 134 // methods. |
151 virtual bool ShouldProcessAboutToNavigateMainFrame(); | 135 virtual bool ShouldProcessAboutToNavigateMainFrame(); |
152 virtual bool ShouldProcessSetSuggestions(); | |
153 virtual bool ShouldProcessShowInstantOverlay(); | |
154 virtual bool ShouldProcessFocusOmnibox(); | 136 virtual bool ShouldProcessFocusOmnibox(); |
155 virtual bool ShouldProcessNavigateToURL(); | 137 virtual bool ShouldProcessNavigateToURL(); |
156 virtual bool ShouldProcessDeleteMostVisitedItem(); | 138 virtual bool ShouldProcessDeleteMostVisitedItem(); |
157 virtual bool ShouldProcessUndoMostVisitedDeletion(); | 139 virtual bool ShouldProcessUndoMostVisitedDeletion(); |
158 virtual bool ShouldProcessUndoAllMostVisitedDeletions(); | 140 virtual bool ShouldProcessUndoAllMostVisitedDeletions(); |
159 | 141 |
160 private: | 142 private: |
161 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 143 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, |
162 DispatchRequestToDeleteMostVisitedItem); | 144 DispatchRequestToDeleteMostVisitedItem); |
163 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 145 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, |
(...skipping 26 matching lines...) Expand all Loading... |
190 const string16& error_description, | 172 const string16& error_description, |
191 content::RenderViewHost* render_view_host) OVERRIDE; | 173 content::RenderViewHost* render_view_host) OVERRIDE; |
192 | 174 |
193 // Overridden from SearchModelObserver: | 175 // Overridden from SearchModelObserver: |
194 virtual void ModelChanged(const SearchModel::State& old_state, | 176 virtual void ModelChanged(const SearchModel::State& old_state, |
195 const SearchModel::State& new_state) OVERRIDE; | 177 const SearchModel::State& new_state) OVERRIDE; |
196 | 178 |
197 // Update the status of Instant support. | 179 // Update the status of Instant support. |
198 void InstantSupportDetermined(bool supports_instant); | 180 void InstantSupportDetermined(bool supports_instant); |
199 | 181 |
200 void OnSetSuggestions(int page_id, | |
201 const std::vector<InstantSuggestion>& suggestions); | |
202 void OnShowInstantOverlay(int page_id, | |
203 int height, | |
204 InstantSizeUnits units); | |
205 void OnFocusOmnibox(int page_id, OmniboxFocusState state); | 182 void OnFocusOmnibox(int page_id, OmniboxFocusState state); |
206 void OnSearchBoxNavigate(int page_id, | 183 void OnSearchBoxNavigate(int page_id, |
207 const GURL& url, | 184 const GURL& url, |
208 content::PageTransition transition, | 185 content::PageTransition transition, |
209 WindowOpenDisposition disposition, | 186 WindowOpenDisposition disposition, |
210 bool is_search_type); | 187 bool is_search_type); |
211 void OnDeleteMostVisitedItem(int page_id, const GURL& url); | 188 void OnDeleteMostVisitedItem(int page_id, const GURL& url); |
212 void OnUndoMostVisitedDeletion(int page_id, const GURL& url); | 189 void OnUndoMostVisitedDeletion(int page_id, const GURL& url); |
213 void OnUndoAllMostVisitedDeletions(int page_id); | 190 void OnUndoAllMostVisitedDeletions(int page_id); |
214 | 191 |
215 void ClearContents(); | 192 void ClearContents(); |
216 | 193 |
217 Delegate* const delegate_; | 194 Delegate* const delegate_; |
218 scoped_ptr<InstantIPCSender> ipc_sender_; | 195 scoped_ptr<InstantIPCSender> ipc_sender_; |
219 const std::string instant_url_; | 196 const std::string instant_url_; |
220 const bool is_incognito_; | 197 const bool is_incognito_; |
221 | 198 |
222 DISALLOW_COPY_AND_ASSIGN(InstantPage); | 199 DISALLOW_COPY_AND_ASSIGN(InstantPage); |
223 }; | 200 }; |
224 | 201 |
225 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ | 202 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ |
OLD | NEW |