Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/instant/instant_ntp.cc

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2012 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 #include "chrome/browser/instant/instant_ntp.h"
6
7 #include "chrome/browser/instant/instant_controller.h"
8 #include "chrome/common/url_constants.h"
9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/web_contents.h"
11
12 namespace {
13
14 const int kStalePageTimeoutMS = 3 * 3600 * 1000; // 3 hours
15
16 } // namespace
17
18 InstantNTP::InstantNTP(InstantController* controller,
19 const std::string& instant_url)
20 : InstantPage(controller),
21 loader_(new InstantLoader(ALLOW_THIS_IN_INITIALIZER_LIST(this))),
22 instant_url_(instant_url),
23 is_stale_(false) {
24 }
25
26 InstantNTP::~InstantNTP() {
27 }
28
29 void InstantNTP::InitContents(Profile* profile,
30 const content::WebContents* active_tab) {
31 loader_->Load(GURL(instant_url_), profile, active_tab, kStalePageTimeoutMS);
32 api()->SetContents(contents());
33 contents()->GetController().GetPendingEntry()->SetVirtualURL(
34 GURL(chrome::kChromeUINewTabURL));
35 }
36
37 content::WebContents* InstantNTP::ReleaseContents() {
38 api()->SetContents(NULL);
39 return loader_->ReleaseContents();
40 }
41
42 content::WebContents* InstantNTP::ReplaceAndReleaseContents(
43 content::WebContents* new_contents) {
44 content::WebContents* old_contents = ReleaseContents();
45 loader_->SetContents(new_contents);
46 api()->SetContents(new_contents);
47 new_contents->GetController().GetPendingEntry()->SetVirtualURL(
48 GURL(chrome::kChromeUINewTabURL));
49 return old_contents;
50 }
51
52 void InstantNTP::OnFocus() {
53 NOTREACHED();
54 }
55
56 bool InstantNTP::OnOpenURL() {
57 return false;
58 }
59
60 void InstantNTP::SetPointerDown() {
61 NOTREACHED();
62 }
63
64 void InstantNTP::MaybeCommitFromPointerRelease() {
65 NOTREACHED();
66 }
67
68 void InstantNTP::OnStalePage() {
69 is_stale_ = true;
70 controller_->OnStaleNTP();
71 }
72
73 void InstantNTP::OnUpdate() {
74 }
75
76 bool InstantNTP::OnRenderViewGone() const {
77 return true;
78 }
79
80 bool InstantNTP::OnAboutToNavigateMainFrame() const {
81 // Nothing to do in an uncommitted NTP.
82 return false;
83 }
84
85 bool InstantNTP::OnSetSuggestions() const {
86 // Nothing to do in an uncommitted NTP.
87 return false;
88 }
89
90 bool InstantNTP::OnShowInstantPreview() const {
91 // Nothing to do in an uncommitted NTP.
92 return false;
93 }
94
95 bool InstantNTP::OnStartCapturingKeyStrokes() const {
96 // Nothing to do in an uncommitted NTP.
97 return false;
98 }
99
100 bool InstantNTP::OnStopCapturingKeyStrokes() const {
101 // Nothing to do in an uncommitted NTP.
102 return false;
103 }
104
105 bool InstantNTP::OnNavigateToURL() const {
106 return true;
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698