| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/extensions/user_script_master.h" | 5 #include "chrome/browser/extensions/user_script_master.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Pickle user scripts and return pointer to the shared memory. | 233 // Pickle user scripts and return pointer to the shared memory. |
| 234 static base::SharedMemory* Serialize(const UserScriptList& scripts) { | 234 static base::SharedMemory* Serialize(const UserScriptList& scripts) { |
| 235 Pickle pickle; | 235 Pickle pickle; |
| 236 pickle.WriteSize(scripts.size()); | 236 pickle.WriteSize(scripts.size()); |
| 237 for (size_t i = 0; i < scripts.size(); i++) { | 237 for (size_t i = 0; i < scripts.size(); i++) { |
| 238 const UserScript& script = scripts[i]; | 238 const UserScript& script = scripts[i]; |
| 239 // TODO(aa): This can be replaced by sending content script metadata to |
| 240 // renderers along with other extension data in ViewMsg_ExtensionLoaded. |
| 241 // See crbug.com/70516. |
| 239 script.Pickle(&pickle); | 242 script.Pickle(&pickle); |
| 240 // Write scripts as 'data' so that we can read it out in the slave without | 243 // Write scripts as 'data' so that we can read it out in the slave without |
| 241 // allocating a new string. | 244 // allocating a new string. |
| 242 for (size_t j = 0; j < script.js_scripts().size(); j++) { | 245 for (size_t j = 0; j < script.js_scripts().size(); j++) { |
| 243 base::StringPiece contents = script.js_scripts()[j].GetContent(); | 246 base::StringPiece contents = script.js_scripts()[j].GetContent(); |
| 244 pickle.WriteData(contents.data(), contents.length()); | 247 pickle.WriteData(contents.data(), contents.length()); |
| 245 } | 248 } |
| 246 for (size_t j = 0; j < script.css_scripts().size(); j++) { | 249 for (size_t j = 0; j < script.css_scripts().size(); j++) { |
| 247 base::StringPiece contents = script.css_scripts()[j].GetContent(); | 250 base::StringPiece contents = script.css_scripts()[j].GetContent(); |
| 248 pickle.WriteData(contents.data(), contents.length()); | 251 pickle.WriteData(contents.data(), contents.length()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 DCHECK(false); | 397 DCHECK(false); |
| 395 } | 398 } |
| 396 } | 399 } |
| 397 | 400 |
| 398 void UserScriptMaster::StartScan() { | 401 void UserScriptMaster::StartScan() { |
| 399 if (!script_reloader_) | 402 if (!script_reloader_) |
| 400 script_reloader_ = new ScriptReloader(this); | 403 script_reloader_ = new ScriptReloader(this); |
| 401 | 404 |
| 402 script_reloader_->StartScan(user_script_dir_, lone_scripts_); | 405 script_reloader_->StartScan(user_script_dir_, lone_scripts_); |
| 403 } | 406 } |
| OLD | NEW |