1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_NTP_H_
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_NTP_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/ui/search/instant_loader.h"
15 #include "chrome/browser/ui/search/instant_page.h"
17 class InstantNTPPrerenderer;
25 // InstantNTP is used to preload an Instant page that will be swapped in when a
26 // user navigates to a New Tab Page (NTP). The InstantNTP contents are never
27 // shown in an un-committed state.
28 class InstantNTP : public InstantPage,
29 public InstantLoader::Delegate {
31 InstantNTP(InstantNTPPrerenderer* delegate,
32 const std::string& instant_url,
34 virtual ~InstantNTP();
36 // Creates a new WebContents and loads |instant_url_| into it.
37 // |on_stale_callback| will be called when |loader_| determines the page to
39 void InitContents(const base::Closure& on_stale_callback);
41 // Releases the WebContents for the Instant page. This should be called when
42 // the page is about to be committed.
43 scoped_ptr<content::WebContents> ReleaseContents();
46 FRIEND_TEST_ALL_PREFIXES(InstantExtendedNetworkTest,
47 NTPReactsToNetworkChanges);
49 // Overridden from content::WebContentsObserver:
50 virtual void RenderProcessGone(
51 base::TerminationStatus status) OVERRIDE;
53 // Overridden from InstantLoader::Delegate:
54 virtual void OnSwappedContents() OVERRIDE;
55 virtual content::WebContents* OpenURLFromTab(
56 content::WebContents* source,
57 const content::OpenURLParams& params) OVERRIDE;
58 virtual void LoadCompletedMainFrame() OVERRIDE;
60 InstantLoader loader_;
61 InstantNTPPrerenderer* const ntp_prerenderer_;
63 DISALLOW_COPY_AND_ASSIGN(InstantNTP);
66 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_NTP_H_