OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // performed. | 560 // performed. |
561 return NULL; | 561 return NULL; |
562 | 562 |
563 return res_iter->second; | 563 return res_iter->second; |
564 } | 564 } |
565 | 565 |
566 void TaskManagerBackgroundContentsResourceProvider::StartUpdating() { | 566 void TaskManagerBackgroundContentsResourceProvider::StartUpdating() { |
567 DCHECK(!updating_); | 567 DCHECK(!updating_); |
568 updating_ = true; | 568 updating_ = true; |
569 | 569 |
570 // Add all the existing BackgroundContents from every profile. | 570 // Add all the existing BackgroundContents from every profile, including |
| 571 // incognito profiles. |
571 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 572 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
572 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 573 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
| 574 size_t num_default_profiles = profiles.size(); |
| 575 for (size_t i = 0; i < num_default_profiles; ++i) { |
| 576 if (profiles[i]->HasOffTheRecordProfile()) { |
| 577 profiles.push_back(profiles[i]->GetOffTheRecordProfile()); |
| 578 } |
| 579 } |
573 for (size_t i = 0; i < profiles.size(); ++i) { | 580 for (size_t i = 0; i < profiles.size(); ++i) { |
574 BackgroundContentsService* background_contents_service = | 581 BackgroundContentsService* background_contents_service = |
575 BackgroundContentsServiceFactory::GetForProfile(profiles[i]); | 582 BackgroundContentsServiceFactory::GetForProfile(profiles[i]); |
576 ExtensionService* extensions_service = profiles[i]->GetExtensionService(); | |
577 std::vector<BackgroundContents*> contents = | 583 std::vector<BackgroundContents*> contents = |
578 background_contents_service->GetBackgroundContents(); | 584 background_contents_service->GetBackgroundContents(); |
| 585 ExtensionService* extension_service = profiles[i]->GetExtensionService(); |
579 for (std::vector<BackgroundContents*>::iterator iterator = contents.begin(); | 586 for (std::vector<BackgroundContents*>::iterator iterator = contents.begin(); |
580 iterator != contents.end(); ++iterator) { | 587 iterator != contents.end(); ++iterator) { |
581 string16 application_name; | 588 string16 application_name; |
582 // Lookup the name from the parent extension. | 589 // Lookup the name from the parent extension. |
583 if (extensions_service) { | 590 if (extension_service) { |
584 const string16& application_id = | 591 const string16& application_id = |
585 background_contents_service->GetParentApplicationId(*iterator); | 592 background_contents_service->GetParentApplicationId(*iterator); |
586 const Extension* extension = extensions_service->GetExtensionById( | 593 const Extension* extension = extension_service->GetExtensionById( |
587 UTF16ToUTF8(application_id), false); | 594 UTF16ToUTF8(application_id), false); |
588 if (extension) | 595 if (extension) |
589 application_name = UTF8ToUTF16(extension->name()); | 596 application_name = UTF8ToUTF16(extension->name()); |
590 } | 597 } |
591 Add(*iterator, application_name); | 598 Add(*iterator, application_name); |
592 } | 599 } |
593 } | 600 } |
594 | 601 |
595 // Then we register for notifications to get new BackgroundContents. | 602 // Then we register for notifications to get new BackgroundContents. |
596 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, | 603 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 | 1361 |
1355 return &resource_; | 1362 return &resource_; |
1356 } | 1363 } |
1357 | 1364 |
1358 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1365 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1359 task_manager_->AddResource(&resource_); | 1366 task_manager_->AddResource(&resource_); |
1360 } | 1367 } |
1361 | 1368 |
1362 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1369 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1363 } | 1370 } |
OLD | NEW |