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 #include "chrome/browser/ui/webui/ntp/android/navigation_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/android/navigation_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 content::PAGE_TRANSITION_FROM_ADDRESS_BAR) || | 28 content::PAGE_TRANSITION_FROM_ADDRESS_BAR) || |
29 entry->GetTransitionType() & content::PAGE_TRANSITION_FORWARD_BACK) { | 29 entry->GetTransitionType() & content::PAGE_TRANSITION_FORWARD_BACK) { |
30 return; | 30 return; |
31 } | 31 } |
32 | 32 |
33 if (entry->GetURL().SchemeIs(chrome::kChromeUIScheme) && | 33 if (entry->GetURL().SchemeIs(chrome::kChromeUIScheme) && |
34 entry->GetURL().host() == chrome::kChromeUINewTabHost) { | 34 entry->GetURL().host() == chrome::kChromeUINewTabHost) { |
35 return; | 35 return; |
36 } | 36 } |
37 | 37 |
38 Action action; | 38 RecordActionForNavigation(*entry); |
39 if ((entry->GetTransitionType() & content::PAGE_TRANSITION_CORE_MASK) == | |
40 content::PAGE_TRANSITION_GENERATED) { | |
41 action = ACTION_SEARCHED_USING_OMNIBOX; | |
42 } else if (google_util::IsGoogleHomePageUrl(entry->GetURL())) { | |
43 action = ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE; | |
44 } else { | |
45 action = ACTION_NAVIGATED_USING_OMNIBOX; | |
46 } | |
47 RecordAction(action); | |
48 } | 39 } |
49 | 40 |
50 void NavigationHandler::RegisterMessages() { | 41 void NavigationHandler::RegisterMessages() { |
51 web_ui()->RegisterMessageCallback( | 42 web_ui()->RegisterMessageCallback( |
52 "openedMostVisited", | 43 "openedMostVisited", |
53 base::Bind(&NavigationHandler::HandleOpenedMostVisited, | 44 base::Bind(&NavigationHandler::HandleOpenedMostVisited, |
54 base::Unretained(this))); | 45 base::Unretained(this))); |
55 web_ui()->RegisterMessageCallback( | 46 web_ui()->RegisterMessageCallback( |
56 "openedRecentlyClosed", | 47 "openedRecentlyClosed", |
57 base::Bind(&NavigationHandler::HandleOpenedRecentlyClosed, | 48 base::Bind(&NavigationHandler::HandleOpenedRecentlyClosed, |
(...skipping 19 matching lines...) Expand all Loading... |
77 | 68 |
78 void NavigationHandler::HandleOpenedBookmark(const base::ListValue* args) { | 69 void NavigationHandler::HandleOpenedBookmark(const base::ListValue* args) { |
79 RecordAction(ACTION_OPENED_BOOKMARK); | 70 RecordAction(ACTION_OPENED_BOOKMARK); |
80 } | 71 } |
81 | 72 |
82 void NavigationHandler::HandleOpenedForeignSession( | 73 void NavigationHandler::HandleOpenedForeignSession( |
83 const base::ListValue* args) { | 74 const base::ListValue* args) { |
84 RecordAction(ACTION_OPENED_FOREIGN_SESSION); | 75 RecordAction(ACTION_OPENED_FOREIGN_SESSION); |
85 } | 76 } |
86 | 77 |
| 78 // static |
| 79 void NavigationHandler::RecordActionForNavigation( |
| 80 const content::NavigationEntry& entry) { |
| 81 Action action; |
| 82 if ((entry.GetTransitionType() & content::PAGE_TRANSITION_CORE_MASK) == |
| 83 content::PAGE_TRANSITION_GENERATED) { |
| 84 action = ACTION_SEARCHED_USING_OMNIBOX; |
| 85 } else if (google_util::IsGoogleHomePageUrl(entry.GetURL())) { |
| 86 action = ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE; |
| 87 } else { |
| 88 action = ACTION_NAVIGATED_USING_OMNIBOX; |
| 89 } |
| 90 RecordAction(action); |
| 91 } |
| 92 |
| 93 // static |
87 void NavigationHandler::RecordAction(Action action) { | 94 void NavigationHandler::RecordAction(Action action) { |
88 UMA_HISTOGRAM_ENUMERATION("NewTabPage.ActionAndroid", action, NUM_ACTIONS); | 95 UMA_HISTOGRAM_ENUMERATION("NewTabPage.ActionAndroid", action, NUM_ACTIONS); |
89 } | 96 } |
OLD | NEW |