| Index: chrome/browser/task_manager/background_resource_provider.cc
|
| diff --git a/chrome/browser/task_manager/task_manager_background_resource_provider.cc b/chrome/browser/task_manager/background_resource_provider.cc
|
| similarity index 80%
|
| rename from chrome/browser/task_manager/task_manager_background_resource_provider.cc
|
| rename to chrome/browser/task_manager/background_resource_provider.cc
|
| index fa0ba46ec5fd856c6c28283949cf7c82f2cf3769..635ea7afce56a766feef631b7fdd9c8cee88f5c1 100644
|
| --- a/chrome/browser/task_manager/task_manager_background_resource_provider.cc
|
| +++ b/chrome/browser/task_manager/background_resource_provider.cc
|
| @@ -2,11 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/task_manager/task_manager_background_resource_provider.h"
|
| +#include "chrome/browser/task_manager/background_resource_provider.h"
|
|
|
| -#include <string>
|
| -
|
| -#include "base/basictypes.h"
|
| #include "base/i18n/rtl.h"
|
| #include "base/string16.h"
|
| #include "base/utf_string_conversions.h"
|
| @@ -17,6 +14,7 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/tab_contents/background_contents.h"
|
| +#include "chrome/browser/task_manager/renderer_resource.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -27,25 +25,51 @@
|
| #include "grit/theme_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/gfx/image/image_skia.h"
|
|
|
| using content::RenderProcessHost;
|
| using content::RenderViewHost;
|
| using content::WebContents;
|
| using extensions::Extension;
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// TaskManagerBackgroundContentsResource class
|
| -////////////////////////////////////////////////////////////////////////////////
|
| +namespace task_manager {
|
| +
|
| +class BackgroundContentsResource : public RendererResource {
|
| + public:
|
| + BackgroundContentsResource(
|
| + BackgroundContents* background_contents,
|
| + const string16& application_name);
|
| + virtual ~BackgroundContentsResource();
|
| +
|
| + // TaskManager::Resource methods:
|
| + virtual string16 GetTitle() const OVERRIDE;
|
| + virtual string16 GetProfileName() const OVERRIDE;
|
| + virtual gfx::ImageSkia GetIcon() const OVERRIDE;
|
| + virtual bool IsBackground() const OVERRIDE;
|
|
|
| -gfx::ImageSkia* TaskManagerBackgroundContentsResource::default_icon_ = NULL;
|
| + const string16& application_name() const { return application_name_; }
|
| + private:
|
| + BackgroundContents* background_contents_;
|
| +
|
| + string16 application_name_;
|
| +
|
| + // The icon painted for BackgroundContents.
|
| + // TODO(atwilson): Use the favicon when there's a way to get the favicon for
|
| + // BackgroundContents.
|
| + static gfx::ImageSkia* default_icon_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BackgroundContentsResource);
|
| +};
|
| +
|
| +gfx::ImageSkia* BackgroundContentsResource::default_icon_ = NULL;
|
|
|
| // TODO(atwilson): http://crbug.com/116893
|
| // HACK: if the process handle is invalid, we use the current process's handle.
|
| // This preserves old behavior but is incorrect, and should be fixed.
|
| -TaskManagerBackgroundContentsResource::TaskManagerBackgroundContentsResource(
|
| +BackgroundContentsResource::BackgroundContentsResource(
|
| BackgroundContents* background_contents,
|
| const string16& application_name)
|
| - : TaskManagerRendererResource(
|
| + : RendererResource(
|
| background_contents->web_contents()->GetRenderProcessHost()->
|
| GetHandle() ?
|
| background_contents->web_contents()->GetRenderProcessHost()->
|
| @@ -65,11 +89,10 @@ TaskManagerBackgroundContentsResource::TaskManagerBackgroundContentsResource(
|
| base::i18n::AdjustStringForLocaleDirection(&application_name_);
|
| }
|
|
|
| -TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource(
|
| - ) {
|
| +BackgroundContentsResource::~BackgroundContentsResource() {
|
| }
|
|
|
| -string16 TaskManagerBackgroundContentsResource::GetTitle() const {
|
| +string16 BackgroundContentsResource::GetTitle() const {
|
| string16 title = application_name_;
|
|
|
| if (title.empty()) {
|
| @@ -81,34 +104,32 @@ string16 TaskManagerBackgroundContentsResource::GetTitle() const {
|
| return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title);
|
| }
|
|
|
| -string16 TaskManagerBackgroundContentsResource::GetProfileName() const {
|
| +string16 BackgroundContentsResource::GetProfileName() const {
|
| return string16();
|
| }
|
|
|
| -gfx::ImageSkia TaskManagerBackgroundContentsResource::GetIcon() const {
|
| +gfx::ImageSkia BackgroundContentsResource::GetIcon() const {
|
| return *default_icon_;
|
| }
|
|
|
| -bool TaskManagerBackgroundContentsResource::IsBackground() const {
|
| +bool BackgroundContentsResource::IsBackground() const {
|
| return true;
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// TaskManagerBackgroundContentsResourceProvider class
|
| +// BackgroundContentsResourceProvider class
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -TaskManagerBackgroundContentsResourceProvider::
|
| - TaskManagerBackgroundContentsResourceProvider(TaskManager* task_manager)
|
| +BackgroundContentsResourceProvider::
|
| + BackgroundContentsResourceProvider(TaskManager* task_manager)
|
| : updating_(false),
|
| task_manager_(task_manager) {
|
| }
|
|
|
| -TaskManagerBackgroundContentsResourceProvider::
|
| - ~TaskManagerBackgroundContentsResourceProvider() {
|
| +BackgroundContentsResourceProvider::~BackgroundContentsResourceProvider() {
|
| }
|
|
|
| -TaskManager::Resource*
|
| -TaskManagerBackgroundContentsResourceProvider::GetResource(
|
| +TaskManager::Resource* BackgroundContentsResourceProvider::GetResource(
|
| int origin_pid,
|
| int render_process_host_id,
|
| int routing_id) {
|
| @@ -130,7 +151,7 @@ TaskManagerBackgroundContentsResourceProvider::GetResource(
|
| return NULL;
|
| }
|
|
|
| -void TaskManagerBackgroundContentsResourceProvider::StartUpdating() {
|
| +void BackgroundContentsResourceProvider::StartUpdating() {
|
| DCHECK(!updating_);
|
| updating_ = true;
|
|
|
| @@ -175,7 +196,7 @@ void TaskManagerBackgroundContentsResourceProvider::StartUpdating() {
|
| content::NotificationService::AllBrowserContextsAndSources());
|
| }
|
|
|
| -void TaskManagerBackgroundContentsResourceProvider::StopUpdating() {
|
| +void BackgroundContentsResourceProvider::StopUpdating() {
|
| DCHECK(updating_);
|
| updating_ = false;
|
|
|
| @@ -196,17 +217,17 @@ void TaskManagerBackgroundContentsResourceProvider::StopUpdating() {
|
| resources_.clear();
|
| }
|
|
|
| -void TaskManagerBackgroundContentsResourceProvider::AddToTaskManager(
|
| +void BackgroundContentsResourceProvider::AddToTaskManager(
|
| BackgroundContents* background_contents,
|
| const string16& application_name) {
|
| - TaskManagerBackgroundContentsResource* resource =
|
| - new TaskManagerBackgroundContentsResource(background_contents,
|
| + BackgroundContentsResource* resource =
|
| + new BackgroundContentsResource(background_contents,
|
| application_name);
|
| resources_[background_contents] = resource;
|
| task_manager_->AddResource(resource);
|
| }
|
|
|
| -void TaskManagerBackgroundContentsResourceProvider::Add(
|
| +void BackgroundContentsResourceProvider::Add(
|
| BackgroundContents* contents, const string16& application_name) {
|
| if (!updating_)
|
| return;
|
| @@ -220,15 +241,14 @@ void TaskManagerBackgroundContentsResourceProvider::Add(
|
| AddToTaskManager(contents, application_name);
|
| }
|
|
|
| -void TaskManagerBackgroundContentsResourceProvider::Remove(
|
| - BackgroundContents* contents) {
|
| +void BackgroundContentsResourceProvider::Remove(BackgroundContents* contents) {
|
| if (!updating_)
|
| return;
|
| Resources::iterator iter = resources_.find(contents);
|
| DCHECK(iter != resources_.end());
|
|
|
| // Remove the resource from the Task Manager.
|
| - TaskManagerBackgroundContentsResource* resource = iter->second;
|
| + BackgroundContentsResource* resource = iter->second;
|
| task_manager_->RemoveResource(resource);
|
| // And from the provider.
|
| resources_.erase(iter);
|
| @@ -236,7 +256,7 @@ void TaskManagerBackgroundContentsResourceProvider::Remove(
|
| delete resource;
|
| }
|
|
|
| -void TaskManagerBackgroundContentsResourceProvider::Observe(
|
| +void BackgroundContentsResourceProvider::Observe(
|
| int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| @@ -290,3 +310,5 @@ void TaskManagerBackgroundContentsResourceProvider::Observe(
|
| return;
|
| }
|
| }
|
| +
|
| +} // namespace task_manager
|
|
|