OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/user_script_loader.h" | 5 #include "extensions/browser/user_script_loader.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 clear_scripts_ = false; | 269 clear_scripts_ = false; |
270 added_scripts_.clear(); | 270 added_scripts_.clear(); |
271 removed_scripts_.clear(); | 271 removed_scripts_.clear(); |
272 user_scripts_.reset(); | 272 user_scripts_.reset(); |
273 } | 273 } |
274 | 274 |
275 // static | 275 // static |
276 scoped_ptr<base::SharedMemory> UserScriptLoader::Serialize( | 276 scoped_ptr<base::SharedMemory> UserScriptLoader::Serialize( |
277 const UserScriptList& scripts) { | 277 const UserScriptList& scripts) { |
278 Pickle pickle; | 278 base::Pickle pickle; |
279 pickle.WriteSizeT(scripts.size()); | 279 pickle.WriteSizeT(scripts.size()); |
280 for (const UserScript& script : scripts) { | 280 for (const UserScript& script : scripts) { |
281 // TODO(aa): This can be replaced by sending content script metadata to | 281 // TODO(aa): This can be replaced by sending content script metadata to |
282 // renderers along with other extension data in ExtensionMsg_Loaded. | 282 // renderers along with other extension data in ExtensionMsg_Loaded. |
283 // See crbug.com/70516. | 283 // See crbug.com/70516. |
284 script.Pickle(&pickle); | 284 script.Pickle(&pickle); |
285 // Write scripts as 'data' so that we can read it out in the slave without | 285 // Write scripts as 'data' so that we can read it out in the slave without |
286 // allocating a new string. | 286 // allocating a new string. |
287 for (const UserScript::File& script_file : script.js_scripts()) { | 287 for (const UserScript::File& script_file : script.js_scripts()) { |
288 base::StringPiece contents = script_file.GetContent(); | 288 base::StringPiece contents = script_file.GetContent(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 397 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
398 return; // This can legitimately fail if the renderer asserts at startup. | 398 return; // This can legitimately fail if the renderer asserts at startup. |
399 | 399 |
400 if (base::SharedMemory::IsHandleValid(handle_for_process)) { | 400 if (base::SharedMemory::IsHandleValid(handle_for_process)) { |
401 process->Send(new ExtensionMsg_UpdateUserScripts( | 401 process->Send(new ExtensionMsg_UpdateUserScripts( |
402 handle_for_process, host_id(), changed_hosts, whitelisted_only)); | 402 handle_for_process, host_id(), changed_hosts, whitelisted_only)); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 } // namespace extensions | 406 } // namespace extensions |
OLD | NEW |