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