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> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "chrome/common/ntp_logging_events.h" | 11 #include "chrome/common/ntp_logging_events.h" |
12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
13 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class WebContents; | 16 class WebContents; |
17 } | 17 } |
18 | 18 |
19 // 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. |
20 class NTPUserDataLogger | 20 class NTPUserDataLogger |
21 : public content::WebContentsObserver, | 21 : public content::WebContentsObserver, |
22 public content::WebContentsUserData<NTPUserDataLogger> { | 22 public content::WebContentsUserData<NTPUserDataLogger> { |
23 public: | 23 public: |
24 virtual ~NTPUserDataLogger(); | 24 ~NTPUserDataLogger() override; |
25 | 25 |
26 static NTPUserDataLogger* GetOrCreateFromWebContents( | 26 static NTPUserDataLogger* GetOrCreateFromWebContents( |
27 content::WebContents* content); | 27 content::WebContents* content); |
28 | 28 |
29 // Returns the name of the histogram that should be logged for an impression | 29 // Returns the name of the histogram that should be logged for an impression |
30 // of a specified Most Visited |provider|. | 30 // of a specified Most Visited |provider|. |
31 static std::string GetMostVisitedImpressionHistogramNameForProvider( | 31 static std::string GetMostVisitedImpressionHistogramNameForProvider( |
32 const std::string& provider); | 32 const std::string& provider); |
33 | 33 |
34 // Returns the name of the histogram that should be logged for a navigation | 34 // Returns the name of the histogram that should be logged for a navigation |
(...skipping 10 matching lines...) Expand all Loading... |
45 // incremented. | 45 // incremented. |
46 void LogEvent(NTPLoggingEventType event); | 46 void LogEvent(NTPLoggingEventType event); |
47 | 47 |
48 // 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. |
49 void LogMostVisitedImpression(int position, const base::string16& provider); | 49 void LogMostVisitedImpression(int position, const base::string16& provider); |
50 | 50 |
51 // Logs a navigation on one of the Most Visited tiles by a given provider. | 51 // Logs a navigation on one of the Most Visited tiles by a given provider. |
52 void LogMostVisitedNavigation(int position, const base::string16& provider); | 52 void LogMostVisitedNavigation(int position, const base::string16& provider); |
53 | 53 |
54 // content::WebContentsObserver override | 54 // content::WebContentsObserver override |
55 virtual void NavigationEntryCommitted( | 55 void NavigationEntryCommitted( |
56 const content::LoadCommittedDetails& load_details) override; | 56 const content::LoadCommittedDetails& load_details) override; |
57 | 57 |
58 protected: | 58 protected: |
59 explicit NTPUserDataLogger(content::WebContents* contents); | 59 explicit NTPUserDataLogger(content::WebContents* contents); |
60 | 60 |
61 private: | 61 private: |
62 friend class content::WebContentsUserData<NTPUserDataLogger>; | 62 friend class content::WebContentsUserData<NTPUserDataLogger>; |
63 | 63 |
64 // True if at least one iframe came from a server-side suggestion. In | 64 // True if at least one iframe came from a server-side suggestion. In |
65 // practice, either all the iframes are server-side suggestions or none are. | 65 // practice, either all the iframes are server-side suggestions or none are. |
(...skipping 30 matching lines...) Expand all Loading... |
96 // Total number of mouseovers for this NTP session. | 96 // Total number of mouseovers for this NTP session. |
97 size_t number_of_mouseovers_; | 97 size_t number_of_mouseovers_; |
98 | 98 |
99 // 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. |
100 GURL ntp_url_; | 100 GURL ntp_url_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); | 102 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); |
103 }; | 103 }; |
104 | 104 |
105 #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 |