OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_NTP_H_ | |
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_NTP_H_ | |
7 | |
8 #include <string> | |
9 | |
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" | |
16 | |
17 class InstantNTPPrerenderer; | |
18 class Profile; | |
19 | |
20 namespace content { | |
21 class RenderViewHost; | |
22 class WebContents; | |
23 } | |
24 | |
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 { | |
30 public: | |
31 InstantNTP(InstantNTPPrerenderer* delegate, | |
32 const std::string& instant_url, | |
33 Profile* profile); | |
34 virtual ~InstantNTP(); | |
35 | |
36 // Creates a new WebContents and loads |instant_url_| into it. | |
37 // |on_stale_callback| will be called when |loader_| determines the page to | |
38 // be stale. | |
39 void InitContents(const base::Closure& on_stale_callback); | |
40 | |
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(); | |
44 | |
45 private: | |
46 FRIEND_TEST_ALL_PREFIXES(InstantExtendedNetworkTest, | |
47 NTPReactsToNetworkChanges); | |
48 | |
49 // Overridden from content::WebContentsObserver: | |
50 virtual void RenderProcessGone( | |
51 base::TerminationStatus status) OVERRIDE; | |
52 | |
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; | |
59 | |
60 InstantLoader loader_; | |
61 InstantNTPPrerenderer* const ntp_prerenderer_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(InstantNTP); | |
64 }; | |
65 | |
66 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_NTP_H_ | |
OLD | NEW |