| Index: chrome/browser/instant/instant_overlay.h
|
| diff --git a/chrome/browser/instant/instant_overlay.h b/chrome/browser/instant/instant_overlay.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e60e346e51848355eef6b8a812b1a61fa3f7d385
|
| --- /dev/null
|
| +++ b/chrome/browser/instant/instant_overlay.h
|
| @@ -0,0 +1,118 @@
|
| +// 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_OVERLAY_H_
|
| +#define CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_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_loader.h"
|
| +#include "chrome/browser/instant/instant_page.h"
|
| +
|
| +struct InstantAutocompleteResult;
|
| +class InstantController;
|
| +class Profile;
|
| +struct ThemeBackgroundInfo;
|
| +
|
| +namespace chrome {
|
| +namespace search {
|
| +struct Mode;
|
| +}
|
| +}
|
| +
|
| +namespace content {
|
| +class WebContents;
|
| +}
|
| +
|
| +// InstantOverlay is used to communicate with a preview WebContents that it owns
|
| +// and loads the "Instant URL" into. This preview can appear and disappear at
|
| +// will as the user types in the omnibox (compare: InstantTab, which talks to a
|
| +// committed tab on the tab strip).
|
| +class InstantOverlay : public InstantPage,
|
| + public InstantLoader::Delegate {
|
| + public:
|
| + // Returns the InstantOverlay for |contents| if it's used for Instant.
|
| + static InstantOverlay* FromWebContents(const content::WebContents* contents);
|
| +
|
| + // Doesn't take ownership of |controller|.
|
| + InstantOverlay(InstantController* controller, const std::string& instant_url);
|
| + virtual ~InstantOverlay();
|
| +
|
| + // Creates a new WebContents and loads |instant_url_| into it. Uses
|
| + // |active_tab|, if non-NULL, to initialize the size of the WebContents.
|
| + void InitContents(Profile* profile,
|
| + const content::WebContents* active_tab);
|
| +
|
| + // Overriden from InstantPage.
|
| + virtual content::WebContents* contents() const OVERRIDE {
|
| + return loader_->contents();
|
| + }
|
| +
|
| + // Releases the overlay WebContents passing ownership to the caller. This
|
| + // should be called when the overlay is committed.
|
| + content::WebContents* ReleaseContents() WARN_UNUSED_RESULT;
|
| +
|
| + // Returns the URL that we're loading.
|
| + const std::string& instant_url() const { return instant_url_; }
|
| +
|
| + // Returns whether the underlying contents is stale (i.e. was loaded too long
|
| + // ago).
|
| + bool is_stale() const { return is_stale_; }
|
| +
|
| + // Returns true if the mouse or a touch pointer is down due to activating the
|
| + // preview contents.
|
| + bool is_pointer_down_from_activate() const {
|
| + return is_pointer_down_from_activate_;
|
| + }
|
| +
|
| + // Returns info about the last navigation by the Instant page. If the page
|
| + // hasn't navigated since the last Update(), the URL is empty.
|
| + const history::HistoryAddPageArgs& last_navigation() const {
|
| + return last_navigation_;
|
| + }
|
| +
|
| + // Called by the history tab helper with information that it would have added
|
| + // to the history service had this WebContents not been used for Instant.
|
| + void DidNavigate(const history::HistoryAddPageArgs& add_page_args);
|
| +
|
| + // Returns true if the overlay is using
|
| + // InstantController::kLocalOmniboxPopupURL as the |instant_url_|.
|
| + bool IsUsingLocalPreview() const;
|
| +
|
| + private:
|
| + // Overriden from InstantLoader::Delegate.
|
| + virtual content::WebContents* ReplaceAndReleaseContents(
|
| + content::WebContents* new_contents) OVERRIDE;
|
| + virtual void OnFocus() OVERRIDE;
|
| + virtual bool OnOpenURL() OVERRIDE;
|
| + virtual void SetPointerDown() OVERRIDE;
|
| + virtual void MaybeCommitFromPointerRelease() OVERRIDE;
|
| + virtual void OnStalePage() OVERRIDE;
|
| +
|
| + // Overridden from InstantAPIWrapper::Controller.
|
| + virtual void OnUpdate() OVERRIDE;
|
| + virtual bool OnRenderViewGone() const OVERRIDE;
|
| + virtual bool OnAboutToNavigateMainFrame() const OVERRIDE;
|
| + virtual bool OnSetSuggestions() const OVERRIDE;
|
| + virtual bool OnShowInstantPreview() const OVERRIDE;
|
| + virtual bool OnStartCapturingKeyStrokes() const OVERRIDE;
|
| + virtual bool OnStopCapturingKeyStrokes() const OVERRIDE;
|
| + virtual bool OnNavigateToURL() const OVERRIDE;
|
| +
|
| + scoped_ptr<InstantLoader> loader_;
|
| + const std::string instant_url_;
|
| + bool is_stale_;
|
| + bool is_pointer_down_from_activate_;
|
| + history::HistoryAddPageArgs last_navigation_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(InstantOverlay);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_H_
|
|
|