| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/process_manager.h" | 5 #include "extensions/browser/process_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // Keepalive count, balanced in RegisterRenderViewHost. | 336 // Keepalive count, balanced in RegisterRenderViewHost. |
| 337 if (view_type != VIEW_TYPE_INVALID && | 337 if (view_type != VIEW_TYPE_INVALID && |
| 338 view_type != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 338 view_type != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 339 const Extension* extension = GetExtensionForRenderViewHost( | 339 const Extension* extension = GetExtensionForRenderViewHost( |
| 340 render_view_host); | 340 render_view_host); |
| 341 if (extension) | 341 if (extension) |
| 342 DecrementLazyKeepaliveCount(extension); | 342 DecrementLazyKeepaliveCount(extension); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 void ProcessManager::RegisterRenderViewHost(RenderViewHost* render_view_host) { | 346 bool ProcessManager::RegisterRenderViewHost(RenderViewHost* render_view_host) { |
| 347 const Extension* extension = GetExtensionForRenderViewHost( | 347 const Extension* extension = GetExtensionForRenderViewHost( |
| 348 render_view_host); | 348 render_view_host); |
| 349 if (!extension) | 349 if (!extension) |
| 350 return; | 350 return false; |
| 351 | 351 |
| 352 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); | 352 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); |
| 353 all_extension_views_[render_view_host] = GetViewType(web_contents); | 353 all_extension_views_[render_view_host] = GetViewType(web_contents); |
| 354 | 354 |
| 355 // Keep the lazy background page alive as long as any non-background-page | 355 // Keep the lazy background page alive as long as any non-background-page |
| 356 // extension views are visible. Keepalive count balanced in | 356 // extension views are visible. Keepalive count balanced in |
| 357 // UnregisterRenderViewHost. | 357 // UnregisterRenderViewHost. |
| 358 IncrementLazyKeepaliveCountForView(render_view_host); | 358 IncrementLazyKeepaliveCountForView(render_view_host); |
| 359 return true; |
| 359 } | 360 } |
| 360 | 361 |
| 361 SiteInstance* ProcessManager::GetSiteInstanceForURL(const GURL& url) { | 362 SiteInstance* ProcessManager::GetSiteInstanceForURL(const GURL& url) { |
| 362 return site_instance_->GetRelatedSiteInstance(url); | 363 return site_instance_->GetRelatedSiteInstance(url); |
| 363 } | 364 } |
| 364 | 365 |
| 365 bool ProcessManager::IsBackgroundHostClosing(const std::string& extension_id) { | 366 bool ProcessManager::IsBackgroundHostClosing(const std::string& extension_id) { |
| 366 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 367 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
| 367 return (host && background_page_data_[extension_id].is_closing); | 368 return (host && background_page_data_[extension_id].is_closing); |
| 368 } | 369 } |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 break; | 666 break; |
| 666 | 667 |
| 667 typedef std::pair<RenderViewHost*, RenderViewHost*> RVHPair; | 668 typedef std::pair<RenderViewHost*, RenderViewHost*> RVHPair; |
| 668 RVHPair* switched_details = content::Details<RVHPair>(details).ptr(); | 669 RVHPair* switched_details = content::Details<RVHPair>(details).ptr(); |
| 669 if (switched_details->first) | 670 if (switched_details->first) |
| 670 UnregisterRenderViewHost(switched_details->first); | 671 UnregisterRenderViewHost(switched_details->first); |
| 671 | 672 |
| 672 // The above will unregister a RVH when it gets swapped out with a new | 673 // The above will unregister a RVH when it gets swapped out with a new |
| 673 // one. However we need to watch the WebContents to know when a RVH is | 674 // one. However we need to watch the WebContents to know when a RVH is |
| 674 // deleted because the WebContents has gone away. | 675 // deleted because the WebContents has gone away. |
| 675 RenderViewHostDestructionObserver::CreateForWebContents(contents); | 676 if (RegisterRenderViewHost(switched_details->second)) { |
| 676 RegisterRenderViewHost(switched_details->second); | 677 RenderViewHostDestructionObserver::CreateForWebContents(contents); |
| 678 } |
| 677 break; | 679 break; |
| 678 } | 680 } |
| 679 | 681 |
| 680 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: { | 682 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: { |
| 681 WebContents* contents = content::Source<WebContents>(source).ptr(); | 683 WebContents* contents = content::Source<WebContents>(source).ptr(); |
| 682 if (contents->GetBrowserContext() != GetBrowserContext()) | 684 if (contents->GetBrowserContext() != GetBrowserContext()) |
| 683 break; | 685 break; |
| 684 const Extension* extension = GetExtensionForRenderViewHost( | 686 const Extension* extension = GetExtensionForRenderViewHost( |
| 685 contents->GetRenderViewHost()); | 687 contents->GetRenderViewHost()); |
| 686 if (!extension) | 688 if (!extension) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 const Extension* extension = | 886 const Extension* extension = |
| 885 registry->enabled_extensions().GetExtensionOrAppByURL(url); | 887 registry->enabled_extensions().GetExtensionOrAppByURL(url); |
| 886 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 888 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
| 887 return original_manager_->GetSiteInstanceForURL(url); | 889 return original_manager_->GetSiteInstanceForURL(url); |
| 888 } | 890 } |
| 889 } | 891 } |
| 890 return ProcessManager::GetSiteInstanceForURL(url); | 892 return ProcessManager::GetSiteInstanceForURL(url); |
| 891 } | 893 } |
| 892 | 894 |
| 893 } // namespace extensions | 895 } // namespace extensions |
| OLD | NEW |