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

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

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 #ifndef CHROME_BROWSER_INSTANT_INSTANT_NTP_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_NTP_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/instant/instant_loader.h"
15 #include "chrome/browser/instant/instant_page.h"
16
17 class InstantController;
18 class InstantLoader;
19 class Profile;
20 struct ThemeBackgroundInfo;
21
22 namespace content {
23 class WebContents;
24 }
25
26 // InstantNTP is used to preload an Instant page that will be swapped in when a
27 // user navigates to a New Tab Page (NTP). The InstantNTP contents are never
28 // shown in an un-committed state.
29 class InstantNTP : public InstantPage,
30 public InstantLoader::Delegate {
31 public:
32 // Doesn't take ownership of |controller|.
33 InstantNTP(InstantController* controller, const std::string& instant_url);
34 virtual ~InstantNTP();
35
36 // Creates a new WebContents and loads |instant_url_| into it. Uses
37 // |active_tab|, if non-NULL, to initialize the size of the WebContents.
38 void InitContents(Profile* profile,
39 const content::WebContents* active_tab);
40
41 // Overriden from InstantPage.
42 virtual content::WebContents* contents() const OVERRIDE {
43 return loader_->contents();
44 }
45
46 // Releases the WebContents for the instant page, passing ownership to the
47 // caller. This should be called when the page is about to be committed.
48 content::WebContents* ReleaseContents() WARN_UNUSED_RESULT;
49
50 // Returns the URL that we're loading.
51 const std::string& instant_url() const { return instant_url_; }
52
53 // Returns whether the underlying contents is stale (i.e. was loaded too long
54 // ago).
55 bool is_stale() const { return is_stale_; }
56
57 private:
58 // Overriden from InstantLoader::Delegate.
59 virtual content::WebContents* ReplaceAndReleaseContents(
60 content::WebContents* new_contents) OVERRIDE;
61 virtual void OnFocus() OVERRIDE;
62 virtual bool OnOpenURL() OVERRIDE;
63 virtual void SetPointerDown() OVERRIDE;
64 virtual void MaybeCommitFromPointerRelease() OVERRIDE;
65 virtual void OnStalePage() OVERRIDE;
66
67 // Overridden from InstantAPIWrapper::Controller.
68 virtual void OnUpdate() OVERRIDE;
69 virtual bool OnRenderViewGone() const OVERRIDE;
70 virtual bool OnAboutToNavigateMainFrame() const OVERRIDE;
71 virtual bool OnSetSuggestions() const OVERRIDE;
72 virtual bool OnShowInstantPreview() const OVERRIDE;
73 virtual bool OnStartCapturingKeyStrokes() const OVERRIDE;
74 virtual bool OnStopCapturingKeyStrokes() const OVERRIDE;
75 virtual bool OnNavigateToURL() const OVERRIDE;
76
77 scoped_ptr<InstantLoader> loader_;
78 const std::string instant_url_;
79 bool is_stale_;
80
81 DISALLOW_COPY_AND_ASSIGN(InstantNTP);
82 };
83
84 #endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698