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

Side by Side 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 #3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_management.h" 5 #include "chrome/browser/extensions/extension_management.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 forcelist.get(), it->first, it->second.update_url); 87 forcelist.get(), it->first, it->second.update_url);
88 } 88 }
89 } 89 }
90 return forcelist.Pass(); 90 return forcelist.Pass();
91 } 91 }
92 92
93 bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const { 93 bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const {
94 return ReadById(id).installation_mode != INSTALLATION_BLOCKED; 94 return ReadById(id).installation_mode != INSTALLATION_BLOCKED;
95 } 95 }
96 96
97 bool ExtensionManagement::IsOffstoreInstallAllowed(const GURL& url,
98 const GURL& referrer_url) {
99 // No allowed install sites specified, disallow by default.
100 if (!global_settings_.has_restricted_install_sources) {
101 return false;
102 }
103
104 const extensions::URLPatternSet& url_patterns =
105 global_settings_.install_sources;
106
107 if (!url_patterns.MatchesURL(url))
108 return false;
109
110 // The referrer URL must also be whitelisted, unless the URL has the file
111 // scheme (there's no referrer for those URLs).
112 return url_patterns.MatchesURL(referrer_url) || url.SchemeIsFile();
Joao da Silva 2014/09/12 13:18:40 invert the order of these 2 tests: if the scheme i
113 }
114
97 const ExtensionManagement::IndividualSettings& ExtensionManagement::ReadById( 115 const ExtensionManagement::IndividualSettings& ExtensionManagement::ReadById(
98 const ExtensionId& id) const { 116 const ExtensionId& id) const {
99 DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id; 117 DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id;
100 SettingsIdMap::const_iterator it = settings_by_id_.find(id); 118 SettingsIdMap::const_iterator it = settings_by_id_.find(id);
101 if (it != settings_by_id_.end()) 119 if (it != settings_by_id_.end())
102 return it->second; 120 return it->second;
103 return default_settings_; 121 return default_settings_;
104 } 122 }
105 123
106 const ExtensionManagement::GlobalSettings& 124 const ExtensionManagement::GlobalSettings&
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return new ExtensionManagement( 287 return new ExtensionManagement(
270 Profile::FromBrowserContext(context)->GetPrefs()); 288 Profile::FromBrowserContext(context)->GetPrefs());
271 } 289 }
272 290
273 content::BrowserContext* ExtensionManagementFactory::GetBrowserContextToUse( 291 content::BrowserContext* ExtensionManagementFactory::GetBrowserContextToUse(
274 content::BrowserContext* context) const { 292 content::BrowserContext* context) const {
275 return chrome::GetBrowserContextRedirectedInIncognito(context); 293 return chrome::GetBrowserContextRedirectedInIncognito(context);
276 } 294 }
277 295
278 } // namespace extensions 296 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698