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

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

Issue 2730533002: chrome.contentSettings API: Block patterns that match extension URLs for mic and video
Patch Set: More tests 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
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..f2694c27eae180ff92e4582aaf1c26275df800b0 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,13 @@ ContentSettingsPattern::ContentSettingsPattern(
is_valid_(valid) {
}
+bool ContentSettingsPattern::MatchesExtensionUrls() const {
msramek 2017/03/02 09:50:40 This is a layering violation. It's not the first e
Devlin 2017/03/02 21:55:02 For this, we should just be able to use crx_file::
meacer 2017/03/07 20:50:38 Thanks! I searched a lot for an existing function
+ const char kExtensionIdRegex[] = "^[a-zA-Z]{32}";
msramek 2017/03/02 09:50:40 It's actually [a-p]{32}. https://cs.chromium.org/
meacer 2017/03/07 20:50:38 Not sure why I put a-z. But removed in favor of Is
+ return (parts_.is_scheme_wildcard || parts_.scheme == "chrome-extension") &&
msramek 2017/03/02 09:50:40 "*://[*.]google.com" is a valid scheme that both i
meacer 2017/03/07 20:50:38 Thanks for pointing this out, I though has_domain_
msramek 2017/03/13 22:05:25 Well, that's not exactly true. There's no way in t
meacer 2017/04/11 18:30:47 I'm explicitly avoiding querying for installed ext
msramek 2017/04/12 09:53:13 Acknowledged. Can you please explain that reasonin
+ (parts_.has_domain_wildcard ||
+ RE2::FullMatch(parts_.host, kExtensionIdRegex));
+}
+
bool ContentSettingsPattern::Matches(
const GURL& url) const {
// An invalid pattern matches nothing.

Powered by Google App Engine
This is Rietveld 408576698