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

Unified Diff: chrome/browser/extensions/extension_management.cc

Issue 555323002: Deprecate direct use of legacy extension management preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes addressing #12 Created 6 years, 3 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: chrome/browser/extensions/extension_management.cc
diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc
index 15caf92fcdc9223be5f44ea06435905af991c7b9..186e4b49d08eb6a2dfcd601f83b6b9e1c898a1f7 100644
--- a/chrome/browser/extensions/extension_management.cc
+++ b/chrome/browser/extensions/extension_management.cc
@@ -17,6 +17,7 @@
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/url_pattern.h"
+#include "url/gurl.h"
namespace extensions {
@@ -94,6 +95,23 @@ bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const {
return ReadById(id).installation_mode != INSTALLATION_BLOCKED;
}
+bool ExtensionManagement::IsOffstoreInstallAllowed(const GURL& url,
+ const GURL& referrer_url) {
+ // No allowed install sites specified, disallow by default.
+ if (!global_settings_.has_restricted_install_sources)
+ return false;
+
+ const extensions::URLPatternSet& url_patterns =
+ global_settings_.install_sources;
+
+ if (!url_patterns.MatchesURL(url))
+ return false;
+
+ // The referrer URL must also be whitelisted, unless the URL has the file
+ // scheme (there's no referrer for those URLs).
+ return url.SchemeIsFile() || url_patterns.MatchesURL(referrer_url);
+}
+
const ExtensionManagement::IndividualSettings& ExtensionManagement::ReadById(
const ExtensionId& id) const {
DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id;
« no previous file with comments | « chrome/browser/extensions/extension_management.h ('k') | chrome/browser/ui/webui/extensions/extension_settings_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698