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

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

Issue 10399069: Reland 137540 - Disable off-store extension installs by default. Also get rid of ExtensionService::… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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) 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
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) {
55 if (extensions::switch_utils::IsOffStoreInstallEnabled() ||
56 WebstoreInstaller::GetAssociatedApproval(download_item)) {
57 return true;
58 } else {
59 return false;
60 }
61 }
62
63 scoped_refptr<CrxInstaller> OpenChromeExtension( 54 scoped_refptr<CrxInstaller> OpenChromeExtension(
64 Profile* profile, 55 Profile* profile,
65 const DownloadItem& download_item) { 56 const DownloadItem& download_item) {
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
67 58
68 ExtensionService* service = profile->GetExtensionService(); 59 ExtensionService* service = profile->GetExtensionService();
69 CHECK(service); 60 CHECK(service);
70 61
71 scoped_refptr<CrxInstaller> installer( 62 scoped_refptr<CrxInstaller> installer(
72 CrxInstaller::Create( 63 CrxInstaller::Create(
73 service, 64 service,
74 CreateExtensionInstallUI(profile), 65 CreateExtensionInstallUI(profile),
75 WebstoreInstaller::GetAssociatedApproval(download_item))); 66 WebstoreInstaller::GetAssociatedApproval(download_item)));
76 installer->set_delete_source(true); 67 installer->set_delete_source(true);
77 68
78 if (UserScript::IsURLUserScript(download_item.GetURL(), 69 if (UserScript::IsURLUserScript(download_item.GetURL(),
79 download_item.GetMimeType())) { 70 download_item.GetMimeType())) {
80 installer->InstallUserScript(download_item.GetFullPath(), 71 installer->InstallUserScript(download_item.GetFullPath(),
81 download_item.GetURL()); 72 download_item.GetURL());
82 } else { 73 } else {
83 bool is_gallery_download = service->IsDownloadFromGallery( 74 bool is_gallery_download =
84 download_item.GetURL(), download_item.GetReferrerUrl()); 75 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL;
85 installer->set_original_mime_type(download_item.GetOriginalMimeType()); 76 installer->set_original_mime_type(download_item.GetOriginalMimeType());
86 installer->set_apps_require_extension_mime_type(true); 77 installer->set_apps_require_extension_mime_type(true);
87 installer->set_download_url(download_item.GetURL()); 78 installer->set_download_url(download_item.GetURL());
88 installer->set_is_gallery_install(is_gallery_download); 79 installer->set_is_gallery_install(is_gallery_download);
89 if (is_gallery_download) 80 if (is_gallery_download)
90 installer->set_original_download_url(download_item.GetOriginalUrl()); 81 installer->set_original_download_url(download_item.GetOriginalUrl());
91 installer->set_allow_silent_install(is_gallery_download); 82 installer->set_allow_silent_install(is_gallery_download);
92 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); 83 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD);
93 installer->InstallCrx(download_item.GetFullPath()); 84 installer->InstallCrx(download_item.GetFullPath());
94 } 85 }
95 86
96 return installer; 87 return installer;
97 } 88 }
98 89
99 } // namespace download_crx_util 90 } // namespace download_crx_util
OLDNEW
« no previous file with comments | « chrome/browser/download/download_crx_util.h ('k') | chrome/browser/download/download_shelf_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698