| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/user_script.h" | 5 #include "extensions/common/user_script.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "extensions/common/switches.h" | 10 #include "extensions/common/switches.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 CHECK(pickle.ReadString(iter, &url)); | 120 CHECK(pickle.ReadString(iter, &url)); |
| 121 set_url(GURL(url)); | 121 set_url(GURL(url)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void UserScript::Pickle(::Pickle* pickle) const { | 124 void UserScript::Pickle(::Pickle* pickle) const { |
| 125 // Write the simple types to the pickle. | 125 // Write the simple types to the pickle. |
| 126 pickle->WriteInt(run_location()); | 126 pickle->WriteInt(run_location()); |
| 127 pickle->WriteString(extension_id()); | 127 pickle->WriteString(extension_id()); |
| 128 pickle->WriteBool(emulate_greasemonkey()); | 128 pickle->WriteBool(emulate_greasemonkey()); |
| 129 pickle->WriteBool(match_all_frames()); | 129 pickle->WriteBool(match_all_frames()); |
| 130 pickle->WriteBool(match_about_blank()); |
| 130 pickle->WriteBool(is_incognito_enabled()); | 131 pickle->WriteBool(is_incognito_enabled()); |
| 131 | 132 |
| 132 PickleGlobs(pickle, globs_); | 133 PickleGlobs(pickle, globs_); |
| 133 PickleGlobs(pickle, exclude_globs_); | 134 PickleGlobs(pickle, exclude_globs_); |
| 134 PickleURLPatternSet(pickle, url_set_); | 135 PickleURLPatternSet(pickle, url_set_); |
| 135 PickleURLPatternSet(pickle, exclude_url_set_); | 136 PickleURLPatternSet(pickle, exclude_url_set_); |
| 136 PickleScripts(pickle, js_scripts_); | 137 PickleScripts(pickle, js_scripts_); |
| 137 PickleScripts(pickle, css_scripts_); | 138 PickleScripts(pickle, css_scripts_); |
| 138 } | 139 } |
| 139 | 140 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 168 void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { | 169 void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { |
| 169 // Read the run location. | 170 // Read the run location. |
| 170 int run_location = 0; | 171 int run_location = 0; |
| 171 CHECK(pickle.ReadInt(iter, &run_location)); | 172 CHECK(pickle.ReadInt(iter, &run_location)); |
| 172 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); | 173 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); |
| 173 run_location_ = static_cast<RunLocation>(run_location); | 174 run_location_ = static_cast<RunLocation>(run_location); |
| 174 | 175 |
| 175 CHECK(pickle.ReadString(iter, &extension_id_)); | 176 CHECK(pickle.ReadString(iter, &extension_id_)); |
| 176 CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); | 177 CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); |
| 177 CHECK(pickle.ReadBool(iter, &match_all_frames_)); | 178 CHECK(pickle.ReadBool(iter, &match_all_frames_)); |
| 179 CHECK(pickle.ReadBool(iter, &match_about_blank_)); |
| 178 CHECK(pickle.ReadBool(iter, &incognito_enabled_)); | 180 CHECK(pickle.ReadBool(iter, &incognito_enabled_)); |
| 179 | 181 |
| 180 UnpickleGlobs(pickle, iter, &globs_); | 182 UnpickleGlobs(pickle, iter, &globs_); |
| 181 UnpickleGlobs(pickle, iter, &exclude_globs_); | 183 UnpickleGlobs(pickle, iter, &exclude_globs_); |
| 182 UnpickleURLPatternSet(pickle, iter, &url_set_); | 184 UnpickleURLPatternSet(pickle, iter, &url_set_); |
| 183 UnpickleURLPatternSet(pickle, iter, &exclude_url_set_); | 185 UnpickleURLPatternSet(pickle, iter, &exclude_url_set_); |
| 184 UnpickleScripts(pickle, iter, &js_scripts_); | 186 UnpickleScripts(pickle, iter, &js_scripts_); |
| 185 UnpickleScripts(pickle, iter, &css_scripts_); | 187 UnpickleScripts(pickle, iter, &css_scripts_); |
| 186 } | 188 } |
| 187 | 189 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 CHECK(pickle.ReadUInt64(iter, &num_files)); | 229 CHECK(pickle.ReadUInt64(iter, &num_files)); |
| 228 scripts->clear(); | 230 scripts->clear(); |
| 229 for (uint64 i = 0; i < num_files; ++i) { | 231 for (uint64 i = 0; i < num_files; ++i) { |
| 230 File file; | 232 File file; |
| 231 file.Unpickle(pickle, iter); | 233 file.Unpickle(pickle, iter); |
| 232 scripts->push_back(file); | 234 scripts->push_back(file); |
| 233 } | 235 } |
| 234 } | 236 } |
| 235 | 237 |
| 236 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |