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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 | 344 |
345 UserScriptMaster::UserScriptMaster(Profile* profile) | 345 UserScriptMaster::UserScriptMaster(Profile* profile) |
346 : user_scripts_(new UserScriptList()), | 346 : user_scripts_(new UserScriptList()), |
347 extensions_service_ready_(false), | 347 extensions_service_ready_(false), |
348 pending_load_(false), | 348 pending_load_(false), |
349 profile_(profile), | 349 profile_(profile), |
350 extension_registry_observer_(this), | 350 extension_registry_observer_(this), |
351 weak_factory_(this) { | 351 weak_factory_(this) { |
352 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 352 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
353 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 353 registrar_.Add(this, |
| 354 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, |
354 content::Source<Profile>(profile_)); | 355 content::Source<Profile>(profile_)); |
355 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 356 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
356 content::NotificationService::AllBrowserContextsAndSources()); | 357 content::NotificationService::AllBrowserContextsAndSources()); |
357 } | 358 } |
358 | 359 |
359 UserScriptMaster::~UserScriptMaster() { | 360 UserScriptMaster::~UserScriptMaster() { |
360 } | 361 } |
361 | 362 |
362 void UserScriptMaster::OnScriptsLoaded( | 363 void UserScriptMaster::OnScriptsLoaded( |
363 scoped_ptr<UserScriptList> user_scripts, | 364 scoped_ptr<UserScriptList> user_scripts, |
(...skipping 25 matching lines...) Expand all Loading... |
389 for (content::RenderProcessHost::iterator i( | 390 for (content::RenderProcessHost::iterator i( |
390 content::RenderProcessHost::AllHostsIterator()); | 391 content::RenderProcessHost::AllHostsIterator()); |
391 !i.IsAtEnd(); i.Advance()) { | 392 !i.IsAtEnd(); i.Advance()) { |
392 SendUpdate(i.GetCurrentValue(), | 393 SendUpdate(i.GetCurrentValue(), |
393 shared_memory_.get(), | 394 shared_memory_.get(), |
394 changed_extensions_); | 395 changed_extensions_); |
395 } | 396 } |
396 changed_extensions_.clear(); | 397 changed_extensions_.clear(); |
397 | 398 |
398 content::NotificationService::current()->Notify( | 399 content::NotificationService::current()->Notify( |
399 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 400 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, |
400 content::Source<Profile>(profile_), | 401 content::Source<Profile>(profile_), |
401 content::Details<base::SharedMemory>(shared_memory_.get())); | 402 content::Details<base::SharedMemory>(shared_memory_.get())); |
402 } | 403 } |
403 | 404 |
404 void UserScriptMaster::OnExtensionLoaded( | 405 void UserScriptMaster::OnExtensionLoaded( |
405 content::BrowserContext* browser_context, | 406 content::BrowserContext* browser_context, |
406 const Extension* extension) { | 407 const Extension* extension) { |
407 added_extensions_.insert(extension->id()); | 408 added_extensions_.insert(extension->id()); |
408 removed_extensions_.erase(extension->id()); | 409 removed_extensions_.erase(extension->id()); |
409 extensions_info_[extension->id()] = | 410 extensions_info_[extension->id()] = |
(...skipping 21 matching lines...) Expand all Loading... |
431 pending_load_ = true; | 432 pending_load_ = true; |
432 else | 433 else |
433 StartLoad(); | 434 StartLoad(); |
434 } | 435 } |
435 | 436 |
436 void UserScriptMaster::Observe(int type, | 437 void UserScriptMaster::Observe(int type, |
437 const content::NotificationSource& source, | 438 const content::NotificationSource& source, |
438 const content::NotificationDetails& details) { | 439 const content::NotificationDetails& details) { |
439 bool should_start_load = false; | 440 bool should_start_load = false; |
440 switch (type) { | 441 switch (type) { |
441 case chrome::NOTIFICATION_EXTENSIONS_READY: | 442 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: |
442 extensions_service_ready_ = true; | 443 extensions_service_ready_ = true; |
443 should_start_load = true; | 444 should_start_load = true; |
444 break; | 445 break; |
445 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { | 446 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { |
446 content::RenderProcessHost* process = | 447 content::RenderProcessHost* process = |
447 content::Source<content::RenderProcessHost>(source).ptr(); | 448 content::Source<content::RenderProcessHost>(source).ptr(); |
448 Profile* profile = Profile::FromBrowserContext( | 449 Profile* profile = Profile::FromBrowserContext( |
449 process->GetBrowserContext()); | 450 process->GetBrowserContext()); |
450 if (!profile_->IsSameProfile(profile)) | 451 if (!profile_->IsSameProfile(profile)) |
451 return; | 452 return; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 544 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
544 return; // This can legitimately fail if the renderer asserts at startup. | 545 return; // This can legitimately fail if the renderer asserts at startup. |
545 | 546 |
546 if (base::SharedMemory::IsHandleValid(handle_for_process)) { | 547 if (base::SharedMemory::IsHandleValid(handle_for_process)) { |
547 process->Send(new ExtensionMsg_UpdateUserScripts( | 548 process->Send(new ExtensionMsg_UpdateUserScripts( |
548 handle_for_process, "" /* owner */, changed_extensions)); | 549 handle_for_process, "" /* owner */, changed_extensions)); |
549 } | 550 } |
550 } | 551 } |
551 | 552 |
552 } // namespace extensions | 553 } // namespace extensions |
OLD | NEW |