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

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: Address comments. 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..f7387c266f5640d77e05bee79a66c30063828345
--- /dev/null
+++ b/chrome/browser/instant/instant_ntp.h
@@ -0,0 +1,65 @@
+// Copyright 2013 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 "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 Profile;
+
+// 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:
+ InstantNTP(InstantPage::Delegate* delegate, 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.
+ // |on_stale_callback| will be called when |loader_| determines the page to
+ // be stale.
+ void InitContents(Profile* profile,
+ const content::WebContents* active_tab,
+ const base::Closure& on_stale_callback);
+
+ // Releases the WebContents for the instant page. This should be called when
+ // the page is about to be 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_; }
+
+ private:
+ // Overriden from InstantLoader::Delegate:
+ virtual scoped_ptr<content::WebContents> SwapContents(
+ scoped_ptr<content::WebContents> new_contents) OVERRIDE;
+ virtual void OnFocus() OVERRIDE;
+ virtual bool OnOpenURL() OVERRIDE;
+ virtual void OnMouseDown() OVERRIDE;
+ virtual void OnMouseUp() OVERRIDE;
+
+ // Overridden from InstantPage:
+ virtual bool ShouldProcessAboutToNavigateMainFrame() const OVERRIDE;
+ virtual bool ShouldProcessSetSuggestions() const OVERRIDE;
+ virtual bool ShouldProcessShowInstantPreview() const OVERRIDE;
+ virtual bool ShouldProcessStartCapturingKeyStrokes() const OVERRIDE;
+ virtual bool ShouldProcessStopCapturingKeyStrokes() const OVERRIDE;
+ virtual bool ShouldProcessNavigateToURL() const OVERRIDE;
+
+ InstantLoader loader_;
+ const std::string instant_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantNTP);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_

Powered by Google App Engine
This is Rietveld 408576698