OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/prerender/prerender_util.h" | 5 #include "chrome/browser/prerender/prerender_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (!new_url.is_empty() && new_url.is_valid()) { | 65 if (!new_url.is_empty() && new_url.is_valid()) { |
66 *alias_url = new_url; | 66 *alias_url = new_url; |
67 return true; | 67 return true; |
68 } | 68 } |
69 return false; | 69 return false; |
70 } | 70 } |
71 return false; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 bool IsGoogleDomain(const GURL& url) { | 74 bool IsGoogleDomain(const GURL& url) { |
75 return base::StartsWithASCII(url.host(), std::string("www.google."), true); | 75 return base::StartsWith(url.host(), "www.google.", |
| 76 base::CompareCase::SENSITIVE); |
76 } | 77 } |
77 | 78 |
78 bool IsGoogleSearchResultURL(const GURL& url) { | 79 bool IsGoogleSearchResultURL(const GURL& url) { |
79 if (!IsGoogleDomain(url)) | 80 if (!IsGoogleDomain(url)) |
80 return false; | 81 return false; |
81 return (url.path().empty() || | 82 return (url.path().empty() || |
82 base::StartsWithASCII(url.path(), std::string("/search"), true) || | 83 base::StartsWith(url.path(), "/search", |
| 84 base::CompareCase::SENSITIVE) || |
83 (url.path() == "/") || | 85 (url.path() == "/") || |
84 base::StartsWithASCII(url.path(), std::string("/webhp"), true)); | 86 base::StartsWith(url.path(), "/webhp", base::CompareCase::SENSITIVE)); |
85 } | 87 } |
86 | 88 |
87 void ReportPrerenderExternalURL() { | 89 void ReportPrerenderExternalURL() { |
88 ReportPrerenderSchemeCancelReason( | 90 ReportPrerenderSchemeCancelReason( |
89 PRERENDER_SCHEME_CANCEL_REASON_EXTERNAL_PROTOCOL); | 91 PRERENDER_SCHEME_CANCEL_REASON_EXTERNAL_PROTOCOL); |
90 } | 92 } |
91 | 93 |
92 void ReportUnsupportedPrerenderScheme(const GURL& url) { | 94 void ReportUnsupportedPrerenderScheme(const GURL& url) { |
93 if (url.SchemeIs("data")) { | 95 if (url.SchemeIs("data")) { |
94 ReportPrerenderSchemeCancelReason(PRERENDER_SCHEME_CANCEL_REASON_DATA); | 96 ReportPrerenderSchemeCancelReason(PRERENDER_SCHEME_CANCEL_REASON_DATA); |
(...skipping 14 matching lines...) Expand all Loading... |
109 ReportPrerenderSchemeCancelReason( | 111 ReportPrerenderSchemeCancelReason( |
110 PRERENDER_SCHEME_CANCEL_REASON_CHROME_EXTENSION); | 112 PRERENDER_SCHEME_CANCEL_REASON_CHROME_EXTENSION); |
111 } else if (url.SchemeIs("about")) { | 113 } else if (url.SchemeIs("about")) { |
112 ReportPrerenderSchemeCancelReason(PRERENDER_SCHEME_CANCEL_REASON_ABOUT); | 114 ReportPrerenderSchemeCancelReason(PRERENDER_SCHEME_CANCEL_REASON_ABOUT); |
113 } else { | 115 } else { |
114 ReportPrerenderSchemeCancelReason(PRERENDER_SCHEME_CANCEL_REASON_UNKNOWN); | 116 ReportPrerenderSchemeCancelReason(PRERENDER_SCHEME_CANCEL_REASON_UNKNOWN); |
115 } | 117 } |
116 } | 118 } |
117 | 119 |
118 } // namespace prerender | 120 } // namespace prerender |
OLD | NEW |