Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6918)

Unified Diff: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc

Issue 55533003: Add extension permissions for new settings override API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing exclusion in gyp file. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/common/extensions/permissions/chrome_api_permissions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
index 391643ecb216e836487042777be37a7f0decf607..c71a1c32c1b3ce44fc4332dadda3559a9e99251a 100644
--- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
+++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
@@ -4,15 +4,23 @@
#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/common/extensions/permissions/permissions_data.h"
+#include "chrome/common/extensions/permissions/settings_override_permission.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
+#include "extensions/common/permissions/api_permission_set.h"
+#include "extensions/common/permissions/permissions_info.h"
+#include "url/gurl.h"
using extensions::api::manifest_types::ChromeSettingsOverrides;
namespace extensions {
namespace {
+const char* kWwwPrefix = "www.";
+
scoped_ptr<GURL> CreateManifestURL(const std::string& url) {
scoped_ptr<GURL> manifest_url(new GURL(url));
if (!manifest_url->is_valid() ||
@@ -54,6 +62,14 @@ std::vector<GURL> ParseStartupPage(const ChromeSettingsOverrides& overrides,
return urls;
}
+// A www. prefix is not informative and thus not worth the limited real estate
+// in the permissions UI.
+std::string RemoveWwwPrefix(const std::string& url) {
+ if (StartsWithASCII(url, kWwwPrefix, false))
+ return url.substr(strlen(kWwwPrefix));
+ return url;
+}
+
} // namespace
SettingsOverrides::SettingsOverrides() {}
@@ -86,6 +102,27 @@ bool SettingsOverridesHandler::Parse(Extension* extension, string16* error) {
*error = ASCIIToUTF16(manifest_errors::kInvalidEmptySettingsOverrides);
return false;
}
+ APIPermissionSet* permission_set =
+ PermissionsData::GetInitialAPIPermissions(extension);
+ DCHECK(permission_set);
+ if (info->search_engine) {
+ permission_set->insert(new SettingsOverrideAPIPermission(
+ PermissionsInfo::GetInstance()->GetByID(APIPermission::kSearchProvider),
+ RemoveWwwPrefix(CreateManifestURL(info->search_engine->search_url)->
+ GetOrigin().host())));
+ }
+ if (!info->startup_pages.empty()) {
+ permission_set->insert(new SettingsOverrideAPIPermission(
+ PermissionsInfo::GetInstance()->GetByID(APIPermission::kStartupPages),
+ // We only support one startup page even though the type of the manifest
+ // property is a list, only the first one is used.
+ RemoveWwwPrefix(info->startup_pages[0].GetContent())));
+ }
+ if (info->homepage) {
+ permission_set->insert(new SettingsOverrideAPIPermission(
+ PermissionsInfo::GetInstance()->GetByID(APIPermission::kHomepage),
+ RemoveWwwPrefix(info->homepage.get()->GetContent())));
+ }
extension->SetManifestData(manifest_keys::kSettingsOverride,
info.release());
return true;
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/common/extensions/permissions/chrome_api_permissions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698