Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CLIENT_H_ | |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_CLIENT_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/string16.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 | |
| 15 struct InstantAutocompleteResult; | |
| 16 class InstantController; | |
| 17 struct InstantSuggestion; | |
| 18 | |
| 19 namespace content { | |
| 20 class WebContents; | |
| 21 } | |
| 22 | |
| 23 // InstantClient is used to communicate messages between the InstantController | |
| 24 // and a page that supports the Instant API (http://dev.chromium.org/searchbox). | |
| 25 class InstantClient : public content::WebContentsObserver { | |
| 26 public: | |
| 27 InstantClient(InstantController* controller, content::WebContents* contents); | |
|
samarth
2012/11/27 18:09:43
Comment either here for below (where the member is
sreeram
2012/11/29 07:33:19
Done.
| |
| 28 virtual ~InstantClient(); | |
| 29 | |
| 30 // Tells the Instant page that the user typed |user_text| into the omnibox. If | |
| 31 // |verbatim| is false, the page predicts the query the user means to type and | |
| 32 // fetches results for the prediction. If |verbatim| is true, |user_text| is | |
| 33 // taken as the exact query (no prediction is made). | |
| 34 void Update(const string16& user_text, bool verbatim); | |
| 35 | |
| 36 // Tells the page that the user pressed Enter in the omnibox. | |
| 37 void Submit(const string16& text); | |
| 38 | |
| 39 // Tells the page about the available autocomplete results. | |
| 40 void SendAutocompleteResults( | |
| 41 const std::vector<InstantAutocompleteResult>& results); | |
| 42 | |
| 43 // Tells the page that the user pressed Up or Down in the omnibox. |count| is | |
| 44 // a repeat count, negative for moving up, positive for moving down. | |
| 45 void UpOrDownKeyPressed(int count); | |
| 46 | |
| 47 // Sends a message to the renderer asking it to determine whether the page | |
| 48 // supports the Instant API. | |
| 49 void DetermineIfPageSupportsInstant(); | |
|
sky
2012/11/27 01:07:51
Seem weird that this is public.
sreeram
2012/11/29 07:33:19
Done.
| |
| 50 | |
| 51 // Returns true if the page is known to support the Instant API. This starts | |
| 52 // out false, and becomes true whenever we get any message from the page. Once | |
| 53 // true, it never becomes false (the page isn't expected to drop Instant API | |
| 54 // support suddenly). | |
| 55 bool supports_instant() const { return supports_instant_; } | |
| 56 | |
| 57 content::WebContents* contents() const { return web_contents(); } | |
|
sky
2012/11/27 01:07:51
nit: one of:
const content::WebContents* contents
sreeram
2012/11/29 07:33:19
I don't understand this rule. Are you saying that
| |
| 58 | |
| 59 protected: | |
| 60 // Overridden from content::WebContentsObserver: | |
| 61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 62 | |
| 63 // If the |controller_| hasn't already been notified, tells it whether the | |
| 64 // page supports the Instant API. | |
|
sky
2012/11/27 01:07:51
You should also add a comment that once invoked wi
sreeram
2012/11/29 07:33:19
I've moved this stuff into private sections now, a
| |
| 65 void NotifyInstantSupportDetermined(bool supports_instant); | |
| 66 | |
| 67 InstantController* const controller_; | |
|
sky
2012/11/27 01:07:51
style guide says no protected members.
sreeram
2012/11/29 07:33:19
Done.
| |
| 68 | |
| 69 private: | |
| 70 // Overridden from content::WebContentsObserver: | |
| 71 virtual void DidFinishLoad( | |
| 72 int64 frame_id, | |
| 73 const GURL& validated_url, | |
| 74 bool is_main_frame, | |
| 75 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 76 | |
| 77 // Message from the page indicating that it has query suggestions. | |
| 78 void OnSetSuggestions(int page_id, | |
| 79 const std::vector<InstantSuggestion>& suggestions); | |
| 80 | |
| 81 // Message from the page determining whether it supports the Instant API. | |
|
Jered
2012/11/27 18:19:53
determining -> indicating
sreeram
2012/11/29 07:33:19
Removed. No longer applicable.
| |
| 82 void OnInstantSupportDetermined(int page_id, bool result); | |
| 83 | |
| 84 bool supports_instant_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(InstantClient); | |
| 87 }; | |
| 88 | |
| 89 #endif // CHROME_BROWSER_INSTANT_INSTANT_CLIENT_H_ | |
| OLD | NEW |