Chromium Code Reviews| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 | 468 |
| 469 content::NotificationService::current()->Notify( | 469 content::NotificationService::current()->Notify( |
| 470 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, | 470 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, |
| 471 content::Source<BrowserContext>(browser_context_), | 471 content::Source<BrowserContext>(browser_context_), |
| 472 content::Details<base::SharedMemory>(shared_memory_.get())); | 472 content::Details<base::SharedMemory>(shared_memory_.get())); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void UserScriptLoader::SendUpdate(content::RenderProcessHost* process, | 475 void UserScriptLoader::SendUpdate(content::RenderProcessHost* process, |
| 476 base::SharedMemory* shared_memory, | 476 base::SharedMemory* shared_memory, |
| 477 const std::set<HostID>& changed_hosts) { | 477 const std::set<HostID>& changed_hosts) { |
| 478 // Don't allow injection of content scripts into <webview>. | |
| 479 if (process->IsIsolatedGuest()) | |
|
Fady Samuel
2015/03/11 11:50:19
Are we sure this doesn't break things now? Content
Xi Han
2015/03/25 19:52:40
I think we won't, since host_id is sent along with
| |
| 480 return; | |
| 481 | |
| 482 // Make sure we only send user scripts to processes in our browser_context. | 478 // Make sure we only send user scripts to processes in our browser_context. |
| 483 if (!ExtensionsBrowserClient::Get()->IsSameContext( | 479 if (!ExtensionsBrowserClient::Get()->IsSameContext( |
| 484 browser_context_, process->GetBrowserContext())) | 480 browser_context_, process->GetBrowserContext())) |
| 485 return; | 481 return; |
| 486 | 482 |
| 487 // If the process is being started asynchronously, early return. We'll end up | 483 // If the process is being started asynchronously, early return. We'll end up |
| 488 // calling InitUserScripts when it's created which will call this again. | 484 // calling InitUserScripts when it's created which will call this again. |
| 489 base::ProcessHandle handle = process->GetHandle(); | 485 base::ProcessHandle handle = process->GetHandle(); |
| 490 if (!handle) | 486 if (!handle) |
| 491 return; | 487 return; |
| 492 | 488 |
| 493 base::SharedMemoryHandle handle_for_process; | 489 base::SharedMemoryHandle handle_for_process; |
| 494 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 490 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
| 495 return; // This can legitimately fail if the renderer asserts at startup. | 491 return; // This can legitimately fail if the renderer asserts at startup. |
| 496 | 492 |
| 497 // TODO(hanxi): update the IPC message to send a set of HostIDs to render. | 493 // TODO(hanxi): update the IPC message to send a set of HostIDs to render. |
| 498 // Also, remove this function when the refactor is done on render side. | 494 // Also, remove this function when the refactor is done on render side. |
| 499 std::set<std::string> changed_ids_set; | 495 std::set<std::string> changed_ids_set; |
| 500 for (const HostID& id : changed_hosts) | 496 for (const HostID& id : changed_hosts) |
| 501 changed_ids_set.insert(id.id()); | 497 changed_ids_set.insert(id.id()); |
| 502 | 498 |
| 503 if (base::SharedMemory::IsHandleValid(handle_for_process)) { | 499 if (base::SharedMemory::IsHandleValid(handle_for_process)) { |
| 504 process->Send(new ExtensionMsg_UpdateUserScripts( | 500 process->Send(new ExtensionMsg_UpdateUserScripts( |
| 505 handle_for_process, host_id().id(), changed_ids_set)); | 501 handle_for_process, host_id().id(), changed_ids_set)); |
| 506 } | 502 } |
| 507 } | 503 } |
| 508 | 504 |
| 509 } // namespace extensions | 505 } // namespace extensions |
| OLD | NEW |