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