Only dispatch tab events when there is someone listening.

This should cut down on the number of occurrences of a crash that happens in JSON serialization.

BUG=25558,26169

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30444 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 79ea12d7..cb5bd4b3 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -71,6 +71,9 @@
   static const int kBrowserActionIconMaxSize;
 
   // Each permission is a module that the extension is permitted to use.
+  static const char* kTabPermission;
+  static const char* kBookmarkPermission;
+
   static const char* kPermissionNames[];
   static const size_t kNumPermissions;
 
@@ -210,6 +213,12 @@
   // specified URL.
   bool CanAccessHost(const GURL& url) const;
 
+  // Returns true if the extension has the specified API permission.
+  bool HasApiPermission(const std::string& permission) const {
+    return std::find(api_permissions_.begin(), api_permissions_.end(),
+                     permission) != api_permissions_.end();
+  }
+
   // Returns the set of hosts that the extension effectively has access to. This
   // is used in the permissions UI and is a combination of the hosts accessible
   // through content scripts and the hosts accessible through XHR.