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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 UTF8ToUTF16(background_contents_->GetURL().spec()))); | 375 UTF8ToUTF16(background_contents_->GetURL().spec()))); |
376 } | 376 } |
377 return l10n_util::GetStringF(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); | 377 return l10n_util::GetStringF(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 SkBitmap TaskManagerBackgroundContentsResource::GetIcon() const { | 381 SkBitmap TaskManagerBackgroundContentsResource::GetIcon() const { |
382 return *default_icon_; | 382 return *default_icon_; |
383 } | 383 } |
384 | 384 |
| 385 bool TaskManagerBackgroundContentsResource::IsBackground() const { |
| 386 return true; |
| 387 } |
| 388 |
385 //////////////////////////////////////////////////////////////////////////////// | 389 //////////////////////////////////////////////////////////////////////////////// |
386 // TaskManagerBackgroundContentsResourceProvider class | 390 // TaskManagerBackgroundContentsResourceProvider class |
387 //////////////////////////////////////////////////////////////////////////////// | 391 //////////////////////////////////////////////////////////////////////////////// |
388 | 392 |
389 TaskManagerBackgroundContentsResourceProvider:: | 393 TaskManagerBackgroundContentsResourceProvider:: |
390 TaskManagerBackgroundContentsResourceProvider(TaskManager* task_manager) | 394 TaskManagerBackgroundContentsResourceProvider(TaskManager* task_manager) |
391 : updating_(false), | 395 : updating_(false), |
392 task_manager_(task_manager) { | 396 task_manager_(task_manager) { |
393 } | 397 } |
394 | 398 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 std::string application_id = UTF16ToUTF8( | 547 std::string application_id = UTF16ToUTF8( |
544 Details<BackgroundContentsOpenedDetails>(details)->application_id); | 548 Details<BackgroundContentsOpenedDetails>(details)->application_id); |
545 const Extension* extension = | 549 const Extension* extension = |
546 service->GetExtensionById(application_id, false); | 550 service->GetExtensionById(application_id, false); |
547 // Extension can be NULL when running unit tests. | 551 // Extension can be NULL when running unit tests. |
548 if (extension) | 552 if (extension) |
549 application_name = UTF8ToWide(extension->name()); | 553 application_name = UTF8ToWide(extension->name()); |
550 } | 554 } |
551 Add(Details<BackgroundContentsOpenedDetails>(details)->contents, | 555 Add(Details<BackgroundContentsOpenedDetails>(details)->contents, |
552 application_name); | 556 application_name); |
| 557 // Opening a new BackgroundContents needs to force the display to refresh |
| 558 // (applications may now be considered "background" that weren't before). |
| 559 task_manager_->ModelChanged(); |
553 break; | 560 break; |
554 } | 561 } |
555 case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: { | 562 case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: { |
556 BackgroundContents* contents = Details<BackgroundContents>(details).ptr(); | 563 BackgroundContents* contents = Details<BackgroundContents>(details).ptr(); |
557 // Should never get a NAVIGATED before OPENED. | 564 // Should never get a NAVIGATED before OPENED. |
558 DCHECK(resources_.find(contents) != resources_.end()); | 565 DCHECK(resources_.find(contents) != resources_.end()); |
559 // Preserve the application name. | 566 // Preserve the application name. |
560 std::wstring application_name( | 567 std::wstring application_name( |
561 resources_.find(contents)->second->application_name()); | 568 resources_.find(contents)->second->application_name()); |
562 Remove(contents); | 569 Remove(contents); |
563 Add(contents, application_name); | 570 Add(contents, application_name); |
564 break; | 571 break; |
565 } | 572 } |
566 case NotificationType::BACKGROUND_CONTENTS_DELETED: | 573 case NotificationType::BACKGROUND_CONTENTS_DELETED: |
567 Remove(Details<BackgroundContents>(details).ptr()); | 574 Remove(Details<BackgroundContents>(details).ptr()); |
| 575 // Closing a BackgroundContents needs to force the display to refresh |
| 576 // (applications may now be considered "foreground" that weren't before). |
| 577 task_manager_->ModelChanged(); |
568 break; | 578 break; |
569 default: | 579 default: |
570 NOTREACHED() << "Unexpected notification."; | 580 NOTREACHED() << "Unexpected notification."; |
571 return; | 581 return; |
572 } | 582 } |
573 } | 583 } |
574 | 584 |
575 //////////////////////////////////////////////////////////////////////////////// | 585 //////////////////////////////////////////////////////////////////////////////// |
576 // TaskManagerChildProcessResource class | 586 // TaskManagerChildProcessResource class |
577 //////////////////////////////////////////////////////////////////////////////// | 587 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 } | 850 } |
841 | 851 |
842 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { | 852 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { |
843 return process_handle_; | 853 return process_handle_; |
844 } | 854 } |
845 | 855 |
846 const Extension* TaskManagerExtensionProcessResource::GetExtension() const { | 856 const Extension* TaskManagerExtensionProcessResource::GetExtension() const { |
847 return extension_host_->extension(); | 857 return extension_host_->extension(); |
848 } | 858 } |
849 | 859 |
| 860 bool TaskManagerExtensionProcessResource::IsBackground() const { |
| 861 return extension_host_->GetRenderViewType() == |
| 862 ViewType::EXTENSION_BACKGROUND_PAGE; |
| 863 } |
| 864 |
850 //////////////////////////////////////////////////////////////////////////////// | 865 //////////////////////////////////////////////////////////////////////////////// |
851 // TaskManagerExtensionProcessResourceProvider class | 866 // TaskManagerExtensionProcessResourceProvider class |
852 //////////////////////////////////////////////////////////////////////////////// | 867 //////////////////////////////////////////////////////////////////////////////// |
853 | 868 |
854 TaskManagerExtensionProcessResourceProvider:: | 869 TaskManagerExtensionProcessResourceProvider:: |
855 TaskManagerExtensionProcessResourceProvider(TaskManager* task_manager) | 870 TaskManagerExtensionProcessResourceProvider(TaskManager* task_manager) |
856 : task_manager_(task_manager), | 871 : task_manager_(task_manager), |
857 updating_(false) { | 872 updating_(false) { |
858 } | 873 } |
859 | 874 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 | 1228 |
1214 return &resource_; | 1229 return &resource_; |
1215 } | 1230 } |
1216 | 1231 |
1217 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1232 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1218 task_manager_->AddResource(&resource_); | 1233 task_manager_->AddResource(&resource_); |
1219 } | 1234 } |
1220 | 1235 |
1221 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1236 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1222 } | 1237 } |
OLD | NEW |