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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 7 years, 11 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_ntp.h
diff --git a/chrome/browser/instant/instant_ntp.h b/chrome/browser/instant/instant_ntp.h
new file mode 100644
index 0000000000000000000000000000000000000000..f5d55b23003f677544b742dcde76479070513ec6
--- /dev/null
+++ b/chrome/browser/instant/instant_ntp.h
@@ -0,0 +1,84 @@
+// 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_NTP_H_
+#define CHROME_BROWSER_INSTANT_INSTANT_NTP_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/instant/instant_loader.h"
+#include "chrome/browser/instant/instant_page.h"
+
+class InstantController;
+class InstantLoader;
+class Profile;
+struct ThemeBackgroundInfo;
+
+namespace content {
+class WebContents;
+}
+
+// InstantNTP is used to preload an Instant page that will be swapped in when a
+// user navigates to a New Tab Page (NTP). The InstantNTP contents are never
+// shown in an un-committed state.
+class InstantNTP : public InstantPage,
+ public InstantLoader::Delegate {
+ public:
+ // Doesn't take ownership of |controller|.
+ InstantNTP(InstantController* controller, const std::string& instant_url);
+ virtual ~InstantNTP();
+
+ // 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 WebContents for the instant page, passing ownership to the
+ // caller. This should be called when the page is about to be 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_; }
+
+ 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_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantNTP);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_

Powered by Google App Engine
This is Rietveld 408576698