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

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 2162983002: [Extensions] Ensure ordering of extension [un]loaded, activated messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review Created 4 years, 5 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/renderer/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 script_context_set_->ForEach( 990 script_context_set_->ForEach(
991 std::string(), nullptr, 991 std::string(), nullptr,
992 base::Bind(&ScriptContextSet::Remove, 992 base::Bind(&ScriptContextSet::Remove,
993 base::Unretained(script_context_set_.get()))); 993 base::Unretained(script_context_set_.get())));
994 } 994 }
995 995
996 void Dispatcher::OnActivateExtension(const std::string& extension_id) { 996 void Dispatcher::OnActivateExtension(const std::string& extension_id) {
997 const Extension* extension = 997 const Extension* extension =
998 RendererExtensionRegistry::Get()->GetByID(extension_id); 998 RendererExtensionRegistry::Get()->GetByID(extension_id);
999 if (!extension) { 999 if (!extension) {
1000 NOTREACHED();
1000 // Extension was activated but was never loaded. This probably means that 1001 // Extension was activated but was never loaded. This probably means that
1001 // the renderer failed to load it (or the browser failed to tell us when it 1002 // the renderer failed to load it (or the browser failed to tell us when it
1002 // did). Failures shouldn't happen, but instead of crashing there (which 1003 // did). Failures shouldn't happen, but instead of crashing there (which
1003 // executes on all renderers) be conservative and only crash in the renderer 1004 // executes on all renderers) be conservative and only crash in the renderer
1004 // of the extension which failed to load; this one. 1005 // of the extension which failed to load; this one.
1005 std::string& error = extension_load_errors_[extension_id]; 1006 std::string& error = extension_load_errors_[extension_id];
1006 char minidump[256]; 1007 char minidump[256];
1007 base::debug::Alias(&minidump); 1008 base::debug::Alias(&minidump);
1008 base::snprintf(minidump, 1009 base::snprintf(minidump,
1009 arraysize(minidump), 1010 arraysize(minidump),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 RendererExtensionRegistry::Get(); 1086 RendererExtensionRegistry::Get();
1086 // TODO(kalman): This test is deliberately not a CHECK (though I wish it 1087 // TODO(kalman): This test is deliberately not a CHECK (though I wish it
1087 // could be) and uses extension->id() not params.id: 1088 // could be) and uses extension->id() not params.id:
1088 // 1. For some reason params.id can be empty. I've only seen it with 1089 // 1. For some reason params.id can be empty. I've only seen it with
1089 // the webstore extension, in tests, and I've spent some time trying to 1090 // the webstore extension, in tests, and I've spent some time trying to
1090 // figure out why - but cost/benefit won. 1091 // figure out why - but cost/benefit won.
1091 // 2. The browser only sends this IPC to RenderProcessHosts once, but the 1092 // 2. The browser only sends this IPC to RenderProcessHosts once, but the
1092 // Dispatcher is attached to a RenderThread. Presumably there is a 1093 // Dispatcher is attached to a RenderThread. Presumably there is a
1093 // mismatch there. In theory one would think it's possible for the 1094 // mismatch there. In theory one would think it's possible for the
1094 // browser to figure this out itself - but again, cost/benefit. 1095 // browser to figure this out itself - but again, cost/benefit.
1096 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and
1097 // consider making this a release CHECK.
1098 DCHECK(!extension_registry->Contains(extension->id()));
lazyboy 2016/07/22 00:29:31 Change these to: if (!extension_registry->Insert(e
Devlin 2016/07/26 03:45:09 Done.
1095 if (!extension_registry->Contains(extension->id())) 1099 if (!extension_registry->Contains(extension->id()))
1096 extension_registry->Insert(extension); 1100 extension_registry->Insert(extension);
1097 } 1101 }
1098 1102
1099 // Update the available bindings for all contexts. These may have changed if 1103 // Update the available bindings for all contexts. These may have changed if
1100 // an externally_connectable extension was loaded that can connect to an 1104 // an externally_connectable extension was loaded that can connect to an
1101 // open webpage. 1105 // open webpage.
1102 UpdateBindings(""); 1106 UpdateBindings("");
1103 } 1107 }
1104 1108
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id)); 1157 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id));
1154 } 1158 }
1155 1159
1156 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) { 1160 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) {
1157 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); 1161 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids));
1158 } 1162 }
1159 1163
1160 void Dispatcher::OnUnloaded(const std::string& id) { 1164 void Dispatcher::OnUnloaded(const std::string& id) {
1161 // See comment in OnLoaded for why it would be nice, but perhaps incorrect, 1165 // See comment in OnLoaded for why it would be nice, but perhaps incorrect,
1162 // to CHECK here rather than guarding. 1166 // to CHECK here rather than guarding.
1163 if (!RendererExtensionRegistry::Get()->Remove(id)) 1167 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and
1168 // consider making this a release CHECK.
1169 if (!RendererExtensionRegistry::Get()->Remove(id)) {
1170 NOTREACHED();
1164 return; 1171 return;
1172 }
1165 1173
1166 active_extension_ids_.erase(id); 1174 active_extension_ids_.erase(id);
1167 1175
1168 script_injection_manager_->OnExtensionUnloaded(id); 1176 script_injection_manager_->OnExtensionUnloaded(id);
1169 1177
1170 // If the extension is later reloaded with a different set of permissions, 1178 // If the extension is later reloaded with a different set of permissions,
1171 // we'd like it to get a new isolated world ID, so that it can pick up the 1179 // we'd like it to get a new isolated world ID, so that it can pick up the
1172 // changed origin whitelist. 1180 // changed origin whitelist.
1173 ScriptInjection::RemoveIsolatedWorld(id); 1181 ScriptInjection::RemoveIsolatedWorld(id);
1174 1182
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 // The "guestViewDeny" module must always be loaded last. It registers 1674 // The "guestViewDeny" module must always be loaded last. It registers
1667 // error-providing custom elements for the GuestView types that are not 1675 // error-providing custom elements for the GuestView types that are not
1668 // available, and thus all of those types must have been checked and loaded 1676 // available, and thus all of those types must have been checked and loaded
1669 // (or not loaded) beforehand. 1677 // (or not loaded) beforehand.
1670 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1678 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1671 module_system->Require("guestViewDeny"); 1679 module_system->Require("guestViewDeny");
1672 } 1680 }
1673 } 1681 }
1674 1682
1675 } // namespace extensions 1683 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698