Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: extensions/common/user_script.cc

Issue 972863002: Revert of Refactoring: de-couple Extensions from "script injection System" [render side]:2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_1
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/user_script.h ('k') | extensions/renderer/extension_injection_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void UserScript::Pickle(::Pickle* pickle) const { 138 void UserScript::Pickle(::Pickle* pickle) const {
139 // Write the simple types to the pickle. 139 // Write the simple types to the pickle.
140 pickle->WriteInt(run_location()); 140 pickle->WriteInt(run_location());
141 pickle->WriteInt(user_script_id_); 141 pickle->WriteInt(user_script_id_);
142 pickle->WriteBool(emulate_greasemonkey()); 142 pickle->WriteBool(emulate_greasemonkey());
143 pickle->WriteBool(match_all_frames()); 143 pickle->WriteBool(match_all_frames());
144 pickle->WriteBool(match_about_blank()); 144 pickle->WriteBool(match_about_blank());
145 pickle->WriteBool(is_incognito_enabled()); 145 pickle->WriteBool(is_incognito_enabled());
146 146
147 PickleHostID(pickle, host_id_); 147 PickleHostID(pickle, host_id_);
148 pickle->WriteInt(consumer_instance_type());
149 PickleRoutingInfo(pickle, routing_info_);
150 PickleGlobs(pickle, globs_); 148 PickleGlobs(pickle, globs_);
151 PickleGlobs(pickle, exclude_globs_); 149 PickleGlobs(pickle, exclude_globs_);
152 PickleURLPatternSet(pickle, url_set_); 150 PickleURLPatternSet(pickle, url_set_);
153 PickleURLPatternSet(pickle, exclude_url_set_); 151 PickleURLPatternSet(pickle, exclude_url_set_);
154 PickleScripts(pickle, js_scripts_); 152 PickleScripts(pickle, js_scripts_);
155 PickleScripts(pickle, css_scripts_); 153 PickleScripts(pickle, css_scripts_);
156 } 154 }
157 155
158 void UserScript::PickleGlobs(::Pickle* pickle, 156 void UserScript::PickleGlobs(::Pickle* pickle,
159 const std::vector<std::string>& globs) const { 157 const std::vector<std::string>& globs) const {
160 pickle->WriteSizeT(globs.size()); 158 pickle->WriteSizeT(globs.size());
161 for (std::vector<std::string>::const_iterator glob = globs.begin(); 159 for (std::vector<std::string>::const_iterator glob = globs.begin();
162 glob != globs.end(); ++glob) { 160 glob != globs.end(); ++glob) {
163 pickle->WriteString(*glob); 161 pickle->WriteString(*glob);
164 } 162 }
165 } 163 }
166 164
167 void UserScript::PickleHostID(::Pickle* pickle, const HostID& host_id) const { 165 void UserScript::PickleHostID(::Pickle* pickle, const HostID& host_id) const {
168 pickle->WriteInt(host_id.type()); 166 pickle->WriteInt(host_id.type());
169 pickle->WriteString(host_id.id()); 167 pickle->WriteString(host_id.id());
170 } 168 }
171 169
172 void UserScript::PickleRoutingInfo(::Pickle* pickle,
173 const RoutingInfo& routing_info) const {
174 pickle->WriteInt(routing_info.render_process_id);
175 pickle->WriteInt(routing_info.render_view_id);
176 }
177
178 void UserScript::PickleURLPatternSet(::Pickle* pickle, 170 void UserScript::PickleURLPatternSet(::Pickle* pickle,
179 const URLPatternSet& pattern_list) const { 171 const URLPatternSet& pattern_list) const {
180 pickle->WriteSizeT(pattern_list.patterns().size()); 172 pickle->WriteSizeT(pattern_list.patterns().size());
181 for (URLPatternSet::const_iterator pattern = pattern_list.begin(); 173 for (URLPatternSet::const_iterator pattern = pattern_list.begin();
182 pattern != pattern_list.end(); ++pattern) { 174 pattern != pattern_list.end(); ++pattern) {
183 pickle->WriteInt(pattern->valid_schemes()); 175 pickle->WriteInt(pattern->valid_schemes());
184 pickle->WriteString(pattern->GetAsString()); 176 pickle->WriteString(pattern->GetAsString());
185 } 177 }
186 } 178 }
187 179
(...skipping 13 matching lines...) Expand all
201 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); 193 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST);
202 run_location_ = static_cast<RunLocation>(run_location); 194 run_location_ = static_cast<RunLocation>(run_location);
203 195
204 CHECK(iter->ReadInt(&user_script_id_)); 196 CHECK(iter->ReadInt(&user_script_id_));
205 CHECK(iter->ReadBool(&emulate_greasemonkey_)); 197 CHECK(iter->ReadBool(&emulate_greasemonkey_));
206 CHECK(iter->ReadBool(&match_all_frames_)); 198 CHECK(iter->ReadBool(&match_all_frames_));
207 CHECK(iter->ReadBool(&match_about_blank_)); 199 CHECK(iter->ReadBool(&match_about_blank_));
208 CHECK(iter->ReadBool(&incognito_enabled_)); 200 CHECK(iter->ReadBool(&incognito_enabled_));
209 201
210 UnpickleHostID(pickle, iter, &host_id_); 202 UnpickleHostID(pickle, iter, &host_id_);
211
212 int consumer_instance_type = 0;
213 CHECK(iter->ReadInt(&consumer_instance_type));
214 consumer_instance_type_ =
215 static_cast<ConsumerInstanceType>(consumer_instance_type);
216
217 UnpickleRoutingInfo(pickle, iter, &routing_info_);
218 UnpickleGlobs(pickle, iter, &globs_); 203 UnpickleGlobs(pickle, iter, &globs_);
219 UnpickleGlobs(pickle, iter, &exclude_globs_); 204 UnpickleGlobs(pickle, iter, &exclude_globs_);
220 UnpickleURLPatternSet(pickle, iter, &url_set_); 205 UnpickleURLPatternSet(pickle, iter, &url_set_);
221 UnpickleURLPatternSet(pickle, iter, &exclude_url_set_); 206 UnpickleURLPatternSet(pickle, iter, &exclude_url_set_);
222 UnpickleScripts(pickle, iter, &js_scripts_); 207 UnpickleScripts(pickle, iter, &js_scripts_);
223 UnpickleScripts(pickle, iter, &css_scripts_); 208 UnpickleScripts(pickle, iter, &css_scripts_);
224 } 209 }
225 210
226 void UserScript::UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter, 211 void UserScript::UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter,
227 std::vector<std::string>* globs) { 212 std::vector<std::string>* globs) {
(...skipping 10 matching lines...) Expand all
238 void UserScript::UnpickleHostID(const ::Pickle& pickle, 223 void UserScript::UnpickleHostID(const ::Pickle& pickle,
239 PickleIterator* iter, 224 PickleIterator* iter,
240 HostID* host_id) { 225 HostID* host_id) {
241 int type = 0; 226 int type = 0;
242 std::string id; 227 std::string id;
243 CHECK(iter->ReadInt(&type)); 228 CHECK(iter->ReadInt(&type));
244 CHECK(iter->ReadString(&id)); 229 CHECK(iter->ReadString(&id));
245 *host_id = HostID(static_cast<HostID::HostType>(type), id); 230 *host_id = HostID(static_cast<HostID::HostType>(type), id);
246 } 231 }
247 232
248 void UserScript::UnpickleRoutingInfo(const ::Pickle& pickle,
249 PickleIterator* iter,
250 RoutingInfo* routing_info) {
251 CHECK(iter->ReadInt(&routing_info->render_process_id));
252 CHECK(iter->ReadInt(&routing_info->render_view_id));
253 }
254
255 void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle, 233 void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle,
256 PickleIterator* iter, 234 PickleIterator* iter,
257 URLPatternSet* pattern_list) { 235 URLPatternSet* pattern_list) {
258 size_t num_patterns = 0; 236 size_t num_patterns = 0;
259 CHECK(iter->ReadSizeT(&num_patterns)); 237 CHECK(iter->ReadSizeT(&num_patterns));
260 238
261 pattern_list->ClearPatterns(); 239 pattern_list->ClearPatterns();
262 for (size_t i = 0; i < num_patterns; ++i) { 240 for (size_t i = 0; i < num_patterns; ++i) {
263 int valid_schemes; 241 int valid_schemes;
264 CHECK(iter->ReadInt(&valid_schemes)); 242 CHECK(iter->ReadInt(&valid_schemes));
(...skipping 24 matching lines...) Expand all
289 } 267 }
290 268
291 bool operator<(const UserScript& script1, const UserScript& script2) { 269 bool operator<(const UserScript& script1, const UserScript& script2) {
292 // The only kind of script that should be compared is the kind that has its 270 // The only kind of script that should be compared is the kind that has its
293 // IDs initialized to a meaningful value. 271 // IDs initialized to a meaningful value.
294 DCHECK(script1.id() != -1 && script2.id() != -1); 272 DCHECK(script1.id() != -1 && script2.id() != -1);
295 return script1.id() < script2.id(); 273 return script1.id() < script2.id();
296 } 274 }
297 275
298 } // namespace extensions 276 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/user_script.h ('k') | extensions/renderer/extension_injection_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698