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

Unified Diff: components/content_settings/core/common/content_settings_pattern.cc

Issue 2728503003: Update permission warning for contentSettings API
Patch Set: chrome.contentSettings API: Do not allow wildcard patterns that match extension URLs Created 3 years, 10 months 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 | « components/content_settings/core/common/content_settings_pattern.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/content_settings/core/common/content_settings_pattern.cc
diff --git a/components/content_settings/core/common/content_settings_pattern.cc b/components/content_settings/core/common/content_settings_pattern.cc
index a83a6959a02240575eae95fe7168e4ea75c644bc..899f9d64ea33fd1630c770e72895421f805d0b12 100644
--- a/components/content_settings/core/common/content_settings_pattern.cc
+++ b/components/content_settings/core/common/content_settings_pattern.cc
@@ -14,6 +14,7 @@
#include "base/strings/string_util.h"
#include "components/content_settings/core/common/content_settings_pattern_parser.h"
#include "net/base/url_util.h"
+#include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"
namespace {
@@ -533,6 +534,15 @@ ContentSettingsPattern::ContentSettingsPattern(
is_valid_(valid) {
}
+bool ContentSettingsPattern::IsExtensionUrlWildcard() const {
+ if (!parts_.is_scheme_wildcard && parts_.scheme != "chrome-extension")
+ return false;
+ const char kExtensionIdRegex[] = "[a-zA-Z]{32}";
+
+ return parts_.has_domain_wildcard ||
+ RE2::FullMatch(parts_.host, kExtensionIdRegex);
+}
+
bool ContentSettingsPattern::Matches(
const GURL& url) const {
// An invalid pattern matches nothing.
« no previous file with comments | « components/content_settings/core/common/content_settings_pattern.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698