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/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" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
88 installer->set_original_mime_type(download_item.GetOriginalMimeType()); | 88 installer->set_original_mime_type(download_item.GetOriginalMimeType()); |
89 installer->set_apps_require_extension_mime_type(true); | 89 installer->set_apps_require_extension_mime_type(true); |
90 | 90 |
91 return installer; | 91 return installer; |
92 } | 92 } |
93 | 93 |
94 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension( | 94 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension( |
95 Profile* profile, | 95 Profile* profile, |
96 const DownloadItem& download_item) { | 96 const DownloadItem& download_item) { |
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 97 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
98 | 98 |
99 scoped_refptr<extensions::CrxInstaller> installer( | 99 scoped_refptr<extensions::CrxInstaller> installer( |
100 CreateCrxInstaller(profile, download_item)); | 100 CreateCrxInstaller(profile, download_item)); |
101 | 101 |
102 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { | 102 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { |
103 installer->set_off_store_install_allow_reason( | 103 installer->set_off_store_install_allow_reason( |
104 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref); | 104 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref); |
105 } | 105 } |
106 | 106 |
107 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 107 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
(...skipping 24 matching lines...) Expand all Loading... |
132 | 132 |
133 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { | 133 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { |
134 // TODO(aa): RefererURL is cleared in some cases, for example when going | 134 // TODO(aa): RefererURL is cleared in some cases, for example when going |
135 // between secure and non-secure URLs. It would be better if DownloadItem | 135 // between secure and non-secure URLs. It would be better if DownloadItem |
136 // tracked the initiating page explicitly. | 136 // tracked the initiating page explicitly. |
137 return extensions::ExtensionManagementFactory::GetForBrowserContext(profile) | 137 return extensions::ExtensionManagementFactory::GetForBrowserContext(profile) |
138 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); | 138 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); |
139 } | 139 } |
140 | 140 |
141 } // namespace download_crx_util | 141 } // namespace download_crx_util |
OLD | NEW |