Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: extensions/browser/user_script_loader.cc

Issue 1140173003: Allow whitelisted content scripts to be injected in WebViews. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@document_has_focus
Patch Set: Use PermissionsData to check whitelist Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/version.h" 10 #include "base/version.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 content::NotificationService::current()->Notify( 371 content::NotificationService::current()->Notify(
372 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, 372 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED,
373 content::Source<BrowserContext>(browser_context_), 373 content::Source<BrowserContext>(browser_context_),
374 content::Details<base::SharedMemory>(shared_memory_.get())); 374 content::Details<base::SharedMemory>(shared_memory_.get()));
375 FOR_EACH_OBSERVER(Observer, observers_, OnScriptsLoaded(this)); 375 FOR_EACH_OBSERVER(Observer, observers_, OnScriptsLoaded(this));
376 } 376 }
377 377
378 void UserScriptLoader::SendUpdate(content::RenderProcessHost* process, 378 void UserScriptLoader::SendUpdate(content::RenderProcessHost* process,
379 base::SharedMemory* shared_memory, 379 base::SharedMemory* shared_memory,
380 const std::set<HostID>& changed_hosts) { 380 const std::set<HostID>& changed_hosts) {
381 // Don't allow injection of extensions' content scripts into <webview>. 381 // Don't allow injection of non-whitelisted extensions' content scripts
382 if (process->IsIsolatedGuest() && host_id().id().empty()) 382 // into <webview>.
383 return; 383 bool whitelisted_only = process->IsIsolatedGuest() && host_id().id().empty();
384 384
385 // Make sure we only send user scripts to processes in our browser_context. 385 // Make sure we only send user scripts to processes in our browser_context.
386 if (!ExtensionsBrowserClient::Get()->IsSameContext( 386 if (!ExtensionsBrowserClient::Get()->IsSameContext(
387 browser_context_, process->GetBrowserContext())) 387 browser_context_, process->GetBrowserContext()))
388 return; 388 return;
389 389
390 // If the process is being started asynchronously, early return. We'll end up 390 // If the process is being started asynchronously, early return. We'll end up
391 // calling InitUserScripts when it's created which will call this again. 391 // calling InitUserScripts when it's created which will call this again.
392 base::ProcessHandle handle = process->GetHandle(); 392 base::ProcessHandle handle = process->GetHandle();
393 if (!handle) 393 if (!handle)
394 return; 394 return;
395 395
396 base::SharedMemoryHandle handle_for_process; 396 base::SharedMemoryHandle handle_for_process;
397 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) 397 if (!shared_memory->ShareToProcess(handle, &handle_for_process))
398 return; // This can legitimately fail if the renderer asserts at startup. 398 return; // This can legitimately fail if the renderer asserts at startup.
399 399
400 if (base::SharedMemory::IsHandleValid(handle_for_process)) { 400 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
401 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process, 401 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process,
402 host_id(), changed_hosts)); 402 host_id(),
403 changed_hosts,
404 whitelisted_only));
403 } 405 }
404 } 406 }
405 407
406 } // namespace extensions 408 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698