blob: d5c9a2e1693f74bc8e2aeb594833d0b1d453f18e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/ntp/android/navigation_handler.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/values.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/page_transition_types.h"
NavigationHandler::NavigationHandler() {}
NavigationHandler::~NavigationHandler() {
// Record an omnibox-based navigation, if there is one.
content::NavigationEntry* entry =
web_ui()->GetWebContents()->GetController().GetActiveEntry();
if (!entry)
return;
if (!(entry->GetTransitionType() &
content::PAGE_TRANSITION_FROM_ADDRESS_BAR) ||
entry->GetTransitionType() & content::PAGE_TRANSITION_FORWARD_BACK) {
return;
}
if (entry->GetURL().SchemeIs(chrome::kChromeUIScheme) &&
entry->GetURL().host() == chrome::kChromeUINewTabHost) {
return;
}
Action action;
if ((entry->GetTransitionType() & content::PAGE_TRANSITION_CORE_MASK) ==
content::PAGE_TRANSITION_GENERATED) {
action = ACTION_SEARCHED_USING_OMNIBOX;
} else if (google_util::IsGoogleHomePageUrl(entry->GetURL())) {
action = ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE;
} else {
action = ACTION_NAVIGATED_USING_OMNIBOX;
}
RecordAction(action);
}
void NavigationHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"openedMostVisited",
base::Bind(&NavigationHandler::HandleOpenedMostVisited,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"openedRecentlyClosed",
base::Bind(&NavigationHandler::HandleOpenedRecentlyClosed,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"openedBookmark",
base::Bind(&NavigationHandler::HandleOpenedBookmark,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"openedForeignSession",
base::Bind(&NavigationHandler::HandleOpenedForeignSession,
base::Unretained(this)));
}
void NavigationHandler::HandleOpenedMostVisited(const base::ListValue* args) {
RecordAction(ACTION_OPENED_MOST_VISITED_ENTRY);
}
void NavigationHandler::HandleOpenedRecentlyClosed(
const base::ListValue* args) {
RecordAction(ACTION_OPENED_RECENTLY_CLOSED_ENTRY);
}
void NavigationHandler::HandleOpenedBookmark(const base::ListValue* args) {
RecordAction(ACTION_OPENED_BOOKMARK);
}
void NavigationHandler::HandleOpenedForeignSession(
const base::ListValue* args) {
RecordAction(ACTION_OPENED_FOREIGN_SESSION);
}
void NavigationHandler::RecordAction(Action action) {
UMA_HISTOGRAM_ENUMERATION("NewTabPage.ActionAndroid", action, NUM_ACTIONS);
}
|