| 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_INSTANT_INSTANT_NTP_H_ | |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_NTP_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/browser/instant/instant_loader.h" | |
| 14 #include "chrome/browser/instant/instant_page.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 // InstantNTP is used to preload an Instant page that will be swapped in when a | |
| 19 // user navigates to a New Tab Page (NTP). The InstantNTP contents are never | |
| 20 // shown in an un-committed state. | |
| 21 class InstantNTP : public InstantPage, | |
| 22 public InstantLoader::Delegate { | |
| 23 public: | |
| 24 InstantNTP(InstantPage::Delegate* delegate, const std::string& instant_url); | |
| 25 virtual ~InstantNTP(); | |
| 26 | |
| 27 // Creates a new WebContents and loads |instant_url_| into it. Uses | |
| 28 // |active_tab|, if non-NULL, to initialize the size of the WebContents. | |
| 29 // |on_stale_callback| will be called when |loader_| determines the page to | |
| 30 // be stale. | |
| 31 void InitContents(Profile* profile, | |
| 32 const content::WebContents* active_tab, | |
| 33 const base::Closure& on_stale_callback); | |
| 34 | |
| 35 // Releases the WebContents for the instant page. This should be called when | |
| 36 // the page is about to be committed. | |
| 37 scoped_ptr<content::WebContents> ReleaseContents() WARN_UNUSED_RESULT; | |
| 38 | |
| 39 // Returns the URL that we're loading. | |
| 40 const std::string& instant_url() const { return instant_url_; } | |
| 41 | |
| 42 private: | |
| 43 // Overriden from InstantLoader::Delegate: | |
| 44 virtual void OnSwappedContents() OVERRIDE; | |
| 45 virtual void OnFocus() OVERRIDE; | |
| 46 virtual void OnMouseDown() OVERRIDE; | |
| 47 virtual void OnMouseUp() OVERRIDE; | |
| 48 virtual content::WebContents* OpenURLFromTab( | |
| 49 content::WebContents* source, | |
| 50 const content::OpenURLParams& params) OVERRIDE; | |
| 51 | |
| 52 // Overridden from InstantPage: | |
| 53 virtual bool ShouldProcessRenderViewCreated() OVERRIDE; | |
| 54 virtual bool ShouldProcessRenderViewGone() OVERRIDE; | |
| 55 | |
| 56 InstantLoader loader_; | |
| 57 const std::string instant_url_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(InstantNTP); | |
| 60 }; | |
| 61 | |
| 62 #endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_ | |
| OLD | NEW |