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_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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 // Tests can call this method to inject a mock ExtensionInstallUI | 48 // Tests can call this method to inject a mock ExtensionInstallUI |
49 // to be used to confirm permissions on a downloaded CRX. | 49 // to be used to confirm permissions on a downloaded CRX. |
50 void SetMockInstallUIForTesting(ExtensionInstallUI* mock_ui) { | 50 void SetMockInstallUIForTesting(ExtensionInstallUI* mock_ui) { |
51 mock_install_ui_for_testing = mock_ui; | 51 mock_install_ui_for_testing = mock_ui; |
52 } | 52 } |
53 | 53 |
54 bool ShouldOpenExtensionDownload(const DownloadItem& download_item) { | 54 bool ShouldOpenExtensionDownload(ExtensionService* service, |
| 55 const DownloadItem& download_item) { |
55 if (extensions::switch_utils::IsOffStoreInstallEnabled() || | 56 if (extensions::switch_utils::IsOffStoreInstallEnabled() || |
56 WebstoreInstaller::GetAssociatedApproval(download_item)) { | 57 (service && service->IsDownloadFromGallery( |
| 58 download_item.GetURL(), download_item.GetReferrerUrl()))) { |
57 return true; | 59 return true; |
58 } else { | 60 } else { |
59 return false; | 61 return false; |
60 } | 62 } |
61 } | 63 } |
62 | 64 |
63 scoped_refptr<CrxInstaller> OpenChromeExtension( | 65 scoped_refptr<CrxInstaller> OpenChromeExtension( |
64 Profile* profile, | 66 Profile* profile, |
65 const DownloadItem& download_item) { | 67 const DownloadItem& download_item) { |
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 23 matching lines...) Expand all Loading... |
90 installer->set_original_download_url(download_item.GetOriginalUrl()); | 92 installer->set_original_download_url(download_item.GetOriginalUrl()); |
91 installer->set_allow_silent_install(is_gallery_download); | 93 installer->set_allow_silent_install(is_gallery_download); |
92 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 94 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
93 installer->InstallCrx(download_item.GetFullPath()); | 95 installer->InstallCrx(download_item.GetFullPath()); |
94 } | 96 } |
95 | 97 |
96 return installer; | 98 return installer; |
97 } | 99 } |
98 | 100 |
99 } // namespace download_crx_util | 101 } // namespace download_crx_util |
OLD | NEW |