| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 const char UserScript::kFileExtension[] = ".user.js"; | 37 const char UserScript::kFileExtension[] = ".user.js"; |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 const int UserScript::kValidUserScriptSchemes = | 40 const int UserScript::kValidUserScriptSchemes = |
| 41 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | | 41 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | |
| 42 URLPattern::SCHEME_FILE | URLPattern::SCHEME_FTP; | 42 URLPattern::SCHEME_HTTPSV | URLPattern::SCHEME_FILE | |
| 43 URLPattern::SCHEME_FTP; |
| 43 | 44 |
| 44 bool UserScript::HasUserScriptFileExtension(const GURL& url) { | 45 bool UserScript::HasUserScriptFileExtension(const GURL& url) { |
| 45 return EndsWith(url.ExtractFileName(), kFileExtension, false); | 46 return EndsWith(url.ExtractFileName(), kFileExtension, false); |
| 46 } | 47 } |
| 47 | 48 |
| 48 bool UserScript::HasUserScriptFileExtension(const FilePath& path) { | 49 bool UserScript::HasUserScriptFileExtension(const FilePath& path) { |
| 49 static FilePath extension(FilePath().AppendASCII(kFileExtension)); | 50 static FilePath extension(FilePath().AppendASCII(kFileExtension)); |
| 50 return EndsWith(path.BaseName().value(), extension.value(), false); | 51 return EndsWith(path.BaseName().value(), extension.value(), false); |
| 51 } | 52 } |
| 52 | 53 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Read css scripts. | 213 // Read css scripts. |
| 213 size_t num_css_files = 0; | 214 size_t num_css_files = 0; |
| 214 CHECK(pickle.ReadSize(iter, &num_css_files)); | 215 CHECK(pickle.ReadSize(iter, &num_css_files)); |
| 215 css_scripts_.clear(); | 216 css_scripts_.clear(); |
| 216 for (size_t i = 0; i < num_css_files; ++i) { | 217 for (size_t i = 0; i < num_css_files; ++i) { |
| 217 File file; | 218 File file; |
| 218 file.Unpickle(pickle, iter); | 219 file.Unpickle(pickle, iter); |
| 219 css_scripts_.push_back(file); | 220 css_scripts_.push_back(file); |
| 220 } | 221 } |
| 221 } | 222 } |
| OLD | NEW |