From 8bcbc759e797556b4bd4ec80d22e597a8ca12695 Mon Sep 17 00:00:00 2001 From: kalman Date: Wed, 3 Jun 2015 16:12:27 -0700 Subject: Don't send unnecessary ExtensionMsg_Loaded IPCs. Each time ExtensionMsg_Loaded is sent it re-creates the set of Extensions it gives, invalidating the existing ones. This means that anything that holds onto Extensions for long periods of time - like ScriptContextSet - can end up in situations where they have an Extension with the same ID as an installed Extension, but different in pointer equality. It turns out that we send ExtensionMsg_Loaded every time a RenderViewHost is created, but it should only be send every time a RenderProcessHost is created, because the Extension sets are process-wide. While this bug is fundamental, one way it manifests itself is by the chrome.permissions.request API not updating the JavaScript context when permissions are granted. BUG=435141 Review URL: https://codereview.chromium.org/1142993002 Cr-Commit-Position: refs/heads/master@{#332720} --- extensions/renderer/dispatcher.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'extensions/renderer/dispatcher.h') diff --git a/extensions/renderer/dispatcher.h b/extensions/renderer/dispatcher.h index f85c1ad..982473b 100644 --- a/extensions/renderer/dispatcher.h +++ b/extensions/renderer/dispatcher.h @@ -137,10 +137,18 @@ class Dispatcher : public content::RenderProcessObserver, bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; } private: + // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs + // to call LoadExtensionForTest and the OnActivateExtension IPCs. friend class ::ChromeRenderViewTest; FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, CannotScriptWebstore); + // Inserts an Extension into |extensions_|. Normally the only way to do this + // would be through the ExtensionMsg_Loaded IPC (OnLoaded) but this can't be + // triggered for tests, because in the process of serializing then + // deserializing the IPC, Extension IDs manually set for testing are lost. + void LoadExtensionForTest(const Extension* extension); + // RenderProcessObserver implementation: bool OnControlMessageReceived(const IPC::Message& message) override; void WebKitInitialized() override; @@ -158,7 +166,6 @@ class Dispatcher : public content::RenderProcessObserver, void OnDispatchOnDisconnect(int port_id, const std::string& error_message); void OnLoaded( const std::vector& loaded_extensions); - void OnLoadedInternal(scoped_refptr extension); void OnMessageInvoke(const std::string& extension_id, const std::string& module_name, const std::string& function_name, -- cgit v1.1