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

Unified Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 11190016: Do not add TabContents from packaged apps to the task manager. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 2 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
« no previous file with comments | « chrome/browser/task_manager/task_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/task_manager/task_manager_resource_providers.cc
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc
index 43740ab42a2179cb7fd21bfd77b5109257480db9..1eb762e59794aae9f0343aeb5df9d4841eb58352 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager/task_manager_resource_providers.cc
@@ -147,6 +147,27 @@ string16 GetTitleFromWebContents(WebContents* web_contents) {
return title;
}
+// Only classify as an app if the URL is an app and the tab is hosting an
+// extension process. (It's possible to be showing the URL from before it
+// was installed as an app.) Return Extension::TYPE_UNKNOWN if the web_contents
+// is not for an extension, not for an app, or the process is not hosting an
+// extension.
+Extension::Type GetAppExtensionType(WebContents* web_contents) {
+ ExtensionService* extension_service = Profile::FromBrowserContext(
+ web_contents->GetBrowserContext())->GetExtensionService();
+ const Extension* extension =
+ extension_service->GetInstalledApp(web_contents->GetURL());
+
+ if (!extension || !extension->is_app())
+ return Extension::TYPE_UNKNOWN;
+
+ const extensions::ProcessMap* process_map = extension_service->process_map();
+ if (!process_map->Contains(web_contents->GetRenderProcessHost()->GetID()))
+ return Extension::TYPE_UNKNOWN;
+
+ return extension->GetType();
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -324,17 +345,8 @@ string16 TaskManagerTabContentsResource::GetTitle() const {
GURL url = contents->GetURL();
string16 tab_title = GetTitleFromWebContents(contents);
- // Only classify as an app if the URL is an app and the tab is hosting an
- // extension process. (It's possible to be showing the URL from before it
- // was installed as an app.)
- ExtensionService* extension_service =
- tab_contents_->profile()->GetExtensionService();
- extensions::ProcessMap* process_map = extension_service->process_map();
- bool is_app = extension_service->IsInstalledApp(url) &&
- process_map->Contains(contents->GetRenderProcessHost()->GetID());
-
int message_id = GetMessagePrefixID(
- is_app,
+ GetAppExtensionType(contents) != Extension::TYPE_UNKNOWN,
HostsExtension(),
tab_contents_->profile()->IsOffTheRecord(),
IsPrerendering(),
@@ -512,12 +524,17 @@ void TaskManagerTabContentsResourceProvider::Update(TabContents* tab_contents) {
void TaskManagerTabContentsResourceProvider::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- TabContents* tab_contents;
- tab_contents = TabContents::FromWebContents(
- content::Source<WebContents>(source).ptr());
+ WebContents* web_contents = content::Source<WebContents>(source).ptr();
+ TabContents* tab_contents = TabContents::FromWebContents(web_contents);
// A background page does not have a TabContents.
if (!tab_contents)
return;
+
+ // Platform Apps' contents are tracked using the RenderViewHost associated
+ // with the extension in the TaskManagerExtensionProcessResourceProvider.
+ if (GetAppExtensionType(web_contents) == Extension::TYPE_PLATFORM_APP)
+ return;
+
switch (type) {
case content::NOTIFICATION_WEB_CONTENTS_CONNECTED:
Add(tab_contents);
« no previous file with comments | « chrome/browser/task_manager/task_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698