OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/strings/string16.h" |
8 #include "chrome/common/ntp_logging_events.h" | 11 #include "chrome/common/ntp_logging_events.h" |
9 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
10 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
11 | 14 |
12 namespace content { | 15 namespace content { |
13 class WebContents; | 16 class WebContents; |
14 } | 17 } |
15 | 18 |
16 // Helper class for logging data from the NTP. Attached to each NTP instance. | 19 // Helper class for logging data from the NTP. Attached to each NTP instance. |
17 class NTPUserDataLogger | 20 class NTPUserDataLogger |
18 : public content::WebContentsObserver, | 21 : public content::WebContentsObserver, |
19 public content::WebContentsUserData<NTPUserDataLogger> { | 22 public content::WebContentsUserData<NTPUserDataLogger> { |
20 public: | 23 public: |
21 virtual ~NTPUserDataLogger(); | 24 virtual ~NTPUserDataLogger(); |
22 | 25 |
23 static NTPUserDataLogger* GetOrCreateFromWebContents( | 26 static NTPUserDataLogger* GetOrCreateFromWebContents( |
24 content::WebContents* content); | 27 content::WebContents* content); |
25 | 28 |
| 29 // Returns the name of the histogram that should be logged for an impression |
| 30 // of a specified Most Visited |provider|. |
| 31 static std::string GetMostVisitedImpressionHistogramNameForProvider( |
| 32 const std::string& provider); |
| 33 |
| 34 // Returns the name of the histogram that should be logged for a navigation |
| 35 // to a specified Most Visited |provider|. |
| 36 static std::string GetMostVisitedNavigationHistogramNameForProvider( |
| 37 const std::string& provider); |
| 38 |
26 // Logs a number of statistics regarding the NTP. Called when an NTP tab is | 39 // Logs a number of statistics regarding the NTP. Called when an NTP tab is |
27 // about to be deactivated (be it by switching tabs, losing focus or closing | 40 // about to be deactivated (be it by switching tabs, losing focus or closing |
28 // the tab/shutting down Chrome), or when the user navigates to a URL. | 41 // the tab/shutting down Chrome), or when the user navigates to a URL. |
29 void EmitNtpStatistics(); | 42 void EmitNtpStatistics(); |
30 | 43 |
31 // Called each time an event occurs on the NTP that requires a counter to be | 44 // Called each time an event occurs on the NTP that requires a counter to be |
32 // incremented. | 45 // incremented. |
33 void LogEvent(NTPLoggingEventType event); | 46 void LogEvent(NTPLoggingEventType event); |
34 | 47 |
35 // Logs an impression on one of the Most Visited tiles by a given provider. | 48 // Logs an impression on one of the Most Visited tiles by a given provider. |
36 void LogImpression(int position, const base::string16& provider); | 49 void LogMostVisitedImpression(int position, const base::string16& provider); |
| 50 |
| 51 // Logs a navigation on one of the Most Visited tiles by a given provider. |
| 52 void LogMostVisitedNavigation(int position, const base::string16& provider); |
37 | 53 |
38 // content::WebContentsObserver override | 54 // content::WebContentsObserver override |
39 virtual void NavigationEntryCommitted( | 55 virtual void NavigationEntryCommitted( |
40 const content::LoadCommittedDetails& load_details) OVERRIDE; | 56 const content::LoadCommittedDetails& load_details) OVERRIDE; |
41 | 57 |
42 protected: | 58 protected: |
43 explicit NTPUserDataLogger(content::WebContents* contents); | 59 explicit NTPUserDataLogger(content::WebContents* contents); |
44 | 60 |
45 private: | 61 private: |
46 friend class content::WebContentsUserData<NTPUserDataLogger>; | 62 friend class content::WebContentsUserData<NTPUserDataLogger>; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Total number of mouseovers for this NTP session. | 96 // Total number of mouseovers for this NTP session. |
81 size_t number_of_mouseovers_; | 97 size_t number_of_mouseovers_; |
82 | 98 |
83 // The URL of this New Tab Page - varies based on NTP version. | 99 // The URL of this New Tab Page - varies based on NTP version. |
84 GURL ntp_url_; | 100 GURL ntp_url_; |
85 | 101 |
86 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); | 102 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); |
87 }; | 103 }; |
88 | 104 |
89 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ | 105 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ |
OLD | NEW |