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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 // Tests can call this method to inject a mock ExtensionInstallPrompt | 66 // Tests can call this method to inject a mock ExtensionInstallPrompt |
67 // to be used to confirm permissions on a downloaded CRX. | 67 // to be used to confirm permissions on a downloaded CRX. |
68 void SetMockInstallPromptForTesting(ExtensionInstallPrompt* mock_prompt) { | 68 void SetMockInstallPromptForTesting(ExtensionInstallPrompt* mock_prompt) { |
69 mock_install_prompt_for_testing = mock_prompt; | 69 mock_install_prompt_for_testing = mock_prompt; |
70 } | 70 } |
71 | 71 |
72 scoped_refptr<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 scoped_refptr<CrxInstaller> installer( | 80 scoped_refptr<extensions::CrxInstaller> installer( |
81 CrxInstaller::Create( | 81 extensions::CrxInstaller::Create( |
82 service, | 82 service, |
83 CreateExtensionInstallPrompt(profile), | 83 CreateExtensionInstallPrompt(profile), |
84 WebstoreInstaller::GetAssociatedApproval(download_item))); | 84 WebstoreInstaller::GetAssociatedApproval(download_item))); |
85 | 85 |
86 installer->set_delete_source(true); | 86 installer->set_delete_source(true); |
87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
88 | 88 |
89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { | 89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { |
90 installer->set_off_store_install_allow_reason( | 90 installer->set_off_store_install_allow_reason( |
91 CrxInstaller::OffStoreInstallAllowedBecausePref); | 91 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref); |
92 } | 92 } |
93 | 93 |
94 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 94 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
95 download_item.GetMimeType())) { | 95 download_item.GetMimeType())) { |
96 installer->InstallUserScript(download_item.GetFullPath(), | 96 installer->InstallUserScript(download_item.GetFullPath(), |
97 download_item.GetURL()); | 97 download_item.GetURL()); |
98 } else { | 98 } else { |
99 bool is_gallery_download = | 99 bool is_gallery_download = |
100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; | 100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; |
101 installer->set_original_mime_type(download_item.GetOriginalMimeType()); | 101 installer->set_original_mime_type(download_item.GetOriginalMimeType()); |
(...skipping 17 matching lines...) Expand all Loading... |
119 if (download_item.GetMimeType() == extensions::Extension::kMimeType || | 119 if (download_item.GetMimeType() == extensions::Extension::kMimeType || |
120 extensions::UserScript::IsURLUserScript(download_item.GetURL(), | 120 extensions::UserScript::IsURLUserScript(download_item.GetURL(), |
121 download_item.GetMimeType())) { | 121 download_item.GetMimeType())) { |
122 return true; | 122 return true; |
123 } else { | 123 } else { |
124 return false; | 124 return false; |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 } // namespace download_crx_util | 128 } // namespace download_crx_util |
OLD | NEW |