| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 &ScriptReloader::NotifyMaster, this, Serialize(user_scripts))); | 315 &ScriptReloader::NotifyMaster, this, Serialize(user_scripts))); |
| 316 } | 316 } |
| 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, |
| 326 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 326 content::Source<Profile>(profile_)); | 327 content::Source<Profile>(profile_)); |
| 327 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 328 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 328 content::Source<Profile>(profile_)); | 329 content::Source<Profile>(profile_)); |
| 329 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 330 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 330 content::NotificationService::AllBrowserContextsAndSources()); | 331 content::NotificationService::AllBrowserContextsAndSources()); |
| 331 } | 332 } |
| 332 | 333 |
| 333 UserScriptMaster::~UserScriptMaster() { | 334 UserScriptMaster::~UserScriptMaster() { |
| 334 if (script_reloader_.get()) | 335 if (script_reloader_.get()) |
| 335 script_reloader_->DisownMaster(); | 336 script_reloader_->DisownMaster(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 365 | 366 |
| 366 void UserScriptMaster::Observe(int type, | 367 void UserScriptMaster::Observe(int type, |
| 367 const content::NotificationSource& source, | 368 const content::NotificationSource& source, |
| 368 const content::NotificationDetails& details) { | 369 const content::NotificationDetails& details) { |
| 369 bool should_start_load = false; | 370 bool should_start_load = false; |
| 370 switch (type) { | 371 switch (type) { |
| 371 case chrome::NOTIFICATION_EXTENSIONS_READY: | 372 case chrome::NOTIFICATION_EXTENSIONS_READY: |
| 372 extensions_service_ready_ = true; | 373 extensions_service_ready_ = true; |
| 373 should_start_load = true; | 374 should_start_load = true; |
| 374 break; | 375 break; |
| 375 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 376 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 376 // Add any content scripts inside the extension. | 377 // Add any content scripts inside the extension. |
| 377 const Extension* extension = | 378 const Extension* extension = |
| 378 content::Details<const Extension>(details).ptr(); | 379 content::Details<const Extension>(details).ptr(); |
| 379 extensions_info_[extension->id()] = | 380 extensions_info_[extension->id()] = |
| 380 ExtensionSet::ExtensionPathAndDefaultLocale( | 381 ExtensionSet::ExtensionPathAndDefaultLocale( |
| 381 extension->path(), LocaleInfo::GetDefaultLocale(extension)); | 382 extension->path(), LocaleInfo::GetDefaultLocale(extension)); |
| 382 bool incognito_enabled = | 383 bool incognito_enabled = |
| 383 util::IsIncognitoEnabled(extension->id(), profile_); | 384 util::IsIncognitoEnabled(extension->id(), profile_); |
| 384 const UserScriptList& scripts = | 385 const UserScriptList& scripts = |
| 385 ContentScriptsInfo::GetContentScripts(extension); | 386 ContentScriptsInfo::GetContentScripts(extension); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 458 |
| 458 base::SharedMemoryHandle handle_for_process; | 459 base::SharedMemoryHandle handle_for_process; |
| 459 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 460 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
| 460 return; // This can legitimately fail if the renderer asserts at startup. | 461 return; // This can legitimately fail if the renderer asserts at startup. |
| 461 | 462 |
| 462 if (base::SharedMemory::IsHandleValid(handle_for_process)) | 463 if (base::SharedMemory::IsHandleValid(handle_for_process)) |
| 463 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); | 464 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); |
| 464 } | 465 } |
| 465 | 466 |
| 466 } // namespace extensions | 467 } // namespace extensions |
| OLD | NEW |