| OLD | NEW |
| 1 // Copyright 2009 The Chromium Authors. All rights reserved. | 1 // Copyright 2009 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 bool UserScript::MatchesUrl(const GURL& url) const { | 10 bool UserScript::MatchesUrl(const GURL& url) const { |
| 11 for (std::vector<std::string>::const_iterator glob = globs_.begin(); | 11 for (std::vector<std::string>::const_iterator glob = globs_.begin(); |
| 12 glob != globs_.end(); ++glob) { | 12 glob != globs_.end(); ++glob) { |
| 13 if (MatchPattern(url.spec(), *glob)) | 13 if (MatchPattern(url.spec(), *glob)) |
| 14 return true; | 14 return true; |
| 15 } | 15 } |
| 16 | 16 |
| 17 for (std::vector<URLPattern>::const_iterator pattern = url_patterns_.begin(); | 17 for (PatternList::const_iterator pattern = url_patterns_.begin(); |
| 18 pattern != url_patterns_.end(); ++pattern) { | 18 pattern != url_patterns_.end(); ++pattern) { |
| 19 if (pattern->MatchesUrl(url)) | 19 if (pattern->MatchesUrl(url)) |
| 20 return true; | 20 return true; |
| 21 } | 21 } |
| 22 | 22 |
| 23 return false; | 23 return false; |
| 24 } | 24 } |
| 25 | 25 |
| 26 void UserScript::File::Pickle(::Pickle* pickle) const { | 26 void UserScript::File::Pickle(::Pickle* pickle) const { |
| 27 pickle->WriteString(url_.spec()); | 27 pickle->WriteString(url_.spec()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 // Write globs. | 46 // Write globs. |
| 47 pickle->WriteSize(globs_.size()); | 47 pickle->WriteSize(globs_.size()); |
| 48 for (std::vector<std::string>::const_iterator glob = globs_.begin(); | 48 for (std::vector<std::string>::const_iterator glob = globs_.begin(); |
| 49 glob != globs_.end(); ++glob) { | 49 glob != globs_.end(); ++glob) { |
| 50 pickle->WriteString(*glob); | 50 pickle->WriteString(*glob); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Write url patterns. | 53 // Write url patterns. |
| 54 pickle->WriteSize(url_patterns_.size()); | 54 pickle->WriteSize(url_patterns_.size()); |
| 55 for (std::vector<URLPattern>::const_iterator pattern = url_patterns_.begin(); | 55 for (PatternList::const_iterator pattern = url_patterns_.begin(); |
| 56 pattern != url_patterns_.end(); ++pattern) { | 56 pattern != url_patterns_.end(); ++pattern) { |
| 57 pickle->WriteString(pattern->GetAsString()); | 57 pickle->WriteString(pattern->GetAsString()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Write js scripts. | 60 // Write js scripts. |
| 61 pickle->WriteSize(js_scripts_.size()); | 61 pickle->WriteSize(js_scripts_.size()); |
| 62 for (FileList::const_iterator file = js_scripts_.begin(); | 62 for (FileList::const_iterator file = js_scripts_.begin(); |
| 63 file != js_scripts_.end(); ++file) { | 63 file != js_scripts_.end(); ++file) { |
| 64 file->Pickle(pickle); | 64 file->Pickle(pickle); |
| 65 } | 65 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // Read css scripts. | 119 // Read css scripts. |
| 120 size_t num_css_files = 0; | 120 size_t num_css_files = 0; |
| 121 CHECK(pickle.ReadSize(iter, &num_css_files)); | 121 CHECK(pickle.ReadSize(iter, &num_css_files)); |
| 122 css_scripts_.clear(); | 122 css_scripts_.clear(); |
| 123 for (size_t i = 0; i < num_css_files; ++i) { | 123 for (size_t i = 0; i < num_css_files; ++i) { |
| 124 File file; | 124 File file; |
| 125 file.Unpickle(pickle, iter); | 125 file.Unpickle(pickle, iter); |
| 126 css_scripts_.push_back(file); | 126 css_scripts_.push_back(file); |
| 127 } | 127 } |
| 128 } | 128 } |
| OLD | NEW |