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