| 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..19c585af6cfb5ae3cfe66c975db3a86aaea8f8f1
|
| --- /dev/null
|
| +++ b/chrome/browser/instant/instant_ntp.cc
|
| @@ -0,0 +1,107 @@
|
| +// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// 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/browser/instant/instant_controller.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
|
| +
|
| +} // namespace
|
| +
|
| +InstantNTP::InstantNTP(InstantController* controller,
|
| + const std::string& instant_url)
|
| + : InstantPage(controller),
|
| + 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);
|
| + api()->SetContents(contents());
|
| + contents()->GetController().GetPendingEntry()->SetVirtualURL(
|
| + GURL(chrome::kChromeUINewTabURL));
|
| +}
|
| +
|
| +content::WebContents* InstantNTP::ReleaseContents() {
|
| + api()->SetContents(NULL);
|
| + return loader_->ReleaseContents();
|
| +}
|
| +
|
| +content::WebContents* InstantNTP::ReplaceAndReleaseContents(
|
| + content::WebContents* new_contents) {
|
| + content::WebContents* old_contents = ReleaseContents();
|
| + loader_->SetContents(new_contents);
|
| + api()->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::SetPointerDown() {
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void InstantNTP::MaybeCommitFromPointerRelease() {
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void InstantNTP::OnStalePage() {
|
| + is_stale_ = true;
|
| + controller_->OnStaleNTP();
|
| +}
|
| +
|
| +void InstantNTP::OnUpdate() {
|
| +}
|
| +
|
| +bool InstantNTP::OnRenderViewGone() const {
|
| + return true;
|
| +}
|
| +
|
| +bool InstantNTP::OnAboutToNavigateMainFrame() const {
|
| + // Nothing to do in an uncommitted NTP.
|
| + return false;
|
| +}
|
| +
|
| +bool InstantNTP::OnSetSuggestions() const {
|
| + // Nothing to do in an uncommitted NTP.
|
| + return false;
|
| +}
|
| +
|
| +bool InstantNTP::OnShowInstantPreview() const {
|
| + // Nothing to do in an uncommitted NTP.
|
| + return false;
|
| +}
|
| +
|
| +bool InstantNTP::OnStartCapturingKeyStrokes() const {
|
| + // Nothing to do in an uncommitted NTP.
|
| + return false;
|
| +}
|
| +
|
| +bool InstantNTP::OnStopCapturingKeyStrokes() const {
|
| + // Nothing to do in an uncommitted NTP.
|
| + return false;
|
| +}
|
| +
|
| +bool InstantNTP::OnNavigateToURL() const {
|
| + return true;
|
| +}
|
|
|