OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 | 318 |
319 UserScriptMaster::UserScriptMaster(Profile* profile) | 319 UserScriptMaster::UserScriptMaster(Profile* profile) |
320 : extensions_service_ready_(false), | 320 : extensions_service_ready_(false), |
321 pending_load_(false), | 321 pending_load_(false), |
322 profile_(profile) { | 322 profile_(profile) { |
323 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 323 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
324 content::Source<Profile>(profile_)); | 324 content::Source<Profile>(profile_)); |
325 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 325 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
326 content::Source<Profile>(profile_)); | 326 content::Source<Profile>(profile_)); |
327 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 327 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
328 content::Source<Profile>(profile_)); | 328 content::Source<Profile>(profile_)); |
329 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 329 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
330 content::NotificationService::AllBrowserContextsAndSources()); | 330 content::NotificationService::AllBrowserContextsAndSources()); |
331 } | 331 } |
332 | 332 |
333 UserScriptMaster::~UserScriptMaster() { | 333 UserScriptMaster::~UserScriptMaster() { |
334 if (script_reloader_.get()) | 334 if (script_reloader_.get()) |
335 script_reloader_->DisownMaster(); | 335 script_reloader_->DisownMaster(); |
336 } | 336 } |
337 | 337 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 ContentScriptsInfo::GetContentScripts(extension); | 385 ContentScriptsInfo::GetContentScripts(extension); |
386 for (UserScriptList::const_iterator iter = scripts.begin(); | 386 for (UserScriptList::const_iterator iter = scripts.begin(); |
387 iter != scripts.end(); ++iter) { | 387 iter != scripts.end(); ++iter) { |
388 user_scripts_.push_back(*iter); | 388 user_scripts_.push_back(*iter); |
389 user_scripts_.back().set_incognito_enabled(incognito_enabled); | 389 user_scripts_.back().set_incognito_enabled(incognito_enabled); |
390 } | 390 } |
391 if (extensions_service_ready_) | 391 if (extensions_service_ready_) |
392 should_start_load = true; | 392 should_start_load = true; |
393 break; | 393 break; |
394 } | 394 } |
395 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 395 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
396 // Remove any content scripts. | 396 // Remove any content scripts. |
397 const Extension* extension = | 397 const Extension* extension = |
398 content::Details<UnloadedExtensionInfo>(details)->extension; | 398 content::Details<UnloadedExtensionInfo>(details)->extension; |
399 extensions_info_.erase(extension->id()); | 399 extensions_info_.erase(extension->id()); |
400 UserScriptList new_user_scripts; | 400 UserScriptList new_user_scripts; |
401 for (UserScriptList::iterator iter = user_scripts_.begin(); | 401 for (UserScriptList::iterator iter = user_scripts_.begin(); |
402 iter != user_scripts_.end(); ++iter) { | 402 iter != user_scripts_.end(); ++iter) { |
403 if (iter->extension_id() != extension->id()) | 403 if (iter->extension_id() != extension->id()) |
404 new_user_scripts.push_back(*iter); | 404 new_user_scripts.push_back(*iter); |
405 } | 405 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 457 |
458 base::SharedMemoryHandle handle_for_process; | 458 base::SharedMemoryHandle handle_for_process; |
459 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 459 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
460 return; // This can legitimately fail if the renderer asserts at startup. | 460 return; // This can legitimately fail if the renderer asserts at startup. |
461 | 461 |
462 if (base::SharedMemory::IsHandleValid(handle_for_process)) | 462 if (base::SharedMemory::IsHandleValid(handle_for_process)) |
463 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); | 463 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); |
464 } | 464 } |
465 | 465 |
466 } // namespace extensions | 466 } // namespace extensions |
OLD | NEW |