Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / ntp / ntp_user_data_logger.h
blobfc0923a522a84be1fb784d2d57c65a7d990b4979
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
8 #include "chrome/common/ntp_logging_events.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h"
12 namespace content {
13 class WebContents;
16 // Helper class for logging data from the NTP. Attached to each NTP instance.
17 class NTPUserDataLogger
18 : public content::WebContentsObserver,
19 public content::WebContentsUserData<NTPUserDataLogger> {
20 public:
21 virtual ~NTPUserDataLogger();
23 static NTPUserDataLogger* GetOrCreateFromWebContents(
24 content::WebContents* content);
26 // 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
28 // the tab/shutting down Chrome), or when the user navigates to a URL.
29 void EmitNtpStatistics();
31 // Called each time an event occurs on the NTP that requires a counter to be
32 // incremented.
33 void LogEvent(NTPLoggingEventType event);
35 // Logs an impression on one of the Most Visited tiles by a given provider.
36 void LogImpression(int position, const base::string16& provider);
38 // content::WebContentsObserver override
39 virtual void NavigationEntryCommitted(
40 const content::LoadCommittedDetails& load_details) OVERRIDE;
42 protected:
43 explicit NTPUserDataLogger(content::WebContents* contents);
45 private:
46 friend class content::WebContentsUserData<NTPUserDataLogger>;
48 // True if at least one iframe came from a server-side suggestion. In
49 // practice, either all the iframes are server-side suggestions or none are.
50 bool has_server_side_suggestions_;
52 // Total number of tiles rendered, no matter if it's a thumbnail, a gray tile
53 // or an external tile.
54 size_t number_of_tiles_;
56 // Total number of tiles using a local thumbnail image for this NTP session.
57 size_t number_of_thumbnail_tiles_;
59 // Total number of tiles for which no thumbnail is specified and a gray tile
60 // with the domain is used as the main tile.
61 size_t number_of_gray_tiles_;
63 // Total number of tiles for which the visual appearance is handled externally
64 // by the page itself.
65 size_t number_of_external_tiles_;
67 // Total number of errors that occurred when trying to load thumbnail images
68 // for this NTP session. When these errors occur a grey tile is shown instead
69 // of a thumbnail image.
70 size_t number_of_thumbnail_errors_;
72 // The number of times a gray tile with the domain was used as the fallback
73 // for a failed thumbnail.
74 size_t number_of_gray_tile_fallbacks_;
76 // The number of times an external tile, for which the visual appearance is
77 // handled by the page itself, was the fallback for a failed thumbnail.
78 size_t number_of_external_tile_fallbacks_;
80 // Total number of mouseovers for this NTP session.
81 size_t number_of_mouseovers_;
83 // The URL of this New Tab Page - varies based on NTP version.
84 GURL ntp_url_;
86 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger);
89 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_