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_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
7 | 7 |
8 #include "content/browser/tab_contents/tab_contents_observer.h" | 8 #include "content/browser/tab_contents/tab_contents_observer.h" |
9 | 9 |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 | 11 |
12 class TabContentsWrapper; | 12 class TabContentsWrapper; |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 namespace prerender { | 15 namespace prerender { |
16 | 16 |
17 class PrerenderContents; | 17 class PrerenderContents; |
18 class PrerenderManager; | 18 class PrerenderManager; |
19 | 19 |
20 // PrerenderTabHelper is responsible for recording perceived pageload times | 20 // PrerenderTabHelper is responsible for recording perceived pageload times |
21 // to compare PLT's with prerendering enabled and disabled. | 21 // to compare PLT's with prerendering enabled and disabled. |
22 class PrerenderTabHelper : public TabContentsObserver { | 22 class PrerenderTabHelper : public TabContentsObserver { |
23 public: | 23 public: |
24 explicit PrerenderTabHelper(TabContentsWrapper* tab); | 24 explicit PrerenderTabHelper(TabContentsWrapper* tab); |
25 virtual ~PrerenderTabHelper(); | 25 virtual ~PrerenderTabHelper(); |
26 | 26 |
27 // TabContentsObserver implementation. | 27 // TabContentsObserver implementation. |
28 virtual void ProvisionalChangeToMainFrameUrl(const GURL& url, | 28 virtual void ProvisionalChangeToMainFrameUrl(const GURL& url, |
29 bool has_opener_set) OVERRIDE; | 29 bool has_opener_set) OVERRIDE; |
30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
31 virtual void DidStopLoading() OVERRIDE; | 30 virtual void DidStopLoading() OVERRIDE; |
| 31 virtual void DidStartProvisionalLoadForFrame( |
| 32 int64 frame_id, |
| 33 bool is_main_frame, |
| 34 const GURL& validated_url, |
| 35 bool is_error_page, |
| 36 RenderViewHost* render_view_host) OVERRIDE; |
32 | 37 |
33 // Called when this prerendered TabContents has just been swapped in. | 38 // Called when this prerendered TabContents has just been swapped in. |
34 void PrerenderSwappedIn(); | 39 void PrerenderSwappedIn(); |
35 | 40 |
| 41 void UpdateTargetURL(int32 page_id, const GURL& url); |
| 42 |
36 private: | 43 private: |
37 // The data we store for a hover (time the hover occurred & URL). | 44 // The data we store for a hover (time the hover occurred & URL). |
38 class HoverData; | 45 class HoverData; |
39 | 46 |
40 // Message handler. | |
41 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | |
42 bool main_frame, | |
43 bool has_opener_set, | |
44 const GURL& url); | |
45 | |
46 void OnMsgUpdateTargetURL(int32 page_id, const GURL& url); | |
47 | |
48 // Retrieves the PrerenderManager, or NULL, if none was found. | 47 // Retrieves the PrerenderManager, or NULL, if none was found. |
49 PrerenderManager* MaybeGetPrerenderManager() const; | 48 PrerenderManager* MaybeGetPrerenderManager() const; |
50 | 49 |
51 // Checks with the PrerenderManager if the specified URL has been preloaded, | 50 // Checks with the PrerenderManager if the specified URL has been preloaded, |
52 // and if so, swap the RenderViewHost with the preload into this TabContents | 51 // and if so, swap the RenderViewHost with the preload into this TabContents |
53 // object. | 52 // object. |
54 bool MaybeUsePrerenderedPage(const GURL& url, bool has_opener_set); | 53 bool MaybeUsePrerenderedPage(const GURL& url, bool has_opener_set); |
55 | 54 |
56 // Returns whether the TabContents being observed is currently prerendering. | 55 // Returns whether the TabContents being observed is currently prerendering. |
57 bool IsPrerendering(); | 56 bool IsPrerendering(); |
(...skipping 18 matching lines...) Expand all Loading... |
76 // Information about the current hover independent of thresholds. | 75 // Information about the current hover independent of thresholds. |
77 GURL current_hover_url_; | 76 GURL current_hover_url_; |
78 base::TimeTicks current_hover_time_; | 77 base::TimeTicks current_hover_time_; |
79 | 78 |
80 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 79 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
81 }; | 80 }; |
82 | 81 |
83 } // namespace prerender | 82 } // namespace prerender |
84 | 83 |
85 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 84 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
OLD | NEW |