| 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_TAB_CONTENTS_NAVIGATION_METRICS_RECORDER_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_METRICS_RECORDER_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_METRICS_RECORDER_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_METRICS_RECORDER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
| 10 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
| 11 | 11 |
| 12 namespace rappor { | 12 namespace rappor { |
| 13 class RapporServiceImpl; | 13 class RapporServiceImpl; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class NavigationMetricsRecorder | 16 class NavigationMetricsRecorder |
| 17 : public content::WebContentsObserver, | 17 : public content::WebContentsObserver, |
| 18 public content::WebContentsUserData<NavigationMetricsRecorder> { | 18 public content::WebContentsUserData<NavigationMetricsRecorder> { |
| 19 public: | 19 public: |
| 20 ~NavigationMetricsRecorder() override; | 20 ~NavigationMetricsRecorder() override; |
| 21 | 21 |
| 22 void set_rappor_service_for_testing( | 22 void set_rappor_service_for_testing( |
| 23 rappor::RapporServiceImpl* rappor_service); | 23 rappor::RapporServiceImpl* rappor_service); |
| 24 | 24 |
| 25 // This enum is used in building a histogram. So, this is append only, |
| 26 // any new scheme should be added at the end, before MIME_TYPE_MAX. |
| 27 enum MimeType { |
| 28 MIME_TYPE_OTHER, |
| 29 MIME_TYPE_HTML, |
| 30 MIME_TYPE_XHTML, |
| 31 MIME_TYPE_PDF, |
| 32 MIME_TYPE_SVG, |
| 33 MIME_TYPE_MAX |
| 34 }; |
| 35 |
| 25 private: | 36 private: |
| 26 explicit NavigationMetricsRecorder(content::WebContents* web_contents); | 37 explicit NavigationMetricsRecorder(content::WebContents* web_contents); |
| 27 friend class content::WebContentsUserData<NavigationMetricsRecorder>; | 38 friend class content::WebContentsUserData<NavigationMetricsRecorder>; |
| 28 | 39 |
| 29 // content::WebContentsObserver overrides: | 40 // content::WebContentsObserver overrides: |
| 30 void DidNavigateMainFrame( | 41 void DidNavigateMainFrame( |
| 31 const content::LoadCommittedDetails& details, | 42 const content::LoadCommittedDetails& details, |
| 32 const content::FrameNavigateParams& params) override; | 43 const content::FrameNavigateParams& params) override; |
| 33 | 44 |
| 34 rappor::RapporServiceImpl* rappor_service_; | 45 rappor::RapporServiceImpl* rappor_service_; |
| 35 | 46 |
| 36 DISALLOW_COPY_AND_ASSIGN(NavigationMetricsRecorder); | 47 DISALLOW_COPY_AND_ASSIGN(NavigationMetricsRecorder); |
| 37 }; | 48 }; |
| 38 | 49 |
| 39 #endif // CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_METRICS_RECORDER_H_ | 50 #endif // CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_METRICS_RECORDER_H_ |
| OLD | NEW |