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

Side by Side Diff: chrome/browser/download/download_crx_util.cc

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix UserScriptListenerTests.MultiProfile Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Download code which handles CRX files (extensions, themes, apps, ...). 5 // Download code which handles CRX files (extensions, themes, apps, ...).
6 6
7 #include "chrome/browser/download/download_crx_util.h" 7 #include "chrome/browser/download/download_crx_util.h"
8 8
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
11 #include "chrome/browser/extensions/extension_install_prompt.h" 11 #include "chrome/browser/extensions/extension_install_prompt.h"
12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/webstore_installer.h" 12 #include "chrome/browser/extensions/webstore_installer.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/host_desktop.h" 15 #include "chrome/browser/ui/host_desktop.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
19 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "extensions/browser/extension_prefs.h"
20 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
21 #include "extensions/common/user_script.h" 21 #include "extensions/common/user_script.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using content::DownloadItem; 24 using content::DownloadItem;
25 using extensions::WebstoreInstaller; 25 using extensions::WebstoreInstaller;
26 26
27 namespace download_crx_util { 27 namespace download_crx_util {
28 28
29 namespace { 29 namespace {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (download_item.GetMimeType() == extensions::Extension::kMimeType || 121 if (download_item.GetMimeType() == extensions::Extension::kMimeType ||
122 extensions::UserScript::IsURLUserScript(download_item.GetURL(), 122 extensions::UserScript::IsURLUserScript(download_item.GetURL(),
123 download_item.GetMimeType())) { 123 download_item.GetMimeType())) {
124 return true; 124 return true;
125 } else { 125 } else {
126 return false; 126 return false;
127 } 127 }
128 } 128 }
129 129
130 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { 130 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) {
131 ExtensionService* service = extensions::ExtensionSystem::Get( 131 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile);
132 profile)->extension_service();
133 if (!service)
134 return false;
135
136 extensions::ExtensionPrefs* prefs = service->extension_prefs();
137 CHECK(prefs); 132 CHECK(prefs);
138 133
139 extensions::URLPatternSet url_patterns = prefs->GetAllowedInstallSites(); 134 extensions::URLPatternSet url_patterns = prefs->GetAllowedInstallSites();
140 135
141 if (!url_patterns.MatchesURL(item.GetURL())) 136 if (!url_patterns.MatchesURL(item.GetURL()))
142 return false; 137 return false;
143 138
144 // The referrer URL must also be whitelisted, unless the URL has the file 139 // The referrer URL must also be whitelisted, unless the URL has the file
145 // scheme (there's no referrer for those URLs). 140 // scheme (there's no referrer for those URLs).
146 // TODO(aa): RefererURL is cleared in some cases, for example when going 141 // TODO(aa): RefererURL is cleared in some cases, for example when going
147 // between secure and non-secure URLs. It would be better if DownloadItem 142 // between secure and non-secure URLs. It would be better if DownloadItem
148 // tracked the initiating page explicitly. 143 // tracked the initiating page explicitly.
149 return url_patterns.MatchesURL(item.GetReferrerUrl()) || 144 return url_patterns.MatchesURL(item.GetReferrerUrl()) ||
150 item.GetURL().SchemeIsFile(); 145 item.GetURL().SchemeIsFile();
151 } 146 }
152 147
153 } // namespace download_crx_util 148 } // namespace download_crx_util
OLDNEW
« no previous file with comments | « chrome/browser/apps/ephemeral_app_service.cc ('k') | chrome/browser/extensions/api/app_runtime/app_runtime_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698