| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_util.h" | 7 #include "chrome/browser/download/download_util.h" |
| 8 #include "chrome/browser/extensions/crx_installer.h" | 8 #include "chrome/browser/extensions/crx_installer.h" |
| 9 #include "chrome/browser/extensions/extension_install_ui.h" | 9 #include "chrome/browser/extensions/extension_install_ui.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 scoped_refptr<CrxInstaller> OpenChromeExtension( | 49 scoped_refptr<CrxInstaller> OpenChromeExtension( |
| 50 Profile* profile, | 50 Profile* profile, |
| 51 const DownloadItem& download_item) { | 51 const DownloadItem& download_item) { |
| 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 53 | 53 |
| 54 ExtensionService* service = profile->GetExtensionService(); | 54 ExtensionService* service = profile->GetExtensionService(); |
| 55 CHECK(service); | 55 CHECK(service); |
| 56 | 56 |
| 57 scoped_refptr<CrxInstaller> installer( | 57 scoped_refptr<CrxInstaller> installer( |
| 58 service->MakeCrxInstaller(CreateExtensionInstallUI(profile))); | 58 CrxInstaller::Create(service, CreateExtensionInstallUI(profile))); |
| 59 installer->set_delete_source(true); | 59 installer->set_delete_source(true); |
| 60 | 60 |
| 61 if (UserScript::IsURLUserScript(download_item.GetURL(), | 61 if (UserScript::IsURLUserScript(download_item.GetURL(), |
| 62 download_item.mime_type())) { | 62 download_item.mime_type())) { |
| 63 installer->InstallUserScript(download_item.full_path(), | 63 installer->InstallUserScript(download_item.full_path(), |
| 64 download_item.GetURL()); | 64 download_item.GetURL()); |
| 65 } else { | 65 } else { |
| 66 bool is_gallery_download = service->IsDownloadFromGallery( | 66 bool is_gallery_download = service->IsDownloadFromGallery( |
| 67 download_item.GetURL(), download_item.referrer_url()); | 67 download_item.GetURL(), download_item.referrer_url()); |
| 68 installer->set_original_mime_type(download_item.original_mime_type()); | 68 installer->set_original_mime_type(download_item.original_mime_type()); |
| 69 installer->set_apps_require_extension_mime_type(true); | 69 installer->set_apps_require_extension_mime_type(true); |
| 70 installer->set_download_url(download_item.GetURL()); | 70 installer->set_download_url(download_item.GetURL()); |
| 71 installer->set_is_gallery_install(is_gallery_download); | 71 installer->set_is_gallery_install(is_gallery_download); |
| 72 if (is_gallery_download) | 72 if (is_gallery_download) |
| 73 installer->set_original_download_url(download_item.original_url()); | 73 installer->set_original_download_url(download_item.original_url()); |
| 74 installer->set_allow_silent_install(is_gallery_download); | 74 installer->set_allow_silent_install(is_gallery_download); |
| 75 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 75 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
| 76 installer->InstallCrx(download_item.full_path()); | 76 installer->InstallCrx(download_item.full_path()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 return installer; | 79 return installer; |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace download_crx_util | 82 } // namespace download_crx_util |
| OLD | NEW |