| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/user_script.h" | 5 #include "chrome/common/extensions/user_script.h" |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 bool UrlMatchesGlobs(const std::vector<std::string>* globs, | 12 bool UrlMatchesGlobs(const std::vector<std::string>* globs, |
| 13 const GURL& url) { | 13 const GURL& url) { |
| 14 for (std::vector<std::string>::const_iterator glob = globs->begin(); | 14 for (std::vector<std::string>::const_iterator glob = globs->begin(); |
| 15 glob != globs->end(); ++glob) { | 15 glob != globs->end(); ++glob) { |
| 16 if (MatchPattern(url.spec(), *glob)) | 16 if (MatchPattern(url.spec(), *glob)) |
| 17 return true; | 17 return true; |
| 18 } | 18 } |
| 19 | 19 |
| 20 return false; | 20 return false; |
| 21 } | 21 } |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace extensions { |
| 26 |
| 25 // static | 27 // static |
| 26 const char UserScript::kFileExtension[] = ".user.js"; | 28 const char UserScript::kFileExtension[] = ".user.js"; |
| 27 | 29 |
| 28 bool UserScript::IsURLUserScript(const GURL& url, | 30 bool UserScript::IsURLUserScript(const GURL& url, |
| 29 const std::string& mime_type) { | 31 const std::string& mime_type) { |
| 30 return EndsWith(url.ExtractFileName(), kFileExtension, false) && | 32 return EndsWith(url.ExtractFileName(), kFileExtension, false) && |
| 31 mime_type != "text/html"; | 33 mime_type != "text/html"; |
| 32 } | 34 } |
| 33 | 35 |
| 34 UserScript::File::File(const FilePath& extension_root, | 36 UserScript::File::File(const FilePath& extension_root, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 FileList* scripts) { | 206 FileList* scripts) { |
| 205 uint64 num_files = 0; | 207 uint64 num_files = 0; |
| 206 CHECK(pickle.ReadUInt64(iter, &num_files)); | 208 CHECK(pickle.ReadUInt64(iter, &num_files)); |
| 207 scripts->clear(); | 209 scripts->clear(); |
| 208 for (uint64 i = 0; i < num_files; ++i) { | 210 for (uint64 i = 0; i < num_files; ++i) { |
| 209 File file; | 211 File file; |
| 210 file.Unpickle(pickle, iter); | 212 file.Unpickle(pickle, iter); |
| 211 scripts->push_back(file); | 213 scripts->push_back(file); |
| 212 } | 214 } |
| 213 } | 215 } |
| 216 |
| 217 } // namespace extensions |
| OLD | NEW |