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_ANDROID_NAVIGATION_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "content/public/browser/navigation_entry.h" |
9 #include "content/public/browser/web_ui_message_handler.h" | 10 #include "content/public/browser/web_ui_message_handler.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 class ListValue; | 13 class ListValue; |
13 } | 14 } |
14 | 15 |
15 // Records a UMA stat ("NewTabPage.ActionAndroid") for the action the user takes | 16 // Records a UMA stat ("NewTabPage.ActionAndroid") for the action the user takes |
16 // to navigate away from the NTP. | 17 // to navigate away from the NTP. |
17 class NavigationHandler : public content::WebUIMessageHandler { | 18 class NavigationHandler : public content::WebUIMessageHandler { |
18 public: | 19 public: |
19 NavigationHandler(); | 20 NavigationHandler(); |
20 virtual ~NavigationHandler(); | 21 virtual ~NavigationHandler(); |
21 | 22 |
22 // WebUIMessageHandler implementation. | 23 // WebUIMessageHandler implementation. |
23 virtual void RegisterMessages() OVERRIDE; | 24 virtual void RegisterMessages() OVERRIDE; |
24 | 25 |
25 // Callback for "openedMostVisited". | 26 // Callback for "openedMostVisited". |
26 void HandleOpenedMostVisited(const base::ListValue* args); | 27 void HandleOpenedMostVisited(const base::ListValue* args); |
27 | 28 |
28 // Callback for "openedRecentlyClosed". | 29 // Callback for "openedRecentlyClosed". |
29 void HandleOpenedRecentlyClosed(const base::ListValue* args); | 30 void HandleOpenedRecentlyClosed(const base::ListValue* args); |
30 | 31 |
31 // Callback for "openedBookmark". | 32 // Callback for "openedBookmark". |
32 void HandleOpenedBookmark(const base::ListValue* args); | 33 void HandleOpenedBookmark(const base::ListValue* args); |
33 | 34 |
34 // Callback for "openedForeignSession". | 35 // Callback for "openedForeignSession". |
35 void HandleOpenedForeignSession(const base::ListValue* args); | 36 void HandleOpenedForeignSession(const base::ListValue* args); |
36 | 37 |
| 38 static void RecordActionForNavigation(const content::NavigationEntry& entry); |
| 39 |
37 private: | 40 private: |
38 // Possible actions taken by the user on the NTP. This enum is also defined in | 41 // Possible actions taken by the user on the NTP. This enum is also defined in |
39 // histograms.xml. WARNING: these values must stay in sync with histograms.xml | 42 // histograms.xml. WARNING: these values must stay in sync with histograms.xml |
40 // and new actions can be added only at the end of the enum. | 43 // and new actions can be added only at the end of the enum. |
41 enum Action { | 44 enum Action { |
42 // User performed a search using the omnibox | 45 // User performed a search using the omnibox |
43 ACTION_SEARCHED_USING_OMNIBOX = 0, | 46 ACTION_SEARCHED_USING_OMNIBOX = 0, |
44 // User navigated to Google search homepage using the omnibox | 47 // User navigated to Google search homepage using the omnibox |
45 ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE = 1, | 48 ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE = 1, |
46 // User navigated to any other page using the omnibox | 49 // User navigated to any other page using the omnibox |
47 ACTION_NAVIGATED_USING_OMNIBOX = 2, | 50 ACTION_NAVIGATED_USING_OMNIBOX = 2, |
48 // User opened a most visited page | 51 // User opened a most visited page |
49 ACTION_OPENED_MOST_VISITED_ENTRY = 3, | 52 ACTION_OPENED_MOST_VISITED_ENTRY = 3, |
50 // User opened a recently closed tab | 53 // User opened a recently closed tab |
51 ACTION_OPENED_RECENTLY_CLOSED_ENTRY = 4, | 54 ACTION_OPENED_RECENTLY_CLOSED_ENTRY = 4, |
52 // User opened a bookmark | 55 // User opened a bookmark |
53 ACTION_OPENED_BOOKMARK = 5, | 56 ACTION_OPENED_BOOKMARK = 5, |
54 // User opened a foreign session (from other devices section) | 57 // User opened a foreign session (from other devices section) |
55 ACTION_OPENED_FOREIGN_SESSION = 6, | 58 ACTION_OPENED_FOREIGN_SESSION = 6, |
56 // The number of possible actions | 59 // The number of possible actions |
57 NUM_ACTIONS = 7 | 60 NUM_ACTIONS = 7 |
58 }; | 61 }; |
59 | 62 |
60 void RecordAction(Action action); | 63 static void RecordAction(Action action); |
61 | 64 |
62 DISALLOW_COPY_AND_ASSIGN(NavigationHandler); | 65 DISALLOW_COPY_AND_ASSIGN(NavigationHandler); |
63 }; | 66 }; |
64 | 67 |
65 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_ | 68 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_ |
OLD | NEW |