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

Unified Diff: chrome/browser/instant/instant_client.h

Issue 11421079: Persist the Instant API to committed search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_client.h
diff --git a/chrome/browser/instant/instant_client.h b/chrome/browser/instant/instant_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..65cbdf9a81506656396d7491319fa7ec677f653e
--- /dev/null
+++ b/chrome/browser/instant/instant_client.h
@@ -0,0 +1,89 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_INSTANT_INSTANT_CLIENT_H_
+#define CHROME_BROWSER_INSTANT_INSTANT_CLIENT_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/string16.h"
+#include "content/public/browser/web_contents_observer.h"
+
+struct InstantAutocompleteResult;
+class InstantController;
+struct InstantSuggestion;
+
+namespace content {
+class WebContents;
+}
+
+// InstantClient is used to communicate messages between the InstantController
+// and a page that supports the Instant API (http://dev.chromium.org/searchbox).
+class InstantClient : public content::WebContentsObserver {
+ public:
+ 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.
+ virtual ~InstantClient();
+
+ // Tells the Instant page that the user typed |user_text| into the omnibox. If
+ // |verbatim| is false, the page predicts the query the user means to type and
+ // fetches results for the prediction. If |verbatim| is true, |user_text| is
+ // taken as the exact query (no prediction is made).
+ void Update(const string16& user_text, bool verbatim);
+
+ // Tells the page that the user pressed Enter in the omnibox.
+ void Submit(const string16& text);
+
+ // Tells the page about the available autocomplete results.
+ void SendAutocompleteResults(
+ const std::vector<InstantAutocompleteResult>& results);
+
+ // Tells the page that the user pressed Up or Down in the omnibox. |count| is
+ // a repeat count, negative for moving up, positive for moving down.
+ void UpOrDownKeyPressed(int count);
+
+ // Sends a message to the renderer asking it to determine whether the page
+ // supports the Instant API.
+ void DetermineIfPageSupportsInstant();
sky 2012/11/27 01:07:51 Seem weird that this is public.
sreeram 2012/11/29 07:33:19 Done.
+
+ // Returns true if the page is known to support the Instant API. This starts
+ // out false, and becomes true whenever we get any message from the page. Once
+ // true, it never becomes false (the page isn't expected to drop Instant API
+ // support suddenly).
+ bool supports_instant() const { return supports_instant_; }
+
+ 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
+
+ protected:
+ // Overridden from content::WebContentsObserver:
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // If the |controller_| hasn't already been notified, tells it whether the
+ // 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
+ void NotifyInstantSupportDetermined(bool supports_instant);
+
+ InstantController* const controller_;
sky 2012/11/27 01:07:51 style guide says no protected members.
sreeram 2012/11/29 07:33:19 Done.
+
+ private:
+ // Overridden from content::WebContentsObserver:
+ virtual void DidFinishLoad(
+ int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ content::RenderViewHost* render_view_host) OVERRIDE;
+
+ // Message from the page indicating that it has query suggestions.
+ void OnSetSuggestions(int page_id,
+ const std::vector<InstantSuggestion>& suggestions);
+
+ // 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.
+ void OnInstantSupportDetermined(int page_id, bool result);
+
+ bool supports_instant_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantClient);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698