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" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
13 #include "content/browser/download/download_item.h" | 13 #include "content/browser/download/download_item.h" |
14 #include "content/common/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
15 | 15 |
16 namespace download_crx_util { | 16 namespace download_crx_util { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Hold a mock ExtensionInstallUI object that will be used when the | 20 // Hold a mock ExtensionInstallUI object that will be used when the |
21 // download system opens a CRX. | 21 // download system opens a CRX. |
22 ExtensionInstallUI* mock_install_ui_for_testing = NULL; | 22 ExtensionInstallUI* mock_install_ui_for_testing = NULL; |
23 | 23 |
24 // Called to get an extension install UI object. In tests, will return | 24 // Called to get an extension install UI object. In tests, will return |
(...skipping 21 matching lines...) Expand all Loading... |
46 mock_install_ui_for_testing = mock_ui; | 46 mock_install_ui_for_testing = mock_ui; |
47 } | 47 } |
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 NotificationService* nservice = NotificationService::current(); | 56 content::NotificationService* nservice = |
| 57 content::NotificationService::current(); |
57 GURL nonconst_download_url = download_item.GetURL(); | 58 GURL nonconst_download_url = download_item.GetURL(); |
58 nservice->Notify(chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, | 59 nservice->Notify(chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, |
59 content::Source<Profile>(profile), | 60 content::Source<Profile>(profile), |
60 content::Details<GURL>(&nonconst_download_url)); | 61 content::Details<GURL>(&nonconst_download_url)); |
61 | 62 |
62 scoped_refptr<CrxInstaller> installer( | 63 scoped_refptr<CrxInstaller> installer( |
63 service->MakeCrxInstaller(CreateExtensionInstallUI(profile))); | 64 service->MakeCrxInstaller(CreateExtensionInstallUI(profile))); |
64 installer->set_delete_source(true); | 65 installer->set_delete_source(true); |
65 | 66 |
66 if (UserScript::IsURLUserScript(download_item.GetURL(), | 67 if (UserScript::IsURLUserScript(download_item.GetURL(), |
(...skipping 11 matching lines...) Expand all Loading... |
78 installer->set_original_download_url(download_item.original_url()); | 79 installer->set_original_download_url(download_item.original_url()); |
79 installer->set_allow_silent_install(is_gallery_download); | 80 installer->set_allow_silent_install(is_gallery_download); |
80 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 81 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
81 installer->InstallCrx(download_item.full_path()); | 82 installer->InstallCrx(download_item.full_path()); |
82 } | 83 } |
83 | 84 |
84 return installer; | 85 return installer; |
85 } | 86 } |
86 | 87 |
87 } // namespace download_crx_util | 88 } // namespace download_crx_util |
OLD | NEW |