| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 96 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
| 97 download_item.GetMimeType())) { | 97 download_item.GetMimeType())) { |
| 98 installer->InstallUserScript(download_item.GetFullPath(), | 98 installer->InstallUserScript(download_item.GetFullPath(), |
| 99 download_item.GetURL()); | 99 download_item.GetURL()); |
| 100 } else { | 100 } else { |
| 101 bool is_gallery_download = | 101 bool is_gallery_download = |
| 102 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; | 102 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; |
| 103 installer->set_original_mime_type(download_item.GetOriginalMimeType()); | 103 installer->set_original_mime_type(download_item.GetOriginalMimeType()); |
| 104 installer->set_apps_require_extension_mime_type(true); | 104 installer->set_apps_require_extension_mime_type(true); |
| 105 installer->set_download_url(download_item.GetURL()); | |
| 106 installer->set_is_gallery_install(is_gallery_download); | 105 installer->set_is_gallery_install(is_gallery_download); |
| 107 if (is_gallery_download) | 106 if (is_gallery_download) |
| 108 installer->set_original_download_url(download_item.GetOriginalUrl()); | 107 installer->set_download_id(download_item.GetId()); |
| 109 installer->set_allow_silent_install(is_gallery_download); | 108 installer->set_allow_silent_install(is_gallery_download); |
| 110 installer->InstallCrx(download_item.GetFullPath()); | 109 installer->InstallCrx(download_item.GetFullPath()); |
| 111 } | 110 } |
| 112 | 111 |
| 113 return installer; | 112 return installer; |
| 114 } | 113 } |
| 115 | 114 |
| 116 bool IsExtensionDownload(const DownloadItem& download_item) { | 115 bool IsExtensionDownload(const DownloadItem& download_item) { |
| 117 if (download_item.GetTargetDisposition() == | 116 if (download_item.GetTargetDisposition() == |
| 118 DownloadItem::TARGET_DISPOSITION_PROMPT) | 117 DownloadItem::TARGET_DISPOSITION_PROMPT) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 139 // The referrer URL must also be whitelisted, unless the URL has the file | 138 // The referrer URL must also be whitelisted, unless the URL has the file |
| 140 // scheme (there's no referrer for those URLs). | 139 // scheme (there's no referrer for those URLs). |
| 141 // TODO(aa): RefererURL is cleared in some cases, for example when going | 140 // TODO(aa): RefererURL is cleared in some cases, for example when going |
| 142 // between secure and non-secure URLs. It would be better if DownloadItem | 141 // between secure and non-secure URLs. It would be better if DownloadItem |
| 143 // tracked the initiating page explicitly. | 142 // tracked the initiating page explicitly. |
| 144 return url_patterns.MatchesURL(item.GetReferrerUrl()) || | 143 return url_patterns.MatchesURL(item.GetReferrerUrl()) || |
| 145 item.GetURL().SchemeIsFile(); | 144 item.GetURL().SchemeIsFile(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 } // namespace download_crx_util | 147 } // namespace download_crx_util |
| OLD | NEW |