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

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

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_overlay.h
diff --git a/chrome/browser/instant/instant_overlay.h b/chrome/browser/instant/instant_overlay.h
index b380554f0a440acaf06f6fa3e305a6be2cb30d2c..254777c13430ff0418dafae1adf0aa6c5c5a3d21 100644
--- a/chrome/browser/instant/instant_overlay.h
+++ b/chrome/browser/instant/instant_overlay.h
@@ -5,51 +5,34 @@
#ifndef CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_H_
#define CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_H_
-#include <string>
-
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/instant/instant_controller.h"
-#include "chrome/browser/instant/instant_loader.h"
-#include "chrome/browser/instant/instant_page.h"
+#include "chrome/browser/instant/instant_web_contents_container.h"
-class Profile;
+class InstantController;
+class InstantPage;
+class InstantService;
namespace content {
class WebContents;
}
-// InstantOverlay is used to communicate with an overlay WebContents that it
-// owns and loads the "Instant URL" into. This overlay can appear and disappear
-// at will as the user types in the omnibox.
-class InstantOverlay : public InstantPage,
- public InstantLoader::Delegate {
+// InstantOverlay represents an overlay WebContents that shows a preview of
+// search results. This overlay can appear and disappear at will as the user
+// types into the omnibox. It may be "committed" (merged into a tab).
+class InstantOverlay : public InstantWebContentsContainer {
public:
- // Returns the InstantOverlay for |contents| if it's used for Instant.
- static InstantOverlay* FromWebContents(const content::WebContents* contents);
-
InstantOverlay(InstantController* controller,
- const std::string& instant_url);
+ InstantService* service,
+ scoped_ptr<content::WebContents> contents);
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);
+ InstantPage* page() { return &page_; }
// Releases the overlay WebContents. This should be called when the overlay
// is committed.
- scoped_ptr<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_; }
+ scoped_ptr<content::WebContents> ReleaseContents();
// Returns true if the mouse or a touch pointer is down due to activating the
// overlay contents.
@@ -57,59 +40,24 @@ class InstantOverlay : public InstantPage,
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 IsUsingLocalOverlay() const;
-
- // Overridden from InstantPage:
- virtual void Update(const string16& text,
- size_t selection_start,
- size_t selection_end,
- bool verbatim) OVERRIDE;
-
private:
- FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefresh);
-
- // Helper to access delegate() as an InstantController object.
- InstantController* instant_controller() const {
- return static_cast<InstantController*>(delegate());
- }
-
- // Overridden from InstantPage:
- virtual bool ShouldProcessRenderViewCreated() OVERRIDE;
- virtual bool ShouldProcessRenderViewGone() OVERRIDE;
- virtual bool ShouldProcessAboutToNavigateMainFrame() OVERRIDE;
- virtual bool ShouldProcessSetSuggestions() OVERRIDE;
- virtual bool ShouldProcessShowInstantOverlay() OVERRIDE;
- virtual bool ShouldProcessNavigateToURL() OVERRIDE;
-
- // Overriden from InstantLoader::Delegate:
- virtual void OnSwappedContents() OVERRIDE;
- virtual void OnFocus() OVERRIDE;
- virtual void OnMouseDown() OVERRIDE;
- virtual void OnMouseUp() OVERRIDE;
+ // Overridden from InstantWebContentsContainer:
+ virtual void SwapTabContents(content::WebContents* old_contents,
+ content::WebContents* new_contents) OVERRIDE;
virtual content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE;
-
- // Called when the underlying page becomes stale.
- void HandleStalePage();
-
- InstantLoader loader_;
- const std::string instant_url_;
- bool is_stale_;
+ virtual void CloseContents(content::WebContents* source) OVERRIDE;
+ virtual void LostCapture() OVERRIDE;
+ virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
+ virtual void HandleMouseDown() OVERRIDE;
+ virtual void HandleMouseUp() OVERRIDE;
+ virtual void HandlePointerActivate() OVERRIDE;
+ virtual void HandleGestureEnd() OVERRIDE;
+ virtual void DragEnded() OVERRIDE;
+
+ InstantController* const controller_;
bool is_pointer_down_from_activate_;
- history::HistoryAddPageArgs last_navigation_;
DISALLOW_COPY_AND_ASSIGN(InstantOverlay);
};

Powered by Google App Engine
This is Rietveld 408576698