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

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

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 | Annotate | Revision Log
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_PRELOADER_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_PRELOADER_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer.h"
13 #include "chrome/browser/instant/instant_page.h"
14 #include "chrome/browser/instant/instant_service_observer.h"
15 #include "chrome/browser/instant/instant_web_contents_container.h"
16
17 class InstantService;
18
19 namespace content {
20 class WebContents;
21 }
22
23 // InstantPreloader maintains a hidden WebContents into which it loads the
24 // default search engine's Instant URL. It is owned by InstantService.
25 class InstantPreloader : public InstantPage::Delegate,
26 public InstantServiceObserver,
27 public InstantWebContentsContainer {
28 public:
29 explicit InstantPreloader(InstantService* service);
30 virtual ~InstantPreloader();
31
32 // Returns whether the |contents_| is known to support the Instant API.
33 bool supports_instant() const { return page_.supports_instant(); }
34
35 // Creates a new |contents_| and loads the Instant URL into it. If |contents_|
36 // is already valid, does nothing.
37 void InitContents();
38
39 // Gives up |contents_| to the caller, and creates a new one in its place.
40 scoped_ptr<content::WebContents> ReleaseContents();
41
42 private:
43 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantPreloaderRefresh);
44
45 // Overridden from InstantPage::Delegate:
46 virtual void RenderViewGone(const content::WebContents* contents) OVERRIDE;
47 virtual void InitSearchBox(const content::WebContents* contents) OVERRIDE;
48 virtual void InstantSupportDetermined(
49 const content::WebContents* contents) OVERRIDE;
50 virtual void SetSuggestion(const content::WebContents* contents,
51 const InstantSuggestion& suggestion) OVERRIDE;
52 virtual void NavigateToURL(const content::WebContents* contents,
53 const GURL& url,
54 content::PageTransition transition,
55 WindowOpenDisposition disposition) OVERRIDE;
56 virtual void ShowOverlay(const content::WebContents* contents,
57 int height,
58 InstantSizeUnits height_units) OVERRIDE;
59 virtual void SetFocusState(const content::WebContents* contents,
60 OmniboxFocusState focus_state) OVERRIDE;
61 virtual void DeleteMostVisitedItem(const content::WebContents* contents,
62 const GURL& url) OVERRIDE;
63 virtual void UndoMostVisitedItemDeletion(const content::WebContents* contents,
64 const GURL& url) OVERRIDE;
65 virtual void UndoAllMostVisitedItemDeletions(
66 const content::WebContents* contents) OVERRIDE;
67
68 // Overridden from InstantServiceObserver:
69 virtual void InstantStatusChanged() OVERRIDE;
70 virtual void ThemeInfoChanged() OVERRIDE;
71 virtual void MostVisitedItemsChanged() OVERRIDE;
72
73 // Overridden from InstantWebContentsContainer:
74 virtual void CloseContents(content::WebContents* source) OVERRIDE;
75 virtual void TearDownContents() OVERRIDE;
76
77 void DeleteContents();
78 void ReloadContents();
79
80 InstantService* const service_;
81 base::OneShotTimer<InstantPreloader> stale_page_timer_;
82
83 DISALLOW_COPY_AND_ASSIGN(InstantPreloader);
84 };
85
86 #endif // CHROME_BROWSER_INSTANT_INSTANT_PRELOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698