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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 : extension_root_(extension_root), | 62 : extension_root_(extension_root), |
63 relative_path_(relative_path), | 63 relative_path_(relative_path), |
64 url_(url) { | 64 url_(url) { |
65 } | 65 } |
66 | 66 |
67 UserScript::File::File() {} | 67 UserScript::File::File() {} |
68 | 68 |
69 UserScript::File::~File() {} | 69 UserScript::File::~File() {} |
70 | 70 |
71 UserScript::UserScript() | 71 UserScript::UserScript() |
72 : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false), | 72 : run_location_(DOCUMENT_IDLE), |
73 match_all_frames_(false), incognito_enabled_(false) { | 73 emulate_greasemonkey_(false), |
74 } | 74 match_all_frames_(false), |
| 75 match_about_blank_(false), |
| 76 incognito_enabled_(false) {} |
75 | 77 |
76 UserScript::~UserScript() { | 78 UserScript::~UserScript() { |
77 } | 79 } |
78 | 80 |
79 void UserScript::add_url_pattern(const URLPattern& pattern) { | 81 void UserScript::add_url_pattern(const URLPattern& pattern) { |
80 url_set_.AddPattern(pattern); | 82 url_set_.AddPattern(pattern); |
81 } | 83 } |
82 | 84 |
83 void UserScript::add_exclude_url_pattern(const URLPattern& pattern) { | 85 void UserScript::add_exclude_url_pattern(const URLPattern& pattern) { |
84 exclude_url_set_.AddPattern(pattern); | 86 exclude_url_set_.AddPattern(pattern); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 CHECK(pickle.ReadString(iter, &url)); | 122 CHECK(pickle.ReadString(iter, &url)); |
121 set_url(GURL(url)); | 123 set_url(GURL(url)); |
122 } | 124 } |
123 | 125 |
124 void UserScript::Pickle(::Pickle* pickle) const { | 126 void UserScript::Pickle(::Pickle* pickle) const { |
125 // Write the simple types to the pickle. | 127 // Write the simple types to the pickle. |
126 pickle->WriteInt(run_location()); | 128 pickle->WriteInt(run_location()); |
127 pickle->WriteString(extension_id()); | 129 pickle->WriteString(extension_id()); |
128 pickle->WriteBool(emulate_greasemonkey()); | 130 pickle->WriteBool(emulate_greasemonkey()); |
129 pickle->WriteBool(match_all_frames()); | 131 pickle->WriteBool(match_all_frames()); |
| 132 pickle->WriteBool(match_about_blank()); |
130 pickle->WriteBool(is_incognito_enabled()); | 133 pickle->WriteBool(is_incognito_enabled()); |
131 | 134 |
132 PickleGlobs(pickle, globs_); | 135 PickleGlobs(pickle, globs_); |
133 PickleGlobs(pickle, exclude_globs_); | 136 PickleGlobs(pickle, exclude_globs_); |
134 PickleURLPatternSet(pickle, url_set_); | 137 PickleURLPatternSet(pickle, url_set_); |
135 PickleURLPatternSet(pickle, exclude_url_set_); | 138 PickleURLPatternSet(pickle, exclude_url_set_); |
136 PickleScripts(pickle, js_scripts_); | 139 PickleScripts(pickle, js_scripts_); |
137 PickleScripts(pickle, css_scripts_); | 140 PickleScripts(pickle, css_scripts_); |
138 } | 141 } |
139 | 142 |
(...skipping 28 matching lines...) Expand all Loading... |
168 void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { | 171 void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { |
169 // Read the run location. | 172 // Read the run location. |
170 int run_location = 0; | 173 int run_location = 0; |
171 CHECK(pickle.ReadInt(iter, &run_location)); | 174 CHECK(pickle.ReadInt(iter, &run_location)); |
172 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); | 175 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); |
173 run_location_ = static_cast<RunLocation>(run_location); | 176 run_location_ = static_cast<RunLocation>(run_location); |
174 | 177 |
175 CHECK(pickle.ReadString(iter, &extension_id_)); | 178 CHECK(pickle.ReadString(iter, &extension_id_)); |
176 CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); | 179 CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); |
177 CHECK(pickle.ReadBool(iter, &match_all_frames_)); | 180 CHECK(pickle.ReadBool(iter, &match_all_frames_)); |
| 181 CHECK(pickle.ReadBool(iter, &match_about_blank_)); |
178 CHECK(pickle.ReadBool(iter, &incognito_enabled_)); | 182 CHECK(pickle.ReadBool(iter, &incognito_enabled_)); |
179 | 183 |
180 UnpickleGlobs(pickle, iter, &globs_); | 184 UnpickleGlobs(pickle, iter, &globs_); |
181 UnpickleGlobs(pickle, iter, &exclude_globs_); | 185 UnpickleGlobs(pickle, iter, &exclude_globs_); |
182 UnpickleURLPatternSet(pickle, iter, &url_set_); | 186 UnpickleURLPatternSet(pickle, iter, &url_set_); |
183 UnpickleURLPatternSet(pickle, iter, &exclude_url_set_); | 187 UnpickleURLPatternSet(pickle, iter, &exclude_url_set_); |
184 UnpickleScripts(pickle, iter, &js_scripts_); | 188 UnpickleScripts(pickle, iter, &js_scripts_); |
185 UnpickleScripts(pickle, iter, &css_scripts_); | 189 UnpickleScripts(pickle, iter, &css_scripts_); |
186 } | 190 } |
187 | 191 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 CHECK(pickle.ReadUInt64(iter, &num_files)); | 231 CHECK(pickle.ReadUInt64(iter, &num_files)); |
228 scripts->clear(); | 232 scripts->clear(); |
229 for (uint64 i = 0; i < num_files; ++i) { | 233 for (uint64 i = 0; i < num_files; ++i) { |
230 File file; | 234 File file; |
231 file.Unpickle(pickle, iter); | 235 file.Unpickle(pickle, iter); |
232 scripts->push_back(file); | 236 scripts->push_back(file); |
233 } | 237 } |
234 } | 238 } |
235 | 239 |
236 } // namespace extensions | 240 } // namespace extensions |
OLD | NEW |