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

Side by Side Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 7828007: Add Profile data to the Task Manager on OS Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_resource_providers.h" 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/background/background_contents_service.h" 17 #include "chrome/browser/background/background_contents_service.h"
18 #include "chrome/browser/background/background_contents_service_factory.h" 18 #include "chrome/browser/background/background_contents_service_factory.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/extensions/extension_host.h" 20 #include "chrome/browser/extensions/extension_host.h"
21 #include "chrome/browser/extensions/extension_process_manager.h" 21 #include "chrome/browser/extensions/extension_process_manager.h"
22 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/favicon/favicon_tab_helper.h" 23 #include "chrome/browser/favicon/favicon_tab_helper.h"
24 #include "chrome/browser/prerender/prerender_manager.h" 24 #include "chrome/browser/prerender/prerender_manager.h"
25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_info_cache.h"
25 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/tab_contents/background_contents.h" 28 #include "chrome/browser/tab_contents/background_contents.h"
27 #include "chrome/browser/tab_contents/tab_util.h" 29 #include "chrome/browser/tab_contents/tab_util.h"
28 #include "chrome/browser/ui/browser_list.h" 30 #include "chrome/browser/ui/browser_list.h"
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 31 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
30 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/extensions/extension.h" 34 #include "chrome/common/extensions/extension.h"
33 #include "chrome/common/render_messages.h" 35 #include "chrome/common/render_messages.h"
34 #include "content/browser/browser_child_process_host.h" 36 #include "content/browser/browser_child_process_host.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 contents->GetRenderProcessHost()->is_extension_process(); 258 contents->GetRenderProcessHost()->is_extension_process();
257 259
258 int message_id = GetMessagePrefixID( 260 int message_id = GetMessagePrefixID(
259 is_app, 261 is_app,
260 HostsExtension(), 262 HostsExtension(),
261 tab_contents_->profile()->IsOffTheRecord(), 263 tab_contents_->profile()->IsOffTheRecord(),
262 IsPrerendering()); 264 IsPrerendering());
263 return l10n_util::GetStringFUTF16(message_id, tab_title); 265 return l10n_util::GetStringFUTF16(message_id, tab_title);
264 } 266 }
265 267
268 string16 TaskManagerTabContentsResource::GetProfileName() const {
269 ProfileInfoCache& cache =
270 g_browser_process->profile_manager()->GetProfileInfoCache();
271 Profile* profile = tab_contents_->profile()->GetOriginalProfile();
272 return cache.GetNameOfProfileAtIndex(
273 cache.GetIndexOfProfileWithPath(profile->GetPath()));
274 }
275
266 SkBitmap TaskManagerTabContentsResource::GetIcon() const { 276 SkBitmap TaskManagerTabContentsResource::GetIcon() const {
267 if (IsPrerendering()) 277 if (IsPrerendering())
268 return *prerender_icon_; 278 return *prerender_icon_;
269 return tab_contents_->favicon_tab_helper()->GetFavicon(); 279 return tab_contents_->favicon_tab_helper()->GetFavicon();
270 } 280 }
271 281
272 TabContentsWrapper* TaskManagerTabContentsResource::GetTabContents() const { 282 TabContentsWrapper* TaskManagerTabContentsResource::GetTabContents() const {
273 return tab_contents_; 283 return tab_contents_;
274 } 284 }
275 285
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 497
488 if (title.empty()) { 498 if (title.empty()) {
489 // No title (can't locate the parent app for some reason) so just display 499 // No title (can't locate the parent app for some reason) so just display
490 // the URL (properly forced to be LTR). 500 // the URL (properly forced to be LTR).
491 title = base::i18n::GetDisplayStringInLTRDirectionality( 501 title = base::i18n::GetDisplayStringInLTRDirectionality(
492 UTF8ToUTF16(background_contents_->GetURL().spec())); 502 UTF8ToUTF16(background_contents_->GetURL().spec()));
493 } 503 }
494 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); 504 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title);
495 } 505 }
496 506
507 string16 TaskManagerBackgroundContentsResource::GetProfileName() const {
508 return string16();
509 }
497 510
498 SkBitmap TaskManagerBackgroundContentsResource::GetIcon() const { 511 SkBitmap TaskManagerBackgroundContentsResource::GetIcon() const {
499 return *default_icon_; 512 return *default_icon_;
500 } 513 }
501 514
502 bool TaskManagerBackgroundContentsResource::IsBackground() const { 515 bool TaskManagerBackgroundContentsResource::IsBackground() const {
503 return true; 516 return true;
504 } 517 }
505 518
506 //////////////////////////////////////////////////////////////////////////////// 519 ////////////////////////////////////////////////////////////////////////////////
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 731 }
719 732
720 // TaskManagerResource methods: 733 // TaskManagerResource methods:
721 string16 TaskManagerChildProcessResource::GetTitle() const { 734 string16 TaskManagerChildProcessResource::GetTitle() const {
722 if (title_.empty()) 735 if (title_.empty())
723 title_ = GetLocalizedTitle(); 736 title_ = GetLocalizedTitle();
724 737
725 return title_; 738 return title_;
726 } 739 }
727 740
741 string16 TaskManagerChildProcessResource::GetProfileName() const {
742 return string16();
743 }
744
728 SkBitmap TaskManagerChildProcessResource::GetIcon() const { 745 SkBitmap TaskManagerChildProcessResource::GetIcon() const {
729 return *default_icon_; 746 return *default_icon_;
730 } 747 }
731 748
732 base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const { 749 base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const {
733 return child_process_.handle(); 750 return child_process_.handle();
734 } 751 }
735 752
736 TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const { 753 TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const {
737 // Translate types to TaskManager::ResourceType, since ChildProcessInfo's type 754 // Translate types to TaskManager::ResourceType, since ChildProcessInfo's type
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 title_ = l10n_util::GetStringFUTF16(message_id, extension_name); 1023 title_ = l10n_util::GetStringFUTF16(message_id, extension_name);
1007 } 1024 }
1008 1025
1009 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { 1026 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() {
1010 } 1027 }
1011 1028
1012 string16 TaskManagerExtensionProcessResource::GetTitle() const { 1029 string16 TaskManagerExtensionProcessResource::GetTitle() const {
1013 return title_; 1030 return title_;
1014 } 1031 }
1015 1032
1033 string16 TaskManagerExtensionProcessResource::GetProfileName() const {
1034 ProfileInfoCache& cache =
1035 g_browser_process->profile_manager()->GetProfileInfoCache();
1036 Profile* profile = extension_host_->profile()->GetOriginalProfile();
1037 return cache.GetNameOfProfileAtIndex(
1038 cache.GetIndexOfProfileWithPath(profile->GetPath()));
1039 }
1040
1016 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { 1041 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const {
1017 return *default_icon_; 1042 return *default_icon_;
1018 } 1043 }
1019 1044
1020 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { 1045 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const {
1021 return process_handle_; 1046 return process_handle_;
1022 } 1047 }
1023 1048
1024 TaskManager::Resource::Type 1049 TaskManager::Resource::Type
1025 TaskManagerExtensionProcessResource::GetType() const { 1050 TaskManagerExtensionProcessResource::GetType() const {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 } 1257 }
1233 1258
1234 // TaskManagerResource methods: 1259 // TaskManagerResource methods:
1235 string16 TaskManagerBrowserProcessResource::GetTitle() const { 1260 string16 TaskManagerBrowserProcessResource::GetTitle() const {
1236 if (title_.empty()) { 1261 if (title_.empty()) {
1237 title_ = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT); 1262 title_ = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT);
1238 } 1263 }
1239 return title_; 1264 return title_;
1240 } 1265 }
1241 1266
1267 string16 TaskManagerBrowserProcessResource::GetProfileName() const {
1268 return string16();
1269 }
1270
1242 SkBitmap TaskManagerBrowserProcessResource::GetIcon() const { 1271 SkBitmap TaskManagerBrowserProcessResource::GetIcon() const {
1243 return *default_icon_; 1272 return *default_icon_;
1244 } 1273 }
1245 1274
1246 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { 1275 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const {
1247 return static_cast<size_t>(sqlite3_memory_used()); 1276 return static_cast<size_t>(sqlite3_memory_used());
1248 } 1277 }
1249 1278
1250 base::ProcessHandle TaskManagerBrowserProcessResource::GetProcess() const { 1279 base::ProcessHandle TaskManagerBrowserProcessResource::GetProcess() const {
1251 return base::GetCurrentProcessHandle(); // process_; 1280 return base::GetCurrentProcessHandle(); // process_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 1342
1314 return &resource_; 1343 return &resource_;
1315 } 1344 }
1316 1345
1317 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { 1346 void TaskManagerBrowserProcessResourceProvider::StartUpdating() {
1318 task_manager_->AddResource(&resource_); 1347 task_manager_->AddResource(&resource_);
1319 } 1348 }
1320 1349
1321 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { 1350 void TaskManagerBrowserProcessResourceProvider::StopUpdating() {
1322 } 1351 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.h ('k') | chrome/browser/task_manager/task_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698