Revert 229235 "Move the tab-lifetime handling functionality out ..."

No longer needed and it adds complexity, so reverting.


> Move the tab-lifetime handling functionality out of ActiveTabPermissionGranter
> and into a new class TabCapabilityTracker, to make room for web connectable
> incognito support for apps.
> 
> BUG=305394
> [email protected]
> 
> Review URL: https://codereview.chromium.org/27604003

[email protected]

Review URL: https://codereview.chromium.org/29683002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229453 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/active_tab_permission_granter.h b/chrome/browser/extensions/active_tab_permission_granter.h
index 186f165..0ef03366 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.h
+++ b/chrome/browser/extensions/active_tab_permission_granter.h
@@ -8,8 +8,6 @@
 #include <set>
 #include <string>
 
-#include "base/compiler_specific.h"
-#include "chrome/browser/extensions/tab_capability_tracker.h"
 #include "chrome/common/extensions/extension_set.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
@@ -28,7 +26,8 @@
 
 // Responsible for granting and revoking tab-specific permissions to extensions
 // with the activeTab or tabCapture permission.
-class ActiveTabPermissionGranter : public TabCapabilityTracker::Observer {
+class ActiveTabPermissionGranter : public content::WebContentsObserver,
+                                   public content::NotificationObserver {
  public:
   ActiveTabPermissionGranter(content::WebContents* web_contents,
                              int tab_id,
@@ -40,9 +39,21 @@
   void GrantIfRequested(const Extension* extension);
 
  private:
-  // TabCapabilityTracker::Observer implementation.
-  virtual void OnGranted(const Extension* extension) OVERRIDE;
-  virtual void OnRevoked(const ExtensionSet* extensions) OVERRIDE;
+  // content::WebContentsObserver implementation.
+  virtual void DidNavigateMainFrame(
+      const content::LoadCommittedDetails& details,
+      const content::FrameNavigateParams& params) OVERRIDE;
+  virtual void WebContentsDestroyed(content::WebContents* web_contents)
+      OVERRIDE;
+
+  // content::NotificationObserver implementation.
+  virtual void Observe(int type,
+                       const content::NotificationSource& source,
+                       const content::NotificationDetails& details) OVERRIDE;
+
+  // Clears any tab-specific permissions for all extensions on |tab_id_| and
+  // notifies renderers.
+  void ClearActiveExtensionsAndNotify();
 
   // Gets the current page id.
   int32 GetPageID();
@@ -50,9 +61,12 @@
   // The tab ID for this tab.
   int tab_id_;
 
-  content::WebContents* web_contents_;
+  // Extensions with the activeTab permission that have been granted
+  // tab-specific permissions until the next navigation/refresh.
+  ExtensionSet granted_extensions_;
 
-  TabCapabilityTracker tab_capability_tracker_;
+  // Listen to extension unloaded notifications.
+  content::NotificationRegistrar registrar_;
 
   DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionGranter);
 };