diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-30 23:08:56 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-30 23:08:56 +0000 |
commit | 9dfed8710fa6d1f3c2617b4ea2635cd38d3bf321 (patch) | |
tree | b6fca583947b1d8f4311cd742b4cee6eb68ea381 /extensions | |
parent | b8455ebd228cfb241c1ddebab877e197fd46241e (diff) | |
download | chromium_src-9dfed8710fa6d1f3c2617b4ea2635cd38d3bf321.zip chromium_src-9dfed8710fa6d1f3c2617b4ea2635cd38d3bf321.tar.gz chromium_src-9dfed8710fa6d1f3c2617b4ea2635cd38d3bf321.tar.bz2 |
Replace the GetAssociatedRenderView call with GetAssociatedRenderFrame in ChromeNetworkDelegate.
BUG=304341
R=koz@chromium.org
Review URL: https://codereview.chromium.org/102643010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/process_manager.cc | 31 | ||||
-rw-r--r-- | extensions/browser/process_manager.h | 7 |
2 files changed, 29 insertions, 9 deletions
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc index 1162b81..7a362e3 100644 --- a/extensions/browser/process_manager.cc +++ b/extensions/browser/process_manager.cc @@ -25,6 +25,7 @@ #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_manager.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/site_instance.h" @@ -65,6 +66,22 @@ std::string GetExtensionID(RenderViewHost* render_view_host) { return render_view_host->GetSiteInstance()->GetSiteURL().host(); } +std::string GetExtensionIDFromFrame( + content::RenderFrameHost* render_frame_host) { + // This works for both apps and extensions because the site has been + // normalized to the extension URL for apps. + if (!render_frame_host->GetSiteInstance()) + return std::string(); + + return render_frame_host->GetSiteInstance()->GetSiteURL().host(); +} + +bool IsFrameInExtensionHost(ExtensionHost* extension_host, + content::RenderFrameHost* render_frame_host) { + return WebContents::FromRenderFrameHost(render_frame_host) == + extension_host->host_contents(); +} + void OnRenderViewHostUnregistered(BrowserContext* context, RenderViewHost* render_view_host) { content::NotificationService::current()->Notify( @@ -511,17 +528,19 @@ void ProcessManager::CloseLazyBackgroundPageNow(const std::string& extension_id, } } -void ProcessManager::OnNetworkRequestStarted(RenderViewHost* render_view_host) { +void ProcessManager::OnNetworkRequestStarted( + content::RenderFrameHost* render_frame_host) { ExtensionHost* host = GetBackgroundHostForExtension( - GetExtensionID(render_view_host)); - if (host && host->render_view_host() == render_view_host) + GetExtensionIDFromFrame(render_frame_host)); + if (host && IsFrameInExtensionHost(host, render_frame_host)) IncrementLazyKeepaliveCount(host->extension()); } -void ProcessManager::OnNetworkRequestDone(RenderViewHost* render_view_host) { +void ProcessManager::OnNetworkRequestDone( + content::RenderFrameHost* render_frame_host) { ExtensionHost* host = GetBackgroundHostForExtension( - GetExtensionID(render_view_host)); - if (host && host->render_view_host() == render_view_host) + GetExtensionIDFromFrame(render_frame_host)); + if (host && IsFrameInExtensionHost(host, render_frame_host)) DecrementLazyKeepaliveCount(host->extension()); } diff --git a/extensions/browser/process_manager.h b/extensions/browser/process_manager.h index fa5f2b6..8b48aab 100644 --- a/extensions/browser/process_manager.h +++ b/extensions/browser/process_manager.h @@ -24,6 +24,7 @@ namespace content { class BrowserContext; class DevToolsAgentHost; class RenderViewHost; +class RenderFrameHost; class SiteInstance; }; @@ -104,10 +105,10 @@ class ProcessManager : public content::NotificationObserver { // Same as above, for the Suspend message. void OnSuspendAck(const std::string& extension_id); - // Tracks network requests for a given RenderViewHost, used to know + // Tracks network requests for a given RenderFrameHost, used to know // when network activity is idle for lazy background pages. - void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); - void OnNetworkRequestDone(content::RenderViewHost* render_view_host); + void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host); + void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host); // Prevents |extension|'s background page from being closed and sends the // onSuspendCanceled() event to it. |