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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 content::NotificationService* nservice = | |
57 content::NotificationService::current(); | |
58 GURL nonconst_download_url = download_item.GetURL(); | |
59 nservice->Notify(chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, | |
60 content::Source<Profile>(profile), | |
61 content::Details<GURL>(&nonconst_download_url)); | |
62 | 56 |
63 scoped_refptr<CrxInstaller> installer( | 57 scoped_refptr<CrxInstaller> installer( |
64 service->MakeCrxInstaller(CreateExtensionInstallUI(profile))); | 58 service->MakeCrxInstaller(CreateExtensionInstallUI(profile))); |
65 installer->set_delete_source(true); | 59 installer->set_delete_source(true); |
66 | 60 |
67 if (UserScript::IsURLUserScript(download_item.GetURL(), | 61 if (UserScript::IsURLUserScript(download_item.GetURL(), |
68 download_item.mime_type())) { | 62 download_item.mime_type())) { |
69 installer->InstallUserScript(download_item.full_path(), | 63 installer->InstallUserScript(download_item.full_path(), |
70 download_item.GetURL()); | 64 download_item.GetURL()); |
71 } else { | 65 } else { |
72 bool is_gallery_download = service->IsDownloadFromGallery( | 66 bool is_gallery_download = service->IsDownloadFromGallery( |
73 download_item.GetURL(), download_item.referrer_url()); | 67 download_item.GetURL(), download_item.referrer_url()); |
74 installer->set_original_mime_type(download_item.original_mime_type()); | 68 installer->set_original_mime_type(download_item.original_mime_type()); |
75 installer->set_apps_require_extension_mime_type(true); | 69 installer->set_apps_require_extension_mime_type(true); |
76 installer->set_download_url(download_item.GetURL()); | 70 installer->set_download_url(download_item.GetURL()); |
77 installer->set_is_gallery_install(is_gallery_download); | 71 installer->set_is_gallery_install(is_gallery_download); |
78 if (is_gallery_download) | 72 if (is_gallery_download) |
79 installer->set_original_download_url(download_item.original_url()); | 73 installer->set_original_download_url(download_item.original_url()); |
80 installer->set_allow_silent_install(is_gallery_download); | 74 installer->set_allow_silent_install(is_gallery_download); |
81 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 75 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
82 installer->InstallCrx(download_item.full_path()); | 76 installer->InstallCrx(download_item.full_path()); |
83 } | 77 } |
84 | 78 |
85 return installer; | 79 return installer; |
86 } | 80 } |
87 | 81 |
88 } // namespace download_crx_util | 82 } // namespace download_crx_util |
OLD | NEW |