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

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

Issue 8759009: Add "Instant:" prefix to Instant preview tabs in the Task manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
11 #include "base/file_version_info.h" 11 #include "base/file_version_info.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/app/chrome_command_ids.h" 19 #include "chrome/app/chrome_command_ids.h"
20 #include "chrome/browser/background/background_contents_service.h" 20 #include "chrome/browser/background/background_contents_service.h"
21 #include "chrome/browser/background/background_contents_service_factory.h" 21 #include "chrome/browser/background/background_contents_service_factory.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/debugger/devtools_window.h" 23 #include "chrome/browser/debugger/devtools_window.h"
24 #include "chrome/browser/extensions/extension_host.h" 24 #include "chrome/browser/extensions/extension_host.h"
25 #include "chrome/browser/extensions/extension_process_manager.h" 25 #include "chrome/browser/extensions/extension_process_manager.h"
26 #include "chrome/browser/extensions/extension_service.h" 26 #include "chrome/browser/extensions/extension_service.h"
27 #include "chrome/browser/favicon/favicon_tab_helper.h" 27 #include "chrome/browser/favicon/favicon_tab_helper.h"
28 #include "chrome/browser/instant/instant_controller.h"
28 #include "chrome/browser/prerender/prerender_manager.h" 29 #include "chrome/browser/prerender/prerender_manager.h"
29 #include "chrome/browser/prerender/prerender_manager_factory.h" 30 #include "chrome/browser/prerender/prerender_manager_factory.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/profiles/profile_info_cache.h" 32 #include "chrome/browser/profiles/profile_info_cache.h"
32 #include "chrome/browser/profiles/profile_manager.h" 33 #include "chrome/browser/profiles/profile_manager.h"
33 #include "chrome/browser/tab_contents/background_contents.h" 34 #include "chrome/browser/tab_contents/background_contents.h"
34 #include "chrome/browser/tab_contents/tab_util.h" 35 #include "chrome/browser/tab_contents/tab_util.h"
35 #include "chrome/browser/ui/browser_list.h" 36 #include "chrome/browser/ui/browser_list.h"
36 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
37 #include "chrome/common/chrome_notification_types.h" 38 #include "chrome/common/chrome_notification_types.h"
(...skipping 24 matching lines...) Expand all
62 #include "chrome/browser/app_icon_win.h" 63 #include "chrome/browser/app_icon_win.h"
63 #include "ui/gfx/icon_util.h" 64 #include "ui/gfx/icon_util.h"
64 #endif // defined(OS_WIN) 65 #endif // defined(OS_WIN)
65 66
66 using content::BrowserThread; 67 using content::BrowserThread;
67 68
68 namespace { 69 namespace {
69 70
70 // Returns the appropriate message prefix ID for tabs and extensions, 71 // Returns the appropriate message prefix ID for tabs and extensions,
71 // reflecting whether they are apps or in incognito mode. 72 // reflecting whether they are apps or in incognito mode.
72 int GetMessagePrefixID(bool is_app, bool is_extension, 73 int GetMessagePrefixID(bool is_app, bool is_extension, bool is_incognito,
sky 2011/12/01 01:48:56 nit: when you wrap each param on its own line.
sreeram 2011/12/01 20:35:26 Done.
73 bool is_incognito, bool is_prerender) { 74 bool is_prerender, bool is_instant_preview) {
74 if (is_app) { 75 if (is_app) {
75 if (is_incognito) 76 if (is_incognito)
76 return IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX; 77 return IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX;
77 else 78 else
78 return IDS_TASK_MANAGER_APP_PREFIX; 79 return IDS_TASK_MANAGER_APP_PREFIX;
79 } else if (is_extension) { 80 } else if (is_extension) {
80 if (is_incognito) 81 if (is_incognito)
81 return IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; 82 return IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX;
82 else 83 else
83 return IDS_TASK_MANAGER_EXTENSION_PREFIX; 84 return IDS_TASK_MANAGER_EXTENSION_PREFIX;
84 } else if (is_prerender) { 85 } else if (is_prerender) {
85 return IDS_TASK_MANAGER_PRERENDER_PREFIX; 86 return IDS_TASK_MANAGER_PRERENDER_PREFIX;
87 } else if (is_instant_preview) {
88 return IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX;
86 } else { 89 } else {
87 return IDS_TASK_MANAGER_TAB_PREFIX; 90 return IDS_TASK_MANAGER_TAB_PREFIX;
88 } 91 }
89 } 92 }
90 93
91 } // namespace 94 } // namespace
92 95
93 //////////////////////////////////////////////////////////////////////////////// 96 ////////////////////////////////////////////////////////////////////////////////
94 // TaskManagerRendererResource class 97 // TaskManagerRendererResource class
95 //////////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////////
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 230
228 bool TaskManagerTabContentsResource::IsPrerendering() const { 231 bool TaskManagerTabContentsResource::IsPrerendering() const {
229 prerender::PrerenderManager* prerender_manager = 232 prerender::PrerenderManager* prerender_manager =
230 prerender::PrerenderManagerFactory::GetForProfile( 233 prerender::PrerenderManagerFactory::GetForProfile(
231 tab_contents_->profile()); 234 tab_contents_->profile());
232 return prerender_manager && 235 return prerender_manager &&
233 prerender_manager->IsTabContentsPrerendering( 236 prerender_manager->IsTabContentsPrerendering(
234 tab_contents_->tab_contents()); 237 tab_contents_->tab_contents());
235 } 238 }
236 239
240 bool TaskManagerTabContentsResource::IsInstantPreview() const {
241 for (BrowserList::const_iterator i = BrowserList::begin();
sky 2011/12/01 01:48:56 How often is this called? Should it be cached?
sreeram 2011/12/01 20:35:26 Done.
242 i != BrowserList::end(); ++i) {
243 if ((*i)->instant() &&
244 (*i)->instant()->GetPreviewContents() == tab_contents_) {
245 return true;
246 }
247 }
248 return false;
249 }
250
237 bool TaskManagerTabContentsResource::HostsExtension() const { 251 bool TaskManagerTabContentsResource::HostsExtension() const {
238 return tab_contents_->tab_contents()->GetURL().SchemeIs( 252 return tab_contents_->tab_contents()->GetURL().SchemeIs(
239 chrome::kExtensionScheme); 253 chrome::kExtensionScheme);
240 } 254 }
241 255
242 TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { 256 TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const {
243 return HostsExtension() ? EXTENSION : RENDERER; 257 return HostsExtension() ? EXTENSION : RENDERER;
244 } 258 }
245 259
246 string16 TaskManagerTabContentsResource::GetTitle() const { 260 string16 TaskManagerTabContentsResource::GetTitle() const {
(...skipping 24 matching lines...) Expand all
271 ExtensionService* extension_service = 285 ExtensionService* extension_service =
272 tab_contents_->profile()->GetExtensionService(); 286 tab_contents_->profile()->GetExtensionService();
273 extensions::ProcessMap* process_map = extension_service->process_map(); 287 extensions::ProcessMap* process_map = extension_service->process_map();
274 bool is_app = extension_service->IsInstalledApp(url) && 288 bool is_app = extension_service->IsInstalledApp(url) &&
275 process_map->Contains(contents->GetRenderProcessHost()->GetID()); 289 process_map->Contains(contents->GetRenderProcessHost()->GetID());
276 290
277 int message_id = GetMessagePrefixID( 291 int message_id = GetMessagePrefixID(
278 is_app, 292 is_app,
279 HostsExtension(), 293 HostsExtension(),
280 tab_contents_->profile()->IsOffTheRecord(), 294 tab_contents_->profile()->IsOffTheRecord(),
281 IsPrerendering()); 295 IsPrerendering(),
296 IsInstantPreview());
282 return l10n_util::GetStringFUTF16(message_id, tab_title); 297 return l10n_util::GetStringFUTF16(message_id, tab_title);
283 } 298 }
284 299
285 string16 TaskManagerTabContentsResource::GetProfileName() const { 300 string16 TaskManagerTabContentsResource::GetProfileName() const {
286 ProfileInfoCache& cache = 301 ProfileInfoCache& cache =
287 g_browser_process->profile_manager()->GetProfileInfoCache(); 302 g_browser_process->profile_manager()->GetProfileInfoCache();
288 Profile* profile = tab_contents_->profile()->GetOriginalProfile(); 303 Profile* profile = tab_contents_->profile()->GetOriginalProfile();
289 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 304 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
290 if (index == std::string::npos) 305 if (index == std::string::npos)
291 return string16(); 306 return string16();
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 if (!default_icon_) { 1075 if (!default_icon_) {
1061 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1076 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1062 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); 1077 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN);
1063 } 1078 }
1064 process_handle_ = extension_host_->render_process_host()->GetHandle(); 1079 process_handle_ = extension_host_->render_process_host()->GetHandle();
1065 pid_ = base::GetProcId(process_handle_); 1080 pid_ = base::GetProcId(process_handle_);
1066 string16 extension_name = UTF8ToUTF16(GetExtension()->name()); 1081 string16 extension_name = UTF8ToUTF16(GetExtension()->name());
1067 DCHECK(!extension_name.empty()); 1082 DCHECK(!extension_name.empty());
1068 1083
1069 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, 1084 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true,
1070 extension_host_->profile()->IsOffTheRecord(), false); 1085 extension_host_->profile()->IsOffTheRecord(), false, false);
1071 title_ = l10n_util::GetStringFUTF16(message_id, extension_name); 1086 title_ = l10n_util::GetStringFUTF16(message_id, extension_name);
1072 } 1087 }
1073 1088
1074 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { 1089 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() {
1075 } 1090 }
1076 1091
1077 string16 TaskManagerExtensionProcessResource::GetTitle() const { 1092 string16 TaskManagerExtensionProcessResource::GetTitle() const {
1078 return title_; 1093 return title_;
1079 } 1094 }
1080 1095
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 1406
1392 return &resource_; 1407 return &resource_;
1393 } 1408 }
1394 1409
1395 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { 1410 void TaskManagerBrowserProcessResourceProvider::StartUpdating() {
1396 task_manager_->AddResource(&resource_); 1411 task_manager_->AddResource(&resource_);
1397 } 1412 }
1398 1413
1399 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { 1414 void TaskManagerBrowserProcessResourceProvider::StopUpdating() {
1400 } 1415 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698