Chromium Code Reviews| 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..6a0c93b0467929f52c14c63328e0a29d5f52565c |
| --- /dev/null |
| +++ b/chrome/browser/instant/instant_ntp.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
|
dhollowa
2013/01/22 22:34:58
nit: 2013
samarth
2013/01/25 21:08:40
Done.
|
| +// 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: |
| + // Doesn't take ownership of |delegate|. |
| + 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. |
| + void InitContents(Profile* profile, |
| + const content::WebContents* active_tab); |
| + |
| + // 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; |
|
dhollowa
2013/01/22 22:34:58
Return type should be scoped_ptr<content::WebConte
samarth
2013/01/25 21:08:40
Done.
|
| + |
| + // 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 OnPointerDown() OVERRIDE; |
| + virtual void OnPointerRelease() OVERRIDE; |
| + virtual void OnStalePage() 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; |
| + |
| + scoped_ptr<InstantLoader> loader_; |
|
dhollowa
2013/01/22 22:34:58
Can this be a direct data member?
samarth
2013/01/25 21:08:40
Done.
|
| + const std::string instant_url_; |
| + bool is_stale_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InstantNTP); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_ |