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

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: Cleanup. 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_client.h"
15
16 class InstantController;
17 class Profile;
18 struct ThemeBackgroundInfo;
19
20 namespace content {
21 class WebContents;
22 }
23
24 // InstantNTP is used to communicate with a WebContents that it owns and loads
25 // the "Instant URL" into. This preview is used when the user navigates to a New
26 // Tab Page.
27 class InstantNTP : public InstantClient::Delegate {
28 public:
29 // Returns the InstantNTP for |contents| if it's used for Instant.
30 static InstantNTP* FromWebContents(const content::WebContents* contents);
31
32 // Doesn't take ownership of |controller|.
33 InstantNTP(InstantController* controller, const std::string& instant_url);
34 virtual ~InstantNTP();
35
36 // The NTP WebContents. InstantNTP retains ownership. This will be
37 // non-NULL after InitFromContents(), and until ReleaseContents() is called.
38 content::WebContents* contents() const { return contents_.get(); }
39
40 // Creates a new WebContents and loads |instant_url_| into it. Uses
41 // |active_tab|, if non-NULL, to initialize the size of the WebContents.
42 void InitContents(Profile* profile,
43 const content::WebContents* active_tab);
44
45 // Releases the preview WebContents passing ownership to the caller. This
46 // should be called when the preview is committed.
47 content::WebContents* ReleaseContents() WARN_UNUSED_RESULT;
48
49 // Returns the URL that we're loading.
50 const std::string& instant_url() const { return instant_url_; }
51
52 // Returns true if the preview is known to support the Instant API. This
53 // starts out false, and becomes true whenever we get any message from the
54 // page. Once true, it never becomes false (the page isn't expected to drop
55 // Instant API support suddenly).
56 bool supports_instant() const { return supports_instant_; }
57
58 // Calls through to methods of the same name on InstantClient.
59 void SetMarginSize(int start, int end);
60 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info);
61 void SendThemeAreaHeight(int height);
62 void SetDisplayInstantResults(bool display_instant_results);
63
64 private:
65 class WebContentsDelegateImpl;
66
67 // Overridden from InstantClient::Delegate:
68 virtual void SetSuggestions(
69 const std::vector<InstantSuggestion>& suggestions) OVERRIDE;
70 virtual void InstantSupportDetermined(bool supports_instant) OVERRIDE;
71 virtual void ShowInstantPreview(InstantShownReason reason,
72 int height,
73 InstantSizeUnits units) OVERRIDE;
74 virtual void StartCapturingKeyStrokes() OVERRIDE;
75 virtual void StopCapturingKeyStrokes() OVERRIDE;
76 virtual void RenderViewGone() OVERRIDE;
77 virtual void AboutToNavigateMainFrame(const GURL& url) OVERRIDE;
78 virtual void NavigateToURL(const GURL& url,
79 content::PageTransition transition) OVERRIDE;
80
81 void SetupPreviewContents();
82 void CleanupPreviewContents();
83 void ReplacePreviewContents(content::WebContents* old_contents,
84 content::WebContents* new_contents);
85
86 InstantClient client_;
dhollowa 2013/01/10 18:50:29 I notice that all three InstantOverlay, InstantNTP
dhollowa 2013/01/10 21:08:03 Err... correction: class InstantNTP : public Insta
samarth 2013/01/11 19:43:05 Channeling sky (who was channeling Ben): """ Ben w
dhollowa 2013/01/11 19:55:01 God also calls a kitten every time the DRY (don't
87 InstantController* const controller_;
88
89 // Delegate of the preview WebContents.
90 scoped_ptr<WebContentsDelegateImpl> delegate_;
91 scoped_ptr<content::WebContents> contents_;
92
93 const std::string instant_url_;
94 bool supports_instant_;
95
96 DISALLOW_COPY_AND_ASSIGN(InstantNTP);
97 };
98
99 #endif // CHROME_BROWSER_INSTANT_INSTANT_NTP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698