OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
12 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
| 15 class PasswordManager; |
| 16 |
| 17 namespace content { |
| 18 struct PasswordForm; |
| 19 } |
| 20 |
15 namespace predictors { | 21 namespace predictors { |
16 class LoggedInPredictorTable; | 22 class LoggedInPredictorTable; |
17 } | 23 } |
18 | 24 |
19 namespace prerender { | 25 namespace prerender { |
20 | 26 |
21 class PrerenderManager; | 27 class PrerenderManager; |
22 | 28 |
23 // PrerenderTabHelper is responsible for recording perceived pageload times | 29 // PrerenderTabHelper is responsible for recording perceived pageload times |
24 // to compare PLT's with prerendering enabled and disabled. | 30 // to compare PLT's with prerendering enabled and disabled. |
25 class PrerenderTabHelper | 31 class PrerenderTabHelper |
26 : public content::WebContentsObserver, | 32 : public content::WebContentsObserver, |
27 public content::WebContentsUserData<PrerenderTabHelper> { | 33 public content::WebContentsUserData<PrerenderTabHelper> { |
28 public: | 34 public: |
29 enum Event { | 35 enum Event { |
30 EVENT_LOGGED_IN_TABLE_REQUESTED = 0, | 36 EVENT_LOGGED_IN_TABLE_REQUESTED = 0, |
31 EVENT_LOGGED_IN_TABLE_PRESENT = 1, | 37 EVENT_LOGGED_IN_TABLE_PRESENT = 1, |
32 EVENT_MAINFRAME_CHANGE = 2, | 38 EVENT_MAINFRAME_CHANGE = 2, |
33 EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN = 3, | 39 EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN = 3, |
34 EVENT_MAINFRAME_COMMIT = 4, | 40 EVENT_MAINFRAME_COMMIT = 4, |
35 EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN = 5, | 41 EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN = 5, |
36 EVENT_LOGIN_ACTION_ADDED = 6, | 42 EVENT_LOGIN_ACTION_ADDED = 6, |
37 EVENT_MAX_VALUE | 43 EVENT_MAX_VALUE |
38 }; | 44 }; |
39 | 45 |
| 46 static void CreateForWebContentsWithPasswordManager( |
| 47 content::WebContents* web_contents, |
| 48 PasswordManager* password_manager); |
| 49 |
40 virtual ~PrerenderTabHelper(); | 50 virtual ~PrerenderTabHelper(); |
41 | 51 |
42 // content::WebContentsObserver implementation. | 52 // content::WebContentsObserver implementation. |
43 virtual void ProvisionalChangeToMainFrameUrl( | 53 virtual void ProvisionalChangeToMainFrameUrl( |
44 const GURL& url, | 54 const GURL& url, |
45 content::RenderViewHost* render_view_host) OVERRIDE; | 55 content::RenderViewHost* render_view_host) OVERRIDE; |
46 virtual void DidStopLoading( | 56 virtual void DidStopLoading( |
47 content::RenderViewHost* render_view_host) OVERRIDE; | 57 content::RenderViewHost* render_view_host) OVERRIDE; |
48 virtual void DidStartProvisionalLoadForFrame( | 58 virtual void DidStartProvisionalLoadForFrame( |
49 int64 frame_id, | 59 int64 frame_id, |
50 int64 parent_frame_id, | 60 int64 parent_frame_id, |
51 bool is_main_frame, | 61 bool is_main_frame, |
52 const GURL& validated_url, | 62 const GURL& validated_url, |
53 bool is_error_page, | 63 bool is_error_page, |
54 bool is_iframe_srcdoc, | 64 bool is_iframe_srcdoc, |
55 content::RenderViewHost* render_view_host) OVERRIDE; | 65 content::RenderViewHost* render_view_host) OVERRIDE; |
56 virtual void DidCommitProvisionalLoadForFrame( | 66 virtual void DidCommitProvisionalLoadForFrame( |
57 int64 frame_id, | 67 int64 frame_id, |
58 bool is_main_frame, | 68 bool is_main_frame, |
59 const GURL& validated_url, | 69 const GURL& validated_url, |
60 content::PageTransition transition_type, | 70 content::PageTransition transition_type, |
61 content::RenderViewHost* render_view_host) OVERRIDE; | 71 content::RenderViewHost* render_view_host) OVERRIDE; |
62 virtual void DidNavigateAnyFrame( | 72 |
63 const content::LoadCommittedDetails& details, | 73 // Called when a password form has been submitted. |
64 const content::FrameNavigateParams& params) OVERRIDE; | 74 void PasswordSubmitted(const content::PasswordForm& form); |
65 | 75 |
66 // Called when this prerendered WebContents has just been swapped in. | 76 // Called when this prerendered WebContents has just been swapped in. |
67 void PrerenderSwappedIn(); | 77 void PrerenderSwappedIn(); |
68 | 78 |
69 private: | 79 private: |
70 explicit PrerenderTabHelper(content::WebContents* web_contents); | 80 PrerenderTabHelper(content::WebContents* web_contents, |
| 81 PasswordManager* password_manager); |
71 friend class content::WebContentsUserData<PrerenderTabHelper>; | 82 friend class content::WebContentsUserData<PrerenderTabHelper>; |
72 | 83 |
73 void RecordEvent(Event event) const; | 84 void RecordEvent(Event event) const; |
74 void RecordEventIfLoggedInURL(Event event, const GURL& url); | 85 void RecordEventIfLoggedInURL(Event event, const GURL& url); |
75 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, | 86 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, |
76 scoped_ptr<bool> lookup_succeeded); | 87 scoped_ptr<bool> lookup_succeeded); |
77 // Helper class to compute pixel-based stats on the paint progress | 88 // Helper class to compute pixel-based stats on the paint progress |
78 // between when a prerendered page is swapped in and when the onload event | 89 // between when a prerendered page is swapped in and when the onload event |
79 // fires. | 90 // fires. |
80 class PixelStats; | 91 class PixelStats; |
(...skipping 21 matching lines...) Expand all Loading... |
102 GURL url_; | 113 GURL url_; |
103 | 114 |
104 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; | 115 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; |
105 | 116 |
106 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 117 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
107 }; | 118 }; |
108 | 119 |
109 } // namespace prerender | 120 } // namespace prerender |
110 | 121 |
111 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 122 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
OLD | NEW |