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

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

Issue 972863002: Revert of Refactoring: de-couple Extensions from "script injection System" [render side]:2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_1
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | extensions/common/user_script.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind.h" 10 #include "base/bind.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // though it removes the possibility that freeing the shared memory block 437 // though it removes the possibility that freeing the shared memory block
438 // would open up enough FDs for long enough for a retry to succeed. 438 // would open up enough FDs for long enough for a retry to succeed.
439 439
440 // Pretend the extension change didn't happen. 440 // Pretend the extension change didn't happen.
441 return; 441 return;
442 } 442 }
443 443
444 // We've got scripts ready to go. 444 // We've got scripts ready to go.
445 shared_memory_.reset(shared_memory.release()); 445 shared_memory_.reset(shared_memory.release());
446 446
447 // If user scripts are comming from a <webview>, will only notify the 447 for (content::RenderProcessHost::iterator i(
448 // RenderProcessHost of that <webview>; otherwise will notify all of the 448 content::RenderProcessHost::AllHostsIterator());
449 // RenderProcessHosts. 449 !i.IsAtEnd();
450 if (user_scripts && !user_scripts->empty() && 450 i.Advance()) {
451 (*user_scripts)[0].consumer_instance_type() == 451 SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
452 UserScript::ConsumerInstanceType::WEBVIEW) {
453 DCHECK_EQ(1u, user_scripts->size());
454 int render_process_id = (*user_scripts)[0].routing_info().render_process_id;
455 content::RenderProcessHost* host =
456 content::RenderProcessHost::FromID(render_process_id);
457 if (host)
458 SendUpdate(host, shared_memory_.get(), changed_hosts_);
459 } else {
460 for (content::RenderProcessHost::iterator i(
461 content::RenderProcessHost::AllHostsIterator());
462 !i.IsAtEnd(); i.Advance()) {
463 SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
464 }
465 } 452 }
466 changed_hosts_.clear(); 453 changed_hosts_.clear();
467 454
468 content::NotificationService::current()->Notify( 455 content::NotificationService::current()->Notify(
469 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, 456 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED,
470 content::Source<BrowserContext>(browser_context_), 457 content::Source<BrowserContext>(browser_context_),
471 content::Details<base::SharedMemory>(shared_memory_.get())); 458 content::Details<base::SharedMemory>(shared_memory_.get()));
472 } 459 }
473 460
474 void UserScriptLoader::SendUpdate(content::RenderProcessHost* process, 461 void UserScriptLoader::SendUpdate(content::RenderProcessHost* process,
(...skipping 24 matching lines...) Expand all
499 for (const HostID& id : changed_hosts) 486 for (const HostID& id : changed_hosts)
500 changed_ids_set.insert(id.id()); 487 changed_ids_set.insert(id.id());
501 488
502 if (base::SharedMemory::IsHandleValid(handle_for_process)) { 489 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
503 process->Send(new ExtensionMsg_UpdateUserScripts( 490 process->Send(new ExtensionMsg_UpdateUserScripts(
504 handle_for_process, host_id().id(), changed_ids_set)); 491 handle_for_process, host_id().id(), changed_ids_set));
505 } 492 }
506 } 493 }
507 494
508 } // namespace extensions 495 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/common/user_script.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698