| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_resource_providers.h" | 5 #include "chrome/browser/task_manager_resource_providers.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <atlbase.h> | 10 #include <atlbase.h> |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( | 486 TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( |
| 487 ExtensionHost* extension_host) | 487 ExtensionHost* extension_host) |
| 488 : extension_host_(extension_host) { | 488 : extension_host_(extension_host) { |
| 489 if (!default_icon_) { | 489 if (!default_icon_) { |
| 490 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 490 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 491 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); | 491 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); |
| 492 } | 492 } |
| 493 base::Process process(extension_host_->render_process_host()->process()); | 493 base::Process process(extension_host_->render_process_host()->process()); |
| 494 process_handle_ = process.handle(); | 494 process_handle_ = process.handle(); |
| 495 pid_ = process.pid(); | 495 pid_ = process.pid(); |
| 496 std::wstring extension_name(UTF8ToWide(extension()->name())); | 496 std::wstring extension_name(UTF8ToWide(GetExtension()->name())); |
| 497 DCHECK(!extension_name.empty()); | 497 DCHECK(!extension_name.empty()); |
| 498 // Since the extension_name will be concatenated with a prefix, we need | 498 // Since the extension_name will be concatenated with a prefix, we need |
| 499 // to explicitly set the extension_name to be LTR format if there is no | 499 // to explicitly set the extension_name to be LTR format if there is no |
| 500 // strong RTL charater in it. Otherwise, if the prefix is an RTL word, | 500 // strong RTL charater in it. Otherwise, if the prefix is an RTL word, |
| 501 // the concatenated result might be wrong. For extension named | 501 // the concatenated result might be wrong. For extension named |
| 502 // "Great Extension!" the concatenated result would be something like | 502 // "Great Extension!" the concatenated result would be something like |
| 503 // "!Great Extension :NOISNETXE", in which capital letters "NOISNETXE" | 503 // "!Great Extension :NOISNETXE", in which capital letters "NOISNETXE" |
| 504 // stand for the Hebrew word for "extension". | 504 // stand for the Hebrew word for "extension". |
| 505 l10n_util::AdjustStringForLocaleDirection(extension_name, &extension_name); | 505 l10n_util::AdjustStringForLocaleDirection(extension_name, &extension_name); |
| 506 title_ = l10n_util::GetStringF(IDS_TASK_MANAGER_EXTENSION_PREFIX, | 506 title_ = l10n_util::GetStringF(IDS_TASK_MANAGER_EXTENSION_PREFIX, |
| 507 extension_name); | 507 extension_name); |
| 508 } | 508 } |
| 509 | 509 |
| 510 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { | 510 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { |
| 511 } | 511 } |
| 512 | 512 |
| 513 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { | 513 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { |
| 514 return title_; | 514 return title_; |
| 515 } | 515 } |
| 516 | 516 |
| 517 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { | 517 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { |
| 518 return *default_icon_; | 518 return *default_icon_; |
| 519 } | 519 } |
| 520 | 520 |
| 521 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { | 521 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { |
| 522 return process_handle_; | 522 return process_handle_; |
| 523 } | 523 } |
| 524 | 524 |
| 525 Extension* TaskManagerExtensionProcessResource::extension() const { | 525 const Extension* TaskManagerExtensionProcessResource::GetExtension() const { |
| 526 return extension_host_->extension(); | 526 return extension_host_->extension(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 //////////////////////////////////////////////////////////////////////////////// | 529 //////////////////////////////////////////////////////////////////////////////// |
| 530 // TaskManagerExtensionProcessResourceProvider class | 530 // TaskManagerExtensionProcessResourceProvider class |
| 531 //////////////////////////////////////////////////////////////////////////////// | 531 //////////////////////////////////////////////////////////////////////////////// |
| 532 | 532 |
| 533 TaskManagerExtensionProcessResourceProvider:: | 533 TaskManagerExtensionProcessResourceProvider:: |
| 534 TaskManagerExtensionProcessResourceProvider(TaskManager* task_manager) | 534 TaskManagerExtensionProcessResourceProvider(TaskManager* task_manager) |
| 535 : task_manager_(task_manager), | 535 : task_manager_(task_manager), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 565 ExtensionProcessManager::const_iterator jt; | 565 ExtensionProcessManager::const_iterator jt; |
| 566 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) | 566 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) |
| 567 AddToTaskManager(*jt); | 567 AddToTaskManager(*jt); |
| 568 } | 568 } |
| 569 | 569 |
| 570 // Register for notifications about extension process changes. | 570 // Register for notifications about extension process changes. |
| 571 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CREATED, | 571 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CREATED, |
| 572 NotificationService::AllSources()); | 572 NotificationService::AllSources()); |
| 573 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, | 573 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, |
| 574 NotificationService::AllSources()); | 574 NotificationService::AllSources()); |
| 575 registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED, |
| 576 NotificationService::AllSources()); |
| 575 } | 577 } |
| 576 | 578 |
| 577 void TaskManagerExtensionProcessResourceProvider::StopUpdating() { | 579 void TaskManagerExtensionProcessResourceProvider::StopUpdating() { |
| 578 DCHECK(updating_); | 580 DCHECK(updating_); |
| 579 updating_ = false; | 581 updating_ = false; |
| 580 | 582 |
| 581 // Unregister for notifications about extension process changes. | 583 // Unregister for notifications about extension process changes. |
| 582 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CREATED, | 584 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CREATED, |
| 583 NotificationService::AllSources()); | 585 NotificationService::AllSources()); |
| 584 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CRASHED, | 586 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CRASHED, |
| 585 NotificationService::AllSources()); | 587 NotificationService::AllSources()); |
| 588 registrar_.Remove(this, NotificationType::EXTENSION_HOST_DESTROYED, |
| 589 NotificationService::AllSources()); |
| 586 | 590 |
| 587 // Delete all the resources. | 591 // Delete all the resources. |
| 588 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); | 592 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); |
| 589 | 593 |
| 590 resources_.clear(); | 594 resources_.clear(); |
| 591 pid_to_resources_.clear(); | 595 pid_to_resources_.clear(); |
| 592 } | 596 } |
| 593 | 597 |
| 594 void TaskManagerExtensionProcessResourceProvider::Observe( | 598 void TaskManagerExtensionProcessResourceProvider::Observe( |
| 595 NotificationType type, | 599 NotificationType type, |
| 596 const NotificationSource& source, | 600 const NotificationSource& source, |
| 597 const NotificationDetails& details) { | 601 const NotificationDetails& details) { |
| 598 switch (type.value) { | 602 switch (type.value) { |
| 599 case NotificationType::EXTENSION_PROCESS_CREATED: | 603 case NotificationType::EXTENSION_PROCESS_CREATED: |
| 600 AddToTaskManager(Details<ExtensionHost>(details).ptr()); | 604 AddToTaskManager(Details<ExtensionHost>(details).ptr()); |
| 601 break; | 605 break; |
| 602 case NotificationType::EXTENSION_PROCESS_CRASHED: | 606 case NotificationType::EXTENSION_PROCESS_CRASHED: |
| 607 case NotificationType::EXTENSION_HOST_DESTROYED: |
| 603 RemoveFromTaskManager(Details<ExtensionHost>(details).ptr()); | 608 RemoveFromTaskManager(Details<ExtensionHost>(details).ptr()); |
| 604 break; | 609 break; |
| 605 default: | 610 default: |
| 606 NOTREACHED() << "Unexpected notification."; | 611 NOTREACHED() << "Unexpected notification."; |
| 607 return; | 612 return; |
| 608 } | 613 } |
| 609 } | 614 } |
| 610 | 615 |
| 611 void TaskManagerExtensionProcessResourceProvider::AddToTaskManager( | 616 void TaskManagerExtensionProcessResourceProvider::AddToTaskManager( |
| 612 ExtensionHost* extension_host) { | 617 ExtensionHost* extension_host) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 | 739 |
| 735 return &resource_; | 740 return &resource_; |
| 736 } | 741 } |
| 737 | 742 |
| 738 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 743 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 739 task_manager_->AddResource(&resource_); | 744 task_manager_->AddResource(&resource_); |
| 740 } | 745 } |
| 741 | 746 |
| 742 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 747 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 743 } | 748 } |
| OLD | NEW |