| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
| 44 | 44 |
| 45 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
| 46 #include "skia/ext/skia_utils_mac.h" | 46 #include "skia/ext/skia_utils_mac.h" |
| 47 #endif | 47 #endif |
| 48 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 49 #include "chrome/browser/app_icon_win.h" | 49 #include "chrome/browser/app_icon_win.h" |
| 50 #include "gfx/icon_util.h" | 50 #include "gfx/icon_util.h" |
| 51 #endif // defined(OS_WIN) | 51 #endif // defined(OS_WIN) |
| 52 | 52 |
| 53 namespace { |
| 54 |
| 55 // Returns the appropriate message prefix ID for tabs and extensions, |
| 56 // reflecting whether they are apps or in incognito mode. |
| 57 int GetMessagePrefixID(bool is_app, bool is_extension, |
| 58 bool is_off_the_record) { |
| 59 return is_app ? |
| 60 (is_off_the_record ? |
| 61 IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX : |
| 62 IDS_TASK_MANAGER_APP_PREFIX) : |
| 63 (is_extension ? |
| 64 (is_off_the_record ? |
| 65 IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX : |
| 66 IDS_TASK_MANAGER_EXTENSION_PREFIX) : |
| 67 IDS_TASK_MANAGER_TAB_PREFIX); |
| 68 } |
| 69 |
| 70 } // namespace |
| 53 | 71 |
| 54 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
| 55 // TaskManagerRendererResource class | 73 // TaskManagerRendererResource class |
| 56 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
| 57 TaskManagerRendererResource::TaskManagerRendererResource( | 75 TaskManagerRendererResource::TaskManagerRendererResource( |
| 58 base::ProcessHandle process, RenderViewHost* render_view_host) | 76 base::ProcessHandle process, RenderViewHost* render_view_host) |
| 59 : process_(process), | 77 : process_(process), |
| 60 render_view_host_(render_view_host), | 78 render_view_host_(render_view_host), |
| 61 pending_stats_update_(false), | 79 pending_stats_update_(false), |
| 62 v8_memory_allocated_(0), | 80 v8_memory_allocated_(0), |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // be LTR format if there is no strong RTL charater in it. Otherwise, if | 163 // be LTR format if there is no strong RTL charater in it. Otherwise, if |
| 146 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result | 164 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
| 147 // might be wrong. For example, http://mail.yahoo.com, whose title is | 165 // might be wrong. For example, http://mail.yahoo.com, whose title is |
| 148 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly | 166 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
| 149 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best | 167 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
| 150 // web-based Email :BAT", in which the capital letters "BAT" stands for | 168 // web-based Email :BAT", in which the capital letters "BAT" stands for |
| 151 // the Hebrew word for "tab". | 169 // the Hebrew word for "tab". |
| 152 base::i18n::AdjustStringForLocaleDirection(&tab_title); | 170 base::i18n::AdjustStringForLocaleDirection(&tab_title); |
| 153 } | 171 } |
| 154 | 172 |
| 155 return l10n_util::GetStringF(IDS_TASK_MANAGER_TAB_PREFIX, tab_title); | 173 int message_id = GetMessagePrefixID(tab_contents_->IsInstalledApp(), |
| 174 tab_contents_->HostsExtension(), |
| 175 tab_contents_->profile()->IsOffTheRecord()); |
| 176 return l10n_util::GetStringF(message_id, tab_title); |
| 156 } | 177 } |
| 157 | 178 |
| 158 | |
| 159 SkBitmap TaskManagerTabContentsResource::GetIcon() const { | 179 SkBitmap TaskManagerTabContentsResource::GetIcon() const { |
| 160 return tab_contents_->GetFavIcon(); | 180 return tab_contents_->GetFavIcon(); |
| 161 } | 181 } |
| 162 | 182 |
| 163 TabContents* TaskManagerTabContentsResource::GetTabContents() const { | 183 TabContents* TaskManagerTabContentsResource::GetTabContents() const { |
| 164 return static_cast<TabContents*>(tab_contents_); | 184 return static_cast<TabContents*>(tab_contents_); |
| 165 } | 185 } |
| 166 | 186 |
| 167 //////////////////////////////////////////////////////////////////////////////// | 187 //////////////////////////////////////////////////////////////////////////////// |
| 168 // TaskManagerTabContentsResourceProvider class | 188 // TaskManagerTabContentsResourceProvider class |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 new TaskManagerTabContentsResource(tab_contents); | 280 new TaskManagerTabContentsResource(tab_contents); |
| 261 resources_[tab_contents] = resource; | 281 resources_[tab_contents] = resource; |
| 262 task_manager_->AddResource(resource); | 282 task_manager_->AddResource(resource); |
| 263 } | 283 } |
| 264 | 284 |
| 265 void TaskManagerTabContentsResourceProvider::Add(TabContents* tab_contents) { | 285 void TaskManagerTabContentsResourceProvider::Add(TabContents* tab_contents) { |
| 266 if (!updating_) | 286 if (!updating_) |
| 267 return; | 287 return; |
| 268 | 288 |
| 269 // Don't add dead tabs or tabs that haven't yet connected. | 289 // Don't add dead tabs or tabs that haven't yet connected. |
| 270 // Also ignore tabs which display extension content. We collapse | |
| 271 // all of these into one extension row. | |
| 272 if (!tab_contents->GetRenderProcessHost()->GetHandle() || | 290 if (!tab_contents->GetRenderProcessHost()->GetHandle() || |
| 273 !tab_contents->notify_disconnection() || | 291 !tab_contents->notify_disconnection()) { |
| 274 tab_contents->HostsExtension()) { | |
| 275 return; | 292 return; |
| 276 } | 293 } |
| 277 | 294 |
| 278 std::map<TabContents*, TaskManagerTabContentsResource*>::const_iterator | 295 std::map<TabContents*, TaskManagerTabContentsResource*>::const_iterator |
| 279 iter = resources_.find(tab_contents); | 296 iter = resources_.find(tab_contents); |
| 280 if (iter != resources_.end()) { | 297 if (iter != resources_.end()) { |
| 281 // The case may happen that we have added a TabContents as part of the | 298 // The case may happen that we have added a TabContents as part of the |
| 282 // iteration performed during StartUpdating() call but the notification that | 299 // iteration performed during StartUpdating() call but the notification that |
| 283 // it has connected was not fired yet. So when the notification happens, we | 300 // it has connected was not fired yet. So when the notification happens, we |
| 284 // already know about this tab and just ignore it. | 301 // already know about this tab and just ignore it. |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 : extension_host_(extension_host) { | 836 : extension_host_(extension_host) { |
| 820 if (!default_icon_) { | 837 if (!default_icon_) { |
| 821 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 838 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 822 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); | 839 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); |
| 823 } | 840 } |
| 824 process_handle_ = extension_host_->render_process_host()->GetHandle(); | 841 process_handle_ = extension_host_->render_process_host()->GetHandle(); |
| 825 pid_ = base::GetProcId(process_handle_); | 842 pid_ = base::GetProcId(process_handle_); |
| 826 std::wstring extension_name(UTF8ToWide(GetExtension()->name())); | 843 std::wstring extension_name(UTF8ToWide(GetExtension()->name())); |
| 827 DCHECK(!extension_name.empty()); | 844 DCHECK(!extension_name.empty()); |
| 828 | 845 |
| 829 int message_id = | 846 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, |
| 830 GetExtension()->is_app() ? | 847 extension_host_->profile()->IsOffTheRecord()); |
| 831 (extension_host_->profile()->IsOffTheRecord() ? | |
| 832 IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX : | |
| 833 IDS_TASK_MANAGER_APP_PREFIX) : | |
| 834 (extension_host_->profile()->IsOffTheRecord() ? | |
| 835 IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX : | |
| 836 IDS_TASK_MANAGER_EXTENSION_PREFIX); | |
| 837 title_ = l10n_util::GetStringF(message_id, extension_name); | 848 title_ = l10n_util::GetStringF(message_id, extension_name); |
| 838 } | 849 } |
| 839 | 850 |
| 840 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { | 851 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { |
| 841 } | 852 } |
| 842 | 853 |
| 843 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { | 854 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { |
| 844 return title_; | 855 return title_; |
| 845 } | 856 } |
| 846 | 857 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 | 1238 |
| 1228 return &resource_; | 1239 return &resource_; |
| 1229 } | 1240 } |
| 1230 | 1241 |
| 1231 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1242 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 1232 task_manager_->AddResource(&resource_); | 1243 task_manager_->AddResource(&resource_); |
| 1233 } | 1244 } |
| 1234 | 1245 |
| 1235 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1246 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 1236 } | 1247 } |
| OLD | NEW |