| 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>, |
| 29 public PasswordManager::SubmissionObserver { |
| 28 public: | 30 public: |
| 29 enum Event { | 31 enum Event { |
| 30 EVENT_LOGGED_IN_TABLE_REQUESTED = 0, | 32 EVENT_LOGGED_IN_TABLE_REQUESTED = 0, |
| 31 EVENT_LOGGED_IN_TABLE_PRESENT = 1, | 33 EVENT_LOGGED_IN_TABLE_PRESENT = 1, |
| 32 EVENT_MAINFRAME_CHANGE = 2, | 34 EVENT_MAINFRAME_CHANGE = 2, |
| 33 EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN = 3, | 35 EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN = 3, |
| 34 EVENT_MAINFRAME_COMMIT = 4, | 36 EVENT_MAINFRAME_COMMIT = 4, |
| 35 EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN = 5, | 37 EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN = 5, |
| 36 EVENT_LOGIN_ACTION_ADDED = 6, | 38 EVENT_LOGIN_ACTION_ADDED = 6, |
| 37 EVENT_MAX_VALUE | 39 EVENT_MAX_VALUE |
| 38 }; | 40 }; |
| 39 | 41 |
| 42 static void CreateForWebContentsWithPasswordManager( |
| 43 content::WebContents* web_contents, |
| 44 PasswordManager* password_manager); |
| 45 |
| 40 virtual ~PrerenderTabHelper(); | 46 virtual ~PrerenderTabHelper(); |
| 41 | 47 |
| 42 // content::WebContentsObserver implementation. | 48 // content::WebContentsObserver implementation. |
| 43 virtual void ProvisionalChangeToMainFrameUrl( | 49 virtual void ProvisionalChangeToMainFrameUrl( |
| 44 const GURL& url, | 50 const GURL& url, |
| 45 content::RenderViewHost* render_view_host) OVERRIDE; | 51 content::RenderViewHost* render_view_host) OVERRIDE; |
| 46 virtual void DidStopLoading( | 52 virtual void DidStopLoading( |
| 47 content::RenderViewHost* render_view_host) OVERRIDE; | 53 content::RenderViewHost* render_view_host) OVERRIDE; |
| 48 virtual void DidStartProvisionalLoadForFrame( | 54 virtual void DidStartProvisionalLoadForFrame( |
| 49 int64 frame_id, | 55 int64 frame_id, |
| 50 int64 parent_frame_id, | 56 int64 parent_frame_id, |
| 51 bool is_main_frame, | 57 bool is_main_frame, |
| 52 const GURL& validated_url, | 58 const GURL& validated_url, |
| 53 bool is_error_page, | 59 bool is_error_page, |
| 54 bool is_iframe_srcdoc, | 60 bool is_iframe_srcdoc, |
| 55 content::RenderViewHost* render_view_host) OVERRIDE; | 61 content::RenderViewHost* render_view_host) OVERRIDE; |
| 56 virtual void DidCommitProvisionalLoadForFrame( | 62 virtual void DidCommitProvisionalLoadForFrame( |
| 57 int64 frame_id, | 63 int64 frame_id, |
| 58 bool is_main_frame, | 64 bool is_main_frame, |
| 59 const GURL& validated_url, | 65 const GURL& validated_url, |
| 60 content::PageTransition transition_type, | 66 content::PageTransition transition_type, |
| 61 content::RenderViewHost* render_view_host) OVERRIDE; | 67 content::RenderViewHost* render_view_host) OVERRIDE; |
| 62 virtual void DidNavigateAnyFrame( | 68 |
| 63 const content::LoadCommittedDetails& details, | 69 // PasswordManager::SubmissionObserver |
| 64 const content::FrameNavigateParams& params) OVERRIDE; | 70 virtual void PasswordSubmitted(const content::PasswordForm& form) OVERRIDE; |
| 65 | 71 |
| 66 // Called when this prerendered WebContents has just been swapped in. | 72 // Called when this prerendered WebContents has just been swapped in. |
| 67 void PrerenderSwappedIn(); | 73 void PrerenderSwappedIn(); |
| 68 | 74 |
| 69 private: | 75 private: |
| 70 explicit PrerenderTabHelper(content::WebContents* web_contents); | 76 PrerenderTabHelper(content::WebContents* web_contents, |
| 77 PasswordManager* password_manager); |
| 71 friend class content::WebContentsUserData<PrerenderTabHelper>; | 78 friend class content::WebContentsUserData<PrerenderTabHelper>; |
| 72 | 79 |
| 73 void RecordEvent(Event event) const; | 80 void RecordEvent(Event event) const; |
| 74 void RecordEventIfLoggedInURL(Event event, const GURL& url); | 81 void RecordEventIfLoggedInURL(Event event, const GURL& url); |
| 75 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, | 82 void RecordEventIfLoggedInURLResult(Event event, scoped_ptr<bool> is_present, |
| 76 scoped_ptr<bool> lookup_succeeded); | 83 scoped_ptr<bool> lookup_succeeded); |
| 77 // Helper class to compute pixel-based stats on the paint progress | 84 // 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 | 85 // between when a prerendered page is swapped in and when the onload event |
| 79 // fires. | 86 // fires. |
| 80 class PixelStats; | 87 class PixelStats; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 102 GURL url_; | 109 GURL url_; |
| 103 | 110 |
| 104 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; | 111 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; |
| 105 | 112 |
| 106 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 113 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
| 107 }; | 114 }; |
| 108 | 115 |
| 109 } // namespace prerender | 116 } // namespace prerender |
| 110 | 117 |
| 111 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 118 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| OLD | NEW |