OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/user_script.h" | 5 #include "extensions/common/user_script.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/strings/pattern.h" |
10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
11 #include "extensions/common/switches.h" | 12 #include "extensions/common/switches.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // This cannot be a plain int or int64 because we need to generate unique IDs | 16 // This cannot be a plain int or int64 because we need to generate unique IDs |
16 // from multiple threads. | 17 // from multiple threads. |
17 base::StaticAtomicSequenceNumber g_user_script_id_generator; | 18 base::StaticAtomicSequenceNumber g_user_script_id_generator; |
18 | 19 |
19 bool UrlMatchesGlobs(const std::vector<std::string>* globs, | 20 bool UrlMatchesGlobs(const std::vector<std::string>* globs, |
20 const GURL& url) { | 21 const GURL& url) { |
21 for (std::vector<std::string>::const_iterator glob = globs->begin(); | 22 for (std::vector<std::string>::const_iterator glob = globs->begin(); |
22 glob != globs->end(); ++glob) { | 23 glob != globs->end(); ++glob) { |
23 if (MatchPattern(url.spec(), *glob)) | 24 if (base::MatchPattern(url.spec(), *glob)) |
24 return true; | 25 return true; |
25 } | 26 } |
26 | 27 |
27 return false; | 28 return false; |
28 } | 29 } |
29 | 30 |
30 } // namespace | 31 } // namespace |
31 | 32 |
32 namespace extensions { | 33 namespace extensions { |
33 | 34 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 281 } |
281 | 282 |
282 bool operator<(const UserScript& script1, const UserScript& script2) { | 283 bool operator<(const UserScript& script1, const UserScript& script2) { |
283 // The only kind of script that should be compared is the kind that has its | 284 // The only kind of script that should be compared is the kind that has its |
284 // IDs initialized to a meaningful value. | 285 // IDs initialized to a meaningful value. |
285 DCHECK(script1.id() != -1 && script2.id() != -1); | 286 DCHECK(script1.id() != -1 && script2.id() != -1); |
286 return script1.id() < script2.id(); | 287 return script1.id() < script2.id(); |
287 } | 288 } |
288 | 289 |
289 } // namespace extensions | 290 } // namespace extensions |
OLD | NEW |