Close Lazy Background Page after event dispatch

BUG=81752
TEST=

Review URL: http://codereview.chromium.org/8230035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106573 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index 6ecd784..41d0bbb 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -65,7 +65,7 @@
 
   // Gets the ExtensionHost for the background page for an extension, or NULL if
   // the extension isn't running or doesn't have a background page.
-  ExtensionHost* GetBackgroundHostForExtension(const Extension* extension);
+  ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id);
 
   // Returns the SiteInstance that the given URL belongs to.
   virtual SiteInstance* GetSiteInstanceForURL(const GURL& url);
@@ -107,6 +107,10 @@
   // Returns true if |host| is managed by this process manager.
   bool HasExtensionHost(ExtensionHost* host) const;
 
+  // Called when the render reports that the extension is idle (only if
+  // lazy background pages are enabled).
+  void OnExtensionIdle(const std::string& extension_id);
+
   typedef std::set<ExtensionHost*> ExtensionHostSet;
   typedef ExtensionHostSet::const_iterator const_iterator;
   const_iterator begin() const { return all_hosts_.begin(); }
@@ -158,6 +162,13 @@
   typedef std::set<RenderViewHost*> RenderViewHostSet;
   RenderViewHostSet all_extension_views_;
 
+ private:
+  // Close the given |host| iff it's a background page.
+  void CloseBackgroundHost(ExtensionHost* host);
+
+  // Excludes background page.
+  bool HasVisibleViews(const std::string& extension_id);
+
   DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
 };