Chromium Code Reviews| 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_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_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 70 } |
| 71 | 71 |
| 72 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension( | 72 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension( |
| 73 Profile* profile, | 73 Profile* profile, |
| 74 const DownloadItem& download_item) { | 74 const DownloadItem& download_item) { |
| 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 76 | 76 |
| 77 ExtensionService* service = profile->GetExtensionService(); | 77 ExtensionService* service = profile->GetExtensionService(); |
| 78 CHECK(service); | 78 CHECK(service); |
| 79 | 79 |
| 80 bool is_gallery_download = | |
| 81 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; | |
| 82 ExtensionInstallPrompt* prompt = NULL; | |
| 83 if (!is_gallery_download) | |
|
Mihai Parparita -not on Chrome
2012/09/07 22:01:36
Doesn't this mean that the SetUseAppInstalledBubbl
asargent_no_longer_on_chrome
2012/09/14 23:24:35
Yes. New version of patch should fix this.
| |
| 84 prompt = CreateExtensionInstallPrompt(profile); | |
| 85 | |
| 80 scoped_refptr<extensions::CrxInstaller> installer( | 86 scoped_refptr<extensions::CrxInstaller> installer( |
| 81 extensions::CrxInstaller::Create( | 87 extensions::CrxInstaller::Create( |
| 82 service, | 88 service, |
| 83 CreateExtensionInstallPrompt(profile), | 89 prompt, |
| 84 WebstoreInstaller::GetAssociatedApproval(download_item))); | 90 WebstoreInstaller::GetAssociatedApproval(download_item))); |
| 85 | 91 |
| 86 installer->set_delete_source(true); | 92 installer->set_delete_source(true); |
| 87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 93 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
| 88 | 94 |
| 89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { | 95 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { |
| 90 installer->set_off_store_install_allow_reason( | 96 installer->set_off_store_install_allow_reason( |
| 91 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref); | 97 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref); |
| 92 } | 98 } |
| 93 | 99 |
| 94 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 100 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
| 95 download_item.GetMimeType())) { | 101 download_item.GetMimeType())) { |
| 96 installer->InstallUserScript(download_item.GetFullPath(), | 102 installer->InstallUserScript(download_item.GetFullPath(), |
| 97 download_item.GetURL()); | 103 download_item.GetURL()); |
| 98 } else { | 104 } else { |
| 99 bool is_gallery_download = | |
| 100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; | |
| 101 installer->set_original_mime_type(download_item.GetOriginalMimeType()); | 105 installer->set_original_mime_type(download_item.GetOriginalMimeType()); |
| 102 installer->set_apps_require_extension_mime_type(true); | 106 installer->set_apps_require_extension_mime_type(true); |
| 103 installer->set_download_url(download_item.GetURL()); | 107 installer->set_download_url(download_item.GetURL()); |
| 104 installer->set_is_gallery_install(is_gallery_download); | 108 installer->set_is_gallery_install(is_gallery_download); |
| 105 if (is_gallery_download) | 109 if (is_gallery_download) |
| 106 installer->set_original_download_url(download_item.GetOriginalUrl()); | 110 installer->set_original_download_url(download_item.GetOriginalUrl()); |
| 107 installer->set_allow_silent_install(is_gallery_download); | 111 installer->set_allow_silent_install(is_gallery_download); |
| 108 installer->InstallCrx(download_item.GetFullPath()); | 112 installer->InstallCrx(download_item.GetFullPath()); |
| 109 } | 113 } |
| 110 | 114 |
| 111 return installer; | 115 return installer; |
| 112 } | 116 } |
| 113 | 117 |
| 114 bool IsExtensionDownload(const DownloadItem& download_item) { | 118 bool IsExtensionDownload(const DownloadItem& download_item) { |
| 115 if (download_item.GetTargetDisposition() == | 119 if (download_item.GetTargetDisposition() == |
| 116 DownloadItem::TARGET_DISPOSITION_PROMPT) | 120 DownloadItem::TARGET_DISPOSITION_PROMPT) |
| 117 return false; | 121 return false; |
| 118 | 122 |
| 119 if (download_item.GetMimeType() == extensions::Extension::kMimeType || | 123 if (download_item.GetMimeType() == extensions::Extension::kMimeType || |
| 120 extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 124 extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
| 121 download_item.GetMimeType())) { | 125 download_item.GetMimeType())) { |
| 122 return true; | 126 return true; |
| 123 } else { | 127 } else { |
| 124 return false; | 128 return false; |
| 125 } | 129 } |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace download_crx_util | 132 } // namespace download_crx_util |
| OLD | NEW |