Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / android / history_report / usage_report_util.cc
blob013842622f6f2b89f91ec3c61d7d689ee48f133d
2 // Copyright 2015 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #include "chrome/browser/android/history_report/usage_report_util.h"
8 #include <iomanip>
9 #include <sstream>
11 #include "chrome/browser/android/proto/delta_file.pb.h"
12 #include "net/base/net_util.h"
13 #include "url/gurl.h"
15 namespace history_report {
16 namespace usage_report_util {
18 // Returns a levelDb key for a report. It's a concatenation of timestamp and id
19 // fields of a report.
20 std::string ReportToKey(const history_report::UsageReport& report) {
21 std::stringstream key;
22 key << std::setfill('0') << std::setw(15) << report.timestamp_ms()
23 << report.id();
24 return key.str();
27 bool IsTypedVisit(ui::PageTransition visit_transition) {
28 ui::PageTransition transition_type =
29 ui::PageTransitionStripQualifier(visit_transition);
30 return transition_type == ui::PAGE_TRANSITION_TYPED &&
31 !ui::PageTransitionIsRedirect(visit_transition);
34 bool ShouldIgnoreUrl(const GURL& url) {
35 if (url.spec().empty())
36 return true;
38 // Ignore local file URLs.
39 // TODO(nileshagrawal): Maybe we should ignore content:// urls too.
40 if (url.SchemeIsFile())
41 return true;
43 // Ignore localhost URLs.
44 if (net::IsLocalhost(url.host()))
45 return true;
47 return false;
50 } // namespace usage_report_util
51 } // namespace history_report