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

Unified Diff: chrome/browser/extensions/extension_process_manager.cc

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: interactive_ui_tests Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_process_manager.cc
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 30fcb4d3dcffbdcce9788182e75f4b5cc7055858..8e80d1c7a0bcfd02147f3b70514bcdbd0ad77fa3 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
@@ -37,6 +38,7 @@ using content::OpenURLParams;
using content::Referrer;
using content::RenderViewHost;
using content::SiteInstance;
+using content::WebContents;
namespace {
@@ -307,56 +309,66 @@ std::set<RenderViewHost*>
return result;
// Gather up all the views for that site.
- for (ExtensionRenderViews::iterator view = all_extension_views_.begin();
- view != all_extension_views_.end(); ++view) {
- if (view->first->GetSiteInstance() == site_instance)
- result.insert(view->first);
+ for (ExtensionWebContents::iterator contents =
+ all_extension_contents_.begin();
+ contents != all_extension_contents_.end(); ++contents) {
+ if (contents->first->GetSiteInstance() == site_instance)
+ result.insert(contents->first->GetRenderViewHost());
}
return result;
}
-void ExtensionProcessManager::RegisterRenderViewHost(
- RenderViewHost* render_view_host,
+const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost(
+ content::RenderViewHost* render_view_host) {
+ ExtensionService* service =
+ ExtensionSystem::Get(GetProfile())->extension_service();
+ return service->extensions()->GetByID(
+ render_view_host->GetSiteInstance()->GetSite().host());
+}
+
+void ExtensionProcessManager::RegisterWebContents(
+ WebContents* web_contents,
const Extension* extension) {
- all_extension_views_[render_view_host] = content::VIEW_TYPE_INVALID;
+ all_extension_contents_[web_contents] = content::VIEW_TYPE_INVALID;
}
-void ExtensionProcessManager::UnregisterRenderViewHost(
- RenderViewHost* render_view_host) {
- ExtensionRenderViews::iterator view =
- all_extension_views_.find(render_view_host);
- if (view == all_extension_views_.end())
+void ExtensionProcessManager::UnregisterWebContents(
+ WebContents* web_contents) {
+ ExtensionWebContents::iterator contents =
+ all_extension_contents_.find(web_contents);
+ if (contents == all_extension_contents_.end())
return;
- content::ViewType view_type = view->second;
- all_extension_views_.erase(view);
+ content::ViewType view_type = contents->second;
+ all_extension_contents_.erase(contents);
// Keepalive count, balanced in UpdateRegisteredRenderView.
if (view_type != content::VIEW_TYPE_INVALID &&
view_type != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
const Extension* extension =
GetProfile()->GetExtensionService()->extensions()->GetByID(
- GetExtensionID(render_view_host));
+ GetExtensionID(contents->first->GetRenderViewHost()));
if (extension)
DecrementLazyKeepaliveCount(extension);
}
}
-void ExtensionProcessManager::UpdateRegisteredRenderView(
- RenderViewHost* render_view_host) {
- ExtensionRenderViews::iterator view =
- all_extension_views_.find(render_view_host);
- if (view == all_extension_views_.end())
+void ExtensionProcessManager::UpdateRegisteredWebContents(
+ WebContents* web_contents) {
+ ExtensionWebContents::iterator contents =
+ all_extension_contents_.find(web_contents);
+ if (contents == all_extension_contents_.end())
return;
- view->second = render_view_host->GetDelegate()->GetRenderViewType();
+ RenderViewHost* render_view_host = contents->first->GetRenderViewHost();
+ contents->second = render_view_host->GetDelegate()->GetRenderViewType();
// Keep the lazy background page alive as long as any non-background-page
// extension views are visible. Keepalive count balanced in
// UnregisterRenderViewHost.
- if (view->second != content::VIEW_TYPE_INVALID &&
- view->second != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
+ if (contents->second != content::VIEW_TYPE_INVALID &&
+ contents->second != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
const Extension* extension =
GetProfile()->GetExtensionService()->extensions()->GetByID(
GetExtensionID(render_view_host));
@@ -369,10 +381,6 @@ SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) {
return site_instance_->GetRelatedSiteInstance(url);
}
-bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const {
- return all_hosts_.find(host) != all_hosts_.end();
-}
-
int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
if (!extension->has_lazy_background_page())
return 0;
@@ -510,9 +518,9 @@ void ExtensionProcessManager::Observe(
case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
- all_hosts_.erase(host);
if (background_hosts_.erase(host))
background_page_data_.erase(host->extension()->id());
+ platform_app_hosts_.erase(host);
break;
}
@@ -528,7 +536,7 @@ void ExtensionProcessManager::Observe(
case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: {
content::WebContents* contents =
content::Source<content::WebContents>(source).ptr();
- UpdateRegisteredRenderView(contents->GetRenderViewHost());
+ UpdateRegisteredWebContents(contents);
break;
}
@@ -583,10 +591,10 @@ Profile* ExtensionProcessManager::GetProfile() const {
void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host,
bool is_background) {
DCHECK_EQ(site_instance_->GetBrowserContext(), host->profile());
-
- all_hosts_.insert(host);
if (is_background)
background_hosts_.insert(host);
+ if (host->extension()->is_platform_app())
+ platform_app_hosts_.insert(host);
}
void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) {
@@ -620,6 +628,17 @@ IncognitoExtensionProcessManager::IncognitoExtensionProcessManager(
content::NotificationService::AllSources());
}
+const ExtensionProcessManager::ContentsSet
+ExtensionProcessManager::GetAllContents() const {
+ ContentsSet result;
+ for (ExtensionWebContents::const_iterator iter =
+ all_extension_contents_.begin();
+ iter != all_extension_contents_.end(); ++iter) {
+ result.insert(iter->first);
+ }
+ return result;
+}
+
ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost(
const Extension* extension,
const GURL& url,

Powered by Google App Engine
This is Rietveld 408576698