| 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..863dcfb57ae25e40959f508e47e7d7bc725f1d1e 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,24 @@ 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;
|
|
|