| 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) { | 10 bool UserScript::MatchesUrl(const GURL& url) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // Read url. | 33 // Read url. |
| 34 std::string url; | 34 std::string url; |
| 35 CHECK(pickle.ReadString(iter, &url)); | 35 CHECK(pickle.ReadString(iter, &url)); |
| 36 set_url(GURL(url)); | 36 set_url(GURL(url)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void UserScript::Pickle(::Pickle* pickle) const { | 39 void UserScript::Pickle(::Pickle* pickle) const { |
| 40 // Write the run location. | 40 // Write the run location. |
| 41 pickle->WriteInt(run_location()); | 41 pickle->WriteInt(run_location()); |
| 42 | 42 |
| 43 // Write the extension id. | |
| 44 pickle->WriteString(extension_id()); | |
| 45 | |
| 46 // Write globs. | 43 // Write globs. |
| 47 pickle->WriteSize(globs_.size()); | 44 pickle->WriteSize(globs_.size()); |
| 48 for (std::vector<std::string>::const_iterator glob = globs_.begin(); | 45 for (std::vector<std::string>::const_iterator glob = globs_.begin(); |
| 49 glob != globs_.end(); ++glob) { | 46 glob != globs_.end(); ++glob) { |
| 50 pickle->WriteString(*glob); | 47 pickle->WriteString(*glob); |
| 51 } | 48 } |
| 52 | 49 |
| 53 // Write url patterns. | 50 // Write url patterns. |
| 54 pickle->WriteSize(url_patterns_.size()); | 51 pickle->WriteSize(url_patterns_.size()); |
| 55 for (std::vector<URLPattern>::const_iterator pattern = url_patterns_.begin(); | 52 for (std::vector<URLPattern>::const_iterator pattern = url_patterns_.begin(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 72 } | 69 } |
| 73 } | 70 } |
| 74 | 71 |
| 75 void UserScript::Unpickle(const ::Pickle& pickle, void** iter) { | 72 void UserScript::Unpickle(const ::Pickle& pickle, void** iter) { |
| 76 // Read the run location. | 73 // Read the run location. |
| 77 int run_location = 0; | 74 int run_location = 0; |
| 78 CHECK(pickle.ReadInt(iter, &run_location)); | 75 CHECK(pickle.ReadInt(iter, &run_location)); |
| 79 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); | 76 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); |
| 80 run_location_ = static_cast<RunLocation>(run_location); | 77 run_location_ = static_cast<RunLocation>(run_location); |
| 81 | 78 |
| 82 // Read the extension ID. | |
| 83 CHECK(pickle.ReadString(iter, &extension_id_)); | |
| 84 | |
| 85 // Read globs. | 79 // Read globs. |
| 86 size_t num_globs = 0; | 80 size_t num_globs = 0; |
| 87 CHECK(pickle.ReadSize(iter, &num_globs)); | 81 CHECK(pickle.ReadSize(iter, &num_globs)); |
| 88 | 82 |
| 89 globs_.clear(); | 83 globs_.clear(); |
| 90 for (size_t i = 0; i < num_globs; ++i) { | 84 for (size_t i = 0; i < num_globs; ++i) { |
| 91 std::string glob; | 85 std::string glob; |
| 92 CHECK(pickle.ReadString(iter, &glob)); | 86 CHECK(pickle.ReadString(iter, &glob)); |
| 93 globs_.push_back(glob); | 87 globs_.push_back(glob); |
| 94 } | 88 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 119 // Read css scripts. | 113 // Read css scripts. |
| 120 size_t num_css_files = 0; | 114 size_t num_css_files = 0; |
| 121 CHECK(pickle.ReadSize(iter, &num_css_files)); | 115 CHECK(pickle.ReadSize(iter, &num_css_files)); |
| 122 css_scripts_.clear(); | 116 css_scripts_.clear(); |
| 123 for (size_t i = 0; i < num_css_files; ++i) { | 117 for (size_t i = 0; i < num_css_files; ++i) { |
| 124 File file; | 118 File file; |
| 125 file.Unpickle(pickle, iter); | 119 file.Unpickle(pickle, iter); |
| 126 css_scripts_.push_back(file); | 120 css_scripts_.push_back(file); |
| 127 } | 121 } |
| 128 } | 122 } |
| OLD | NEW |