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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 years, 10 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 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 #ifndef CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
sreeram 2013/02/01 20:36:53 #include "base/gtest_prod_util.h" (for the FRIEND
samarth 2013/02/04 20:43:32 Done.
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h"
sreeram 2013/02/01 20:36:53 No need for this include (the only reference to st
samarth 2013/02/04 20:43:32 Done.
14 #include "chrome/browser/history/history_types.h"
15 #include "chrome/browser/instant/instant_controller.h"
sreeram 2013/02/01 20:36:53 You don't need this include. You just need a forwa
samarth 2013/02/04 20:43:32 I need it for the instant_controller() accessor be
16 #include "chrome/browser/instant/instant_loader.h"
17 #include "chrome/browser/instant/instant_page.h"
18
19 class Profile;
sreeram 2013/02/01 20:36:53 Add a forward declaration for content::WebContents
samarth 2013/02/04 20:43:32 Done.
20
21 // InstantOverlay is used to communicate with a preview WebContents that it owns
22 // and loads the "Instant URL" into. This preview can appear and disappear at
23 // will as the user types in the omnibox.
24 class InstantOverlay : public InstantPage,
25 public InstantLoader::Delegate {
26 public:
27 // Returns the InstantOverlay for |contents| if it's used for Instant.
28 static InstantOverlay* FromWebContents(const content::WebContents* contents);
29
30 InstantOverlay(InstantController* controller,
31 const std::string& instant_url);
32 virtual ~InstantOverlay();
33
34 // Creates a new WebContents and loads |instant_url_| into it. Uses
35 // |active_tab|, if non-NULL, to initialize the size of the WebContents.
36 void InitContents(Profile* profile,
37 const content::WebContents* active_tab);
38
39 // Releases the overlay WebContents. This should be called when the overlay
40 // is committed.
41 scoped_ptr<content::WebContents> ReleaseContents() WARN_UNUSED_RESULT;
42
43 // Returns the URL that we're loading.
44 const std::string& instant_url() const { return instant_url_; }
45
46 // Returns whether the underlying contents is stale (i.e. was loaded too long
47 // ago).
48 bool is_stale() const { return is_stale_; }
49
50 // Returns true if the mouse or a touch pointer is down due to activating the
51 // preview contents.
52 bool is_pointer_down_from_activate() const {
53 return is_pointer_down_from_activate_;
54 }
55
56 // Returns info about the last navigation by the Instant page. If the page
57 // hasn't navigated since the last Update(), the URL is empty.
58 const history::HistoryAddPageArgs& last_navigation() const {
59 return last_navigation_;
60 }
61
62 // Called by the history tab helper with information that it would have added
63 // to the history service had this WebContents not been used for Instant.
64 void DidNavigate(const history::HistoryAddPageArgs& add_page_args);
65
66 // Returns true if the overlay is using
67 // InstantController::kLocalOmniboxPopupURL as the |instant_url_|.
68 bool IsUsingLocalPreview() const;
69
70 // Overridden from InstantPage:
71 virtual void Update(const string16& text,
72 size_t selection_start,
73 size_t selection_end,
74 bool verbatim) OVERRIDE;
75
76 private:
77 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefresh);
78
79 // Helper to access delegate() as an InstantController object.
80 InstantController* instant_controller() const {
81 return static_cast<InstantController*>(delegate());
82 }
83
84 // Overriden from InstantLoader::Delegate:
85 virtual void OnSwappedContents() OVERRIDE;
86 virtual void OnFocus() OVERRIDE;
87 virtual void OnMouseDown() OVERRIDE;
88 virtual void OnMouseUp() OVERRIDE;
89 virtual content::WebContents* OpenURLFromTab(
90 content::WebContents* source,
91 const content::OpenURLParams& params) OVERRIDE;
92
93 // Called when the underlying page becomes stale.
94 void HandleStalePage();
95
96 InstantLoader loader_;
97 const std::string instant_url_;
98 bool is_stale_;
99 bool is_pointer_down_from_activate_;
100 history::HistoryAddPageArgs last_navigation_;
101
102 DISALLOW_COPY_AND_ASSIGN(InstantOverlay);
103 };
104
105 #endif // CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698