| 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" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/thread.h" | 17 #include "base/thread.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
| 20 #include "chrome/browser/background_contents_service.h" | 20 #include "chrome/browser/background_contents_service.h" |
| 21 #include "chrome/browser/browser_child_process_host.h" | 21 #include "chrome/browser/browser_child_process_host.h" |
| 22 #include "chrome/browser/browser_list.h" | 22 #include "chrome/browser/browser_list.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browser_thread.h" | 24 #include "chrome/browser/browser_thread.h" |
| 25 #include "chrome/browser/extensions/extension_host.h" | 25 #include "chrome/browser/extensions/extension_host.h" |
| 26 #include "chrome/browser/extensions/extension_process_manager.h" | 26 #include "chrome/browser/extensions/extension_process_manager.h" |
| 27 #include "chrome/browser/extensions/extensions_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 28 #include "chrome/browser/notifications/balloon_collection.h" | 28 #include "chrome/browser/notifications/balloon_collection.h" |
| 29 #include "chrome/browser/notifications/balloon_host.h" | 29 #include "chrome/browser/notifications/balloon_host.h" |
| 30 #include "chrome/browser/notifications/notification_ui_manager.h" | 30 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 31 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 32 #include "chrome/browser/renderer_host/render_message_filter.h" | 32 #include "chrome/browser/renderer_host/render_message_filter.h" |
| 33 #include "chrome/browser/renderer_host/render_process_host.h" | 33 #include "chrome/browser/renderer_host/render_process_host.h" |
| 34 #include "chrome/browser/renderer_host/render_view_host.h" | 34 #include "chrome/browser/renderer_host/render_view_host.h" |
| 35 #include "chrome/browser/tab_contents/background_contents.h" | 35 #include "chrome/browser/tab_contents/background_contents.h" |
| 36 #include "chrome/browser/tab_contents/tab_contents.h" | 36 #include "chrome/browser/tab_contents/tab_contents.h" |
| 37 #include "chrome/browser/tab_contents/tab_util.h" | 37 #include "chrome/browser/tab_contents/tab_util.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // be LTR format if there is no strong RTL charater in it. Otherwise, if | 167 // be LTR format if there is no strong RTL charater in it. Otherwise, if |
| 168 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result | 168 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
| 169 // might be wrong. For example, http://mail.yahoo.com, whose title is | 169 // might be wrong. For example, http://mail.yahoo.com, whose title is |
| 170 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly | 170 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
| 171 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best | 171 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
| 172 // web-based Email :BAT", in which the capital letters "BAT" stands for | 172 // web-based Email :BAT", in which the capital letters "BAT" stands for |
| 173 // the Hebrew word for "tab". | 173 // the Hebrew word for "tab". |
| 174 base::i18n::AdjustStringForLocaleDirection(&tab_title); | 174 base::i18n::AdjustStringForLocaleDirection(&tab_title); |
| 175 } | 175 } |
| 176 | 176 |
| 177 ExtensionsService* extensions_service = | 177 ExtensionService* extensions_service = |
| 178 tab_contents_->profile()->GetExtensionsService(); | 178 tab_contents_->profile()->GetExtensionService(); |
| 179 int message_id = GetMessagePrefixID( | 179 int message_id = GetMessagePrefixID( |
| 180 extensions_service->IsInstalledApp(tab_contents_->GetURL()), | 180 extensions_service->IsInstalledApp(tab_contents_->GetURL()), |
| 181 tab_contents_->HostsExtension(), | 181 tab_contents_->HostsExtension(), |
| 182 tab_contents_->profile()->IsOffTheRecord()); | 182 tab_contents_->profile()->IsOffTheRecord()); |
| 183 return l10n_util::GetStringF(message_id, tab_title); | 183 return l10n_util::GetStringF(message_id, tab_title); |
| 184 } | 184 } |
| 185 | 185 |
| 186 SkBitmap TaskManagerTabContentsResource::GetIcon() const { | 186 SkBitmap TaskManagerTabContentsResource::GetIcon() const { |
| 187 return tab_contents_->GetFavIcon(); | 187 return tab_contents_->GetFavIcon(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TabContents* TaskManagerTabContentsResource::GetTabContents() const { | 190 TabContents* TaskManagerTabContentsResource::GetTabContents() const { |
| 191 return static_cast<TabContents*>(tab_contents_); | 191 return static_cast<TabContents*>(tab_contents_); |
| 192 } | 192 } |
| 193 | 193 |
| 194 const Extension* TaskManagerTabContentsResource::GetExtension() const { | 194 const Extension* TaskManagerTabContentsResource::GetExtension() const { |
| 195 if (tab_contents_->HostsExtension()) { | 195 if (tab_contents_->HostsExtension()) { |
| 196 ExtensionsService* extensions_service = | 196 ExtensionService* extensions_service = |
| 197 tab_contents_->profile()->GetExtensionsService(); | 197 tab_contents_->profile()->GetExtensionService(); |
| 198 return extensions_service->GetExtensionByURL(tab_contents_->GetURL()); | 198 return extensions_service->GetExtensionByURL(tab_contents_->GetURL()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 return NULL; | 201 return NULL; |
| 202 } | 202 } |
| 203 | 203 |
| 204 //////////////////////////////////////////////////////////////////////////////// | 204 //////////////////////////////////////////////////////////////////////////////// |
| 205 // TaskManagerTabContentsResourceProvider class | 205 // TaskManagerTabContentsResourceProvider class |
| 206 //////////////////////////////////////////////////////////////////////////////// | 206 //////////////////////////////////////////////////////////////////////////////// |
| 207 | 207 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 void TaskManagerBackgroundContentsResourceProvider::StartUpdating() { | 467 void TaskManagerBackgroundContentsResourceProvider::StartUpdating() { |
| 468 DCHECK(!updating_); | 468 DCHECK(!updating_); |
| 469 updating_ = true; | 469 updating_ = true; |
| 470 | 470 |
| 471 // Add all the existing BackgroundContents from every profile. | 471 // Add all the existing BackgroundContents from every profile. |
| 472 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 472 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 473 for (ProfileManager::const_iterator it = profile_manager->begin(); | 473 for (ProfileManager::const_iterator it = profile_manager->begin(); |
| 474 it != profile_manager->end(); ++it) { | 474 it != profile_manager->end(); ++it) { |
| 475 BackgroundContentsService* background_contents_service = | 475 BackgroundContentsService* background_contents_service = |
| 476 (*it)->GetBackgroundContentsService(); | 476 (*it)->GetBackgroundContentsService(); |
| 477 ExtensionsService* extensions_service = (*it)->GetExtensionsService(); | 477 ExtensionService* extensions_service = (*it)->GetExtensionService(); |
| 478 std::vector<BackgroundContents*> contents = | 478 std::vector<BackgroundContents*> contents = |
| 479 background_contents_service->GetBackgroundContents(); | 479 background_contents_service->GetBackgroundContents(); |
| 480 for (std::vector<BackgroundContents*>::iterator iterator = contents.begin(); | 480 for (std::vector<BackgroundContents*>::iterator iterator = contents.begin(); |
| 481 iterator != contents.end(); ++iterator) { | 481 iterator != contents.end(); ++iterator) { |
| 482 std::wstring application_name; | 482 std::wstring application_name; |
| 483 // Lookup the name from the parent extension. | 483 // Lookup the name from the parent extension. |
| 484 if (extensions_service) { | 484 if (extensions_service) { |
| 485 const string16& application_id = | 485 const string16& application_id = |
| 486 background_contents_service->GetParentApplicationId(*iterator); | 486 background_contents_service->GetParentApplicationId(*iterator); |
| 487 const Extension* extension = extensions_service->GetExtensionById( | 487 const Extension* extension = extensions_service->GetExtensionById( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 const NotificationSource& source, | 567 const NotificationSource& source, |
| 568 const NotificationDetails& details) { | 568 const NotificationDetails& details) { |
| 569 switch (type.value) { | 569 switch (type.value) { |
| 570 case NotificationType::BACKGROUND_CONTENTS_OPENED: { | 570 case NotificationType::BACKGROUND_CONTENTS_OPENED: { |
| 571 // Get the name from the parent application. If no parent application is | 571 // Get the name from the parent application. If no parent application is |
| 572 // found, just pass an empty string - BackgroundContentsResource::GetTitle | 572 // found, just pass an empty string - BackgroundContentsResource::GetTitle |
| 573 // will display the URL instead in this case. This should never happen | 573 // will display the URL instead in this case. This should never happen |
| 574 // except in rare cases when an extension is being unloaded or chrome is | 574 // except in rare cases when an extension is being unloaded or chrome is |
| 575 // exiting while the task manager is displayed. | 575 // exiting while the task manager is displayed. |
| 576 std::wstring application_name; | 576 std::wstring application_name; |
| 577 ExtensionsService* service = | 577 ExtensionService* service = |
| 578 Source<Profile>(source)->GetExtensionsService(); | 578 Source<Profile>(source)->GetExtensionService(); |
| 579 if (service) { | 579 if (service) { |
| 580 std::string application_id = UTF16ToUTF8( | 580 std::string application_id = UTF16ToUTF8( |
| 581 Details<BackgroundContentsOpenedDetails>(details)->application_id); | 581 Details<BackgroundContentsOpenedDetails>(details)->application_id); |
| 582 const Extension* extension = | 582 const Extension* extension = |
| 583 service->GetExtensionById(application_id, false); | 583 service->GetExtensionById(application_id, false); |
| 584 // Extension can be NULL when running unit tests. | 584 // Extension can be NULL when running unit tests. |
| 585 if (extension) | 585 if (extension) |
| 586 application_name = UTF8ToWide(extension->name()); | 586 application_name = UTF8ToWide(extension->name()); |
| 587 } | 587 } |
| 588 Add(Details<BackgroundContentsOpenedDetails>(details)->contents, | 588 Add(Details<BackgroundContentsOpenedDetails>(details)->contents, |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 | 1263 |
| 1264 return &resource_; | 1264 return &resource_; |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1267 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 1268 task_manager_->AddResource(&resource_); | 1268 task_manager_->AddResource(&resource_); |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1271 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 1272 } | 1272 } |
| OLD | NEW |