diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 03:24:36 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 03:24:36 +0000 |
commit | cf9a246cf386c7af0fb6524ac5d025c0d4e8563a (patch) | |
tree | 914b55375eee47f6d21f2fc3f106c4ba506637ec /chrome/browser/extensions/extension_process_manager.cc | |
parent | 0c48c17f7ebcc0c8f79eba1aeae56d32b3c2f03f (diff) | |
download | chromium_src-cf9a246cf386c7af0fb6524ac5d025c0d4e8563a.zip chromium_src-cf9a246cf386c7af0fb6524ac5d025c0d4e8563a.tar.gz chromium_src-cf9a246cf386c7af0fb6524ac5d025c0d4e8563a.tar.bz2 |
EFD now notifies EPM of renderviews created, which in turn notifies the renderer of page actions that it knows about.
Remove generic event "page-action-executed" in favor of page action specific event (sent as extension_id/page_action_id).
In the bindings, we now setup events for each page action we know about so we can register for specific events, and not receive broadcast events from all page actions. To setup these events I added a GetCurrentPageActions() to extension_process_bindings.cc and a helper function GetCurrentExtensionId().
And, finally, I simplified the page action background page by removing the check to see if we are already subscribed to the feed (since we now support multiple feed readers, it doesn't make sense anymore to always check Google Reader). This check might make a comeback later in a different form.
BUG=13936
TEST=The RSS sample extension should work as before.
Review URL: http://codereview.chromium.org/155514
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_process_manager.cc')
-rw-r--r-- | chrome/browser/extensions/extension_process_manager.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 4c2047b..3018ea8 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -9,9 +9,11 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" +#include "chrome/common/render_messages.h" static void CreateBackgroundHosts( ExtensionProcessManager* manager, const ExtensionList* extensions) { @@ -33,6 +35,10 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile) NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED, Source<Profile>(profile)); + registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, + NotificationService::AllSources()); + registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, + NotificationService::AllSources()); } ExtensionProcessManager::~ExtensionProcessManager() { @@ -78,6 +84,39 @@ ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( return host; } +void ExtensionProcessManager::RegisterExtensionProcess( + std::string extension_id, int process_id) { + ProcessIDMap::const_iterator it = process_ids_.find(extension_id); + if (it != process_ids_.end() && (*it).second == process_id) + return; + + process_ids_[extension_id] = process_id; + + ExtensionsService* extension_service = + browsing_instance_->profile()->GetExtensionsService(); + + std::vector<std::string> page_action_ids; + Extension* extension = extension_service->GetExtensionById(extension_id); + for (PageActionMap::const_iterator i = extension->page_actions().begin(); + i != extension->page_actions().end(); ++i) { + page_action_ids.push_back(i->first); + } + + RenderProcessHost* rph = RenderProcessHost::FromID(process_id); + rph->Send(new ViewMsg_Extension_UpdatePageActions(extension_id, + page_action_ids)); +} + +void ExtensionProcessManager::UnregisterExtensionProcess(int process_id) { + ProcessIDMap::iterator it = process_ids_.begin(); + while (it != process_ids_.end()) { + if (it->second == process_id) + process_ids_.erase(it++); + else + ++it; + } +} + SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { return browsing_instance_->GetSiteInstanceForURL(url); } @@ -122,6 +161,13 @@ void ExtensionProcessManager::Observe(NotificationType type, break; } + case NotificationType::RENDERER_PROCESS_TERMINATED: + case NotificationType::RENDERER_PROCESS_CLOSED: { + RenderProcessHost* host = Source<RenderProcessHost>(source).ptr(); + UnregisterExtensionProcess(host->pid()); + break; + } + default: NOTREACHED(); } |