Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: chrome/browser/ui/search/instant_page.h

Issue 17132011: Add setVoiceSearchSupported to the searchbox API. This will be used to determine whether to show a … (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Move listener to SearchTabHelper. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "chrome/browser/ui/search/search_model_observer.h"
14 #include "chrome/common/instant_types.h" 15 #include "chrome/common/instant_types.h"
15 #include "chrome/common/omnibox_focus_state.h" 16 #include "chrome/common/omnibox_focus_state.h"
16 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/common/page_transition_types.h" 18 #include "content/public/common/page_transition_types.h"
18 19
19 class GURL; 20 class GURL;
20 21
21 namespace content { 22 namespace content {
22 struct FrameNavigateParams; 23 struct FrameNavigateParams;
23 struct LoadCommittedDetails; 24 struct LoadCommittedDetails;
24 class WebContents; 25 class WebContents;
25 } 26 }
26 27
27 namespace gfx { 28 namespace gfx {
28 class Rect; 29 class Rect;
29 } 30 }
30 31
31 // InstantPage is used to exchange messages with a page that implements the 32 // InstantPage is used to exchange messages with a page that implements the
32 // Instant/Embedded Search API (http://dev.chromium.org/embeddedsearch). 33 // Instant/Embedded Search API (http://dev.chromium.org/embeddedsearch).
33 // InstantPage is not used directly but via one of its derived classes: 34 // InstantPage is not used directly but via one of its derived classes:
34 // InstantOverlay, InstantNTP and InstantTab. 35 // InstantOverlay, InstantNTP and InstantTab.
35 class InstantPage : public content::WebContentsObserver { 36 class InstantPage : public content::WebContentsObserver,
37 public SearchModelObserver {
36 public: 38 public:
37 // InstantPage calls its delegate in response to messages received from the 39 // InstantPage calls its delegate in response to messages received from the
38 // page. Each method is called with the |contents| corresponding to the page 40 // page. Each method is called with the |contents| corresponding to the page
39 // we are observing. 41 // we are observing.
40 class Delegate { 42 class Delegate {
41 public: 43 public:
42 // Called when a RenderView is created, so that state can be initialized. 44 // Called when a RenderView is created, so that state can be initialized.
43 virtual void InstantPageRenderViewCreated( 45 virtual void InstantPageRenderViewCreated(
44 const content::WebContents* contents) = 0; 46 const content::WebContents* contents) = 0;
45 47
(...skipping 10 matching lines...) Expand all
56 virtual void InstantPageAboutToNavigateMainFrame( 58 virtual void InstantPageAboutToNavigateMainFrame(
57 const content::WebContents* contents, 59 const content::WebContents* contents,
58 const GURL& url) = 0; 60 const GURL& url) = 0;
59 61
60 // Called when the page has suggestions. Usually in response to Update(), 62 // Called when the page has suggestions. Usually in response to Update(),
61 // SendAutocompleteResults() or UpOrDownKeyPressed(). 63 // SendAutocompleteResults() or UpOrDownKeyPressed().
62 virtual void SetSuggestions( 64 virtual void SetSuggestions(
63 const content::WebContents* contents, 65 const content::WebContents* contents,
64 const std::vector<InstantSuggestion>& suggestions) = 0; 66 const std::vector<InstantSuggestion>& suggestions) = 0;
65 67
68 // Called upon determination of whether the page supports voice search.
69 virtual void SetVoiceSearchSupported(const content::WebContents* contents,
70 bool supported) = 0;
71
66 // Called when the page wants to be shown. Usually in response to Update() 72 // Called when the page wants to be shown. Usually in response to Update()
67 // or SendAutocompleteResults(). 73 // or SendAutocompleteResults().
68 virtual void ShowInstantOverlay(const content::WebContents* contents, 74 virtual void ShowInstantOverlay(const content::WebContents* contents,
69 int height, 75 int height,
70 InstantSizeUnits units) = 0; 76 InstantSizeUnits units) = 0;
71 77
72 // Called when the page shows suggestions for logging purposes, regardless 78 // Called when the page shows suggestions for logging purposes, regardless
73 // of whether the page is processing the call. 79 // of whether the page is processing the call.
74 virtual void LogDropdownShown() = 0; 80 virtual void LogDropdownShown() = 0;
75 81
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Tells the page about new Most Visited data. 203 // Tells the page about new Most Visited data.
198 void SendMostVisitedItems( 204 void SendMostVisitedItems(
199 const std::vector<InstantMostVisitedItem>& items); 205 const std::vector<InstantMostVisitedItem>& items);
200 206
201 // Tells the page to toggle voice search. 207 // Tells the page to toggle voice search.
202 void ToggleVoiceSearch(); 208 void ToggleVoiceSearch();
203 209
204 protected: 210 protected:
205 InstantPage(Delegate* delegate, const std::string& instant_url); 211 InstantPage(Delegate* delegate, const std::string& instant_url);
206 212
207 // Sets |contents| as the page to communicate with. |contents| may be NULL, 213 // Sets |web_contents| as the page to communicate with. |web_contents| may be
208 // which effectively stops all communication. 214 // NULL, which effectively stops all communication.
209 void SetContents(content::WebContents* contents); 215 void SetContents(content::WebContents* web_contents);
210 216
211 Delegate* delegate() const { return delegate_; } 217 Delegate* delegate() const { return delegate_; }
212 218
213 // These functions are called before processing messages received from the 219 // These functions are called before processing messages received from the
214 // page. By default, all messages are handled, but any derived classes may 220 // page. By default, all messages are handled, but any derived classes may
215 // choose to ignore some or all of the received messages by overriding these 221 // choose to ignore some or all of the received messages by overriding these
216 // methods. 222 // methods.
217 virtual bool ShouldProcessRenderViewCreated(); 223 virtual bool ShouldProcessRenderViewCreated();
218 virtual bool ShouldProcessRenderViewGone(); 224 virtual bool ShouldProcessRenderViewGone();
219 virtual bool ShouldProcessAboutToNavigateMainFrame(); 225 virtual bool ShouldProcessAboutToNavigateMainFrame();
220 virtual bool ShouldProcessSetSuggestions(); 226 virtual bool ShouldProcessSetSuggestions();
227 virtual bool ShouldProcessSetVoiceSearchSupported();
221 virtual bool ShouldProcessShowInstantOverlay(); 228 virtual bool ShouldProcessShowInstantOverlay();
222 virtual bool ShouldProcessFocusOmnibox(); 229 virtual bool ShouldProcessFocusOmnibox();
223 virtual bool ShouldProcessNavigateToURL(); 230 virtual bool ShouldProcessNavigateToURL();
224 virtual bool ShouldProcessDeleteMostVisitedItem(); 231 virtual bool ShouldProcessDeleteMostVisitedItem();
225 virtual bool ShouldProcessUndoMostVisitedDeletion(); 232 virtual bool ShouldProcessUndoMostVisitedDeletion();
226 virtual bool ShouldProcessUndoAllMostVisitedDeletions(); 233 virtual bool ShouldProcessUndoAllMostVisitedDeletions();
227 234
228 private: 235 private:
229 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 236 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
230 DispatchRequestToDeleteMostVisitedItem); 237 DispatchRequestToDeleteMostVisitedItem);
(...skipping 25 matching lines...) Expand all
256 virtual void DidNavigateMainFrame( 263 virtual void DidNavigateMainFrame(
257 const content::LoadCommittedDetails& details, 264 const content::LoadCommittedDetails& details,
258 const content::FrameNavigateParams& params) OVERRIDE; 265 const content::FrameNavigateParams& params) OVERRIDE;
259 virtual void DidFailProvisionalLoad( 266 virtual void DidFailProvisionalLoad(
260 int64 frame_id, 267 int64 frame_id,
261 bool is_main_frame, 268 bool is_main_frame,
262 const GURL& validated_url, 269 const GURL& validated_url,
263 int error_code, 270 int error_code,
264 const string16& error_description, 271 const string16& error_description,
265 content::RenderViewHost* render_view_host) OVERRIDE; 272 content::RenderViewHost* render_view_host) OVERRIDE;
273 // Overridden from SearchModelObserver:
274 virtual void ModelChanged(const SearchModel::State& old_state,
275 const SearchModel::State& new_state) OVERRIDE;
276
277 // Helper to look up the SearchModel for this page.
278 SearchModel* GetSearchModel();
266 279
267 void OnSetSuggestions(int page_id, 280 void OnSetSuggestions(int page_id,
268 const std::vector<InstantSuggestion>& suggestions); 281 const std::vector<InstantSuggestion>& suggestions);
282 void OnSetVoiceSearchSupported(int page_id, bool supported);
269 void OnInstantSupportDetermined(int page_id, bool supports_instant); 283 void OnInstantSupportDetermined(int page_id, bool supports_instant);
270 void OnShowInstantOverlay(int page_id, 284 void OnShowInstantOverlay(int page_id,
271 int height, 285 int height,
272 InstantSizeUnits units); 286 InstantSizeUnits units);
273 void OnFocusOmnibox(int page_id, OmniboxFocusState state); 287 void OnFocusOmnibox(int page_id, OmniboxFocusState state);
274 void OnSearchBoxNavigate(int page_id, 288 void OnSearchBoxNavigate(int page_id,
275 const GURL& url, 289 const GURL& url,
276 content::PageTransition transition, 290 content::PageTransition transition,
277 WindowOpenDisposition disposition, 291 WindowOpenDisposition disposition,
278 bool is_search_type); 292 bool is_search_type);
279 void OnDeleteMostVisitedItem(int page_id, const GURL& url); 293 void OnDeleteMostVisitedItem(int page_id, const GURL& url);
280 void OnUndoMostVisitedDeletion(int page_id, const GURL& url); 294 void OnUndoMostVisitedDeletion(int page_id, const GURL& url);
281 void OnUndoAllMostVisitedDeletions(int page_id); 295 void OnUndoAllMostVisitedDeletions(int page_id);
282 296
283 Delegate* const delegate_; 297 Delegate* const delegate_;
284 const std::string instant_url_; 298 const std::string instant_url_;
285 bool supports_instant_; 299 bool supports_instant_;
286 bool instant_support_determined_; 300 bool instant_support_determined_;
287 301
288 DISALLOW_COPY_AND_ASSIGN(InstantPage); 302 DISALLOW_COPY_AND_ASSIGN(InstantPage);
289 }; 303 };
290 304
291 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ 305 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698