OLD | NEW |
(Empty) | |
| 1 |
| 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. |
| 5 |
| 6 #include "chrome/browser/android/history_report/usage_report_util.h" |
| 7 |
| 8 #include <iomanip> |
| 9 #include <sstream> |
| 10 |
| 11 #include "chrome/browser/android/proto/delta_file.pb.h" |
| 12 #include "net/base/net_util.h" |
| 13 #include "url/gurl.h" |
| 14 |
| 15 namespace history_report { |
| 16 namespace usage_report_util { |
| 17 |
| 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(); |
| 25 } |
| 26 |
| 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); |
| 32 } |
| 33 |
| 34 bool ShouldIgnoreUrl(const GURL& url) { |
| 35 if (url.spec().empty()) |
| 36 return true; |
| 37 |
| 38 // Ignore local file URLs. |
| 39 // TODO(nileshagrawal): Maybe we should ignore content:// urls too. |
| 40 if (url.SchemeIsFile()) |
| 41 return true; |
| 42 |
| 43 // Ignore localhost URLs. |
| 44 if (net::IsLocalhost(url.host())) |
| 45 return true; |
| 46 |
| 47 return false; |
| 48 } |
| 49 |
| 50 } // namespace usage_report_util |
| 51 } // namespace history_report |
OLD | NEW |