| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/background/background_contents_service.h" | |
| 19 #include "chrome/browser/background/background_contents_service_factory.h" | |
| 20 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/extensions/extension_process_manager.h" | 19 #include "chrome/browser/extensions/extension_process_manager.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/task_manager/background_resource_provider.h" | 22 #include "chrome/browser/task_manager/background_resource_provider.h" |
| 25 #include "chrome/browser/task_manager/browser_process_resource_provider.h" | 23 #include "chrome/browser/task_manager/browser_process_resource_provider.h" |
| 26 #include "chrome/browser/task_manager/child_process_resource_provider.h" | 24 #include "chrome/browser/task_manager/child_process_resource_provider.h" |
| 27 #include "chrome/browser/task_manager/extension_process_resource_provider.h" | 25 #include "chrome/browser/task_manager/extension_process_resource_provider.h" |
| 28 #include "chrome/browser/task_manager/guest_resource_provider.h" | 26 #include "chrome/browser/task_manager/guest_resource_provider.h" |
| 29 #include "chrome/browser/task_manager/notification_resource_provider.h" | 27 #include "chrome/browser/task_manager/notification_resource_provider.h" |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 void TaskManager::OpenAboutMemory(chrome::HostDesktopType desktop_type) { | 1536 void TaskManager::OpenAboutMemory(chrome::HostDesktopType desktop_type) { |
| 1539 Browser* browser = chrome::FindOrCreateTabbedBrowser( | 1537 Browser* browser = chrome::FindOrCreateTabbedBrowser( |
| 1540 ProfileManager::GetLastUsedProfileAllowedByPolicy(), desktop_type); | 1538 ProfileManager::GetLastUsedProfileAllowedByPolicy(), desktop_type); |
| 1541 chrome::NavigateParams params(browser, GURL(chrome::kChromeUIMemoryURL), | 1539 chrome::NavigateParams params(browser, GURL(chrome::kChromeUIMemoryURL), |
| 1542 content::PAGE_TRANSITION_LINK); | 1540 content::PAGE_TRANSITION_LINK); |
| 1543 params.disposition = NEW_FOREGROUND_TAB; | 1541 params.disposition = NEW_FOREGROUND_TAB; |
| 1544 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 1542 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 1545 chrome::Navigate(¶ms); | 1543 chrome::Navigate(¶ms); |
| 1546 } | 1544 } |
| 1547 | 1545 |
| 1548 // static | |
| 1549 int TaskManager::GetBackgroundPageCount() { | |
| 1550 int count = 0; | |
| 1551 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1552 if (!profile_manager) // Null when running unit tests. | |
| 1553 return count; | |
| 1554 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | |
| 1555 for (std::vector<Profile*>::const_iterator iter = profiles.begin(); | |
| 1556 iter != profiles.end(); | |
| 1557 ++iter) { | |
| 1558 Profile* profile = *iter; | |
| 1559 // Count the number of Background Contents (background pages for hosted | |
| 1560 // apps). Incognito windows do not support hosted apps, so just check the | |
| 1561 // main profile. | |
| 1562 BackgroundContentsService* background_contents_service = | |
| 1563 BackgroundContentsServiceFactory::GetForProfile(profile); | |
| 1564 if (background_contents_service) | |
| 1565 count += background_contents_service->GetBackgroundContents().size(); | |
| 1566 | |
| 1567 // Count the number of extensions with background pages (including | |
| 1568 // incognito). | |
| 1569 count += CountExtensionBackgroundPagesForProfile(profile); | |
| 1570 if (profile->HasOffTheRecordProfile()) { | |
| 1571 count += CountExtensionBackgroundPagesForProfile( | |
| 1572 profile->GetOffTheRecordProfile()); | |
| 1573 } | |
| 1574 } | |
| 1575 return count; | |
| 1576 } | |
| 1577 | |
| 1578 TaskManager::TaskManager() | 1546 TaskManager::TaskManager() |
| 1579 : model_(new TaskManagerModel(this)) { | 1547 : model_(new TaskManagerModel(this)) { |
| 1580 } | 1548 } |
| 1581 | 1549 |
| 1582 TaskManager::~TaskManager() { | 1550 TaskManager::~TaskManager() { |
| 1583 } | 1551 } |
| OLD | NEW |