| Index: chrome/browser/instant/instant_loader.h
|
| diff --git a/chrome/browser/instant/instant_loader.h b/chrome/browser/instant/instant_loader.h
|
| index 10a4e79880c92a3bc4e1062ed89ca7ff0e8760cd..901749a6b7289363ba1660ad65dafe85d53dddfb 100644
|
| --- a/chrome/browser/instant/instant_loader.h
|
| +++ b/chrome/browser/instant/instant_loader.h
|
| @@ -6,21 +6,18 @@
|
| #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_
|
|
|
| #include <string>
|
| -#include <vector>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "base/string16.h"
|
| #include "chrome/browser/history/history_types.h"
|
| -#include "chrome/browser/instant/instant_commit_type.h"
|
| +#include "chrome/browser/instant/instant_client.h"
|
| +#include "chrome/common/instant_types.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_registrar.h"
|
|
|
| -struct InstantAutocompleteResult;
|
| class InstantController;
|
| class TabContents;
|
| -struct ThemeBackgroundInfo;
|
|
|
| namespace chrome {
|
| namespace search {
|
| @@ -36,12 +33,12 @@ namespace gfx {
|
| class Rect;
|
| }
|
|
|
| -// InstantLoader is created with an "Instant URL". It loads the URL and tells
|
| -// the InstantController of all interesting events. For example, it determines
|
| -// if the page supports the Instant API (http://dev.chromium.org/searchbox) and
|
| -// forwards messages (such as queries and autocomplete suggestions) between the
|
| -// page and the controller.
|
| -class InstantLoader : public content::NotificationObserver {
|
| +// InstantLoader is an InstantClient that talks to a preview WebContents that it
|
| +// owns and that it has loaded the "Instant URL" into. Since this preview can
|
| +// appear and disappear at will, it supports a richer set of functionality than
|
| +// the barebones InstantClient.
|
| +class InstantLoader : public InstantClient,
|
| + public content::NotificationObserver {
|
| public:
|
| // Returns the Instant loader for |web_contents| if it's used for Instant.
|
| static InstantLoader* FromWebContents(content::WebContents* web_contents);
|
| @@ -59,31 +56,20 @@ class InstantLoader : public content::NotificationObserver {
|
| // Initializes |preview_contents_| and loads |instant_url_|.
|
| void Init();
|
|
|
| - // Tells the preview 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 clicked on it.
|
| + void Cancel(const string16& text);
|
|
|
| // Tells the preview page of the bounds of the omnibox dropdown (in screen
|
| // coordinates). This is used by the page to offset the results to avoid them
|
| // being covered by the omnibox dropdown.
|
| void SetOmniboxBounds(const gfx::Rect& bounds);
|
|
|
| - // Tells the preview page about the available autocomplete results.
|
| - void SendAutocompleteResults(
|
| - const std::vector<InstantAutocompleteResult>& results);
|
| -
|
| // Tells the preview page about the current theme background.
|
| void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info);
|
|
|
| // Tells the preview page about the current theme area height.
|
| void SendThemeAreaHeight(int height);
|
|
|
| - // Tells the preview page that the user pressed the up or down key. |count|
|
| - // is a repeat count, negative for moving up, positive for moving down.
|
| - void OnUpOrDownKeyPressed(int count);
|
| -
|
| // Tells the preview page that the active tab's search mode has changed.
|
| void SearchModeChanged(const chrome::search::Mode& mode);
|
|
|
| @@ -92,28 +78,22 @@ class InstantLoader : public content::NotificationObserver {
|
| // Instant.
|
| void DidNavigate(const history::HistoryAddPageArgs& add_page_args);
|
|
|
| + // The preview TabContents. The loader retains ownership. This will be
|
| + // non-NULL until release_preview_contents() is called.
|
| + TabContents* preview_contents() const { return preview_contents_.get(); }
|
| +
|
| // Releases the preview TabContents passing ownership to the caller. This
|
| - // should be called when the preview is committed. Notifies the page but not
|
| - // the controller. |text| is the final omnibox text being committed. NOTE: The
|
| - // caller should destroy this loader object right after this method, since
|
| - // none of the other methods will work once the preview has been released.
|
| - TabContents* ReleasePreviewContents(InstantCommitType type,
|
| - const string16& text) WARN_UNUSED_RESULT;
|
| + // should be called when the preview is committed. NOTE: caller should destroy
|
| + // this loader object right after this method, since none of the other methods
|
| + // will work once the preview has been released.
|
| + TabContents* release_preview_contents() WARN_UNUSED_RESULT {
|
| + return preview_contents_.release();
|
| + }
|
|
|
| // Severs delegate and observer connections, resets popup blocking, etc., on
|
| // the |preview_contents_|.
|
| void CleanupPreviewContents();
|
|
|
| - // The preview TabContents. The loader retains ownership. This will be
|
| - // non-NULL until ReleasePreviewContents() is called.
|
| - TabContents* preview_contents() const { return preview_contents_.get(); }
|
| -
|
| - // Returns true if the preview 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_; }
|
| -
|
| // Returns the URL that we're loading.
|
| const std::string& instant_url() const { return instant_url_; }
|
|
|
| @@ -130,6 +110,9 @@ class InstantLoader : public content::NotificationObserver {
|
| private:
|
| class WebContentsDelegateImpl;
|
|
|
| + // Overridden from InstantClient:
|
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
| +
|
| // Overridden from content::NotificationObserver:
|
| virtual void Observe(int type,
|
| const content::NotificationSource& source,
|
| @@ -139,7 +122,11 @@ class InstantLoader : public content::NotificationObserver {
|
| void ReplacePreviewContents(content::WebContents* old_contents,
|
| content::WebContents* new_contents);
|
|
|
| - InstantController* const controller_;
|
| + // Message from the renderer requesting the preview be shown.
|
| + void OnShowInstantPreview(int page_id,
|
| + InstantShownReason reason,
|
| + int height,
|
| + InstantSizeUnits units);
|
|
|
| // Delegate of the preview WebContents. Used when the user does some gesture
|
| // on the WebContents and it needs to be activated. This MUST be defined above
|
| @@ -150,9 +137,6 @@ class InstantLoader : public content::NotificationObserver {
|
| scoped_ptr<TabContents> preview_contents_;
|
|
|
| // See comments on the getter above.
|
| - bool supports_instant_;
|
| -
|
| - // See comments on the getter above.
|
| const std::string instant_url_;
|
|
|
| // Used to get notifications about renderers coming and going.
|
|
|