| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 void UserScriptMaster::StartLoad() { | 486 void UserScriptMaster::StartLoad() { |
| 487 if (!script_reloader_.get()) | 487 if (!script_reloader_.get()) |
| 488 script_reloader_ = new ScriptReloader(this); | 488 script_reloader_ = new ScriptReloader(this); |
| 489 | 489 |
| 490 script_reloader_->StartLoad(user_scripts_, extensions_info_); | 490 script_reloader_->StartLoad(user_scripts_, extensions_info_); |
| 491 } | 491 } |
| 492 | 492 |
| 493 void UserScriptMaster::SendUpdate(content::RenderProcessHost* process, | 493 void UserScriptMaster::SendUpdate(content::RenderProcessHost* process, |
| 494 base::SharedMemory* shared_memory) { | 494 base::SharedMemory* shared_memory) { |
| 495 // Don't allow injection of content scripts into <webview>. | 495 // Don't allow injection of content scripts into <webview>. |
| 496 if (process->IsGuest()) | 496 if (process->IsIsolatedGuest()) |
| 497 return; | 497 return; |
| 498 | 498 |
| 499 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); | 499 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
| 500 // Make sure we only send user scripts to processes in our profile. | 500 // Make sure we only send user scripts to processes in our profile. |
| 501 if (!profile_->IsSameProfile(profile)) | 501 if (!profile_->IsSameProfile(profile)) |
| 502 return; | 502 return; |
| 503 | 503 |
| 504 // If the process is being started asynchronously, early return. We'll end up | 504 // If the process is being started asynchronously, early return. We'll end up |
| 505 // calling InitUserScripts when it's created which will call this again. | 505 // calling InitUserScripts when it's created which will call this again. |
| 506 base::ProcessHandle handle = process->GetHandle(); | 506 base::ProcessHandle handle = process->GetHandle(); |
| 507 if (!handle) | 507 if (!handle) |
| 508 return; | 508 return; |
| 509 | 509 |
| 510 base::SharedMemoryHandle handle_for_process; | 510 base::SharedMemoryHandle handle_for_process; |
| 511 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 511 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
| 512 return; // This can legitimately fail if the renderer asserts at startup. | 512 return; // This can legitimately fail if the renderer asserts at startup. |
| 513 | 513 |
| 514 if (base::SharedMemory::IsHandleValid(handle_for_process)) | 514 if (base::SharedMemory::IsHandleValid(handle_for_process)) |
| 515 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); | 515 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); |
| 516 } | 516 } |
| 517 | 517 |
| 518 } // namespace extensions | 518 } // namespace extensions |
| OLD | NEW |