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_LOGIN_ACTION_ADDED_MAINFRAME = 7, | 43 EVENT_LOGIN_ACTION_ADDED_PW_EMPTY = 7, |
38 EVENT_LOGIN_ACTION_ADDED_MAINFRAME_PW_EMPTY = 8, | |
39 EVENT_LOGIN_ACTION_ADDED_SUBFRAME = 9, | |
40 EVENT_LOGIN_ACTION_ADDED_SUBFRAME_PW_EMPTY = 10, | |
41 EVENT_MAX_VALUE | 44 EVENT_MAX_VALUE |
42 }; | 45 }; |
43 | 46 |
| 47 static void CreateForWebContentsWithPasswordManager( |
| 48 content::WebContents* web_contents, |
| 49 PasswordManager* password_manager); |
| 50 |
44 virtual ~PrerenderTabHelper(); | 51 virtual ~PrerenderTabHelper(); |
45 | 52 |
46 // content::WebContentsObserver implementation. | 53 // content::WebContentsObserver implementation. |
47 virtual void ProvisionalChangeToMainFrameUrl( | 54 virtual void ProvisionalChangeToMainFrameUrl( |
48 const GURL& url, | 55 const GURL& url, |
49 content::RenderViewHost* render_view_host) OVERRIDE; | 56 content::RenderViewHost* render_view_host) OVERRIDE; |
50 virtual void DidStopLoading( | 57 virtual void DidStopLoading( |
51 content::RenderViewHost* render_view_host) OVERRIDE; | 58 content::RenderViewHost* render_view_host) OVERRIDE; |
52 virtual void DidStartProvisionalLoadForFrame( | 59 virtual void DidStartProvisionalLoadForFrame( |
53 int64 frame_id, | 60 int64 frame_id, |
54 int64 parent_frame_id, | 61 int64 parent_frame_id, |
55 bool is_main_frame, | 62 bool is_main_frame, |
56 const GURL& validated_url, | 63 const GURL& validated_url, |
57 bool is_error_page, | 64 bool is_error_page, |
58 bool is_iframe_srcdoc, | 65 bool is_iframe_srcdoc, |
59 content::RenderViewHost* render_view_host) OVERRIDE; | 66 content::RenderViewHost* render_view_host) OVERRIDE; |
60 virtual void DidCommitProvisionalLoadForFrame( | 67 virtual void DidCommitProvisionalLoadForFrame( |
61 int64 frame_id, | 68 int64 frame_id, |
62 bool is_main_frame, | 69 bool is_main_frame, |
63 const GURL& validated_url, | 70 const GURL& validated_url, |
64 content::PageTransition transition_type, | 71 content::PageTransition transition_type, |
65 content::RenderViewHost* render_view_host) OVERRIDE; | 72 content::RenderViewHost* render_view_host) OVERRIDE; |
66 virtual void DidNavigateAnyFrame( | 73 |
67 const content::LoadCommittedDetails& details, | 74 // Called when a password form has been submitted. |
68 const content::FrameNavigateParams& params) OVERRIDE; | 75 void PasswordSubmitted(const content::PasswordForm& form); |
69 | 76 |
70 // Called when this prerendered WebContents has just been swapped in. | 77 // Called when this prerendered WebContents has just been swapped in. |
71 void PrerenderSwappedIn(); | 78 void PrerenderSwappedIn(); |
72 | 79 |
73 private: | 80 private: |
74 explicit PrerenderTabHelper(content::WebContents* web_contents); | 81 PrerenderTabHelper(content::WebContents* web_contents, |
| 82 PasswordManager* password_manager); |
75 friend class content::WebContentsUserData<PrerenderTabHelper>; | 83 friend class content::WebContentsUserData<PrerenderTabHelper>; |
76 | 84 |
77 void RecordEvent(Event event) const; | 85 void RecordEvent(Event event) const; |
78 void RecordEventIfLoggedInURL(Event event, const GURL& url); | 86 void RecordEventIfLoggedInURL(Event event, const GURL& url); |
79 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, | 87 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, |
80 scoped_ptr<bool> lookup_succeeded); | 88 scoped_ptr<bool> lookup_succeeded); |
81 // Helper class to compute pixel-based stats on the paint progress | 89 // Helper class to compute pixel-based stats on the paint progress |
82 // between when a prerendered page is swapped in and when the onload event | 90 // between when a prerendered page is swapped in and when the onload event |
83 // fires. | 91 // fires. |
84 class PixelStats; | 92 class PixelStats; |
(...skipping 21 matching lines...) Expand all Loading... |
106 GURL url_; | 114 GURL url_; |
107 | 115 |
108 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; | 116 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; |
109 | 117 |
110 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 118 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
111 }; | 119 }; |
112 | 120 |
113 } // namespace prerender | 121 } // namespace prerender |
114 | 122 |
115 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 123 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
OLD | NEW |