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

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

Issue 906493004: 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: Rebase. Created 5 years, 10 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 "chrome/browser/extensions/user_script_loader.h" 5 #include "chrome/browser/extensions/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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // though it removes the possibility that freeing the shared memory block 434 // though it removes the possibility that freeing the shared memory block
435 // would open up enough FDs for long enough for a retry to succeed. 435 // would open up enough FDs for long enough for a retry to succeed.
436 436
437 // Pretend the extension change didn't happen. 437 // Pretend the extension change didn't happen.
438 return; 438 return;
439 } 439 }
440 440
441 // We've got scripts ready to go. 441 // We've got scripts ready to go.
442 shared_memory_.reset(shared_memory.release()); 442 shared_memory_.reset(shared_memory.release());
443 443
444 // If user scripts are comming from a <webview>, will only notify the
445 // RenderProcessHost of that <webview>; otherwise will notify all of the
446 // RenderProcessHosts.
447 bool is_web_view = false;
448 int render_process_id = -1;
449 const UserScriptList* scripts = user_scripts.get();
450 if (scripts && !scripts->empty() &&
451 (*scripts)[0].consumer_instance_info().type() ==
452 ConsumerInstanceInfo::WEBVIEW) {
453 DCHECK(scripts->size() == 1);
454 is_web_view = true;
455 render_process_id = (*scripts)[0].routing_info().render_process_id;
456 }
457
444 for (content::RenderProcessHost::iterator i( 458 for (content::RenderProcessHost::iterator i(
445 content::RenderProcessHost::AllHostsIterator()); 459 content::RenderProcessHost::AllHostsIterator());
446 !i.IsAtEnd(); 460 !i.IsAtEnd();
447 i.Advance()) { 461 i.Advance()) {
462 if (is_web_view) {
463 if (i.GetCurrentValue()->GetID() != render_process_id) {
Fady Samuel 2015/02/11 19:08:22 if (is_web_view && i.GetCurrentValue()->GetID() !=
464 continue;
465 } else {
Fady Samuel 2015/02/11 19:08:22 Not necessary.
Xi Han 2015/02/11 21:57:24 I add the else for early break (line 467 "break").
Xi Han 2015/02/11 22:06:57 Adopt Fady's suggestion.
466 SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
467 break;
468 }
469 }
448 SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_); 470 SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
449 } 471 }
450 changed_hosts_.clear(); 472 changed_hosts_.clear();
451 473
452 content::NotificationService::current()->Notify( 474 content::NotificationService::current()->Notify(
453 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, 475 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED,
454 content::Source<Profile>(profile_), 476 content::Source<Profile>(profile_),
455 content::Details<base::SharedMemory>(shared_memory_.get())); 477 content::Details<base::SharedMemory>(shared_memory_.get()));
456 } 478 }
457 479
(...skipping 25 matching lines...) Expand all
483 for (const HostID& id : changed_hosts) 505 for (const HostID& id : changed_hosts)
484 changed_ids_set.insert(id.id()); 506 changed_ids_set.insert(id.id());
485 507
486 if (base::SharedMemory::IsHandleValid(handle_for_process)) { 508 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
487 process->Send(new ExtensionMsg_UpdateUserScripts( 509 process->Send(new ExtensionMsg_UpdateUserScripts(
488 handle_for_process, host_id().id(), changed_ids_set)); 510 handle_for_process, host_id().id(), changed_ids_set));
489 } 511 }
490 } 512 }
491 513
492 } // namespace extensions 514 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/common/consumer_instance_info.h » ('j') | extensions/common/user_script.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698