Chromium Code Reviews| 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 "chrome/browser/password_manager/password_manager.h" | |
| 11 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 namespace predictors { | 16 namespace predictors { |
| 16 class LoggedInPredictorTable; | 17 class LoggedInPredictorTable; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace prerender { | 20 namespace prerender { |
| 20 | 21 |
| 21 class PrerenderManager; | 22 class PrerenderManager; |
| 22 | 23 |
| 23 // PrerenderTabHelper is responsible for recording perceived pageload times | 24 // PrerenderTabHelper is responsible for recording perceived pageload times |
| 24 // to compare PLT's with prerendering enabled and disabled. | 25 // to compare PLT's with prerendering enabled and disabled. |
| 25 class PrerenderTabHelper | 26 class PrerenderTabHelper |
| 26 : public content::WebContentsObserver, | 27 : public content::WebContentsObserver, |
| 27 public content::WebContentsUserData<PrerenderTabHelper> { | 28 public content::WebContentsUserData<PrerenderTabHelper> { |
| 28 public: | 29 public: |
| 29 enum Event { | 30 enum Event { |
| 30 EVENT_LOGGED_IN_TABLE_REQUESTED = 0, | 31 EVENT_LOGGED_IN_TABLE_REQUESTED = 0, |
| 31 EVENT_LOGGED_IN_TABLE_PRESENT = 1, | 32 EVENT_LOGGED_IN_TABLE_PRESENT = 1, |
| 32 EVENT_MAINFRAME_CHANGE = 2, | 33 EVENT_MAINFRAME_CHANGE = 2, |
| 33 EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN = 3, | 34 EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN = 3, |
| 34 EVENT_MAINFRAME_COMMIT = 4, | 35 EVENT_MAINFRAME_COMMIT = 4, |
| 35 EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN = 5, | 36 EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN = 5, |
| 36 EVENT_LOGIN_ACTION_ADDED = 6, | 37 EVENT_LOGIN_ACTION_ADDED = 6, |
| 37 EVENT_MAX_VALUE | 38 EVENT_MAX_VALUE |
| 38 }; | 39 }; |
| 39 | 40 |
| 41 static void CreateForWebContentsWithPasswordManager( | |
| 42 content::WebContents* web_contents, | |
| 43 PasswordManager* password_manager); | |
| 44 | |
| 40 virtual ~PrerenderTabHelper(); | 45 virtual ~PrerenderTabHelper(); |
| 41 | 46 |
| 42 // content::WebContentsObserver implementation. | 47 // content::WebContentsObserver implementation. |
| 43 virtual void ProvisionalChangeToMainFrameUrl( | 48 virtual void ProvisionalChangeToMainFrameUrl( |
| 44 const GURL& url, | 49 const GURL& url, |
| 45 content::RenderViewHost* render_view_host) OVERRIDE; | 50 content::RenderViewHost* render_view_host) OVERRIDE; |
| 46 virtual void DidStopLoading( | 51 virtual void DidStopLoading( |
| 47 content::RenderViewHost* render_view_host) OVERRIDE; | 52 content::RenderViewHost* render_view_host) OVERRIDE; |
| 48 virtual void DidStartProvisionalLoadForFrame( | 53 virtual void DidStartProvisionalLoadForFrame( |
| 49 int64 frame_id, | 54 int64 frame_id, |
| 50 int64 parent_frame_id, | 55 int64 parent_frame_id, |
| 51 bool is_main_frame, | 56 bool is_main_frame, |
| 52 const GURL& validated_url, | 57 const GURL& validated_url, |
| 53 bool is_error_page, | 58 bool is_error_page, |
| 54 bool is_iframe_srcdoc, | 59 bool is_iframe_srcdoc, |
| 55 content::RenderViewHost* render_view_host) OVERRIDE; | 60 content::RenderViewHost* render_view_host) OVERRIDE; |
| 56 virtual void DidCommitProvisionalLoadForFrame( | 61 virtual void DidCommitProvisionalLoadForFrame( |
| 57 int64 frame_id, | 62 int64 frame_id, |
| 58 bool is_main_frame, | 63 bool is_main_frame, |
| 59 const GURL& validated_url, | 64 const GURL& validated_url, |
| 60 content::PageTransition transition_type, | 65 content::PageTransition transition_type, |
| 61 content::RenderViewHost* render_view_host) OVERRIDE; | 66 content::RenderViewHost* render_view_host) OVERRIDE; |
| 62 virtual void DidNavigateAnyFrame( | 67 |
| 63 const content::LoadCommittedDetails& details, | 68 void PasswordSubmitted(const content::PasswordForm& form); |
| 64 const content::FrameNavigateParams& params) OVERRIDE; | |
| 65 | 69 |
| 66 // Called when this prerendered WebContents has just been swapped in. | 70 // Called when this prerendered WebContents has just been swapped in. |
| 67 void PrerenderSwappedIn(); | 71 void PrerenderSwappedIn(); |
| 68 | 72 |
| 69 private: | 73 private: |
| 70 explicit PrerenderTabHelper(content::WebContents* web_contents); | 74 PrerenderTabHelper(content::WebContents* web_contents, |
| 75 PasswordManager* password_manager); | |
| 71 friend class content::WebContentsUserData<PrerenderTabHelper>; | 76 friend class content::WebContentsUserData<PrerenderTabHelper>; |
| 72 | 77 |
| 73 void RecordEvent(Event event) const; | 78 void RecordEvent(Event event) const; |
| 74 void RecordEventIfLoggedInURL(Event event, const GURL& url); | 79 void RecordEventIfLoggedInURL(Event event, const GURL& url); |
| 75 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, | 80 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, |
| 76 scoped_ptr<bool> lookup_succeeded); | 81 scoped_ptr<bool> lookup_succeeded); |
| 77 // Helper class to compute pixel-based stats on the paint progress | 82 // 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 | 83 // between when a prerendered page is swapped in and when the onload event |
| 79 // fires. | 84 // fires. |
| 80 class PixelStats; | 85 class PixelStats; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 94 base::TimeTicks pplt_load_start_; | 99 base::TimeTicks pplt_load_start_; |
| 95 | 100 |
| 96 // System time at which the actual pageload started (pre-swapin), if | 101 // System time at which the actual pageload started (pre-swapin), if |
| 97 // a applicable (in cases when a prerender that was still loading was | 102 // a applicable (in cases when a prerender that was still loading was |
| 98 // swapped in). | 103 // swapped in). |
| 99 base::TimeTicks actual_load_start_; | 104 base::TimeTicks actual_load_start_; |
| 100 | 105 |
| 101 // Current URL being loaded. | 106 // Current URL being loaded. |
| 102 GURL url_; | 107 GURL url_; |
| 103 | 108 |
| 109 // Callback to track submitted passwords | |
| 110 PasswordManager::PasswordSubmittedCallback password_callback_; | |
|
Ilya Sherman
2013/07/27 01:09:48
Why does this need to be stored as a member variab
Garrett Casto
2013/08/03 00:38:42
Leftover from an earlier iteration. Removed.
| |
| 111 | |
| 104 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; | 112 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; |
| 105 | 113 |
| 106 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 114 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
| 107 }; | 115 }; |
| 108 | 116 |
| 109 } // namespace prerender | 117 } // namespace prerender |
| 110 | 118 |
| 111 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 119 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| OLD | NEW |