Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: third_party/WebKit/Source/core/frame/csp/CSPSource.cpp

Issue 2146163003: Use StringView for startsWith and endsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/frame/csp/CSPSource.h" 5 #include "core/frame/csp/CSPSource.h"
6 6
7 #include "core/frame/UseCounter.h" 7 #include "core/frame/UseCounter.h"
8 #include "core/frame/csp/ContentSecurityPolicy.h" 8 #include "core/frame/csp/ContentSecurityPolicy.h"
9 #include "platform/weborigin/KURL.h" 9 #include "platform/weborigin/KURL.h"
10 #include "platform/weborigin/KnownPorts.h" 10 #include "platform/weborigin/KnownPorts.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 bool CSPSource::hostMatches(const KURL& url) const 48 bool CSPSource::hostMatches(const KURL& url) const
49 { 49 {
50 const String& host = url.host(); 50 const String& host = url.host();
51 Document* document = m_policy->document(); 51 Document* document = m_policy->document();
52 bool match; 52 bool match;
53 53
54 bool equalHosts = equalIgnoringCase(host, m_host); 54 bool equalHosts = equalIgnoringCase(host, m_host);
55 if (m_hostWildcard == HasWildcard) { 55 if (m_hostWildcard == HasWildcard) {
56 match = host.endsWith("." + m_host, TextCaseInsensitive); 56 match = host.endsWith(String("." + m_host), TextCaseInsensitive);
esprehn 2016/07/13 23:42:55 a + b returns a StringAppend, which can't be conve
57 57
58 // Chrome used to, incorrectly, match *.x.y to x.y. This was fixed, but 58 // Chrome used to, incorrectly, match *.x.y to x.y. This was fixed, but
59 // the following count measures when a match fails that would have 59 // the following count measures when a match fails that would have
60 // passed the old, incorrect style, in case a lot of sites were 60 // passed the old, incorrect style, in case a lot of sites were
61 // relying on that behavior. 61 // relying on that behavior.
62 if (document && equalHosts) 62 if (document && equalHosts)
63 UseCounter::count(*document, UseCounter::CSPSourceWildcardWouldMatch ExactHost); 63 UseCounter::count(*document, UseCounter::CSPSourceWildcardWouldMatch ExactHost);
64 } else { 64 } else {
65 match = equalHosts; 65 match = equalHosts;
66 } 66 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 { 107 {
108 return m_host.isEmpty(); 108 return m_host.isEmpty();
109 } 109 }
110 110
111 DEFINE_TRACE(CSPSource) 111 DEFINE_TRACE(CSPSource)
112 { 112 {
113 visitor->trace(m_policy); 113 visitor->trace(m_policy);
114 } 114 }
115 115
116 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698