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_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 using extensions::Extension; | 78 using extensions::Extension; |
79 | 79 |
80 namespace { | 80 namespace { |
81 | 81 |
82 // Returns the appropriate message prefix ID for tabs and extensions, | 82 // Returns the appropriate message prefix ID for tabs and extensions, |
83 // reflecting whether they are apps or in incognito mode. | 83 // reflecting whether they are apps or in incognito mode. |
84 int GetMessagePrefixID(bool is_app, | 84 int GetMessagePrefixID(bool is_app, |
85 bool is_extension, | 85 bool is_extension, |
86 bool is_incognito, | 86 bool is_incognito, |
87 bool is_prerender, | 87 bool is_prerender, |
88 bool is_instant_preview) { | 88 bool is_instant_preview, |
| 89 bool is_background) { |
89 if (is_app) { | 90 if (is_app) { |
90 if (is_incognito) | 91 if (is_background) { |
| 92 return IDS_TASK_MANAGER_BACKGROUND_PREFIX; |
| 93 } else if (is_incognito) { |
91 return IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX; | 94 return IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX; |
92 else | 95 } else { |
93 return IDS_TASK_MANAGER_APP_PREFIX; | 96 return IDS_TASK_MANAGER_APP_PREFIX; |
| 97 } |
94 } else if (is_extension) { | 98 } else if (is_extension) { |
95 if (is_incognito) | 99 if (is_incognito) |
96 return IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; | 100 return IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; |
97 else | 101 else |
98 return IDS_TASK_MANAGER_EXTENSION_PREFIX; | 102 return IDS_TASK_MANAGER_EXTENSION_PREFIX; |
99 } else if (is_prerender) { | 103 } else if (is_prerender) { |
100 return IDS_TASK_MANAGER_PRERENDER_PREFIX; | 104 return IDS_TASK_MANAGER_PRERENDER_PREFIX; |
101 } else if (is_instant_preview) { | 105 } else if (is_instant_preview) { |
102 return IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX; | 106 return IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX; |
103 } else { | 107 } else { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 tab_contents_->profile()->GetExtensionService(); | 320 tab_contents_->profile()->GetExtensionService(); |
317 extensions::ProcessMap* process_map = extension_service->process_map(); | 321 extensions::ProcessMap* process_map = extension_service->process_map(); |
318 bool is_app = extension_service->IsInstalledApp(url) && | 322 bool is_app = extension_service->IsInstalledApp(url) && |
319 process_map->Contains(contents->GetRenderProcessHost()->GetID()); | 323 process_map->Contains(contents->GetRenderProcessHost()->GetID()); |
320 | 324 |
321 int message_id = GetMessagePrefixID( | 325 int message_id = GetMessagePrefixID( |
322 is_app, | 326 is_app, |
323 HostsExtension(), | 327 HostsExtension(), |
324 tab_contents_->profile()->IsOffTheRecord(), | 328 tab_contents_->profile()->IsOffTheRecord(), |
325 IsPrerendering(), | 329 IsPrerendering(), |
326 is_instant_preview_); | 330 is_instant_preview_, |
| 331 false); |
327 return l10n_util::GetStringFUTF16(message_id, tab_title); | 332 return l10n_util::GetStringFUTF16(message_id, tab_title); |
328 } | 333 } |
329 | 334 |
330 string16 TaskManagerTabContentsResource::GetProfileName() const { | 335 string16 TaskManagerTabContentsResource::GetProfileName() const { |
331 return GetProfileNameFromInfoCache(tab_contents_->profile()); | 336 return GetProfileNameFromInfoCache(tab_contents_->profile()); |
332 } | 337 } |
333 | 338 |
334 gfx::ImageSkia TaskManagerTabContentsResource::GetIcon() const { | 339 gfx::ImageSkia TaskManagerTabContentsResource::GetIcon() const { |
335 if (IsPrerendering()) | 340 if (IsPrerendering()) |
336 return *prerender_icon_; | 341 return *prerender_icon_; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // TaskManagerPanelResource class | 538 // TaskManagerPanelResource class |
534 //////////////////////////////////////////////////////////////////////////////// | 539 //////////////////////////////////////////////////////////////////////////////// |
535 | 540 |
536 TaskManagerPanelResource::TaskManagerPanelResource(Panel* panel) | 541 TaskManagerPanelResource::TaskManagerPanelResource(Panel* panel) |
537 : TaskManagerRendererResource( | 542 : TaskManagerRendererResource( |
538 panel->GetWebContents()->GetRenderProcessHost()->GetHandle(), | 543 panel->GetWebContents()->GetRenderProcessHost()->GetHandle(), |
539 panel->GetWebContents()->GetRenderViewHost()), | 544 panel->GetWebContents()->GetRenderViewHost()), |
540 panel_(panel) { | 545 panel_(panel) { |
541 message_prefix_id_ = GetMessagePrefixID( | 546 message_prefix_id_ = GetMessagePrefixID( |
542 GetExtension()->is_app(), true, panel->profile()->IsOffTheRecord(), | 547 GetExtension()->is_app(), true, panel->profile()->IsOffTheRecord(), |
543 false, false); | 548 false, false, false); |
544 } | 549 } |
545 | 550 |
546 TaskManagerPanelResource::~TaskManagerPanelResource() { | 551 TaskManagerPanelResource::~TaskManagerPanelResource() { |
547 } | 552 } |
548 | 553 |
549 TaskManager::Resource::Type TaskManagerPanelResource::GetType() const { | 554 TaskManager::Resource::Type TaskManagerPanelResource::GetType() const { |
550 return EXTENSION; | 555 return EXTENSION; |
551 } | 556 } |
552 | 557 |
553 string16 TaskManagerPanelResource::GetTitle() const { | 558 string16 TaskManagerPanelResource::GetTitle() const { |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 } | 1323 } |
1319 process_handle_ = render_view_host_->GetProcess()->GetHandle(); | 1324 process_handle_ = render_view_host_->GetProcess()->GetHandle(); |
1320 unique_process_id_ = render_view_host->GetProcess()->GetID(); | 1325 unique_process_id_ = render_view_host->GetProcess()->GetID(); |
1321 pid_ = base::GetProcId(process_handle_); | 1326 pid_ = base::GetProcId(process_handle_); |
1322 string16 extension_name = UTF8ToUTF16(GetExtension()->name()); | 1327 string16 extension_name = UTF8ToUTF16(GetExtension()->name()); |
1323 DCHECK(!extension_name.empty()); | 1328 DCHECK(!extension_name.empty()); |
1324 | 1329 |
1325 Profile* profile = Profile::FromBrowserContext( | 1330 Profile* profile = Profile::FromBrowserContext( |
1326 render_view_host->GetProcess()->GetBrowserContext()); | 1331 render_view_host->GetProcess()->GetBrowserContext()); |
1327 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, | 1332 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, |
1328 profile->IsOffTheRecord(), false, false); | 1333 profile->IsOffTheRecord(), false, false, IsBackground()); |
1329 title_ = l10n_util::GetStringFUTF16(message_id, extension_name); | 1334 title_ = l10n_util::GetStringFUTF16(message_id, extension_name); |
1330 } | 1335 } |
1331 | 1336 |
1332 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { | 1337 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { |
1333 } | 1338 } |
1334 | 1339 |
1335 string16 TaskManagerExtensionProcessResource::GetTitle() const { | 1340 string16 TaskManagerExtensionProcessResource::GetTitle() const { |
1336 return title_; | 1341 return title_; |
1337 } | 1342 } |
1338 | 1343 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 | 1696 |
1692 return &resource_; | 1697 return &resource_; |
1693 } | 1698 } |
1694 | 1699 |
1695 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1700 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1696 task_manager_->AddResource(&resource_); | 1701 task_manager_->AddResource(&resource_); |
1697 } | 1702 } |
1698 | 1703 |
1699 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1704 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1700 } | 1705 } |
OLD | NEW |