Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 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 // Doesn't take ownership of |delegate|. | |
| 25 InstantNTP(InstantPage::Delegate* delegate, const std::string& instant_url); | |
| 26 virtual ~InstantNTP(); | |
| 27 | |
| 28 // Creates a new WebContents and loads |instant_url_| into it. Uses | |
| 29 // |active_tab|, if non-NULL, to initialize the size of the WebContents. | |
| 30 void InitContents(Profile* profile, | |
| 31 const content::WebContents* active_tab); | |
| 32 | |
| 33 // Releases the WebContents for the instant page, passing ownership to the | |
| 34 // caller. This should be called when the page is about to be committed. | |
| 35 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.
| |
| 36 | |
| 37 // Returns the URL that we're loading. | |
| 38 const std::string& instant_url() const { return instant_url_; } | |
| 39 | |
| 40 // Returns whether the underlying contents is stale (i.e. was loaded too long | |
| 41 // ago). | |
| 42 bool is_stale() const { return is_stale_; } | |
| 43 | |
| 44 private: | |
| 45 // Overriden from InstantLoader::Delegate. | |
| 46 virtual content::WebContents* ReplaceAndReleaseContents( | |
| 47 content::WebContents* new_contents) OVERRIDE; | |
| 48 virtual void OnFocus() OVERRIDE; | |
| 49 virtual bool OnOpenURL() OVERRIDE; | |
| 50 virtual void OnPointerDown() OVERRIDE; | |
| 51 virtual void OnPointerRelease() OVERRIDE; | |
| 52 virtual void OnStalePage() OVERRIDE; | |
| 53 | |
| 54 // Overridden from InstantPage. | |
| 55 virtual bool ShouldProcessAboutToNavigateMainFrame() const OVERRIDE; | |
| 56 virtual bool ShouldProcessSetSuggestions() const OVERRIDE; | |
| 57 virtual bool ShouldProcessShowInstantPreview() const OVERRIDE; | |
| 58 virtual bool ShouldProcessStartCapturingKeyStrokes() const OVERRIDE; | |
| 59 virtual bool ShouldProcessStopCapturingKeyStrokes() const OVERRIDE; | |
| 60 virtual bool ShouldProcessNavigateToURL() const OVERRIDE; | |
| 61 | |
| 62 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.
| |
| 63 const std::string instant_url_; | |
| 64 bool is_stale_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(InstantNTP); | |
| 67 }; | |
| 68 | |
| 69 #endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_ | |
| OLD | NEW |