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 #include "chrome/browser/instant/instant_ntp.h" | |
| 6 | |
| 7 #include "chrome/common/url_constants.h" | |
| 8 #include "content/public/browser/navigation_entry.h" | |
| 9 #include "content/public/browser/web_contents.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 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.
| |
| 14 | |
| 15 } // namespace | |
| 16 | |
| 17 InstantNTP::InstantNTP(InstantPage::Delegate* delegate, | |
| 18 const std::string& instant_url) | |
| 19 : InstantPage(delegate), | |
| 20 loader_(new InstantLoader(ALLOW_THIS_IN_INITIALIZER_LIST(this))), | |
| 21 instant_url_(instant_url), | |
| 22 is_stale_(false) { | |
| 23 } | |
| 24 | |
| 25 InstantNTP::~InstantNTP() { | |
| 26 } | |
| 27 | |
| 28 void InstantNTP::InitContents(Profile* profile, | |
| 29 const content::WebContents* active_tab) { | |
| 30 loader_->Load(GURL(instant_url_), profile, active_tab, kStalePageTimeoutMS); | |
| 31 SetContents(loader_->contents()); | |
| 32 contents()->GetController().GetPendingEntry()->SetVirtualURL( | |
| 33 GURL(chrome::kChromeUINewTabURL)); | |
| 34 } | |
| 35 | |
| 36 content::WebContents* InstantNTP::ReleaseContents() { | |
| 37 SetContents(NULL); | |
| 38 return loader_->ReleaseContents(); | |
| 39 } | |
| 40 | |
| 41 content::WebContents* InstantNTP::ReplaceAndReleaseContents( | |
| 42 content::WebContents* new_contents) { | |
| 43 content::WebContents* old_contents = ReleaseContents(); | |
| 44 loader_->SetContents(new_contents); | |
| 45 SetContents(new_contents); | |
| 46 new_contents->GetController().GetPendingEntry()->SetVirtualURL( | |
| 47 GURL(chrome::kChromeUINewTabURL)); | |
| 48 return old_contents; | |
| 49 } | |
| 50 | |
| 51 void InstantNTP::OnFocus() { | |
| 52 NOTREACHED(); | |
| 53 } | |
| 54 | |
| 55 bool InstantNTP::OnOpenURL() { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 void InstantNTP::OnPointerDown() { | |
| 60 NOTREACHED(); | |
| 61 } | |
| 62 | |
| 63 void InstantNTP::OnPointerRelease() { | |
| 64 NOTREACHED(); | |
| 65 } | |
| 66 | |
| 67 void InstantNTP::OnStalePage() { | |
| 68 is_stale_ = true; | |
| 69 delegate()->OnStalePage(contents()); | |
| 70 } | |
| 71 | |
| 72 bool InstantNTP::ShouldProcessAboutToNavigateMainFrame() const { | |
| 73 // Nothing to do in an uncommitted NTP. | |
| 74 return false; | |
| 75 } | |
| 76 | |
| 77 bool InstantNTP::ShouldProcessSetSuggestions() const { | |
| 78 // Nothing to do in an uncommitted NTP. | |
| 79 return false; | |
| 80 } | |
| 81 | |
| 82 bool InstantNTP::ShouldProcessShowInstantPreview() const { | |
| 83 // Nothing to do in an uncommitted NTP. | |
| 84 return false; | |
| 85 } | |
| 86 | |
| 87 bool InstantNTP::ShouldProcessStartCapturingKeyStrokes() const { | |
| 88 // Nothing to do in an uncommitted NTP. | |
| 89 return false; | |
| 90 } | |
| 91 | |
| 92 bool InstantNTP::ShouldProcessStopCapturingKeyStrokes() const { | |
| 93 // Nothing to do in an uncommitted NTP. | |
| 94 return false; | |
| 95 } | |
| 96 | |
| 97 bool InstantNTP::ShouldProcessNavigateToURL() const { | |
| 98 // Nothing to do in an uncommitted NTP. | |
| 99 return false; | |
| 100 } | |
| OLD | NEW |