| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ShouldProcessRenderViewCreated(); | 135 virtual bool ShouldProcessRenderViewCreated(); |
| 152 virtual bool ShouldProcessRenderViewGone(); | 136 virtual bool ShouldProcessRenderViewGone(); |
| 153 virtual bool ShouldProcessAboutToNavigateMainFrame(); | 137 virtual bool ShouldProcessAboutToNavigateMainFrame(); |
| 154 virtual bool ShouldProcessSetSuggestions(); | |
| 155 virtual bool ShouldProcessShowInstantOverlay(); | |
| 156 virtual bool ShouldProcessFocusOmnibox(); | 138 virtual bool ShouldProcessFocusOmnibox(); |
| 157 virtual bool ShouldProcessNavigateToURL(); | 139 virtual bool ShouldProcessNavigateToURL(); |
| 158 virtual bool ShouldProcessDeleteMostVisitedItem(); | 140 virtual bool ShouldProcessDeleteMostVisitedItem(); |
| 159 virtual bool ShouldProcessUndoMostVisitedDeletion(); | 141 virtual bool ShouldProcessUndoMostVisitedDeletion(); |
| 160 virtual bool ShouldProcessUndoAllMostVisitedDeletions(); | 142 virtual bool ShouldProcessUndoAllMostVisitedDeletions(); |
| 161 | 143 |
| 162 private: | 144 private: |
| 163 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 145 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, |
| 164 DispatchRequestToDeleteMostVisitedItem); | 146 DispatchRequestToDeleteMostVisitedItem); |
| 165 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 147 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 195 const string16& error_description, | 177 const string16& error_description, |
| 196 content::RenderViewHost* render_view_host) OVERRIDE; | 178 content::RenderViewHost* render_view_host) OVERRIDE; |
| 197 | 179 |
| 198 // Overridden from SearchModelObserver: | 180 // Overridden from SearchModelObserver: |
| 199 virtual void ModelChanged(const SearchModel::State& old_state, | 181 virtual void ModelChanged(const SearchModel::State& old_state, |
| 200 const SearchModel::State& new_state) OVERRIDE; | 182 const SearchModel::State& new_state) OVERRIDE; |
| 201 | 183 |
| 202 // Update the status of Instant support. | 184 // Update the status of Instant support. |
| 203 void InstantSupportDetermined(bool supports_instant); | 185 void InstantSupportDetermined(bool supports_instant); |
| 204 | 186 |
| 205 void OnSetSuggestions(int page_id, | |
| 206 const std::vector<InstantSuggestion>& suggestions); | |
| 207 void OnShowInstantOverlay(int page_id, | |
| 208 int height, | |
| 209 InstantSizeUnits units); | |
| 210 void OnFocusOmnibox(int page_id, OmniboxFocusState state); | 187 void OnFocusOmnibox(int page_id, OmniboxFocusState state); |
| 211 void OnSearchBoxNavigate(int page_id, | 188 void OnSearchBoxNavigate(int page_id, |
| 212 const GURL& url, | 189 const GURL& url, |
| 213 content::PageTransition transition, | 190 content::PageTransition transition, |
| 214 WindowOpenDisposition disposition, | 191 WindowOpenDisposition disposition, |
| 215 bool is_search_type); | 192 bool is_search_type); |
| 216 void OnDeleteMostVisitedItem(int page_id, const GURL& url); | 193 void OnDeleteMostVisitedItem(int page_id, const GURL& url); |
| 217 void OnUndoMostVisitedDeletion(int page_id, const GURL& url); | 194 void OnUndoMostVisitedDeletion(int page_id, const GURL& url); |
| 218 void OnUndoAllMostVisitedDeletions(int page_id); | 195 void OnUndoAllMostVisitedDeletions(int page_id); |
| 219 | 196 |
| 220 void ClearContents(); | 197 void ClearContents(); |
| 221 | 198 |
| 222 Delegate* const delegate_; | 199 Delegate* const delegate_; |
| 223 scoped_ptr<InstantIPCSender> ipc_sender_; | 200 scoped_ptr<InstantIPCSender> ipc_sender_; |
| 224 const std::string instant_url_; | 201 const std::string instant_url_; |
| 225 const bool is_incognito_; | 202 const bool is_incognito_; |
| 226 | 203 |
| 227 DISALLOW_COPY_AND_ASSIGN(InstantPage); | 204 DISALLOW_COPY_AND_ASSIGN(InstantPage); |
| 228 }; | 205 }; |
| 229 | 206 |
| 230 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ | 207 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ |
| OLD | NEW |