OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/page_load_metrics/page_track_decider.h" | 5 #include "chrome/common/page_load_metrics/page_track_decider.h" |
6 | 6 |
7 namespace page_load_metrics { | 7 namespace page_load_metrics { |
8 | 8 |
9 PageTrackDecider::PageTrackDecider() {} | 9 PageTrackDecider::PageTrackDecider() {} |
10 PageTrackDecider::~PageTrackDecider() {} | 10 PageTrackDecider::~PageTrackDecider() {} |
11 | 11 |
12 bool PageTrackDecider::ShouldTrack() { | 12 bool PageTrackDecider::ShouldTrack() { |
13 // Ignore non-HTTP schemes (e.g. chrome://). | 13 // Ignore NTP loads. |
14 if (!IsHttpOrHttpsUrl()) | 14 if (IsNewTabPageUrl()) |
15 return false; | 15 return false; |
16 | 16 |
17 // Ignore NTP loads. | 17 if (IsAboutBlankUrl()) |
18 if (IsNewTabPageUrl()) | |
19 return false; | 18 return false; |
20 | 19 |
21 if (HasCommitted()) { | 20 if (HasCommitted()) { |
22 // Ignore Chrome error pages (e.g. No Internet connection). | 21 // Ignore Chrome error pages (e.g. No Internet connection). |
23 if (IsChromeErrorPage()) | 22 if (IsChromeErrorPage()) |
24 return false; | 23 return false; |
25 | 24 |
26 // Ignore non-HTML documents (e.g. SVG, images). | 25 // Ignore non-HTML documents (e.g. SVG, images). |
27 if (!IsHtmlOrXhtmlPage()) | 26 if (!IsHtmlOrXhtmlPage()) |
28 return false; | 27 return false; |
29 | 28 |
30 // Ignore network error pages (e.g. 4xx, 5xx). | 29 // Ignore network error pages (e.g. 4xx, 5xx). |
31 int http_status_code = GetHttpStatusCode(); | 30 int http_status_code = GetHttpStatusCode(); |
32 if (http_status_code > 0 && | 31 if (http_status_code > 0 && |
33 (http_status_code < 200 || http_status_code >= 400)) | 32 (http_status_code < 200 || http_status_code >= 400)) |
34 return false; | 33 return false; |
35 } | 34 } |
36 | 35 |
37 return true; | 36 return true; |
38 } | 37 } |
39 | 38 |
40 } // namespace page_load_metrics | 39 } // namespace page_load_metrics |
OLD | NEW |