Chromium Code Reviews| Index: chrome/browser/instant/instant_ntp.cc |
| diff --git a/chrome/browser/instant/instant_ntp.cc b/chrome/browser/instant/instant_ntp.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a775d1f65f7ad7f310e270aa6087edbab1961578 |
| --- /dev/null |
| +++ b/chrome/browser/instant/instant_ntp.cc |
| @@ -0,0 +1,100 @@ |
| +// 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. |
| + |
| +#include "chrome/browser/instant/instant_ntp.h" |
| + |
| +#include "chrome/common/url_constants.h" |
| +#include "content/public/browser/navigation_entry.h" |
| +#include "content/public/browser/web_contents.h" |
| + |
| +namespace { |
| + |
| +const int kStalePageTimeoutMS = 3 * 3600 * 1000; // 3 hours |
|
dhollowa
2013/01/22 22:34:58
DRY violation. Move to common location in instant
samarth
2013/01/25 21:08:40
Done.
|
| + |
| +} // namespace |
| + |
| +InstantNTP::InstantNTP(InstantPage::Delegate* delegate, |
| + const std::string& instant_url) |
| + : InstantPage(delegate), |
| + loader_(new InstantLoader(ALLOW_THIS_IN_INITIALIZER_LIST(this))), |
| + instant_url_(instant_url), |
| + is_stale_(false) { |
| +} |
| + |
| +InstantNTP::~InstantNTP() { |
| +} |
| + |
| +void InstantNTP::InitContents(Profile* profile, |
| + const content::WebContents* active_tab) { |
| + loader_->Load(GURL(instant_url_), profile, active_tab, kStalePageTimeoutMS); |
| + SetContents(loader_->contents()); |
| + contents()->GetController().GetPendingEntry()->SetVirtualURL( |
| + GURL(chrome::kChromeUINewTabURL)); |
| +} |
| + |
| +content::WebContents* InstantNTP::ReleaseContents() { |
| + SetContents(NULL); |
| + return loader_->ReleaseContents(); |
| +} |
| + |
| +content::WebContents* InstantNTP::ReplaceAndReleaseContents( |
| + content::WebContents* new_contents) { |
| + content::WebContents* old_contents = ReleaseContents(); |
| + loader_->SetContents(new_contents); |
| + SetContents(new_contents); |
| + new_contents->GetController().GetPendingEntry()->SetVirtualURL( |
| + GURL(chrome::kChromeUINewTabURL)); |
| + return old_contents; |
| +} |
| + |
| +void InstantNTP::OnFocus() { |
| + NOTREACHED(); |
| +} |
| + |
| +bool InstantNTP::OnOpenURL() { |
| + return false; |
| +} |
| + |
| +void InstantNTP::OnPointerDown() { |
| + NOTREACHED(); |
| +} |
| + |
| +void InstantNTP::OnPointerRelease() { |
| + NOTREACHED(); |
| +} |
| + |
| +void InstantNTP::OnStalePage() { |
| + is_stale_ = true; |
| + delegate()->OnStalePage(contents()); |
| +} |
| + |
| +bool InstantNTP::ShouldProcessAboutToNavigateMainFrame() const { |
| + // Nothing to do in an uncommitted NTP. |
| + return false; |
| +} |
| + |
| +bool InstantNTP::ShouldProcessSetSuggestions() const { |
| + // Nothing to do in an uncommitted NTP. |
| + return false; |
| +} |
| + |
| +bool InstantNTP::ShouldProcessShowInstantPreview() const { |
| + // Nothing to do in an uncommitted NTP. |
| + return false; |
| +} |
| + |
| +bool InstantNTP::ShouldProcessStartCapturingKeyStrokes() const { |
| + // Nothing to do in an uncommitted NTP. |
| + return false; |
| +} |
| + |
| +bool InstantNTP::ShouldProcessStopCapturingKeyStrokes() const { |
| + // Nothing to do in an uncommitted NTP. |
| + return false; |
| +} |
| + |
| +bool InstantNTP::ShouldProcessNavigateToURL() const { |
| + // Nothing to do in an uncommitted NTP. |
| + return false; |
| +} |