OLD | NEW |
| (Empty) |
1 // Copyright 2013 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/ui/search/instant_ntp.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" | |
10 #include "chrome/browser/ui/search/search_tab_helper.h" | |
11 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" | |
12 #include "content/public/browser/web_contents.h" | |
13 #include "url/gurl.h" | |
14 | |
15 InstantNTP::InstantNTP(InstantNTPPrerenderer* ntp_prerenderer, | |
16 const std::string& instant_url, | |
17 Profile* profile) | |
18 : InstantPage(ntp_prerenderer, instant_url, profile, | |
19 profile->IsOffTheRecord()), | |
20 loader_(this), | |
21 ntp_prerenderer_(ntp_prerenderer) { | |
22 } | |
23 | |
24 InstantNTP::~InstantNTP() { | |
25 if (contents()) | |
26 ReleaseContents().reset(); | |
27 } | |
28 | |
29 void InstantNTP::InitContents(const base::Closure& on_stale_callback) { | |
30 DCHECK(!contents()); | |
31 GURL instantNTP_url(instant_url()); | |
32 loader_.Init(instantNTP_url, profile(), on_stale_callback); | |
33 SetContents(loader_.contents()); | |
34 content::WebContents* content = contents(); | |
35 SearchTabHelper::FromWebContents(content)->InitForPreloadedNTP(); | |
36 | |
37 loader_.Load(); | |
38 } | |
39 | |
40 scoped_ptr<content::WebContents> InstantNTP::ReleaseContents() { | |
41 SetContents(NULL); | |
42 return loader_.ReleaseContents(); | |
43 } | |
44 | |
45 void InstantNTP::LoadCompletedMainFrame() { | |
46 ntp_prerenderer_->LoadCompletedMainFrame(); | |
47 } | |
48 | |
49 void InstantNTP::RenderProcessGone(base::TerminationStatus /* status */) { | |
50 ntp_prerenderer_->RenderProcessGone(); | |
51 } | |
52 | |
53 void InstantNTP::OnSwappedContents() { | |
54 SetContents(loader_.contents()); | |
55 } | |
56 | |
57 content::WebContents* InstantNTP::OpenURLFromTab( | |
58 content::WebContents* source, | |
59 const content::OpenURLParams& params) { | |
60 return NULL; | |
61 } | |
OLD | NEW |