blob: f6c9efdcb3bc675edcbf78c0cb234771fa4207d6 (
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
|
// Copyright 2015 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/android/history_report/usage_report_util.h"
#include <iomanip>
#include <sstream>
#include "chrome/browser/android/proto/delta_file.pb.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
namespace history_report {
namespace usage_report_util {
// Returns a levelDb key for a report. It's a concatenation of timestamp and id
// fields of a report.
std::string ReportToKey(const history_report::UsageReport& report) {
std::stringstream key;
key << std::setfill('0') << std::setw(15) << report.timestamp_ms()
<< report.id();
return key.str();
}
bool IsTypedVisit(ui::PageTransition visit_transition) {
ui::PageTransition transition_type =
ui::PageTransitionStripQualifier(visit_transition);
return transition_type == ui::PAGE_TRANSITION_TYPED &&
!ui::PageTransitionIsRedirect(visit_transition);
}
bool ShouldIgnoreUrl(const GURL& url) {
if (url.spec().empty())
return true;
// Ignore local file URLs.
// TODO(nileshagrawal): Maybe we should ignore content:// urls too.
if (url.SchemeIsFile())
return true;
// Ignore localhost URLs.
if (net::IsLocalhost(url.host_piece()))
return true;
return false;
}
} // namespace usage_report_util
} // namespace history_report
|