Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Side by Side Diff: chrome/browser/download/download_crx_util.cc

Issue 8135017: Refactor downloads into a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated latest rounds of comments from John. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_service.h"
8 #include "chrome/browser/download/download_service_factory.h"
7 #include "chrome/browser/download/download_util.h" 9 #include "chrome/browser/download/download_util.h"
8 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_install_ui.h" 11 #include "chrome/browser/extensions/extension_install_ui.h"
10 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
13 #include "content/browser/download/download_item.h" 15 #include "content/browser/download/download_item.h"
14 #include "content/common/notification_service.h" 16 #include "content/common/notification_service.h"
15 17
16 namespace download_crx_util { 18 namespace download_crx_util {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 50
49 scoped_refptr<CrxInstaller> OpenChromeExtension( 51 scoped_refptr<CrxInstaller> OpenChromeExtension(
50 Profile* profile, 52 Profile* profile,
51 const DownloadItem& download_item) { 53 const DownloadItem& download_item) {
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
53 55
54 ExtensionService* service = profile->GetExtensionService(); 56 ExtensionService* service = profile->GetExtensionService();
55 CHECK(service); 57 CHECK(service);
56 NotificationService* nservice = NotificationService::current(); 58 NotificationService* nservice = NotificationService::current();
57 GURL nonconst_download_url = download_item.GetURL(); 59 GURL nonconst_download_url = download_item.GetURL();
60 DownloadManager* download_manager =
61 DownloadServiceFactory::GetForProfile(profile)->GetDownloadManager();
58 nservice->Notify(chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, 62 nservice->Notify(chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL,
59 Source<DownloadManager>(profile->GetDownloadManager()), 63 Source<DownloadManager>(download_manager),
60 Details<GURL>(&nonconst_download_url)); 64 Details<GURL>(&nonconst_download_url));
61 65
62 scoped_refptr<CrxInstaller> installer( 66 scoped_refptr<CrxInstaller> installer(
63 service->MakeCrxInstaller(CreateExtensionInstallUI(profile))); 67 service->MakeCrxInstaller(CreateExtensionInstallUI(profile)));
64 installer->set_delete_source(true); 68 installer->set_delete_source(true);
65 69
66 if (UserScript::IsURLUserScript(download_item.GetURL(), 70 if (UserScript::IsURLUserScript(download_item.GetURL(),
67 download_item.mime_type())) { 71 download_item.mime_type())) {
68 installer->InstallUserScript(download_item.full_path(), 72 installer->InstallUserScript(download_item.full_path(),
69 download_item.GetURL()); 73 download_item.GetURL());
70 } else { 74 } else {
71 bool is_gallery_download = service->IsDownloadFromGallery( 75 bool is_gallery_download = service->IsDownloadFromGallery(
72 download_item.GetURL(), download_item.referrer_url()); 76 download_item.GetURL(), download_item.referrer_url());
73 installer->set_original_mime_type(download_item.original_mime_type()); 77 installer->set_original_mime_type(download_item.original_mime_type());
74 installer->set_apps_require_extension_mime_type(true); 78 installer->set_apps_require_extension_mime_type(true);
75 installer->set_original_url(download_item.GetURL()); 79 installer->set_original_url(download_item.GetURL());
76 installer->set_is_gallery_install(is_gallery_download); 80 installer->set_is_gallery_install(is_gallery_download);
77 installer->set_allow_silent_install(is_gallery_download); 81 installer->set_allow_silent_install(is_gallery_download);
78 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); 82 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD);
79 installer->InstallCrx(download_item.full_path()); 83 installer->InstallCrx(download_item.full_path());
80 } 84 }
81 85
82 return installer; 86 return installer;
83 } 87 }
84 88
85 } // namespace download_crx_util 89 } // namespace download_crx_util
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/download_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698