OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 ExtensionHost* host = *iter; | 305 ExtensionHost* host = *iter; |
306 if (host->extension_id() == extension_id) | 306 if (host->extension_id() == extension_id) |
307 return host; | 307 return host; |
308 } | 308 } |
309 return NULL; | 309 return NULL; |
310 } | 310 } |
311 | 311 |
312 std::set<RenderViewHost*> | 312 std::set<RenderViewHost*> |
313 ExtensionProcessManager::GetRenderViewHostsForExtension( | 313 ExtensionProcessManager::GetRenderViewHostsForExtension( |
314 const std::string& extension_id) { | 314 const std::string& extension_id) { |
315 std::set<RenderViewHost*> result; | 315 return DoGetRenderViewHostsForExtension( |
| 316 extension_id, false, chrome::VIEW_TYPE_INVALID); |
| 317 } |
316 | 318 |
317 SiteInstance* site_instance = GetSiteInstanceForURL( | 319 std::set<RenderViewHost*> |
318 Extension::GetBaseURLFromExtensionId(extension_id)); | 320 ExtensionProcessManager::GetRenderViewHostsWithTypeForExtension( |
319 if (!site_instance) | 321 const std::string& extension_id, chrome::ViewType view_type) { |
320 return result; | 322 return DoGetRenderViewHostsForExtension(extension_id, true, view_type); |
321 | |
322 // Gather up all the views for that site. | |
323 for (ExtensionRenderViews::iterator view = all_extension_views_.begin(); | |
324 view != all_extension_views_.end(); ++view) { | |
325 if (view->first->GetSiteInstance() == site_instance) | |
326 result.insert(view->first); | |
327 } | |
328 | |
329 return result; | |
330 } | 323 } |
331 | 324 |
332 const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost( | 325 const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost( |
333 content::RenderViewHost* render_view_host) { | 326 content::RenderViewHost* render_view_host) { |
334 if (!render_view_host->GetSiteInstance()) | 327 if (!render_view_host->GetSiteInstance()) |
335 return NULL; | 328 return NULL; |
336 | 329 |
337 ExtensionService* service = | 330 ExtensionService* service = |
338 ExtensionSystem::Get(GetProfile())->extension_service(); | 331 ExtensionSystem::Get(GetProfile())->extension_service(); |
339 return service->extensions()->GetByID(GetExtensionID(render_view_host)); | 332 return service->extensions()->GetByID(GetExtensionID(render_view_host)); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // Re-register all RenderViews for this extension. We do this to restore | 666 // Re-register all RenderViews for this extension. We do this to restore |
674 // the lazy_keepalive_count (if any) to properly reflect the number of open | 667 // the lazy_keepalive_count (if any) to properly reflect the number of open |
675 // views. | 668 // views. |
676 for (ExtensionRenderViews::const_iterator it = all_extension_views_.begin(); | 669 for (ExtensionRenderViews::const_iterator it = all_extension_views_.begin(); |
677 it != all_extension_views_.end(); ++it) { | 670 it != all_extension_views_.end(); ++it) { |
678 if (GetExtensionID(it->first) == extension_id) | 671 if (GetExtensionID(it->first) == extension_id) |
679 IncrementLazyKeepaliveCountForView(it->first); | 672 IncrementLazyKeepaliveCountForView(it->first); |
680 } | 673 } |
681 } | 674 } |
682 | 675 |
| 676 std::set<RenderViewHost*> |
| 677 ExtensionProcessManager::DoGetRenderViewHostsForExtension( |
| 678 const std::string& extension_id, |
| 679 bool restrict_to_type, |
| 680 chrome::ViewType view_type) { |
| 681 std::set<RenderViewHost*> result; |
| 682 |
| 683 SiteInstance* site_instance = GetSiteInstanceForURL( |
| 684 Extension::GetBaseURLFromExtensionId(extension_id)); |
| 685 if (!site_instance) |
| 686 return result; |
| 687 |
| 688 // Gather up all the views for that site. |
| 689 for (ExtensionRenderViews::iterator view = all_extension_views_.begin(); |
| 690 view != all_extension_views_.end(); ++view) { |
| 691 if (view->first->GetSiteInstance() == site_instance && |
| 692 (view->second == view_type || !restrict_to_type)) { |
| 693 result.insert(view->first); |
| 694 } |
| 695 } |
| 696 |
| 697 return result; |
| 698 } |
| 699 |
683 // | 700 // |
684 // IncognitoExtensionProcessManager | 701 // IncognitoExtensionProcessManager |
685 // | 702 // |
686 | 703 |
687 IncognitoExtensionProcessManager::IncognitoExtensionProcessManager( | 704 IncognitoExtensionProcessManager::IncognitoExtensionProcessManager( |
688 Profile* profile) | 705 Profile* profile) |
689 : ExtensionProcessManager(profile), | 706 : ExtensionProcessManager(profile), |
690 original_manager_(profile->GetOriginalProfile()-> | 707 original_manager_(profile->GetOriginalProfile()-> |
691 GetExtensionProcessManager()) { | 708 GetExtensionProcessManager()) { |
692 DCHECK(profile->IsOffTheRecord()); | 709 DCHECK(profile->IsOffTheRecord()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 if (service && service->is_ready()) | 792 if (service && service->is_ready()) |
776 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 793 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
777 } | 794 } |
778 break; | 795 break; |
779 } | 796 } |
780 default: | 797 default: |
781 ExtensionProcessManager::Observe(type, source, details); | 798 ExtensionProcessManager::Observe(type, source, details); |
782 break; | 799 break; |
783 } | 800 } |
784 } | 801 } |
OLD | NEW |