| OLD | NEW |
| 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/extensions/crx_installer.h" | 9 #include "chrome/browser/extensions/crx_installer.h" |
| 10 #include "chrome/browser/extensions/extension_install_prompt.h" | 10 #include "chrome/browser/extensions/extension_install_prompt.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (download_item.GetMimeType() == extensions::Extension::kMimeType || | 118 if (download_item.GetMimeType() == extensions::Extension::kMimeType || |
| 119 extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 119 extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
| 120 download_item.GetMimeType())) { | 120 download_item.GetMimeType())) { |
| 121 return true; | 121 return true; |
| 122 } else { | 122 } else { |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { | 127 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { |
| 128 extensions::ExtensionPrefs* prefs = extensions::ExtensionSystem::Get( | 128 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 129 profile)->extension_service()->extension_prefs(); | 129 profile)->extension_service(); |
| 130 if (!service) |
| 131 return false; |
| 132 |
| 133 extensions::ExtensionPrefs* prefs = service->extension_prefs(); |
| 130 CHECK(prefs); | 134 CHECK(prefs); |
| 131 | 135 |
| 132 extensions::URLPatternSet url_patterns = prefs->GetAllowedInstallSites(); | 136 extensions::URLPatternSet url_patterns = prefs->GetAllowedInstallSites(); |
| 133 | 137 |
| 134 if (!url_patterns.MatchesURL(item.GetURL())) | 138 if (!url_patterns.MatchesURL(item.GetURL())) |
| 135 return false; | 139 return false; |
| 136 | 140 |
| 137 // The referrer URL must also be whitelisted, unless the URL has the file | 141 // The referrer URL must also be whitelisted, unless the URL has the file |
| 138 // scheme (there's no referrer for those URLs). | 142 // scheme (there's no referrer for those URLs). |
| 139 // TODO(aa): RefererURL is cleared in some cases, for example when going | 143 // TODO(aa): RefererURL is cleared in some cases, for example when going |
| 140 // between secure and non-secure URLs. It would be better if DownloadItem | 144 // between secure and non-secure URLs. It would be better if DownloadItem |
| 141 // tracked the initiating page explicitly. | 145 // tracked the initiating page explicitly. |
| 142 return url_patterns.MatchesURL(item.GetReferrerUrl()) || | 146 return url_patterns.MatchesURL(item.GetReferrerUrl()) || |
| 143 item.GetURL().SchemeIsFile(); | 147 item.GetURL().SchemeIsFile(); |
| 144 } | 148 } |
| 145 | 149 |
| 146 } // namespace download_crx_util | 150 } // namespace download_crx_util |
| OLD | NEW |