diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-03 06:02:34 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-03 06:02:34 +0000 |
commit | 215160af1c6806ae0315e6ea762761d97a703b91 (patch) | |
tree | b7f1a0ccdf56a5a681c2e9b78da10b876b53abf1 /chrome | |
parent | d69754f2b9b45a586657e0672ae20c1eb1e8b6e5 (diff) | |
download | chromium_src-215160af1c6806ae0315e6ea762761d97a703b91.zip chromium_src-215160af1c6806ae0315e6ea762761d97a703b91.tar.gz chromium_src-215160af1c6806ae0315e6ea762761d97a703b91.tar.bz2 |
Fix a few places where we were incorrectly classifying
notifications and storage permissions as "access to your
browsing history".
Review URL: http://codereview.chromium.org/1526007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
8 files changed, 49 insertions, 11 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 245557c..a40ae58 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -95,7 +95,7 @@ static std::wstring GetInstallWarning(Extension* extension) { // a single host, no hosts. For each of these, we also have a variation of the // message for when api permissions are also requested. if (extension->HasAccessToAllHosts()) { - if (extension->api_permissions().empty()) + if (!extension->HasEffectiveBrowsingHistoryPermission()) return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS); else return l10n_util::GetString( @@ -104,7 +104,7 @@ static std::wstring GetInstallWarning(Extension* extension) { const std::set<std::string> hosts = extension->GetEffectiveHostPermissions(); if (hosts.size() > 1) { - if (extension->api_permissions().empty()) + if (!extension->HasEffectiveBrowsingHistoryPermission()) return l10n_util::GetString( IDS_EXTENSION_PROMPT_WARNING_MULTIPLE_HOSTS); else @@ -113,7 +113,7 @@ static std::wstring GetInstallWarning(Extension* extension) { } if (hosts.size() == 1) { - if (extension->api_permissions().empty()) + if (!extension->HasEffectiveBrowsingHistoryPermission()) return l10n_util::GetStringF( IDS_EXTENSION_PROMPT_WARNING_SINGLE_HOST, UTF8ToWide(*hosts.begin())); @@ -124,7 +124,7 @@ static std::wstring GetInstallWarning(Extension* extension) { } DCHECK(hosts.size() == 0); - if (extension->api_permissions().empty()) + if (!extension->HasEffectiveBrowsingHistoryPermission()) return L""; else return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_BROWSER); @@ -172,8 +172,7 @@ static void GetV2Warnings(Extension* extension, } } - if (extension->HasApiPermission(Extension::kTabPermission) || - extension->HasApiPermission(Extension::kBookmarkPermission)) { + if (extension->HasEffectiveBrowsingHistoryPermission()) { warnings->push_back( l10n_util::GetStringUTF16( IDS_EXTENSION_PROMPT2_WARNING_BROWSING_HISTORY)); diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index c583bc9..63d0b28 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -823,17 +823,23 @@ bool Extension::IsPrivilegeIncrease(Extension* old_extension, return true; } - // If we're going from not having api permissions to having them, it's a - // privilege increase. - if (old_extension->api_permissions().size() == 0 && - new_extension->api_permissions().size() > 0) + // If we're going from not having history to not having it, it's an increase. + if (!old_extension->HasEffectiveBrowsingHistoryPermission() && + new_extension->HasEffectiveBrowsingHistoryPermission()) { return true; + } // Nothing much has changed. return false; } // static +bool Extension::HasEffectiveBrowsingHistoryPermission() const { + return HasApiPermission(kTabPermission) || + HasApiPermission(kBookmarkPermission); +} + +// static void Extension::DecodeIcon(Extension* extension, Icons icon_size, scoped_ptr<SkBitmap>* result) { diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 7964052..7559162 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -258,6 +258,11 @@ class Extension { // through content scripts and the hosts accessible through XHR. const std::set<std::string> GetEffectiveHostPermissions() const; + // Returns true if the extension effectively has access to the user's browsing + // history. There are several permissions that we group together into this + // bucket. For example: tabs, bookmarks, and history. + bool HasEffectiveBrowsingHistoryPermission() const; + // Whether the extension has access to all hosts. This is true if there is // a content script that matches all hosts, or if there is a host permission // for all hosts. diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index d046503..fc88ab3 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -768,7 +768,9 @@ TEST(ExtensionTest, IsPrivilegeIncrease) { { "permissions4", false }, // plugin -> plugin,tabs { "plugin1", false }, // plugin -> plugin { "plugin2", false }, // plugin -> none - { "plugin3", true } // none -> plugin + { "plugin3", true }, // none -> plugin + { "storage", false }, // none -> storage + { "notifications", false } // none -> notifications }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { diff --git a/chrome/test/data/extensions/allow_silent_upgrade/notifications_new.json b/chrome/test/data/extensions/allow_silent_upgrade/notifications_new.json new file mode 100644 index 0000000..617a59f --- /dev/null +++ b/chrome/test/data/extensions/allow_silent_upgrade/notifications_new.json @@ -0,0 +1,7 @@ +{
+ "name": "allow silent update",
+ "version": "1.0",
+ "permissions": [
+ "notifications"
+ ]
+}
diff --git a/chrome/test/data/extensions/allow_silent_upgrade/notifications_old.json b/chrome/test/data/extensions/allow_silent_upgrade/notifications_old.json new file mode 100755 index 0000000..0f2cc18 --- /dev/null +++ b/chrome/test/data/extensions/allow_silent_upgrade/notifications_old.json @@ -0,0 +1,6 @@ +{
+ "name": "allow silent update",
+ "version": "1.0",
+ "permissions": [
+ ]
+}
diff --git a/chrome/test/data/extensions/allow_silent_upgrade/storage_new.json b/chrome/test/data/extensions/allow_silent_upgrade/storage_new.json new file mode 100755 index 0000000..fd2ba74 --- /dev/null +++ b/chrome/test/data/extensions/allow_silent_upgrade/storage_new.json @@ -0,0 +1,7 @@ +{
+ "name": "allow silent update",
+ "version": "1.0",
+ "permissions": [
+ "unlimited_storage"
+ ]
+}
diff --git a/chrome/test/data/extensions/allow_silent_upgrade/storage_old.json b/chrome/test/data/extensions/allow_silent_upgrade/storage_old.json new file mode 100755 index 0000000..0f2cc18 --- /dev/null +++ b/chrome/test/data/extensions/allow_silent_upgrade/storage_old.json @@ -0,0 +1,6 @@ +{
+ "name": "allow silent update",
+ "version": "1.0",
+ "permissions": [
+ ]
+}
|