diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 07:34:45 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 07:34:45 +0000 |
commit | aeb53b34fe924159674c8f15a6a82d23e470e487 (patch) | |
tree | cb2378f4a8414dbd82969cf0b79ac571c0df0670 /chrome/common | |
parent | b56fec5936adb2d3af47681f0cc7a053bd8db6da (diff) | |
download | chromium_src-aeb53b34fe924159674c8f15a6a82d23e470e487.zip chromium_src-aeb53b34fe924159674c8f15a6a82d23e470e487.tar.gz chromium_src-aeb53b34fe924159674c8f15a6a82d23e470e487.tar.bz2 |
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
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/extension.cc | 7 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index ab2ff76..cb41400 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -99,9 +99,12 @@ const int Extension::kIconSizes[] = { const int Extension::kPageActionIconMaxSize = 19; const int Extension::kBrowserActionIconMaxSize = 19; +const char* Extension::kTabPermission = "tabs"; +const char* Extension::kBookmarkPermission = "bookmarks"; + const char* Extension::kPermissionNames[] = { - "tabs", - "bookmarks", + Extension::kTabPermission, + Extension::kBookmarkPermission, }; const size_t Extension::kNumPermissions = arraysize(Extension::kPermissionNames); diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 79ea12d..cb5bd4b 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -71,6 +71,9 @@ class Extension { 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 @@ class Extension { // 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. |