| 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 a click to a |
| 30 // specified Most Visited |provider|. |
| 31 static std::string GetHistogramNameForProvider(const std::string& provider); |
| 32 |
| 26 // Logs a number of statistics regarding the NTP. Called when an NTP tab is | 33 // 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 | 34 // 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. | 35 // the tab/shutting down Chrome), or when the user navigates to a URL. |
| 29 void EmitNtpStatistics(); | 36 void EmitNtpStatistics(); |
| 30 | 37 |
| 31 // Called each time an event occurs on the NTP that requires a counter to be | 38 // Called each time an event occurs on the NTP that requires a counter to be |
| 32 // incremented. | 39 // incremented. |
| 33 void LogEvent(NTPLoggingEventType event); | 40 void LogEvent(NTPLoggingEventType event); |
| 34 | 41 |
| 35 // Logs an impression on one of the Most Visited tiles by a given provider. | 42 // Logs an impression on one of the Most Visited tiles by a given provider. |
| 36 void LogImpression(int position, const base::string16& provider); | 43 void LogImpression(int position, const base::string16& provider); |
| 37 | 44 |
| 45 // Logs a navigation on one of the Most Visited tiles by a given provider. |
| 46 void LogNavigation(int position, const base::string16& provider); |
| 47 |
| 38 // content::WebContentsObserver override | 48 // content::WebContentsObserver override |
| 39 virtual void NavigationEntryCommitted( | 49 virtual void NavigationEntryCommitted( |
| 40 const content::LoadCommittedDetails& load_details) OVERRIDE; | 50 const content::LoadCommittedDetails& load_details) OVERRIDE; |
| 41 | 51 |
| 42 protected: | 52 protected: |
| 43 explicit NTPUserDataLogger(content::WebContents* contents); | 53 explicit NTPUserDataLogger(content::WebContents* contents); |
| 44 | 54 |
| 45 private: | 55 private: |
| 46 friend class content::WebContentsUserData<NTPUserDataLogger>; | 56 friend class content::WebContentsUserData<NTPUserDataLogger>; |
| 47 | 57 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Total number of mouseovers for this NTP session. | 90 // Total number of mouseovers for this NTP session. |
| 81 size_t number_of_mouseovers_; | 91 size_t number_of_mouseovers_; |
| 82 | 92 |
| 83 // The URL of this New Tab Page - varies based on NTP version. | 93 // The URL of this New Tab Page - varies based on NTP version. |
| 84 GURL ntp_url_; | 94 GURL ntp_url_; |
| 85 | 95 |
| 86 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); | 96 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); |
| 87 }; | 97 }; |
| 88 | 98 |
| 89 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ | 99 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ |
| OLD | NEW |