OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 22 matching lines...) Expand all Loading... | |
33 class ProcessMetrics; | 33 class ProcessMetrics; |
34 } | 34 } |
35 | 35 |
36 namespace gfx { | 36 namespace gfx { |
37 class Rect; | 37 class Rect; |
38 } | 38 } |
39 | 39 |
40 namespace prerender { | 40 namespace prerender { |
41 | 41 |
42 class PrerenderManager; | 42 class PrerenderManager; |
43 class PrerenderTracker; | |
43 | 44 |
44 // This class is a peer of TabContents. It can host a renderer, but does not | 45 // This class is a peer of TabContents. It can host a renderer, but does not |
45 // have any visible display. Its navigation is not managed by a | 46 // have any visible display. Its navigation is not managed by a |
46 // NavigationController because is has no facility for navigating (other than | 47 // NavigationController because is has no facility for navigating (other than |
47 // programatically view window.location.href) or RenderViewHostManager because | 48 // programatically view window.location.href) or RenderViewHostManager because |
48 // it is never allowed to navigate across a SiteInstance boundary. | 49 // it is never allowed to navigate across a SiteInstance boundary. |
49 // TODO(dominich): Remove RenderViewHostDelegate inheritance when UseTabContents | 50 // TODO(dominich): Remove RenderViewHostDelegate inheritance when UseTabContents |
50 // returns true by default. | 51 // returns true by default. |
51 class PrerenderContents : public RenderViewHostDelegate, | 52 class PrerenderContents : public RenderViewHostDelegate, |
52 public RenderViewHostDelegate::View, | 53 public RenderViewHostDelegate::View, |
53 public NotificationObserver, | 54 public NotificationObserver, |
54 public TabContentsObserver, | 55 public TabContentsObserver, |
55 public JavaScriptAppModalDialogDelegate, | 56 public JavaScriptAppModalDialogDelegate, |
56 public DownloadTabHelperDelegate { | 57 public DownloadTabHelperDelegate { |
57 public: | 58 public: |
58 // PrerenderContents::Create uses the currently registered Factory to create | 59 // PrerenderContents::Create uses the currently registered Factory to create |
59 // the PrerenderContents. Factory is intended for testing. | 60 // the PrerenderContents. Factory is intended for testing. |
60 class Factory { | 61 class Factory { |
61 public: | 62 public: |
62 Factory() {} | 63 Factory() {} |
63 virtual ~Factory() {} | 64 virtual ~Factory() {} |
64 | 65 |
65 virtual PrerenderContents* CreatePrerenderContents( | 66 virtual PrerenderContents* CreatePrerenderContents( |
cbentzel
2011/05/24 17:13:54
The lack-of-ownership and lifetime-expectations of
dominich
2011/05/24 18:01:47
Done.
| |
66 PrerenderManager* prerender_manager, | 67 PrerenderManager* prerender_manager, |
67 Profile* profile, | 68 Profile* profile, |
69 PrerenderTracker* prerender_tracker, | |
68 const GURL& url, | 70 const GURL& url, |
69 const GURL& referrer) = 0; | 71 const GURL& referrer) = 0; |
70 | 72 |
71 private: | 73 private: |
72 DISALLOW_COPY_AND_ASSIGN(Factory); | 74 DISALLOW_COPY_AND_ASSIGN(Factory); |
73 }; | 75 }; |
74 | 76 |
75 virtual ~PrerenderContents(); | 77 virtual ~PrerenderContents(); |
76 | 78 |
77 bool Init(); | 79 bool Init(); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 | 254 |
253 // Applies all the URL history encountered during prerendering to the | 255 // Applies all the URL history encountered during prerendering to the |
254 // new tab. | 256 // new tab. |
255 void CommitHistory(TabContents* tc); | 257 void CommitHistory(TabContents* tc); |
256 | 258 |
257 int32 starting_page_id() { return starting_page_id_; } | 259 int32 starting_page_id() { return starting_page_id_; } |
258 | 260 |
259 protected: | 261 protected: |
260 PrerenderContents(PrerenderManager* prerender_manager, | 262 PrerenderContents(PrerenderManager* prerender_manager, |
261 Profile* profile, | 263 Profile* profile, |
264 PrerenderTracker* prerender_tracker, | |
262 const GURL& url, | 265 const GURL& url, |
263 const GURL& referrer); | 266 const GURL& referrer); |
264 | 267 |
265 const GURL& prerender_url() const { return prerender_url_; } | 268 const GURL& prerender_url() const { return prerender_url_; } |
266 | 269 |
267 NotificationRegistrar& notification_registrar() { | 270 NotificationRegistrar& notification_registrar() { |
268 return notification_registrar_; | 271 return notification_registrar_; |
269 } | 272 } |
270 | 273 |
271 // Called whenever a RenderViewHost is created for prerendering. Only called | 274 // Called whenever a RenderViewHost is created for prerendering. Only called |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 | 310 |
308 // The referrer. | 311 // The referrer. |
309 GURL referrer_; | 312 GURL referrer_; |
310 | 313 |
311 // The NavigationParameters of the finished navigation. | 314 // The NavigationParameters of the finished navigation. |
312 scoped_ptr<ViewHostMsg_FrameNavigate_Params> navigate_params_; | 315 scoped_ptr<ViewHostMsg_FrameNavigate_Params> navigate_params_; |
313 | 316 |
314 // The profile being used | 317 // The profile being used |
315 Profile* profile_; | 318 Profile* profile_; |
316 | 319 |
320 PrerenderTracker* prerender_tracker_; | |
321 | |
317 // Information about the title and URL of the page that this class as a | 322 // Information about the title and URL of the page that this class as a |
318 // RenderViewHostDelegate has received from the RenderView. | 323 // RenderViewHostDelegate has received from the RenderView. |
319 // Used to apply to the new RenderViewHost delegate that might eventually | 324 // Used to apply to the new RenderViewHost delegate that might eventually |
320 // own the contained RenderViewHost when the prerendered page is shown | 325 // own the contained RenderViewHost when the prerendered page is shown |
321 // in a TabContents. | 326 // in a TabContents. |
322 string16 title_; | 327 string16 title_; |
323 int32 page_id_; | 328 int32 page_id_; |
324 GURL url_; | 329 GURL url_; |
325 GURL icon_url_; | 330 GURL icon_url_; |
326 NotificationRegistrar notification_registrar_; | 331 NotificationRegistrar notification_registrar_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 | 373 |
369 // Offset by which to offset prerendered pages | 374 // Offset by which to offset prerendered pages |
370 static const int32 kPrerenderPageIdOffset = 10; | 375 static const int32 kPrerenderPageIdOffset = 10; |
371 | 376 |
372 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 377 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
373 }; | 378 }; |
374 | 379 |
375 } // namespace prerender | 380 } // namespace prerender |
376 | 381 |
377 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 382 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |