OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 18 matching lines...) Expand all Loading... |
29 // This class is a peer of TabContents. It can host a renderer, but does not | 29 // This class is a peer of TabContents. It can host a renderer, but does not |
30 // have any visible display. Its navigation is not managed by a | 30 // have any visible display. Its navigation is not managed by a |
31 // NavigationController because is has no facility for navigating (other than | 31 // NavigationController because is has no facility for navigating (other than |
32 // programatically view window.location.href) or RenderViewHostManager because | 32 // programatically view window.location.href) or RenderViewHostManager because |
33 // it is never allowed to navigate across a SiteInstance boundary. | 33 // it is never allowed to navigate across a SiteInstance boundary. |
34 class PrerenderContents : public RenderViewHostDelegate, | 34 class PrerenderContents : public RenderViewHostDelegate, |
35 public RenderViewHostDelegate::View, | 35 public RenderViewHostDelegate::View, |
36 public NotificationObserver, | 36 public NotificationObserver, |
37 public JavaScriptAppModalDialogDelegate { | 37 public JavaScriptAppModalDialogDelegate { |
38 public: | 38 public: |
39 PrerenderContents(PrerenderManager* prerender_manager, Profile* profile, | 39 // PrerenderContents::Create uses the currently registered Factory to create |
40 const GURL& url, const std::vector<GURL>& alias_urls); | 40 // the PrerenderContents. Factory is intended for testing. |
| 41 class Factory { |
| 42 public: |
| 43 Factory() {} |
| 44 virtual ~Factory() {} |
| 45 |
| 46 virtual PrerenderContents* CreatePrerenderContents( |
| 47 PrerenderManager* prerender_manager, Profile* profile, const GURL& url, |
| 48 const std::vector<GURL>& alias_urls) = 0; |
| 49 |
| 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(Factory); |
| 52 }; |
| 53 |
41 virtual ~PrerenderContents(); | 54 virtual ~PrerenderContents(); |
| 55 |
| 56 static Factory* CreateFactory(); |
| 57 |
42 virtual void StartPrerendering(); | 58 virtual void StartPrerendering(); |
43 | 59 |
44 RenderViewHost* render_view_host() { return render_view_host_; } | 60 RenderViewHost* render_view_host() { return render_view_host_; } |
45 // Allows replacing of the RenderViewHost owned by this class, including | 61 // Allows replacing of the RenderViewHost owned by this class, including |
46 // replacing with a NULL value. When a caller uses this, the caller will | 62 // replacing with a NULL value. When a caller uses this, the caller will |
47 // own (and is responsible for freeing) the old RVH. | 63 // own (and is responsible for freeing) the old RVH. |
48 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } | 64 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } |
49 ViewHostMsg_FrameNavigate_Params* navigate_params() { | 65 ViewHostMsg_FrameNavigate_Params* navigate_params() { |
50 return navigate_params_.get(); | 66 return navigate_params_.get(); |
51 } | 67 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} | 146 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} |
131 virtual gfx::NativeWindow GetMessageBoxRootWindow(); | 147 virtual gfx::NativeWindow GetMessageBoxRootWindow(); |
132 virtual TabContents* AsTabContents(); | 148 virtual TabContents* AsTabContents(); |
133 virtual ExtensionHost* AsExtensionHost(); | 149 virtual ExtensionHost* AsExtensionHost(); |
134 | 150 |
135 virtual void UpdateInspectorSetting(const std::string& key, | 151 virtual void UpdateInspectorSetting(const std::string& key, |
136 const std::string& value); | 152 const std::string& value); |
137 virtual void ClearInspectorSettings(); | 153 virtual void ClearInspectorSettings(); |
138 | 154 |
139 protected: | 155 protected: |
| 156 PrerenderContents(PrerenderManager* prerender_manager, Profile* profile, |
| 157 const GURL& url, const std::vector<GURL>& alias_urls); |
| 158 |
140 // from RenderViewHostDelegate. | 159 // from RenderViewHostDelegate. |
141 virtual bool OnMessageReceived(const IPC::Message& message); | 160 virtual bool OnMessageReceived(const IPC::Message& message); |
142 | 161 |
143 private: | 162 private: |
| 163 // Needs to be able to call the constructor. |
| 164 friend class PrerenderContentsFactoryImpl; |
| 165 |
144 // Message handlers. | 166 // Message handlers. |
145 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | 167 void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
146 bool main_frame, | 168 bool main_frame, |
147 const GURL& url); | 169 const GURL& url); |
148 void OnDidRedirectProvisionalLoad(int32 page_id, | 170 void OnDidRedirectProvisionalLoad(int32 page_id, |
149 const GURL& source_url, | 171 const GURL& source_url, |
150 const GURL& target_url); | 172 const GURL& target_url); |
151 | 173 |
152 void AddAliasURL(const GURL& url); | 174 void AddAliasURL(const GURL& url); |
153 | 175 |
(...skipping 27 matching lines...) Expand all Loading... |
181 | 203 |
182 // A vector of URLs that this prerendered page matches against. | 204 // A vector of URLs that this prerendered page matches against. |
183 // This array can contain more than element as a result of redirects, | 205 // This array can contain more than element as a result of redirects, |
184 // such as HTTP redirects or javascript redirects. | 206 // such as HTTP redirects or javascript redirects. |
185 std::vector<GURL> alias_urls_; | 207 std::vector<GURL> alias_urls_; |
186 | 208 |
187 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 209 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
188 }; | 210 }; |
189 | 211 |
190 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 212 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |